diff --git a/client/X11/xfreerdp.c b/client/X11/xfreerdp.c index 44450d674..d073f84e9 100644 --- a/client/X11/xfreerdp.c +++ b/client/X11/xfreerdp.c @@ -777,7 +777,7 @@ int xf_process_client_args(rdpSettings* settings, const char* opt, const char* v if (strcmp("--kbd-list", opt) == 0) { int i; - rdpKeyboardLayout* layouts; + RDP_KEYBOARD_LAYOUT* layouts; layouts = freerdp_keyboard_get_layouts(RDP_KEYBOARD_LAYOUT_TYPE_STANDARD); printf("\nKeyboard Layouts\n"); diff --git a/include/freerdp/locale/keyboard.h b/include/freerdp/locale/keyboard.h index c06a4323b..cc4f6e5b5 100644 --- a/include/freerdp/locale/keyboard.h +++ b/include/freerdp/locale/keyboard.h @@ -27,17 +27,31 @@ #define RDP_KEYBOARD_LAYOUT_TYPE_VARIANT 2 #define RDP_KEYBOARD_LAYOUT_TYPE_IME 4 -struct rdp_keyboard_layout +struct _RDP_KEYBOARD_LAYOUT { - uint32 code; - char name[64]; + uint32 code; /* Keyboard layout code */ + char* name; /* Keyboard layout name */ }; -typedef struct rdp_keyboard_layout rdpKeyboardLayout; +typedef struct _RDP_KEYBOARD_LAYOUT RDP_KEYBOARD_LAYOUT; + +struct _RDP_SCANCODE +{ + uint32 code; /* Windows "scan code" */ + boolean extended; /* extended key flag */ +}; +typedef struct _RDP_SCANCODE RDP_SCANCODE; + +struct _VIRTUAL_KEY_CODE +{ + uint32 code; /* Windows Virtual Key Code */ + const char* name; /* Virtual Key Code Name */ +}; +typedef struct _VIRTUAL_KEY_CODE VIRTUAL_KEY_CODE; struct _VIRTUAL_KEY { - uint32 scancode; /* Windows "scan code", aka keycode in RDP */ - boolean extended; /* Windows "extended" flag, boolean */ + uint32 scancode; /* Windows "scan code" */ + boolean extended; /* extended key flag */ const char* name; /* Windows virtual key name */ const char* x_keyname; /* XKB keyname */ }; @@ -249,7 +263,7 @@ typedef struct _VIRTUAL_KEY VIRTUAL_KEY; /* Application launcher keys */ #define VK_LAUNCH_MAIL 0xB4 /* Windows 2000/XP: Start Mail key */ -#define VK_LAUNCH_MEDIA_SELECT 0xB5 /* Windows 2000/XP: Select Media key */ +#define VK_MEDIA_SELECT 0xB5 /* Windows 2000/XP: Select Media key */ #define VK_LAUNCH_APP1 0xB6 /* Windows 2000/XP: Start Application 1 key */ #define VK_LAUNCH_APP2 0xB7 /* Windows 2000/XP: Start Application 2 key */ @@ -475,7 +489,7 @@ typedef struct _VIRTUAL_KEY VIRTUAL_KEY; #define KBD_CHINESE_TRADITIONAL_ALPHANUMERIC 0xE00F0404 FREERDP_API uint32 freerdp_keyboard_init(uint32 keyboard_layout_id); -FREERDP_API rdpKeyboardLayout* freerdp_keyboard_get_layouts(uint32 types); +FREERDP_API RDP_KEYBOARD_LAYOUT* freerdp_keyboard_get_layouts(uint32 types); FREERDP_API const char* freerdp_keyboard_get_layout_name_from_id(uint32 keyboardLayoutID); FREERDP_API uint32 freerdp_keyboard_get_scancode_from_keycode(uint32 keycode, boolean* extended); FREERDP_API uint32 freerdp_keyboard_get_keycode_from_scancode(uint32 scancode, boolean extended); diff --git a/libfreerdp-locale/keyboard.c b/libfreerdp-locale/keyboard.c index 2e9d6a674..9b6d3b8ab 100644 --- a/libfreerdp-locale/keyboard.c +++ b/libfreerdp-locale/keyboard.c @@ -53,9 +53,9 @@ extern const VIRTUAL_KEY virtualKeyboard[258]; * but it only depends on which keycodes the X servers keyboard driver uses and is thus very static. */ -RdpScancodes x_keycode_to_rdp_scancode; +RDP_KEYCODE x11_keycode_to_rdp_scancode[256]; -uint8 rdp_scancode_to_x_keycode[256][2]; +uint32 rdp_scancode_to_x11_keycode[256][2]; static int freerdp_keyboard_load_map(KeycodeToVkcode map, char* name) { @@ -201,16 +201,16 @@ static int freerdp_keyboard_load_map(KeycodeToVkcode map, char* name) return 1; } -void freerdp_keyboard_load_maps(KeycodeToVkcode keycodeToVkcode, char* xkbfile) +void freerdp_keyboard_load_maps(KeycodeToVkcode keycodeToVkcode, char* names) { char* kbd; - char* xkbfileEnd; + char* namesEnd; int keymapLoaded = 0; memset(keycodeToVkcode, 0, sizeof(keycodeToVkcode)); - kbd = xkbfile; - xkbfileEnd = xkbfile + strlen(xkbfile); + kbd = names; + namesEnd = names + strlen(names); do { @@ -223,7 +223,7 @@ void freerdp_keyboard_load_maps(KeycodeToVkcode keycodeToVkcode, char* xkbfile) kbd += kbdlen + 1; } - while (kbd < xkbfileEnd); + while (kbd < namesEnd); DEBUG_KBD("loaded %d keymaps", keymapLoaded); @@ -256,8 +256,8 @@ uint32 freerdp_detect_keyboard(uint32 keyboardLayoutID) uint32 freerdp_keyboard_init_xkb(uint32 keyboardLayoutId) { void* display; - memset(x_keycode_to_rdp_scancode, 0, sizeof(x_keycode_to_rdp_scancode)); - memset(rdp_scancode_to_x_keycode, '\0', sizeof(rdp_scancode_to_x_keycode)); + memset(x11_keycode_to_rdp_scancode, 0, sizeof(x11_keycode_to_rdp_scancode)); + memset(rdp_scancode_to_x11_keycode, '\0', sizeof(rdp_scancode_to_x11_keycode)); display = freerdp_keyboard_xkb_init(); @@ -273,7 +273,7 @@ uint32 freerdp_keyboard_init_xkb(uint32 keyboardLayoutId) DEBUG_KBD("detect_keyboard_layout_from_xkb: %X", keyboardLayoutId); } - freerdp_keyboard_load_map_from_xkb(display, x_keycode_to_rdp_scancode, rdp_scancode_to_x_keycode); + freerdp_keyboard_load_map_from_xkb(display, x11_keycode_to_rdp_scancode, rdp_scancode_to_x11_keycode); return keyboardLayoutId; } @@ -286,8 +286,8 @@ uint32 freerdp_keyboard_init_x11(uint32 keyboardLayoutId) uint32 keycode; KeycodeToVkcode keycodeToVkcode; - memset(x_keycode_to_rdp_scancode, 0, sizeof(x_keycode_to_rdp_scancode)); - memset(rdp_scancode_to_x_keycode, '\0', sizeof(rdp_scancode_to_x_keycode)); + memset(x11_keycode_to_rdp_scancode, 0, sizeof(x11_keycode_to_rdp_scancode)); + memset(rdp_scancode_to_x11_keycode, '\0', sizeof(rdp_scancode_to_x11_keycode)); if (keyboardLayoutId == 0) { @@ -314,14 +314,14 @@ uint32 freerdp_keyboard_init_x11(uint32 keyboardLayoutId) keycode, vkcode, virtualKeyboard[vkcode].name, virtualKeyboard[vkcode].extended, virtualKeyboard[vkcode].scancode); - x_keycode_to_rdp_scancode[keycode].keycode = virtualKeyboard[vkcode].scancode; - x_keycode_to_rdp_scancode[keycode].extended = virtualKeyboard[vkcode].extended; - x_keycode_to_rdp_scancode[keycode].keyname = virtualKeyboard[vkcode].name; + x11_keycode_to_rdp_scancode[keycode].keycode = virtualKeyboard[vkcode].scancode; + x11_keycode_to_rdp_scancode[keycode].extended = virtualKeyboard[vkcode].extended; + x11_keycode_to_rdp_scancode[keycode].keyname = virtualKeyboard[vkcode].name; - if (x_keycode_to_rdp_scancode[keycode].extended) - rdp_scancode_to_x_keycode[virtualKeyboard[vkcode].scancode][1] = keycode; + if (x11_keycode_to_rdp_scancode[keycode].extended) + rdp_scancode_to_x11_keycode[virtualKeyboard[vkcode].scancode][1] = keycode; else - rdp_scancode_to_x_keycode[virtualKeyboard[vkcode].scancode][0] = keycode; + rdp_scancode_to_x11_keycode[virtualKeyboard[vkcode].scancode][0] = keycode; } return keyboardLayoutId; @@ -347,20 +347,20 @@ uint32 freerdp_keyboard_init(uint32 keyboardLayoutId) uint32 freerdp_keyboard_get_scancode_from_keycode(uint32 keycode, boolean* extended) { - DEBUG_KBD("%2x %4s -> %d/%d", keycode, x_keycode_to_rdp_scancode[keycode].keyname, - x_keycode_to_rdp_scancode[keycode].extended, x_keycode_to_rdp_scancode[keycode].keycode); + DEBUG_KBD("%2x %4s -> %d/%d", keycode, x11_keycode_to_rdp_scancode[keycode].keyname, + x11_keycode_to_rdp_scancode[keycode].extended, x11_keycode_to_rdp_scancode[keycode].keycode); - *extended = x_keycode_to_rdp_scancode[keycode].extended; + *extended = x11_keycode_to_rdp_scancode[keycode].extended; - return x_keycode_to_rdp_scancode[keycode].keycode; + return x11_keycode_to_rdp_scancode[keycode].keycode; } uint32 freerdp_keyboard_get_keycode_from_scancode(uint32 scancode, boolean extended) { if (extended) - return rdp_scancode_to_x_keycode[scancode][1]; + return rdp_scancode_to_x11_keycode[scancode][1]; else - return rdp_scancode_to_x_keycode[scancode][0]; + return rdp_scancode_to_x11_keycode[scancode][0]; } uint32 freerdp_keyboard_get_scancode_from_vkcode(uint32 vkcode, boolean* extended) diff --git a/libfreerdp-locale/keyboard.h b/libfreerdp-locale/keyboard.h index ba732ab2d..9a971e6d2 100644 --- a/libfreerdp-locale/keyboard.h +++ b/libfreerdp-locale/keyboard.h @@ -22,15 +22,16 @@ #include -typedef unsigned char KeycodeToVkcode[256]; +typedef uint32 KeycodeToVkcode[256]; -typedef struct +struct _RDP_KEYCODE { - uint8 extended; - uint8 keycode; + uint32 extended; + uint32 keycode; const char* keyname; -} RdpKeycodeRec, RdpScancodes[256]; +}; +typedef struct _RDP_KEYCODE RDP_KEYCODE; -void freerdp_keyboard_load_maps(KeycodeToVkcode keycodeToVkcode, char* xkbfile); +void freerdp_keyboard_load_maps(KeycodeToVkcode keycodeToVkcode, char* names); #endif /* __KEYBOARD_H */ diff --git a/libfreerdp-locale/keyboard_layout.c b/libfreerdp-locale/keyboard_layout.c index 3998ec925..b2c07a2ec 100644 --- a/libfreerdp-locale/keyboard_layout.c +++ b/libfreerdp-locale/keyboard_layout.c @@ -26,19 +26,12 @@ #include #include -struct _keyboardLayout -{ - uint32 code; /* Keyboard layout code */ - const char* name; /* Keyboard layout name */ -}; -typedef struct _keyboardLayout keyboardLayout; - /* * In Windows XP, this information is available in the system registry at * HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet001/Control/Keyboard Layouts/ */ -static const keyboardLayout keyboardLayouts[] = +static const RDP_KEYBOARD_LAYOUT RDP_KEYBOARD_LAYOUT_TABLE[] = { { KBD_ARABIC_101, "Arabic (101)" }, { KBD_BULGARIAN, "Bulgarian" }, @@ -126,15 +119,15 @@ static const keyboardLayout keyboardLayouts[] = { KBD_BOSNIAN_CYRILLIC, "Bosnian Cyrillic" } }; -typedef struct +struct _RDP_KEYBOARD_LAYOUT_VARIANT { uint32 code; /* Keyboard layout code */ - uint16 id; /* Keyboard variant ID */ + uint32 id; /* Keyboard variant ID */ const char* name; /* Keyboard layout variant name */ +}; +typedef struct _RDP_KEYBOARD_LAYOUT_VARIANT RDP_KEYBOARD_LAYOUT_VARIANT; -} keyboardLayoutVariant; - -static const keyboardLayoutVariant keyboardLayoutVariants[] = +static const RDP_KEYBOARD_LAYOUT_VARIANT RDP_KEYBOARD_LAYOUT_VARIANT_TABLE[] = { { KBD_ARABIC_102, 0x0028, "Arabic (102)" }, { KBD_BULGARIAN_LATIN, 0x0004, "Bulgarian (Latin)" }, @@ -183,18 +176,17 @@ static const keyboardLayoutVariant keyboardLayoutVariants[] = /* Input Method Editor (IME) */ -typedef struct +struct _RDP_KEYBOARD_IME { uint32 code; /* Keyboard layout code */ - const char* fileName; /* IME file name */ + const char* file; /* IME file */ const char* name; /* Keyboard layout name */ - -} keyboardIME; - +}; +typedef struct _RDP_KEYBOARD_IME RDP_KEYBOARD_IME; /* Global Input Method Editors (IME) */ -static const keyboardIME keyboardIMEs[] = +static const RDP_KEYBOARD_IME RDP_KEYBOARD_IME_TABLE[] = { { KBD_CHINESE_TRADITIONAL_PHONETIC, "phon.ime", "Chinese (Traditional) - Phonetic" }, { KBD_JAPANESE_INPUT_SYSTEM_MS_IME2002, "imjp81.ime", "Japanese Input System (MS-IME2002)" }, @@ -215,6 +207,447 @@ static const keyboardIME keyboardIMEs[] = { KBD_CHINESE_TRADITIONAL_ALPHANUMERIC, "romanime.ime", "Chinese (Traditional) - Alphanumeric" } }; +const VIRTUAL_KEY_CODE VIRTUAL_KEY_CODES[] = +{ + { VK_LBUTTON, "VK_LBUTTON" }, + { VK_RBUTTON, "VK_RBUTTON" }, + { VK_CANCEL, "VK_CANCEL" }, + { VK_MBUTTON, "VK_MBUTTON" }, + { VK_XBUTTON1, "VK_XBUTTON1" }, + { VK_XBUTTON2, "VK_XBUTTON2" }, + { VK_BACK, "VK_BACK" }, + { VK_TAB, "VK_TAB" }, + { VK_CLEAR, "VK_CLEAR" }, + { VK_RETURN, "VK_RETURN" }, + { VK_SHIFT, "VK_SHIFT" }, + { VK_CONTROL, "VK_CONTROL" }, + { VK_MENU, "VK_MENU" }, + { VK_PAUSE, "VK_PAUSE" }, + { VK_CAPITAL, "VK_CAPITAL" }, + { VK_KANA, "VK_KANA" }, + { VK_HANGUEL, "VK_HANGUEL" }, + { VK_HANGUL, "VK_HANGUL" }, + { VK_JUNJA, "VK_JUNJA" }, + { VK_FINAL, "VK_FINAL" }, + { VK_HANJA, "VK_HANJA" }, + { VK_KANJI, "VK_KANJI" }, + { VK_ESCAPE, "VK_ESCAPE" }, + { VK_CONVERT, "VK_CONVERT" }, + { VK_NONCONVERT, "VK_NONCONVERT" }, + { VK_ACCEPT, "VK_ACCEPT" }, + { VK_MODECHANGE, "VK_MODECHANGE" }, + { VK_SPACE, "VK_SPACE" }, + { VK_PRIOR, "VK_PRIOR" }, + { VK_NEXT, "VK_NEXT" }, + { VK_END, "VK_END" }, + { VK_HOME, "VK_HOME" }, + { VK_LEFT, "VK_LEFT" }, + { VK_UP, "VK_UP" }, + { VK_RIGHT, "VK_RIGHT" }, + { VK_DOWN, "VK_DOWN" }, + { VK_SELECT, "VK_SELECT" }, + { VK_PRINT, "VK_PRINT" }, + { VK_EXECUTE, "VK_EXECUTE" }, + { VK_SNAPSHOT, "VK_SNAPSHOT" }, + { VK_INSERT, "VK_INSERT" }, + { VK_DELETE, "VK_DELETE" }, + { VK_HELP, "VK_HELP" }, + { VK_KEY_0, "VK_KEY_0" }, + { VK_KEY_1, "VK_KEY_1" }, + { VK_KEY_2, "VK_KEY_2" }, + { VK_KEY_3, "VK_KEY_3" }, + { VK_KEY_4, "VK_KEY_4" }, + { VK_KEY_5, "VK_KEY_5" }, + { VK_KEY_6, "VK_KEY_6" }, + { VK_KEY_7, "VK_KEY_7" }, + { VK_KEY_8, "VK_KEY_8" }, + { VK_KEY_9, "VK_KEY_9" }, + { VK_KEY_A, "VK_KEY_A" }, + { VK_KEY_B, "VK_KEY_B" }, + { VK_KEY_C, "VK_KEY_C" }, + { VK_KEY_D, "VK_KEY_D" }, + { VK_KEY_E, "VK_KEY_E" }, + { VK_KEY_F, "VK_KEY_F" }, + { VK_KEY_G, "VK_KEY_G" }, + { VK_KEY_H, "VK_KEY_H" }, + { VK_KEY_I, "VK_KEY_I" }, + { VK_KEY_J, "VK_KEY_J" }, + { VK_KEY_K, "VK_KEY_K" }, + { VK_KEY_L, "VK_KEY_L" }, + { VK_KEY_M, "VK_KEY_M" }, + { VK_KEY_N, "VK_KEY_N" }, + { VK_KEY_O, "VK_KEY_O" }, + { VK_KEY_P, "VK_KEY_P" }, + { VK_KEY_Q, "VK_KEY_Q" }, + { VK_KEY_R, "VK_KEY_R" }, + { VK_KEY_S, "VK_KEY_S" }, + { VK_KEY_T, "VK_KEY_T" }, + { VK_KEY_U, "VK_KEY_U" }, + { VK_KEY_V, "VK_KEY_V" }, + { VK_KEY_W, "VK_KEY_W" }, + { VK_KEY_X, "VK_KEY_X" }, + { VK_KEY_Y, "VK_KEY_Y" }, + { VK_KEY_Z, "VK_KEY_Z" }, + { VK_LWIN, "VK_LWIN" }, + { VK_RWIN, "VK_RWIN" }, + { VK_APPS, "VK_APPS" }, + { VK_SLEEP, "VK_SLEEP" }, + { VK_NUMPAD0, "VK_NUMPAD0" }, + { VK_NUMPAD1, "VK_NUMPAD1" }, + { VK_NUMPAD2, "VK_NUMPAD2" }, + { VK_NUMPAD3, "VK_NUMPAD3" }, + { VK_NUMPAD4, "VK_NUMPAD4" }, + { VK_NUMPAD5, "VK_NUMPAD5" }, + { VK_NUMPAD6, "VK_NUMPAD6" }, + { VK_NUMPAD7, "VK_NUMPAD7" }, + { VK_NUMPAD8, "VK_NUMPAD8" }, + { VK_NUMPAD9, "VK_NUMPAD9" }, + { VK_MULTIPLY, "VK_MULTIPLY" }, + { VK_ADD, "VK_ADD" }, + { VK_SEPARATOR, "VK_SEPARATOR" }, + { VK_SUBTRACT, "VK_SUBTRACT" }, + { VK_DECIMAL, "VK_DECIMAL" }, + { VK_DIVIDE, "VK_DIVIDE" }, + { VK_F1, "VK_F1" }, + { VK_F2, "VK_F2" }, + { VK_F3, "VK_F3" }, + { VK_F4, "VK_F4" }, + { VK_F5, "VK_F5" }, + { VK_F6, "VK_F6" }, + { VK_F7, "VK_F7" }, + { VK_F8, "VK_F8" }, + { VK_F9, "VK_F9" }, + { VK_F10, "VK_F10" }, + { VK_F11, "VK_F11" }, + { VK_F12, "VK_F12" }, + { VK_F13, "VK_F13" }, + { VK_F14, "VK_F14" }, + { VK_F15, "VK_F15" }, + { VK_F16, "VK_F16" }, + { VK_F17, "VK_F17" }, + { VK_F18, "VK_F18" }, + { VK_F19, "VK_F19" }, + { VK_F20, "VK_F20" }, + { VK_F21, "VK_F21" }, + { VK_F22, "VK_F22" }, + { VK_F23, "VK_F23" }, + { VK_F24, "VK_F24" }, + { VK_NUMLOCK, "VK_NUMLOCK" }, + { VK_SCROLL, "VK_SCROLL" }, + { VK_LSHIFT, "VK_LSHIFT" }, + { VK_RSHIFT, "VK_RSHIFT" }, + { VK_LCONTROL, "VK_LCONTROL" }, + { VK_RCONTROL, "VK_RCONTROL" }, + { VK_LMENU, "VK_LMENU" }, + { VK_RMENU, "VK_RMENU" }, + { VK_BROWSER_BACK, "VK_BROWSER_BACK" }, + { VK_BROWSER_FORWARD, "VK_BROWSER_FORWARD" }, + { VK_BROWSER_REFRESH, "VK_BROWSER_REFRESH" }, + { VK_BROWSER_STOP, "VK_BROWSER_STOP" }, + { VK_BROWSER_SEARCH, "VK_BROWSER_SEARCH" }, + { VK_BROWSER_FAVORITES, "VK_BROWSER_FAVORITES" }, + { VK_BROWSER_HOME, "VK_BROWSER_HOME" }, + { VK_VOLUME_MUTE, "VK_VOLUME_MUTE" }, + { VK_VOLUME_DOWN, "VK_VOLUME_DOWN" }, + { VK_VOLUME_UP, "VK_VOLUME_UP" }, + { VK_MEDIA_NEXT_TRACK, "VK_MEDIA_NEXT_TRACK" }, + { VK_MEDIA_PREV_TRACK, "VK_MEDIA_PREV_TRACK" }, + { VK_MEDIA_STOP, "VK_MEDIA_STOP" }, + { VK_MEDIA_PLAY_PAUSE, "VK_MEDIA_PLAY_PAUSE" }, + { VK_LAUNCH_MAIL, "VK_LAUNCH_MAIL" }, + { VK_MEDIA_SELECT, "VK_MEDIA_SELECT" }, + { VK_LAUNCH_APP1, "VK_LAUNCH_APP1" }, + { VK_LAUNCH_APP2, "VK_LAUNCH_APP2" }, + { VK_OEM_1, "VK_OEM_1" }, + { VK_OEM_PLUS, "VK_OEM_PLUS" }, + { VK_OEM_COMMA, "VK_OEM_COMMA" }, + { VK_OEM_MINUS, "VK_OEM_MINUS" }, + { VK_OEM_PERIOD, "VK_OEM_PERIOD" }, + { VK_OEM_2, "VK_OEM_2" }, + { VK_OEM_3, "VK_OEM_3" }, + { VK_ABNT_C1, "VK_ABNT_C1" }, + { VK_ABNT_C2, "VK_ABNT_C2" }, + { VK_OEM_4, "VK_OEM_4" }, + { VK_OEM_5, "VK_OEM_5" }, + { VK_OEM_6, "VK_OEM_6" }, + { VK_OEM_7, "VK_OEM_7" }, + { VK_OEM_8, "VK_OEM_8" }, + { VK_OEM_102, "VK_OEM_102" }, + { VK_PROCESSKEY, "VK_PROCESSKEY" }, + { VK_PACKET, "VK_PACKET" }, + { VK_ATTN, "VK_ATTN" }, + { VK_CRSEL, "VK_CRSEL" }, + { VK_EXSEL, "VK_EXSEL" }, + { VK_EREOF, "VK_EREOF" }, + { VK_PLAY, "VK_PLAY" }, + { VK_ZOOM, "VK_ZOOM" }, + { VK_NONAME, "VK_NONAME" }, + { VK_PA1, "VK_PA1" }, + { VK_OEM_CLEAR, "VK_OEM_CLEAR" } +}; + +/* the index in this table is the virtual key code */ + +const RDP_SCANCODE VIRTUAL_KEY_CODE_TO_RDP_SCANCODE_TABLE[] = +{ + { 0x00, 0 }, + { 0x00, 0 }, /* VK_LBUTTON */ + { 0x00, 0 }, /* VK_RBUTTON */ + { 0x00, 0 }, /* VK_CANCEL */ + { 0x00, 0 }, /* VK_MBUTTON */ + { 0x00, 0 }, /* VK_XBUTTON1 */ + { 0x00, 0 }, /* VK_XBUTTON2 */ + { 0x00, 0 }, + { 0x0E, 0 }, /* VK_BACK */ + { 0x0F, 0 }, /* VK_TAB */ + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, /* VK_CLEAR */ + { 0x1C, 0 }, /* VK_RETURN */ + { 0x00, 0 }, + { 0x00, 0 }, + { 0x2A, 0 }, /* VK_SHIFT */ + { 0x00, 0 }, /* VK_CONTROL */ + { 0x38, 0 }, /* VK_MENU */ + { 0x46, 1 }, /* VK_PAUSE */ + { 0x3A, 0 }, /* VK_CAPITAL */ + { 0x72, 0 }, /* VK_KANA / VK_HANGUL */ + { 0x00, 0 }, + { 0x00, 0 }, /* VK_JUNJA */ + { 0x00, 0 }, /* VK_FINAL */ + { 0x71, 0 }, /* VK_HANJA / VK_KANJI */ + { 0x00, 0 }, + { 0x01, 0 }, /* VK_ESCAPE */ + { 0x00, 0 }, /* VK_CONVERT */ + { 0x00, 0 }, /* VK_NONCONVERT */ + { 0x00, 0 }, /* VK_ACCEPT */ + { 0x00, 0 }, /* VK_MODECHANGE */ + { 0x39, 0 }, /* VK_SPACE */ + { 0x49, 1 }, /* VK_PRIOR */ + { 0x51, 1 }, /* VK_NEXT */ + { 0x4F, 1 }, /* VK_END */ + { 0x47, 1 }, /* VK_HOME */ + { 0x4B, 1 }, /* VK_LEFT */ + { 0x48, 1 }, /* VK_UP */ + { 0x4D, 1 }, /* VK_RIGHT */ + { 0x50, 1 }, /* VK_DOWN */ + { 0x00, 0 }, /* VK_SELECT */ + { 0x37, 1 }, /* VK_PRINT */ + { 0x37, 1 }, /* VK_EXECUTE */ + { 0x37, 1 }, /* VK_SNAPSHOT */ + { 0x52, 1 }, /* VK_INSERT */ + { 0x53, 1 }, /* VK_DELETE */ + { 0x63, 0 }, /* VK_HELP */ + { 0x0B, 0 }, /* VK_KEY_0 */ + { 0x02, 0 }, /* VK_KEY_1 */ + { 0x03, 0 }, /* VK_KEY_2 */ + { 0x04, 0 }, /* VK_KEY_3 */ + { 0x05, 0 }, /* VK_KEY_4 */ + { 0x06, 0 }, /* VK_KEY_5 */ + { 0x07, 0 }, /* VK_KEY_6 */ + { 0x08, 0 }, /* VK_KEY_7 */ + { 0x09, 0 }, /* VK_KEY_8 */ + { 0x0A, 0 }, /* VK_KEY_9 */ + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x1E, 0 }, /* VK_KEY_A */ + { 0x30, 0 }, /* VK_KEY_B */ + { 0x2E, 0 }, /* VK_KEY_C */ + { 0x20, 0 }, /* VK_KEY_D */ + { 0x12, 0 }, /* VK_KEY_E */ + { 0x21, 0 }, /* VK_KEY_F */ + { 0x22, 0 }, /* VK_KEY_G */ + { 0x23, 0 }, /* VK_KEY_H */ + { 0x17, 0 }, /* VK_KEY_I */ + { 0x24, 0 }, /* VK_KEY_J */ + { 0x25, 0 }, /* VK_KEY_K */ + { 0x26, 0 }, /* VK_KEY_L */ + { 0x32, 0 }, /* VK_KEY_M */ + { 0x31, 0 }, /* VK_KEY_N */ + { 0x18, 0 }, /* VK_KEY_O */ + { 0x19, 0 }, /* VK_KEY_P */ + { 0x10, 0 }, /* VK_KEY_Q */ + { 0x13, 0 }, /* VK_KEY_R */ + { 0x1F, 0 }, /* VK_KEY_S */ + { 0x14, 0 }, /* VK_KEY_T */ + { 0x16, 0 }, /* VK_KEY_U */ + { 0x2F, 0 }, /* VK_KEY_V */ + { 0x11, 0 }, /* VK_KEY_W */ + { 0x2D, 0 }, /* VK_KEY_X */ + { 0x15, 0 }, /* VK_KEY_Y */ + { 0x2C, 0 }, /* VK_KEY_Z */ + { 0x5B, 1 }, /* VK_LWIN */ + { 0x5C, 1 }, /* VK_RWIN */ + { 0x5D, 1 }, /* VK_APPS */ + { 0x00, 0 }, + { 0x5F, 0 }, /* VK_SLEEP */ + { 0x52, 0 }, /* VK_NUMPAD0 */ + { 0x4F, 0 }, /* VK_NUMPAD1 */ + { 0x50, 0 }, /* VK_NUMPAD2 */ + { 0x51, 0 }, /* VK_NUMPAD3 */ + { 0x4B, 0 }, /* VK_NUMPAD4 */ + { 0x4C, 0 }, /* VK_NUMPAD5 */ + { 0x4D, 0 }, /* VK_NUMPAD6 */ + { 0x47, 0 }, /* VK_NUMPAD7 */ + { 0x48, 0 }, /* VK_NUMPAD8 */ + { 0x49, 0 }, /* VK_NUMPAD9 */ + { 0x37, 0 }, /* VK_MULTIPLY */ + { 0x4E, 0 }, /* VK_ADD */ + { 0x00, 0 }, /* VK_SEPARATOR */ + { 0x4A, 0 }, /* VK_SUBTRACT */ + { 0x53, 0 }, /* VK_DECIMAL */ + { 0x35, 0 }, /* VK_DIVIDE */ + { 0x3B, 0 }, /* VK_F1 */ + { 0x3C, 0 }, /* VK_F2 */ + { 0x3D, 0 }, /* VK_F3 */ + { 0x3E, 0 }, /* VK_F4 */ + { 0x3F, 0 }, /* VK_F5 */ + { 0x40, 0 }, /* VK_F6 */ + { 0x41, 0 }, /* VK_F7 */ + { 0x42, 0 }, /* VK_F8 */ + { 0x43, 0 }, /* VK_F9 */ + { 0x44, 0 }, /* VK_F10 */ + { 0x57, 0 }, /* VK_F11 */ + { 0x58, 0 }, /* VK_F12 */ + { 0x64, 0 }, /* VK_F13 */ + { 0x65, 0 }, /* VK_F14 */ + { 0x66, 0 }, /* VK_F15 */ + { 0x67, 0 }, /* VK_F16 */ + { 0x68, 0 }, /* VK_F17 */ + { 0x69, 0 }, /* VK_F18 */ + { 0x6A, 0 }, /* VK_F19 */ + { 0x6B, 0 }, /* VK_F20 */ + { 0x6C, 0 }, /* VK_F21 */ + { 0x6D, 0 }, /* VK_F22 */ + { 0x6E, 0 }, /* VK_F23 */ + { 0x6F, 0 }, /* VK_F24 */ + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x45, 0 }, /* VK_NUMLOCK */ + { 0x46, 0 }, /* VK_SCROLL */ + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x2A, 0 }, /* VK_LSHIFT */ + { 0x36, 0 }, /* VK_RSHIFT */ + { 0x1D, 0 }, /* VK_LCONTROL */ + { 0x1D, 1 }, /* VK_RCONTROL */ + { 0x38, 0 }, /* VK_LMENU */ + { 0x38, 1 }, /* VK_RMENU */ + { 0x00, 0 }, /* VK_BROWSER_BACK */ + { 0x00, 0 }, /* VK_BROWSER_FORWARD */ + { 0x00, 0 }, /* VK_BROWSER_REFRESH */ + { 0x00, 0 }, /* VK_BROWSER_STOP */ + { 0x00, 0 }, /* VK_BROWSER_SEARCH */ + { 0x00, 0 }, /* VK_BROWSER_FAVORITES */ + { 0x00, 0 }, /* VK_BROWSER_HOME */ + { 0x00, 0 }, /* VK_VOLUME_MUTE */ + { 0x00, 0 }, /* VK_VOLUME_DOWN */ + { 0x00, 0 }, /* VK_VOLUME_UP */ + { 0x00, 0 }, /* VK_MEDIA_NEXT_TRACK */ + { 0x00, 0 }, /* VK_MEDIA_PREV_TRACK */ + { 0x00, 0 }, /* VK_MEDIA_STOP */ + { 0x00, 0 }, /* VK_MEDIA_PLAY_PAUSE */ + { 0x00, 0 }, /* VK_LAUNCH_MAIL */ + { 0x00, 0 }, /* VK_MEDIA_SELECT */ + { 0x00, 0 }, /* VK_LAUNCH_APP1 */ + { 0x00, 0 }, /* VK_LAUNCH_APP2 */ + { 0x00, 0 }, + { 0x00, 0 }, + { 0x27, 0 }, /* VK_OEM_1 */ + { 0x0D, 0 }, /* VK_OEM_PLUS */ + { 0x33, 0 }, /* VK_OEM_COMMA */ + { 0x0C, 0 }, /* VK_OEM_MINUS */ + { 0x34, 0 }, /* VK_OEM_PERIOD */ + { 0x35, 0 }, /* VK_OEM_2 */ + { 0x29, 0 }, /* VK_OEM_3 */ + { 0x73, 0 }, /* VK_ABNT_C1 */ + { 0x7E, 0 }, /* VK_ABNT_C2 */ + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x1A, 0 }, /* VK_OEM_4 */ + { 0x2B, 0 }, /* VK_OEM_5 */ + { 0x1B, 0 }, /* VK_OEM_6 */ + { 0x28, 0 }, /* VK_OEM_7 */ + { 0x1D, 0 }, /* VK_OEM_8 */ + { 0x00, 0 }, + { 0x00, 0 }, + { 0x56, 0 }, /* VK_OEM_102 */ + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, /* VK_PROCESSKEY */ + { 0x00, 0 }, + { 0x00, 0 }, /* VK_PACKET */ + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, + { 0x00, 0 }, /* VK_ATTN */ + { 0x00, 0 }, /* VK_CRSEL */ + { 0x00, 0 }, /* VK_EXSEL */ + { 0x00, 0 }, /* VK_EREOF */ + { 0x00, 0 }, /* VK_PLAY */ + { 0x62, 0 }, /* VK_ZOOM */ + { 0x00, 0 }, /* VK_NONAME */ + { 0x00, 0 }, /* VK_PA1 */ + { 0x00, 0 }, /* VK_OEM_CLEAR */ + { 0x00, 0 } +}; + const VIRTUAL_KEY virtualKeyboard[] = { { 0x00, 0, "" , NULL }, @@ -478,50 +911,50 @@ const VIRTUAL_KEY virtualKeyboard[] = { 0x1C, 1, "" , "KPEN" } }; -rdpKeyboardLayout* freerdp_keyboard_get_layouts(uint32 types) +RDP_KEYBOARD_LAYOUT* freerdp_keyboard_get_layouts(uint32 types) { int num, length, i; - rdpKeyboardLayout* layouts; + RDP_KEYBOARD_LAYOUT* layouts; num = 0; - layouts = (rdpKeyboardLayout*) xmalloc((num + 1) * sizeof(rdpKeyboardLayout)); + layouts = (RDP_KEYBOARD_LAYOUT*) xmalloc((num + 1) * sizeof(RDP_KEYBOARD_LAYOUT)); if ((types & RDP_KEYBOARD_LAYOUT_TYPE_STANDARD) != 0) { - length = sizeof(keyboardLayouts) / sizeof(keyboardLayout); + length = sizeof(RDP_KEYBOARD_LAYOUT_TABLE) / sizeof(RDP_KEYBOARD_LAYOUT); - layouts = (rdpKeyboardLayout *) xrealloc(layouts, (num + length + 1) * sizeof(rdpKeyboardLayout)); + layouts = (RDP_KEYBOARD_LAYOUT*) xrealloc(layouts, (num + length + 1) * sizeof(RDP_KEYBOARD_LAYOUT)); for (i = 0; i < length; i++, num++) { - layouts[num].code = keyboardLayouts[i].code; - strcpy(layouts[num].name, keyboardLayouts[i].name); + layouts[num].code = RDP_KEYBOARD_LAYOUT_TABLE[i].code; + strcpy(layouts[num].name, RDP_KEYBOARD_LAYOUT_TABLE[i].name); } } if ((types & RDP_KEYBOARD_LAYOUT_TYPE_VARIANT) != 0) { - length = sizeof(keyboardLayoutVariants) / sizeof(keyboardLayoutVariant); - layouts = (rdpKeyboardLayout *) xrealloc(layouts, (num + length + 1) * sizeof(rdpKeyboardLayout)); + length = sizeof(RDP_KEYBOARD_LAYOUT_VARIANT_TABLE) / sizeof(RDP_KEYBOARD_LAYOUT_VARIANT); + layouts = (RDP_KEYBOARD_LAYOUT*) xrealloc(layouts, (num + length + 1) * sizeof(RDP_KEYBOARD_LAYOUT)); for (i = 0; i < length; i++, num++) { - layouts[num].code = keyboardLayoutVariants[i].code; - strcpy(layouts[num].name, keyboardLayoutVariants[i].name); + layouts[num].code = RDP_KEYBOARD_LAYOUT_VARIANT_TABLE[i].code; + strcpy(layouts[num].name, RDP_KEYBOARD_LAYOUT_VARIANT_TABLE[i].name); } } if ((types & RDP_KEYBOARD_LAYOUT_TYPE_IME) != 0) { - length = sizeof(keyboardIMEs) / sizeof(keyboardIME); - layouts = (rdpKeyboardLayout *) realloc(layouts, (num + length + 1) * sizeof(rdpKeyboardLayout)); + length = sizeof(RDP_KEYBOARD_IME_TABLE) / sizeof(RDP_KEYBOARD_IME); + layouts = (RDP_KEYBOARD_LAYOUT*) realloc(layouts, (num + length + 1) * sizeof(RDP_KEYBOARD_LAYOUT)); for (i = 0; i < length; i++, num++) { - layouts[num].code = keyboardIMEs[i].code; - strcpy(layouts[num].name, keyboardIMEs[i].name); + layouts[num].code = RDP_KEYBOARD_IME_TABLE[i].code; + strcpy(layouts[num].name, RDP_KEYBOARD_IME_TABLE[i].name); } } - memset(&layouts[num], 0, sizeof(rdpKeyboardLayout)); + memset(&layouts[num], 0, sizeof(RDP_KEYBOARD_LAYOUT)); return layouts; } @@ -530,22 +963,22 @@ const char* freerdp_keyboard_get_layout_name_from_id(uint32 keyboardLayoutID) { int i; - for (i = 0; i < sizeof(keyboardLayouts) / sizeof(keyboardLayout); i++) + for (i = 0; i < sizeof(RDP_KEYBOARD_LAYOUT_TABLE) / sizeof(RDP_KEYBOARD_LAYOUT); i++) { - if (keyboardLayouts[i].code == keyboardLayoutID) - return keyboardLayouts[i].name; + if (RDP_KEYBOARD_LAYOUT_TABLE[i].code == keyboardLayoutID) + return RDP_KEYBOARD_LAYOUT_TABLE[i].name; } - for (i = 0; i < sizeof(keyboardLayoutVariants) / sizeof(keyboardLayoutVariant); i++) + for (i = 0; i < sizeof(RDP_KEYBOARD_LAYOUT_VARIANT_TABLE) / sizeof(RDP_KEYBOARD_LAYOUT_VARIANT); i++) { - if (keyboardLayoutVariants[i].code == keyboardLayoutID) - return keyboardLayoutVariants[i].name; + if (RDP_KEYBOARD_LAYOUT_VARIANT_TABLE[i].code == keyboardLayoutID) + return RDP_KEYBOARD_LAYOUT_VARIANT_TABLE[i].name; } - for (i = 0; i < sizeof(keyboardIMEs) / sizeof(keyboardIME); i++) + for (i = 0; i < sizeof(RDP_KEYBOARD_IME_TABLE) / sizeof(RDP_KEYBOARD_IME); i++) { - if (keyboardIMEs[i].code == keyboardLayoutID) - return keyboardIMEs[i].name; + if (RDP_KEYBOARD_IME_TABLE[i].code == keyboardLayoutID) + return RDP_KEYBOARD_IME_TABLE[i].name; } return "unknown"; diff --git a/libfreerdp-locale/keyboard_xkb.c b/libfreerdp-locale/keyboard_xkb.c index f11f2faf3..9b6fd5b9b 100644 --- a/libfreerdp-locale/keyboard_xkb.c +++ b/libfreerdp-locale/keyboard_xkb.c @@ -23,7 +23,7 @@ #include "keyboard_x11.h" #include -extern const VIRTUAL_KEY virtualKeyboard[258]; +extern const RDP_SCANCODE VIRTUAL_KEY_CODE_TO_RDP_SCANCODE_TABLE[]; #include #include @@ -32,6 +32,271 @@ extern const VIRTUAL_KEY virtualKeyboard[258]; #include +VIRTUAL_KEY_CODE_TO_XKB_KEY_NAME VIRTUAL_KEY_CODE_TO_XKB_KEY_NAME_TABLE[] = +{ + { 0, "" }, + { VK_LBUTTON, "" }, + { VK_RBUTTON, "" }, + { VK_CANCEL, "" }, + { VK_MBUTTON, "" }, + { VK_XBUTTON1, "" }, + { VK_XBUTTON2, "" }, + { 0, "" }, + { VK_BACK, "BKSP" }, + { VK_TAB, "TAB" }, + { 0, "" }, + { 0, "" }, + { VK_CLEAR, "" }, + { VK_RETURN, "RTRN" }, + { 0, "" }, + { 0, "" }, + { VK_SHIFT, "LFSH" }, + { VK_CONTROL, "" }, + { VK_MENU, "LALT" }, + { VK_PAUSE, "PAUS" }, + { VK_CAPITAL, "CAPS" }, + { VK_KANA / VK_HANGUL, "" }, + { 0, "" }, + { VK_JUNJA, "" }, + { VK_FINAL, "" }, + { VK_HANJA / VK_KANJI, "" }, + { 0, "" }, + { VK_ESCAPE, "ESC" }, + { VK_CONVERT, "" }, + { VK_NONCONVERT, "" }, + { VK_ACCEPT, "" }, + { VK_MODECHANGE, "" }, + { VK_SPACE, "SPCE" }, + { VK_PRIOR, "PGUP" }, + { VK_NEXT, "PGDN" }, + { VK_END, "END" }, + { VK_HOME, "HOME" }, + { VK_LEFT, "LEFT" }, + { VK_UP, "UP" }, + { VK_RIGHT, "RGHT" }, + { VK_DOWN, "DOWN" }, + { VK_SELECT, "" }, + { VK_PRINT, "PRSC" }, + { VK_EXECUTE, "" }, + { VK_SNAPSHOT, "" }, + { VK_INSERT, "INS" }, + { VK_DELETE, "DELE" }, + { VK_HELP, "" }, + { VK_KEY_0, "AE10" }, + { VK_KEY_1, "AE01" }, + { VK_KEY_2, "AE02" }, + { VK_KEY_3, "AE03" }, + { VK_KEY_4, "AE04" }, + { VK_KEY_5, "AE05" }, + { VK_KEY_6, "AE06" }, + { VK_KEY_7, "AE07" }, + { VK_KEY_8, "AE08" }, + { VK_KEY_9, "AE09" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { VK_KEY_A, "AC01" }, + { VK_KEY_B, "AB05" }, + { VK_KEY_C, "AB03" }, + { VK_KEY_D, "AC03" }, + { VK_KEY_E, "AD03" }, + { VK_KEY_F, "AC04" }, + { VK_KEY_G, "AC05" }, + { VK_KEY_H, "AC06" }, + { VK_KEY_I, "AD08" }, + { VK_KEY_J, "AC07" }, + { VK_KEY_K, "AC08" }, + { VK_KEY_L, "AC09" }, + { VK_KEY_M, "AB07" }, + { VK_KEY_N, "AB06" }, + { VK_KEY_O, "AD09" }, + { VK_KEY_P, "AD10" }, + { VK_KEY_Q, "AD01" }, + { VK_KEY_R, "AD04" }, + { VK_KEY_S, "AC02" }, + { VK_KEY_T, "AD05" }, + { VK_KEY_U, "AD07" }, + { VK_KEY_V, "AB04" }, + { VK_KEY_W, "AD02" }, + { VK_KEY_X, "AB02" }, + { VK_KEY_Y, "AD06" }, + { VK_KEY_Z, "AB01" }, + { VK_LWIN, "LWIN" }, + { VK_RWIN, "RWIN" }, + { VK_APPS, "COMP" }, + { 0, "" }, + { VK_SLEEP, "" }, + { VK_NUMPAD0, "KP0" }, + { VK_NUMPAD1, "KP1" }, + { VK_NUMPAD2, "KP2" }, + { VK_NUMPAD3, "KP3" }, + { VK_NUMPAD4, "KP4" }, + { VK_NUMPAD5, "KP5" }, + { VK_NUMPAD6, "KP6" }, + { VK_NUMPAD7, "KP7" }, + { VK_NUMPAD8, "KP8" }, + { VK_NUMPAD9, "KP9" }, + { VK_MULTIPLY, "KPMU" }, + { VK_ADD, "KPAD" }, + { VK_SEPARATOR, "" }, + { VK_SUBTRACT, "KPSU" }, + { VK_DECIMAL, "KPDL" }, + { VK_DIVIDE, "KPDV" }, + { VK_F1, "FK01" }, + { VK_F2, "FK02" }, + { VK_F3, "FK03" }, + { VK_F4, "FK04" }, + { VK_F5, "FK05" }, + { VK_F6, "FK06" }, + { VK_F7, "FK07" }, + { VK_F8, "FK08" }, + { VK_F9, "FK09" }, + { VK_F10, "FK10" }, + { VK_F11, "FK11" }, + { VK_F12, "FK12" }, + { VK_F13, "" }, + { VK_F14, "" }, + { VK_F15, "" }, + { VK_F16, "" }, + { VK_F17, "" }, + { VK_F18, "" }, + { VK_F19, "" }, + { VK_F20, "" }, + { VK_F21, "" }, + { VK_F22, "" }, + { VK_F23, "" }, + { VK_F24, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { VK_NUMLOCK, "NMLK" }, + { VK_SCROLL, "SCLK" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { VK_LSHIFT, "" }, + { VK_RSHIFT, "RTSH" }, + { VK_LCONTROL, "LCTL" }, + { VK_RCONTROL, "RCTL" }, + { VK_LMENU, "" }, + { VK_RMENU, "RALT" }, + { VK_BROWSER_BACK, "" }, + { VK_BROWSER_FORWARD, "" }, + { VK_BROWSER_REFRESH, "" }, + { VK_BROWSER_STOP, "" }, + { VK_BROWSER_SEARCH, "" }, + { VK_BROWSER_FAVORITES, "" }, + { VK_BROWSER_HOME, "" }, + { VK_VOLUME_MUTE, "" }, + { VK_VOLUME_DOWN, "" }, + { VK_VOLUME_UP, "" }, + { VK_MEDIA_NEXT_TRACK, "" }, + { VK_MEDIA_PREV_TRACK, "" }, + { VK_MEDIA_STOP, "" }, + { VK_MEDIA_PLAY_PAUSE, "" }, + { VK_LAUNCH_MAIL, "" }, + { VK_MEDIA_SELECT, "" }, + { VK_LAUNCH_APP1, "" }, + { VK_LAUNCH_APP2, "" }, + { 0, "" }, + { 0, "" }, + { VK_OEM_1, "AC10" }, + { VK_OEM_PLUS, "AE12" }, + { VK_OEM_COMMA, "AB08" }, + { VK_OEM_MINUS, "AE11" }, + { VK_OEM_PERIOD, "AB09" }, + { VK_OEM_2, "AB10" }, + { VK_OEM_3, "TLDE" }, + { VK_ABNT_C1, "AB11" }, + { VK_ABNT_C2, "I129" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { VK_OEM_4, "AD11" }, + { VK_OEM_5, "BKSL" }, + { VK_OEM_6, "AD12" }, + { VK_OEM_7, "AC11" }, + { VK_OEM_8, "" }, + { 0, "" }, + { 0, "" }, + { VK_OEM_102, "LSGT" }, + { 0, "" }, + { 0, "" }, + { VK_PROCESSKEY, "" }, + { 0, "" }, + { VK_PACKET, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { 0, "" }, + { VK_ATTN, "" }, + { VK_CRSEL, "" }, + { VK_EXSEL, "" }, + { VK_EREOF, "" }, + { VK_PLAY, "" }, + { VK_ZOOM, "" }, + { VK_NONAME, "" }, + { VK_PA1, "" }, + { VK_OEM_CLEAR, "" }, + { 0, "" } +}; + +/* +{ 0x54, 0, "" , "LVL3" }, +{ 0x1C, 1, "" , "KPEN" } +*/ + void* freerdp_keyboard_xkb_init() { int status; @@ -112,51 +377,52 @@ uint32 detect_keyboard_layout_from_xkb(void* display) return keyboard_layout; } -int freerdp_keyboard_load_map_from_xkb(void* display, RdpScancodes x_keycode_to_rdp_scancode, uint8 rdp_scancode_to_x_keycode[256][2]) +int freerdp_keyboard_load_map_from_xkb(void* display, RDP_KEYCODE x_keycode_to_rdp_scancode[256], uint32 rdp_scancode_to_x_keycode[256][2]) { - int status = 0; + int i, j; + boolean found; XkbDescPtr xkb; + boolean status = false; if (display && (xkb = XkbGetMap(display, 0, XkbUseCoreKbd))) { if (XkbGetNames(display, XkbKeyNamesMask, xkb) == Success) { - int i, j; - char buf[5] = {42, 42, 42, 42, 0}; /* end-of-string at pos 5 */ + char xkb_keyname[5] = { 42, 42, 42, 42, 0 }; /* end-of-string at index 5 */ for (i = xkb->min_key_code; i <= xkb->max_key_code; i++) { - memcpy(buf, xkb->names->keys[i].name, 4); + found = false; + memcpy(xkb_keyname, xkb->names->keys[i].name, 4); - j = sizeof(virtualKeyboard) / sizeof(virtualKeyboard[0]) - 1; - - while (j >= 0) + for (j = 0; j < 256; j++) { - if (virtualKeyboard[j].x_keyname && !strcmp(buf, virtualKeyboard[j].x_keyname)) - break; - j--; + if (VIRTUAL_KEY_CODE_TO_XKB_KEY_NAME_TABLE[j].xkb_keyname) + { + if (!strcmp(xkb_keyname, VIRTUAL_KEY_CODE_TO_XKB_KEY_NAME_TABLE[j].xkb_keyname)) + { + found = true; + break; + } + } } - if (j >= 0) + if (found) { - DEBUG_KBD("X keycode %3d has keyname %-4s -> RDP scancode %d/%d", - i, buf, virtualKeyboard[j].extended, virtualKeyboard[j].scancode); + uint32 vkcode = VIRTUAL_KEY_CODE_TO_XKB_KEY_NAME_TABLE[j].vkcode; - x_keycode_to_rdp_scancode[i].extended = virtualKeyboard[j].extended; - x_keycode_to_rdp_scancode[i].keycode = virtualKeyboard[j].scancode; - x_keycode_to_rdp_scancode[i].keyname = virtualKeyboard[j].x_keyname; + x_keycode_to_rdp_scancode[i].keycode = VIRTUAL_KEY_CODE_TO_RDP_SCANCODE_TABLE[vkcode].code; + x_keycode_to_rdp_scancode[i].extended = VIRTUAL_KEY_CODE_TO_RDP_SCANCODE_TABLE[vkcode].extended; + x_keycode_to_rdp_scancode[i].keyname = VIRTUAL_KEY_CODE_TO_XKB_KEY_NAME_TABLE[j].xkb_keyname; if (x_keycode_to_rdp_scancode[i].extended) - rdp_scancode_to_x_keycode[virtualKeyboard[j].scancode][1] = i; + rdp_scancode_to_x_keycode[VIRTUAL_KEY_CODE_TO_RDP_SCANCODE_TABLE[vkcode].code][1] = i; else - rdp_scancode_to_x_keycode[virtualKeyboard[j].scancode][0] = i; - } - else - { - DEBUG_KBD("X key code %3d has keyname %-4s -> ??? - not found", i, buf); + rdp_scancode_to_x_keycode[VIRTUAL_KEY_CODE_TO_RDP_SCANCODE_TABLE[vkcode].code][0] = i; } } - status = 1; + + status = true; } XkbFreeKeyboard(xkb, 0, 1); diff --git a/libfreerdp-locale/keyboard_xkb.h b/libfreerdp-locale/keyboard_xkb.h index b7041e155..d569a4e2d 100644 --- a/libfreerdp-locale/keyboard_xkb.h +++ b/libfreerdp-locale/keyboard_xkb.h @@ -21,6 +21,13 @@ #include "keyboard.h" +struct _VIRTUAL_KEY_CODE_TO_XKB_KEY_NAME +{ + uint32 vkcode; /* virtual key code */ + const char* xkb_keyname; /* XKB keyname */ +}; +typedef struct _VIRTUAL_KEY_CODE_TO_XKB_KEY_NAME VIRTUAL_KEY_CODE_TO_XKB_KEY_NAME; + void* freerdp_keyboard_xkb_init(); uint32 detect_keyboard_layout_from_xkb(void* display); -int freerdp_keyboard_load_map_from_xkb(void* display, RdpScancodes x_keycode_to_rdp_scancode, uint8 rdp_scancode_to_x_keycode[256][2]); +int freerdp_keyboard_load_map_from_xkb(void* display, RDP_KEYCODE x11_keycode_to_rdp_scancode[256], uint32 rdp_scancode_to_x11_keycode[256][2]);