Linux/BSD: Modify only keypad keys

The `keycode` field of `InputEventKey` is supposed to be "unshifted";
That is, what the key would output if no modifier keys were pressed.
This should match what's written on the key label, but `Key` enumerates
also all keypad keys, which require a modifier. We thus require some
extra checks for them.

Note that this can still allow "stuck keys", but that's an even deeper
problem.
This commit is contained in:
Riteo 2025-01-29 20:24:46 +01:00
parent a013481b09
commit 140a63be25
6 changed files with 96 additions and 11 deletions

View file

@ -369,6 +369,30 @@ void KeyMappingXKB::initialize() {
location_map[0x86] = KeyLocation::RIGHT;
}
bool KeyMappingXKB::is_sym_numpad(xkb_keysym_t p_keysym) {
switch (p_keysym) {
case XKB_KEY_KP_Multiply:
case XKB_KEY_KP_Divide:
case XKB_KEY_KP_Subtract:
case XKB_KEY_KP_Separator:
case XKB_KEY_KP_Add:
case XKB_KEY_KP_0:
case XKB_KEY_KP_1:
case XKB_KEY_KP_2:
case XKB_KEY_KP_3:
case XKB_KEY_KP_4:
case XKB_KEY_KP_5:
case XKB_KEY_KP_6:
case XKB_KEY_KP_7:
case XKB_KEY_KP_8:
case XKB_KEY_KP_9: {
return true;
} break;
}
return false;
}
Key KeyMappingXKB::get_keycode(xkb_keycode_t p_keysym) {
if (p_keysym >= 0x20 && p_keysym < 0x7E) { // ASCII, maps 1-1
if (p_keysym > 0x60 && p_keysym < 0x7B) { // Lowercase ASCII.