mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:47:44 +00:00
Kernel+KeyboardSettings: Remove numlock syscall and implement ioctl
This commit is contained in:
parent
385e2ccb66
commit
99328e1038
10 changed files with 21 additions and 38 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue