diff options
author | Frixuu <kontakt@lukasz.xyz> | 2021-09-17 03:07:59 +0200 |
---|---|---|
committer | Frixuu <kontakt@lukasz.xyz> | 2021-09-21 00:03:02 +0200 |
commit | 650e63a7ca433e70ab458893f1dcbb8820278d86 (patch) | |
tree | 2416b7d41bc9a0bd160dbe4631cd89f5d0dbd537 /platform/linuxbsd/display_server_x11.cpp | |
parent | 2d1699ef82a29ef65d810194ee76dddc0d9e0389 (diff) |
Allow for mapping keycodes to current layout
Diffstat (limited to 'platform/linuxbsd/display_server_x11.cpp')
-rw-r--r-- | platform/linuxbsd/display_server_x11.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/platform/linuxbsd/display_server_x11.cpp b/platform/linuxbsd/display_server_x11.cpp index 5c6824cf44..a0a5522235 100644 --- a/platform/linuxbsd/display_server_x11.cpp +++ b/platform/linuxbsd/display_server_x11.cpp @@ -2068,6 +2068,24 @@ String DisplayServerX11::keyboard_get_layout_name(int p_index) const { return ret; } +Key DisplayServerX11::keyboard_get_keycode_from_physical(Key p_keycode) const { + unsigned int modifiers = p_keycode & KEY_MODIFIER_MASK; + unsigned int keycode_no_mod = p_keycode & KEY_CODE_MASK; + unsigned int xkeycode = KeyMappingX11::get_xlibcode((Key)keycode_no_mod); + KeySym xkeysym = XkbKeycodeToKeysym(x11_display, xkeycode, 0, 0); + if (xkeysym >= 'a' && xkeysym <= 'z') { + xkeysym -= ('a' - 'A'); + } + + Key key = KeyMappingX11::get_keycode(xkeysym); + // If not found, fallback to QWERTY. + // This should match the behavior of the event pump + if (key == KEY_NONE) { + return p_keycode; + } + return (Key)(key | modifiers); +} + DisplayServerX11::Property DisplayServerX11::_read_property(Display *p_display, Window p_window, Atom p_property) { Atom actual_type = None; int actual_format = 0; |