mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 20:28:11 +00:00
Kernel: Allow remapping Caps Lock to Control (#6883)
We use a global setting to determine if Caps Lock should be remapped to Control because we don't care how keyboard events come in, just that they should be massaged into different scan codes. The `proc` filesystem is able to manipulate this global variable using the `sysctl` utility like so: ``` # sysctl caps_lock_to_ctrl=1 ```
This commit is contained in:
parent
18d344609f
commit
0f89e47a1a
5 changed files with 18 additions and 1 deletions
|
@ -234,9 +234,15 @@ void KeyboardDevice::key_state_changed(u8 scan_code, bool pressed)
|
|||
}
|
||||
}
|
||||
|
||||
if (key == Key_CapsLock && 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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue