Skip to content

Commit

Permalink
Kernel: Expose minor device numbers for keyboard and mouse
Browse files Browse the repository at this point in the history
A fix for two FIXMEs, and paving the way for multi-keyboard/mouse
support, I guess.
  • Loading branch information
vkoskiv authored and linusg committed May 1, 2021
1 parent 6536a97 commit 370231c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
4 changes: 1 addition & 3 deletions Kernel/Devices/HID/KeyboardDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ class KeyboardDevice : public HIDDevice {
// ^Device
virtual mode_t required_mode() const override { return 0440; }

//FIXME: It should be something like String::formatted("keyboard{}", minor())
// instead of a fixed string like this
virtual String device_name() const override { return "keyboard"; }
virtual String device_name() const override { return String::formatted("keyboard{}", minor()); }

void update_modifier(u8 modifier, bool state)
{
Expand Down
4 changes: 1 addition & 3 deletions Kernel/Devices/HID/MouseDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ class MouseDevice : public HIDDevice {
// ^Device
virtual mode_t required_mode() const override { return 0440; }

//FIXME: It should be something like String::formatted("mouse{}", minor())
// instead of a fixed string like this
virtual String device_name() const override { return "mouse"; }
virtual String device_name() const override { return String::formatted("mouse{}", minor()); }

protected:
MouseDevice();
Expand Down
4 changes: 2 additions & 2 deletions Userland/Services/SystemServer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ static void prepare_devfs()
VERIFY(phys_group);
chown_wrapper("/dev/fb0", 0, phys_group->gr_gid);

chown_wrapper("/dev/keyboard", 0, phys_group->gr_gid);
chown_wrapper("/dev/keyboard0", 0, phys_group->gr_gid);

chown_wrapper("/dev/mouse", 0, phys_group->gr_gid);
chown_wrapper("/dev/mouse0", 0, phys_group->gr_gid);

auto tty_group = getgrnam("tty");
VERIFY(tty_group);
Expand Down
8 changes: 4 additions & 4 deletions Userland/Services/WindowServer/EventLoop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ EventLoop::EventLoop()
: m_window_server(Core::LocalServer::construct())
, m_wm_server(Core::LocalServer::construct())
{
m_keyboard_fd = open("/dev/keyboard", O_RDONLY | O_NONBLOCK | O_CLOEXEC);
m_mouse_fd = open("/dev/mouse", O_RDONLY | O_NONBLOCK | O_CLOEXEC);
m_keyboard_fd = open("/dev/keyboard0", O_RDONLY | O_NONBLOCK | O_CLOEXEC);
m_mouse_fd = open("/dev/mouse0", O_RDONLY | O_NONBLOCK | O_CLOEXEC);

bool ok = m_window_server->take_over_from_system_server("/tmp/portal/window");
VERIFY(ok);
Expand Down Expand Up @@ -64,14 +64,14 @@ EventLoop::EventLoop()
m_keyboard_notifier = Core::Notifier::construct(m_keyboard_fd, Core::Notifier::Read);
m_keyboard_notifier->on_ready_to_read = [this] { drain_keyboard(); };
} else {
dbgln("Couldn't open /dev/keyboard");
dbgln("Couldn't open /dev/keyboard0");
}

if (m_mouse_fd >= 0) {
m_mouse_notifier = Core::Notifier::construct(m_mouse_fd, Core::Notifier::Read);
m_mouse_notifier->on_ready_to_read = [this] { drain_mouse(); };
} else {
dbgln("Couldn't open /dev/mouse");
dbgln("Couldn't open /dev/mouse0");
}
}

Expand Down

0 comments on commit 370231c

Please sign in to comment.