1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 04:58:13 +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:
Spencer Dixon 2021-05-05 17:10:56 -04:00 committed by GitHub
parent 18d344609f
commit 0f89e47a1a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 1 deletions

View file

@ -1,5 +1,6 @@
/*
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021, Spencer Dixon <spencercdixon@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -970,6 +971,7 @@ bool ProcFS::initialize()
{
static Lockable<bool>* kmalloc_stack_helper;
static Lockable<bool>* ubsan_deadly_helper;
static Lockable<bool>* caps_lock_to_ctrl_helper;
if (kmalloc_stack_helper == nullptr) {
kmalloc_stack_helper = new Lockable<bool>();
@ -982,6 +984,10 @@ bool ProcFS::initialize()
ProcFS::add_sys_bool("ubsan_is_deadly", *ubsan_deadly_helper, [] {
UBSanitizer::g_ubsan_is_deadly = ubsan_deadly_helper->resource();
});
caps_lock_to_ctrl_helper = new Lockable<bool>();
ProcFS::add_sys_bool("caps_lock_to_ctrl", *caps_lock_to_ctrl_helper, [] {
Kernel::g_caps_lock_remapped_to_ctrl.exchange(caps_lock_to_ctrl_helper->resource());
});
}
return true;
}