summaryrefslogtreecommitdiff
path: root/Kernel/Devices
diff options
context:
space:
mode:
authorCorey Williamson <euclidianAce@protonmail.com>2021-12-21 00:46:46 -0600
committerAndreas Kling <kling@serenityos.org>2022-01-03 15:54:32 +0100
commitf51834d6107e05a06a785b11893cd12f4a102d2b (patch)
tree754b39a0b7456e5768cd148e588d452ea78952d9 /Kernel/Devices
parent452150c632c1f2ee63839ae7597eb7e511cde6e9 (diff)
downloadserenity-f51834d6107e05a06a785b11893cd12f4a102d2b.zip
Kernel: Allow backspace '\b' to be remapped
Previously, one could put '\b' in a keymap, but in non-Terminal applications, it would just insert a literal '\b' character instead of behaving like backspace. This patch modifes `visible_code_point_to_key_code` to include backspace, as well as renaming it to `code_point_to_key_code` since '\b' is not a visible character. Additionally, `KeyboardDevice::key_state_changed` has been rearranged to apply the user's keymap before checking for things like caps lock.
Diffstat (limited to 'Kernel/Devices')
-rw-r--r--Kernel/Devices/HID/KeyboardDevice.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/Kernel/Devices/HID/KeyboardDevice.cpp b/Kernel/Devices/HID/KeyboardDevice.cpp
index e9cf3ac903..9c6ecbf137 100644
--- a/Kernel/Devices/HID/KeyboardDevice.cpp
+++ b/Kernel/Devices/HID/KeyboardDevice.cpp
@@ -228,15 +228,6 @@ void KeyboardDevice::key_state_changed(u8 scan_code, bool pressed)
}
}
- if (!g_caps_lock_remapped_to_ctrl && key == Key_CapsLock && pressed)
- m_caps_lock_on = !m_caps_lock_on;
-
- if (g_caps_lock_remapped_to_ctrl && key == Key_CapsLock)
- m_caps_lock_to_ctrl_pressed = pressed;
-
- if (g_caps_lock_remapped_to_ctrl)
- update_modifier(Mod_Ctrl, m_caps_lock_to_ctrl_pressed);
-
Event event;
event.key = key;
event.scancode = m_has_e0_prefix ? 0xe000 + scan_code : scan_code;
@@ -246,9 +237,20 @@ void KeyboardDevice::key_state_changed(u8 scan_code, bool pressed)
event.code_point = HIDManagement::the().character_map().get_char(event);
// If using a non-QWERTY layout, event.key needs to be updated to be the same as event.code_point
- KeyCode mapped_key = visible_code_point_to_key_code(event.code_point);
- if (mapped_key != KeyCode::Key_Invalid)
+ KeyCode mapped_key = code_point_to_key_code(event.code_point);
+ if (mapped_key != KeyCode::Key_Invalid) {
event.key = mapped_key;
+ key = mapped_key;
+ }
+
+ if (!g_caps_lock_remapped_to_ctrl && key == Key_CapsLock && pressed)
+ m_caps_lock_on = !m_caps_lock_on;
+
+ if (g_caps_lock_remapped_to_ctrl && key == Key_CapsLock)
+ m_caps_lock_to_ctrl_pressed = pressed;
+
+ if (g_caps_lock_remapped_to_ctrl)
+ update_modifier(Mod_Ctrl, m_caps_lock_to_ctrl_pressed);
if (pressed)
event.flags |= Is_Press;