summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-08-07 06:44:06 -0400
committermidipix <writeonce@midipix.org>2016-08-10 21:47:27 -0400
commit5ee033f002dee29f1a1395a1b3838089a3e18fa6 (patch)
tree1428ae67b47a709ca36df624dd0ca2c9f6dbf2a4 /src
parent6494811a247d5c11587c44027a103b41676554c3 (diff)
downloadptycon-5ee033f002dee29f1a1395a1b3838089a3e18fa6.tar.bz2
ptycon-5ee033f002dee29f1a1395a1b3838089a3e18fa6.tar.xz
console: keyboard reader: ptyc_repeat(): implementation and integration.
Diffstat (limited to 'src')
-rw-r--r--src/console/ptyc_console_reader.c47
1 files changed, 46 insertions, 1 deletions
diff --git a/src/console/ptyc_console_reader.c b/src/console/ptyc_console_reader.c
index 75547b5..44287ec 100644
--- a/src/console/ptyc_console_reader.c
+++ b/src/console/ptyc_console_reader.c
@@ -14,6 +14,48 @@
typedef nt_unicode_conversion_params_utf16_to_utf8 uc_conv_params;
+static size_t ptyc_repeat(unsigned char * ch, size_t n, uint16_t count)
+{
+ unsigned char * dst;
+ int i;
+
+ if (!--count)
+ return n;
+
+ if (n == 1) {
+ for (i=count, dst=&ch[n]; i; i--) {
+ dst[0] = ch[0];
+ dst = &dst[n];
+ }
+
+ } else if (n == 2) {
+ for (i=count, dst=&ch[n]; i; i--) {
+ dst[0] = ch[0];
+ dst[1] = ch[1];
+ dst = &dst[n];
+ }
+
+ } else if (n == 3) {
+ for (i=count, dst=&ch[n]; i; i--) {
+ dst[0] = ch[0];
+ dst[1] = ch[1];
+ dst[2] = ch[2];
+ dst = &dst[n];
+ }
+
+ } else if (n == 4) {
+ for (i=count, dst=&ch[n]; i; i--) {
+ dst[0] = ch[0];
+ dst[1] = ch[1];
+ dst[2] = ch[2];
+ dst[3] = ch[3];
+ dst = &dst[n];
+ }
+ }
+
+ return n*count;
+}
+
static size_t ptyc_translate_keyboard_event(
nt_input_record * rec,
unsigned char * ch,
@@ -57,7 +99,10 @@ static size_t ptyc_translate_keyboard_event(
ntapi->uc_convert_unicode_stream_utf16_to_utf8(
&params);
- return params.bytes_written;
+ return ptyc_repeat(
+ ch,
+ params.bytes_written,
+ rec->key_event.repeat_count);
}
static size_t ptyc_translate_mouse_event(