summaryrefslogtreecommitdiffstats
path: root/platform/linuxbsd/x11/key_mapping_x11.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-01-29 13:15:42 +0100
committerRémi Verschelde <rverschelde@gmail.com>2024-01-29 13:15:42 +0100
commitf220d46cdccb15f1aa141cd89c9dacee85b1b6ec (patch)
treebd02a89eb9942b5e6e6b54335ad750661502bc86 /platform/linuxbsd/x11/key_mapping_x11.cpp
parent17e7f85c06366b427e5068c5b3e2940e27ff5f1d (diff)
parent8406e60522bb8d09649193be43c1c819edc1d059 (diff)
downloadredot-engine-f220d46cdccb15f1aa141cd89c9dacee85b1b6ec.tar.gz
Merge pull request #80231 from romlok/input-key-location
Support detecting and mapping ctrl/alt/shift/meta by their left/right physical location
Diffstat (limited to 'platform/linuxbsd/x11/key_mapping_x11.cpp')
-rw-r--r--platform/linuxbsd/x11/key_mapping_x11.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/platform/linuxbsd/x11/key_mapping_x11.cpp b/platform/linuxbsd/x11/key_mapping_x11.cpp
index c0e6b91d57..b589a2a573 100644
--- a/platform/linuxbsd/x11/key_mapping_x11.cpp
+++ b/platform/linuxbsd/x11/key_mapping_x11.cpp
@@ -1113,6 +1113,20 @@ void KeyMappingX11::initialize() {
xkeysym_unicode_map[0x13BD] = 0x0153;
xkeysym_unicode_map[0x13BE] = 0x0178;
xkeysym_unicode_map[0x20AC] = 0x20AC;
+
+ // Scancode to physical location map.
+ // Ctrl.
+ location_map[0x25] = KeyLocation::LEFT;
+ location_map[0x69] = KeyLocation::RIGHT;
+ // Shift.
+ location_map[0x32] = KeyLocation::LEFT;
+ location_map[0x3E] = KeyLocation::RIGHT;
+ // Alt.
+ location_map[0x40] = KeyLocation::LEFT;
+ location_map[0x6C] = KeyLocation::RIGHT;
+ // Meta.
+ location_map[0x85] = KeyLocation::LEFT;
+ location_map[0x86] = KeyLocation::RIGHT;
}
Key KeyMappingX11::get_keycode(KeySym p_keysym) {
@@ -1173,3 +1187,11 @@ char32_t KeyMappingX11::get_unicode_from_keysym(KeySym p_keysym) {
}
return 0;
}
+
+KeyLocation KeyMappingX11::get_location(unsigned int p_code) {
+ const KeyLocation *location = location_map.getptr(p_code);
+ if (location) {
+ return *location;
+ }
+ return KeyLocation::UNSPECIFIED;
+}