X-Git-Url: http://git.joshuawise.com/netwatch.git/blobdiff_plain/50d89a314a394e5427d0791a08ffc3a3b79b6670..923ea2c2cd9df7f02ddcfd8c543f63b76be44660:/aseg/keyboard.c?ds=sidebyside diff --git a/aseg/keyboard.c b/aseg/keyboard.c index 878fa33..4b84b4f 100644 --- a/aseg/keyboard.c +++ b/aseg/keyboard.c @@ -4,61 +4,61 @@ static unsigned char kbd_inj_buffer[128]; static int kbd_inj_start = 0; static int kbd_inj_end = 0; -int kbd_mode = 2; +int kbd_mode = 1; static const char scancodes2[][8] = { - ['a'] = "\x1e\xf0\x1e", - ['b'] = "\x30\xf0\x30", - ['c'] = "\x2e\xf0\x2e", - ['d'] = "\x20\xf0\x20", - ['e'] = "\x12\xf0\x12", - ['f'] = "\x21\xf0\x21", - ['g'] = "\x22\xf0\x22", - ['h'] = "\x23\xf0\x23", - ['i'] = "\x17\xf0\x17", - ['j'] = "\x24\xf0\x24", - ['k'] = "\x25\xf0\x25", - ['l'] = "\x26\xf0\x26", - ['m'] = "\x32\xf0\x32", + ['a'] = "\x1c\xf0\x1c", + ['b'] = "\x32\xf0\x32", + ['c'] = "\x21\xf0\x21", + ['d'] = "\x23\xf0\x23", + ['e'] = "\x24\xf0\x24", + ['f'] = "\x2b\xf0\x2b", + ['g'] = "\x34\xf0\x34", + ['h'] = "\x33\xf0\x33", + ['i'] = "\x43\xf0\x43", + ['j'] = "\x3b\xf0\x3b", + ['k'] = "\x42\xf0\x42", + ['l'] = "\x4b\xf0\x4b", + ['m'] = "\x3a\xf0\x3a", ['n'] = "\x31\xf0\x31", - ['o'] = "\x18\xf0\x18", - ['p'] = "\x19\xf0\x19", - ['q'] = "\x10\xf0\x10", - ['r'] = "\x13\xf0\x13", - ['s'] = "\x1f\xf0\x1f", - ['t'] = "\x14\xf0\x14", - ['u'] = "\x16\xf0\x16", - ['v'] = "\x2f\xf0\x2f", - ['w'] = "\x11\xf0\x11", - ['x'] = "\x2d\xf0\x2d", - ['y'] = "\x15\xf0\x15", - ['z'] = "\x2c\xf0\x2c", - ['A'] = "\x12\x1e\xf0\x1e\xf0\x12", - ['B'] = "\x12\x30\xf0\x30\xf0\x12", - ['C'] = "\x12\x2e\xf0\x2e\xf0\x12", - ['D'] = "\x12\x20\xf0\x20\xf0\x12", - ['E'] = "\x12\x12\xf0\x12\xf0\x12", - ['F'] = "\x12\x21\xf0\x21\xf0\x12", - ['G'] = "\x12\x22\xf0\x22\xf0\x12", - ['H'] = "\x12\x23\xf0\x23\xf0\x12", - ['I'] = "\x12\x17\xf0\x17\xf0\x12", - ['J'] = "\x12\x24\xf0\x24\xf0\x12", - ['K'] = "\x12\x25\xf0\x25\xf0\x12", - ['L'] = "\x12\x26\xf0\x26\xf0\x12", - ['M'] = "\x12\x32\xf0\x32\xf0\x12", + ['o'] = "\x44\xf0\x44", + ['p'] = "\x4d\xf0\x4d", + ['q'] = "\x15\xf0\x15", + ['r'] = "\x2d\xf0\x2d", + ['s'] = "\x1b\xf0\x1b", + ['t'] = "\x2c\xf0\x2c", + ['u'] = "\x3c\xf0\x3c", + ['v'] = "\x2a\xf0\x2a", + ['w'] = "\x1d\xf0\x1d", + ['x'] = "\x22\xf0\x22", + ['y'] = "\x35\xf0\x35", + ['z'] = "\x1a\xf0\x1a", + ['A'] = "\x12\x1c\xf0\x1c\xf0\x12", + ['B'] = "\x12\x32\xf0\x32\xf0\x12", + ['C'] = "\x12\x21\xf0\x21\xf0\x12", + ['D'] = "\x12\x23\xf0\x23\xf0\x12", + ['E'] = "\x12\x24\xf0\x24\xf0\x12", + ['F'] = "\x12\x2b\xf0\x2b\xf0\x12", + ['G'] = "\x12\x34\xf0\x34\xf0\x12", + ['H'] = "\x12\x33\xf0\x33\xf0\x12", + ['I'] = "\x12\x43\xf0\x43\xf0\x12", + ['J'] = "\x12\x3b\xf0\x3b\xf0\x12", + ['K'] = "\x12\x42\xf0\x42\xf0\x12", + ['L'] = "\x12\x4b\xf0\x4b\xf0\x12", + ['M'] = "\x12\x3a\xf0\x3a\xf0\x12", ['N'] = "\x12\x31\xf0\x31\xf0\x12", - ['O'] = "\x12\x18\xf0\x18\xf0\x12", - ['P'] = "\x12\x19\xf0\x19\xf0\x12", - ['Q'] = "\x12\x10\xf0\x10\xf0\x12", - ['R'] = "\x12\x13\xf0\x13\xf0\x12", - ['S'] = "\x12\x1f\xf0\x1f\xf0\x12", - ['T'] = "\x12\x14\xf0\x14\xf0\x12", - ['U'] = "\x12\x16\xf0\x16\xf0\x12", - ['V'] = "\x12\x2f\xf0\x2f\xf0\x12", - ['W'] = "\x12\x11\xf0\x11\xf0\x12", - ['X'] = "\x12\x2d\xf0\x2d\xf0\x12", - ['Y'] = "\x12\x15\xf0\x15\xf0\x12", - ['Z'] = "\x12\x2c\xf0\x2c\xf0\x12", + ['O'] = "\x12\x44\xf0\x44\xf0\x12", + ['P'] = "\x12\x4d\xf0\x4d\xf0\x12", + ['Q'] = "\x12\x15\xf0\x15\xf0\x12", + ['R'] = "\x12\x2d\xf0\x2d\xf0\x12", + ['S'] = "\x12\x1b\xf0\x1b\xf0\x12", + ['T'] = "\x12\x2c\xf0\x2c\xf0\x12", + ['U'] = "\x12\x3c\xf0\x3c\xf0\x12", + ['V'] = "\x12\x2a\xf0\x2a\xf0\x12", + ['W'] = "\x12\x1d\xf0\x1d\xf0\x12", + ['X'] = "\x12\x22\xf0\x22\xf0\x12", + ['Y'] = "\x12\x35\xf0\x35\xf0\x12", + ['Z'] = "\x12\x1a\xf0\x1a\xf0\x12", ['`'] = "\x0e\xf0\x0e", ['~'] = "\x12\x0e\xf0\x0e\xf0\x12", ['1'] = "\x16\xf0\x16", @@ -101,6 +101,14 @@ static const char scancodes2[][8] = { ['>'] = "\x12\x49\xf0\x49\xf0\x12", ['/'] = "\x4a\xf0\x4a", ['?'] = "\x12\x4a\xf0\x4a\xf0\x12", + ['\n'] = "\x5a\xf0\x5a", + ['\t'] = "\x0d\xf0\x0d", + ['\b'] = "\x66\xf0\x66", + [' '] = "\x29\xf0\x29", + [0x82] = "\xE0\x75\xE0\xF0\x75", + [0x83] = "\xE0\x72\xE0\xF0\x72", + [0x84] = "\xE0\x6B\xE0\xF0\x6B", + [0x85] = "\xE0\x74\xE0\xF0\x74" }; const unsigned char convert_table[] = { @@ -122,15 +130,18 @@ const unsigned char convert_table[] = { 0x00, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff }; -unsigned char sc_convert_1(unsigned char in) { +unsigned char sc_convert_1(unsigned char in) +{ static int shifted = 0; - if (shifted) { + if (shifted) + { shifted = 0; return convert_table[in] | 0x80; } - if (in == 0xF0) { + if (in == 0xF0) + { shifted = 1; return 0; } else { @@ -138,17 +149,20 @@ unsigned char sc_convert_1(unsigned char in) { } } -void kbd_inject_scancode (unsigned char sc) { +void kbd_inject_scancode (unsigned char sc) +{ outputf("Buffering %02x", sc); kbd_inj_buffer[kbd_inj_end] = sc; kbd_inj_end += 1; kbd_inj_end %= sizeof(kbd_inj_buffer); } -void kbd_inject_key(unsigned char k) { +void kbd_inject_key(unsigned char k) +{ + const char * c; if (kbd_mode == 1) { - const char * c = scancodes2[k]; + c = scancodes2[k]; if (!c) return; while (*c) { char cconv = sc_convert_1(*c); @@ -156,7 +170,7 @@ void kbd_inject_key(unsigned char k) { c++; } } else { - const char * c = scancodes2[k]; + c = scancodes2[k]; if (!c) return; while (*c) { kbd_inject_scancode(*c); @@ -169,7 +183,8 @@ unsigned char kbd_get_injected_scancode() { unsigned char b; - if (kbd_inj_end != kbd_inj_start) { + if (kbd_inj_end != kbd_inj_start) + { b = kbd_inj_buffer[kbd_inj_start]; kbd_inj_start += 1; kbd_inj_start %= sizeof(kbd_inj_buffer); @@ -180,3 +195,13 @@ unsigned char kbd_get_injected_scancode() return 0; } } + +int kbd_has_injected_scancode() +{ + if (kbd_inj_end != kbd_inj_start) + { + return 1; + } else { + return 0; + } +}