@@ -535,8 +535,19 @@ namespace lvh::detail {
535535 return it->second ;
536536 }
537537
538- int key_code_to_linux (KeyboardKeyCode key_code) {
539- static constexpr std::array<std::pair<KeyboardKeyCode, int >, 47 > special_keys {{
538+ int key_code_to_linux (KeyboardKeyCode key_code, bool uses_normalized_key_code) {
539+ if (!uses_normalized_key_code) {
540+ switch (key_code) {
541+ case 0xDC :
542+ return KEY_YEN ;
543+ case 0xE2 :
544+ return KEY_RO ;
545+ default :
546+ break ;
547+ }
548+ }
549+
550+ static constexpr std::array<std::pair<KeyboardKeyCode, int >, 50 > special_keys {{
540551 {0x08 , KEY_BACKSPACE },
541552 {0x09 , KEY_TAB },
542553 {0x0D , KEY_ENTER },
@@ -547,7 +558,10 @@ namespace lvh::detail {
547558 {0x12 , KEY_LEFTALT },
548559 {0xA4 , KEY_LEFTALT },
549560 {0x14 , KEY_CAPSLOCK },
561+ {0x15 , KEY_KATAKANAHIRAGANA },
550562 {0x1B , KEY_ESC },
563+ {0x1C , KEY_HENKAN },
564+ {0x1D , KEY_MUHENKAN },
551565 {0x20 , KEY_SPACE },
552566 {0x21 , KEY_PAGEUP },
553567 {0x22 , KEY_PAGEDOWN },
@@ -1442,7 +1456,7 @@ namespace lvh::detail {
14421456
14431457 private:
14441458 OperationStatus emit_keyboard_event (const KeyboardEvent &event) {
1445- const auto linux_key = key_code_to_linux (event.key_code );
1459+ const auto linux_key = key_code_to_linux (event.key_code , event. uses_normalized_key_code );
14461460 if (linux_key < 0 ) {
14471461 return OperationStatus::failure (ErrorCode::invalid_argument, " keyboard key code is not supported by the Linux backend" );
14481462 }
@@ -2034,8 +2048,19 @@ namespace lvh::detail {
20342048 };
20352049
20362050#if defined(LIBVIRTUALHID_HAVE_XTEST)
2037- KeySym key_code_to_keysym (KeyboardKeyCode key_code) {
2038- static constexpr std::array<std::pair<KeyboardKeyCode, KeySym>, 45 > special_keysyms {{
2051+ KeySym key_code_to_keysym (KeyboardKeyCode key_code, bool uses_normalized_key_code) {
2052+ if (!uses_normalized_key_code) {
2053+ switch (key_code) {
2054+ case 0xDC :
2055+ return XK_yen;
2056+ case 0xE2 :
2057+ return XK_backslash;
2058+ default :
2059+ break ;
2060+ }
2061+ }
2062+
2063+ static constexpr std::array<std::pair<KeyboardKeyCode, KeySym>, 49 > special_keysyms {{
20392064 {0x08 , XK_BackSpace},
20402065 {0x09 , XK_Tab},
20412066 {0x0D , XK_Return},
@@ -2046,7 +2071,10 @@ namespace lvh::detail {
20462071 {0x12 , XK_Alt_L},
20472072 {0xA4 , XK_Alt_L},
20482073 {0x14 , XK_Caps_Lock},
2074+ {0x15 , XK_Hiragana_Katakana},
20492075 {0x1B , XK_Escape},
2076+ {0x1C , XK_Henkan},
2077+ {0x1D , XK_Muhenkan},
20502078 {0x20 , XK_space},
20512079 {0x21 , XK_Page_Up},
20522080 {0x22 , XK_Page_Down},
@@ -2081,6 +2109,7 @@ namespace lvh::detail {
20812109 {0xDC , XK_backslash},
20822110 {0xDD , XK_bracketright},
20832111 {0xDE , XK_apostrophe},
2112+ {0xE2 , XK_backslash},
20842113 }};
20852114
20862115 if (const auto keysym = mapped_keyboard_code (key_code, special_keysyms); keysym.has_value ()) {
@@ -2169,7 +2198,7 @@ namespace lvh::detail {
21692198 return OperationStatus::failure (ErrorCode::device_closed, " XTest keyboard is closed" );
21702199 }
21712200
2172- const auto keysym = key_code_to_keysym (event.key_code );
2201+ const auto keysym = key_code_to_keysym (event.key_code , event. uses_normalized_key_code );
21732202 if (keysym == NoSymbol) {
21742203 return OperationStatus::failure (ErrorCode::invalid_argument, " keyboard key code is not supported by XTest fallback" );
21752204 }
0 commit comments