1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:47:44 +00:00

Kernel: Ensure KeyEvent::key sent to Userspace respects keyboard layout

Before, only KeyEvent::code_point took the user's keyboard layout
into consideration, while KeyEvent::key was hardcoded QWERTY. This
affected, among other things, Vim Emulation.

Now, KeyEvent::key respects the user's keyboard layout, so will be the
same as KeyEvent::code_point for visible (alphanumeric + symbol) keys.

Co-Authored-By: Ben Wiederhake <BenWiederhake.GitHub@gmx.de>
This commit is contained in:
macarc 2021-05-31 13:20:34 +01:00 committed by Brian Gianforcaro
parent 58746a08a1
commit bffdc056a2
2 changed files with 94 additions and 0 deletions

View file

@ -245,6 +245,11 @@ void KeyboardDevice::key_state_changed(u8 scan_code, bool pressed)
event.caps_lock_on = m_caps_lock_on;
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)
event.key = mapped_key;
if (pressed)
event.flags |= Is_Press;
if (HIDManagement::the().m_client)