From 99328e1038f4f87e9ea523dc12264a946769b058 Mon Sep 17 00:00:00 2001 From: Edwin Hoksberg Date: Mon, 5 Jul 2021 21:51:54 +0200 Subject: Kernel+KeyboardSettings: Remove numlock syscall and implement ioctl --- .../Services/KeyboardPreferenceLoader/main.cpp | 23 ++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'Userland/Services') diff --git a/Userland/Services/KeyboardPreferenceLoader/main.cpp b/Userland/Services/KeyboardPreferenceLoader/main.cpp index acebe25edf..63d2f1036e 100644 --- a/Userland/Services/KeyboardPreferenceLoader/main.cpp +++ b/Userland/Services/KeyboardPreferenceLoader/main.cpp @@ -5,10 +5,12 @@ */ #include +#include #include #include #include #include +#include #include int main() @@ -30,6 +32,11 @@ int main() return 1; } + if (unveil("/dev/keyboard0", "r") < 0) { + perror("unveil /dev/keyboard0"); + return 1; + } + if (unveil(nullptr, nullptr) < 0) { perror("unveil"); return 1; @@ -45,6 +52,18 @@ int main() exit(1); } - bool enable_num_lock = keyboard_settings_config->read_bool_entry("StartupEnable", "NumLock", true); - set_num_lock(enable_num_lock); + bool enable_num_lock = keyboard_settings_config->read_bool_entry("StartupEnable", "NumLock", false); + + auto keyboard_device_or_error = Core::File::open("/dev/keyboard0", Core::OpenMode::ReadOnly); + if (keyboard_device_or_error.is_error()) { + warnln("Failed to open /dev/keyboard0: {}", keyboard_device_or_error.error()); + VERIFY_NOT_REACHED(); + } + auto keyboard_device = keyboard_device_or_error.release_value(); + + int rc = ioctl(keyboard_device->fd(), KEYBOARD_IOCTL_SET_NUM_LOCK, enable_num_lock); + if (rc < 0) { + perror("ioctl(KEYBOARD_IOCTL_SET_NUM_LOCK)"); + return 1; + } } -- cgit v1.2.3