1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-16 14:00:40 +00:00

Allow for mapping keycodes to current layout

This commit is contained in:
Frixuu
2021-09-17 03:07:59 +02:00
parent 2d1699ef82
commit 650e63a7ca
13 changed files with 250 additions and 135 deletions

View File

@@ -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;