1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 01:47:34 +00:00

Kernel/HID: Introduce the all-mice device

This device will be used by userspace to read mouse packets from all
mouse devices that are attached to the machine.

This change is a preparation before we can enable seamless hotplug
capabilities in WindowServer for mouse devices, without any major change
on the userspace side.
This commit is contained in:
Liav A 2023-10-06 21:59:39 +03:00 committed by Andrew Kaster
parent 75183402fd
commit 8a0a3638f0
6 changed files with 111 additions and 0 deletions

View file

@ -16,6 +16,7 @@
#include <AK/Types.h>
#include <Kernel/API/KeyCode.h>
#include <Kernel/Bus/SerialIO/Controller.h>
#include <Kernel/Devices/HID/AllMiceDevice.h>
#include <Kernel/Devices/HID/Device.h>
#include <Kernel/Locking/Spinlock.h>
#include <Kernel/Locking/SpinlockProtected.h>
@ -32,6 +33,7 @@ class KeyboardClient;
class HIDManagement {
friend class KeyboardDevice;
friend class MouseDevice;
friend class AllMiceDevice;
public:
HIDManagement();
@ -56,6 +58,8 @@ public:
void attach_standalone_hid_device(HIDDevice&);
void detach_standalone_hid_device(HIDDevice&);
void enqueue_mouse_packet(Badge<MouseDevice>, MousePacket);
private:
size_t generate_minor_device_number_for_mouse();
size_t generate_minor_device_number_for_keyboard();
@ -65,6 +69,8 @@ private:
size_t m_keyboard_minor_number { 0 };
KeyboardClient* m_client { nullptr };
NonnullRefPtr<AllMiceDevice> m_all_mice_device;
SpinlockProtected<IntrusiveList<&SerialIOController::m_list_node>, LockRank::None> m_hid_serial_io_controllers;
// NOTE: This list is used for standalone devices, like USB HID devices
// (which are not attached via a SerialIO controller in the sense that