diff --git a/xrdp/lang.c b/xrdp/lang.c index 256619a2..b565dba8 100644 --- a/xrdp/lang.c +++ b/xrdp/lang.c @@ -23,6 +23,8 @@ #include "xrdp.h" +/* map for rdp to x11 scancodes + code1 is regular scancode, code2 is extended scancode */ struct codepair { tui8 code1; @@ -40,17 +42,22 @@ static struct codepair g_map[] = { 43, 0 }, { 44, 0 }, { 45, 0 }, { 46, 0 }, { 47, 0 }, /* 35 - 39 */ { 48, 0 }, { 49, 0 }, { 50, 0 }, { 51, 0 }, { 52, 0 }, /* 40 - 44 */ { 53, 0 }, { 54, 0 }, { 55, 0 }, { 56, 0 }, { 57, 0 }, /* 45 - 49 */ - { 58, 0 }, { 59, 0 }, { 60, 0 }, { 61, 112 }, { 62, 0 }, /* 50 - 54 */ - { 63, 111 }, { 64, 113 }, { 65, 0 }, { 66, 0 }, { 67, 0 }, /* 55 - 59 */ - { 68, 0 }, { 69, 0 }, { 70, 0 }, { 71, 0 }, { 72, 0 }, /* 60 - 64 */ - { 73, 0 }, { 74, 0 }, { 75, 0 }, { 76, 0 }, { 77, 0 }, /* 65 - 69 */ - { 78, 0 }, { 79, 97 }, { 80, 98 }, { 81, 99 }, { 82, 0 }, /* 70 - 74 */ + { 58, 0 }, { 59, 0 }, { 60, 0 }, { 61, 112 }, { 62, 0 }, /* 50 - 54 */ + { 63, 111 }, { 64, 113 }, { 65, 0 }, { 66, 0 }, { 67, 0 }, /* 55 - 59 */ + { 68, 0 }, { 69, 0 }, { 70, 0 }, { 71, 0 }, { 72, 0 }, /* 60 - 64 */ + { 73, 0 }, { 74, 0 }, { 75, 0 }, { 76, 0 }, { 77, 0 }, /* 65 - 69 */ + { 78, 0 }, { 79, 97 }, { 80, 98 }, { 81, 99 }, { 82, 0 }, /* 70 - 74 */ { 83, 100 }, { 84, 0 }, { 85, 102 }, { 86, 0 }, { 87, 103 }, /* 75 - 79 */ { 88, 104 }, { 89, 105 }, { 90, 106 }, { 91, 107 }, { 92, 0 }, /* 80 - 84 */ - { 93, 0 }, { 94, 0 }, { 95, 0 }, { 96, 0 }, { 97, 0 }, /* 85 - 89 */ - { 98, 0 }, { 0, 115 }, { 0, 116 }, { 0, 117 }, { 102, 0 }, /* 90 - 94 */ - { 103, 0 }, { 104, 0 }, { 105, 0 }, { 106, 0 }, { 107, 0 }, /* 95 - 99 */ - { 108, 0 }, { 109, 0 }, { 110, 0 }, { 111, 0 }, { 112, 0 }, /* 100 - 104 */ + { 93, 0 }, { 94, 0 }, { 95, 0 }, { 96, 0 }, { 97, 0 }, /* 85 - 89 */ + { 98, 0 }, { 0, 115 }, { 0, 116 }, { 0, 117 }, { 102, 0 }, /* 90 - 94 */ + { 103, 0 }, { 104, 0 }, { 105, 0 }, { 106, 0 }, { 107, 0 }, /* 95 - 99 */ + { 108, 0 }, { 109, 0 }, { 110, 0 }, { 111, 0 }, { 112, 0 }, /* 100 - 104 */ + { 113, 0 }, { 114, 0 }, { 115, 0 }, { 116, 0 }, { 117, 0 }, /* 105 - 109 */ + { 118, 0 }, { 119, 0 }, { 120, 0 }, { 121, 0 }, { 122, 0 }, /* 110 - 114 */ + { 123, 0 }, { 124, 0 }, { 125, 0 }, { 126, 0 }, { 127, 0 }, /* 115 - 119 */ + { 128, 0 }, { 129, 0 }, { 130, 0 }, { 131, 0 }, { 132, 0 }, /* 120 - 124 */ + { 133, 0 }, { 134, 0 }, { 135, 0 } /* 125 - 127 */ }; /*****************************************************************************/ @@ -65,27 +72,23 @@ get_key_info_from_scan_code(int device_flags, int scan_code, int* keys, int ext; int index; - ext = device_flags & 0x0100; + ext = device_flags & KBD_FLAG_EXT; /* 0x0100 */ shift = keys[42] || keys[54]; - altgr = keys[56]; /* right alt */ + altgr = keys[56] & KBD_FLAG_EXT; /* right alt */ rv = 0; - scan_code = scan_code % 128; - index = 0; - if (scan_code <= (sizeof(g_map) / sizeof(g_map[0]))) - { - index = ext ? g_map[scan_code].code2 : g_map[scan_code].code1; - } + scan_code = scan_code & 0x7f; + index = ext ? g_map[scan_code].code2 : g_map[scan_code].code1; /* keymap file is created with numlock off so we have to do this */ if ((index >= 79) && (index <= 91)) { - if (num_lock) - { - rv = &(keymap->keys_shift[index]); - } - else - { - rv = &(keymap->keys_noshift[index]); - } + if (num_lock) + { + rv = &(keymap->keys_shift[index]); + } + else + { + rv = &(keymap->keys_noshift[index]); + } } else if (shift && caps_lock) { diff --git a/xrdp/xrdp_wm.c b/xrdp/xrdp_wm.c index e532e2ab..9d7dcde9 100644 --- a/xrdp/xrdp_wm.c +++ b/xrdp/xrdp_wm.c @@ -1106,7 +1106,7 @@ xrdp_wm_key(struct xrdp_wm* self, int device_flags, int scan_code) } else /* key down */ { - self->keys[scan_code] = 1; + self->keys[scan_code] = 1 | device_flags; msg = WM_KEYDOWN; switch (scan_code) {