diff options
author | Edwin Hoksberg <mail@edwinhoksberg.nl> | 2021-07-05 21:51:54 +0200 |
---|---|---|
committer | Gunnar Beutner <gunnar@beutner.name> | 2021-07-07 10:44:20 +0200 |
commit | 99328e1038f4f87e9ea523dc12264a946769b058 (patch) | |
tree | 7ab1dd45d9486d131e5bb30a02c065d285df84b3 /Userland/Services | |
parent | 385e2ccb66b13990587a88cd15e7663117d414c5 (diff) | |
download | serenity-99328e1038f4f87e9ea523dc12264a946769b058.zip |
Kernel+KeyboardSettings: Remove numlock syscall and implement ioctl
Diffstat (limited to 'Userland/Services')
-rw-r--r-- | Userland/Services/KeyboardPreferenceLoader/main.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
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 <LibCore/ConfigFile.h> +#include <LibCore/File.h> #include <errno.h> #include <serenity.h> #include <spawn.h> #include <stdio.h> +#include <sys/ioctl.h> #include <unistd.h> 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; + } } |