mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:37:35 +00:00
Kernel/HID: Add methods to attach and detach standalone devices
This commit is contained in:
parent
83835c7256
commit
62c2c9df69
3 changed files with 27 additions and 0 deletions
|
@ -11,7 +11,9 @@
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
|
class HIDManagement;
|
||||||
class HIDDevice : public CharacterDevice {
|
class HIDDevice : public CharacterDevice {
|
||||||
|
friend class HIDManagement;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
HIDDevice(MajorNumber major, MinorNumber minor)
|
HIDDevice(MajorNumber major, MinorNumber minor)
|
||||||
|
@ -20,6 +22,8 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
EntropySource m_entropy_source;
|
EntropySource m_entropy_source;
|
||||||
|
|
||||||
|
IntrusiveListNode<HIDDevice, NonnullRefPtr<HIDDevice>> m_list_node;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,6 +115,20 @@ void HIDManagement::set_maps(NonnullOwnPtr<KString> character_map_name, Keyboard
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HIDManagement::detach_standalone_hid_device(HIDDevice& device)
|
||||||
|
{
|
||||||
|
m_standalone_hid_devices.with([&](auto& list) {
|
||||||
|
list.remove(device);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void HIDManagement::attach_standalone_hid_device(HIDDevice& device)
|
||||||
|
{
|
||||||
|
m_standalone_hid_devices.with([&](auto& list) {
|
||||||
|
list.append(device);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
UNMAP_AFTER_INIT ErrorOr<void> HIDManagement::enumerate()
|
UNMAP_AFTER_INIT ErrorOr<void> HIDManagement::enumerate()
|
||||||
{
|
{
|
||||||
// FIXME: When we have USB HID support, we should ensure that we disable
|
// FIXME: When we have USB HID support, we should ensure that we disable
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <AK/Atomic.h>
|
#include <AK/Atomic.h>
|
||||||
|
#include <AK/Badge.h>
|
||||||
#include <AK/CircularQueue.h>
|
#include <AK/CircularQueue.h>
|
||||||
#include <AK/Error.h>
|
#include <AK/Error.h>
|
||||||
#include <AK/IntrusiveList.h>
|
#include <AK/IntrusiveList.h>
|
||||||
|
@ -15,6 +16,7 @@
|
||||||
#include <AK/Types.h>
|
#include <AK/Types.h>
|
||||||
#include <Kernel/API/KeyCode.h>
|
#include <Kernel/API/KeyCode.h>
|
||||||
#include <Kernel/Bus/SerialIO/Controller.h>
|
#include <Kernel/Bus/SerialIO/Controller.h>
|
||||||
|
#include <Kernel/Devices/HID/Device.h>
|
||||||
#include <Kernel/Locking/Spinlock.h>
|
#include <Kernel/Locking/Spinlock.h>
|
||||||
#include <Kernel/Locking/SpinlockProtected.h>
|
#include <Kernel/Locking/SpinlockProtected.h>
|
||||||
#include <Kernel/UnixTypes.h>
|
#include <Kernel/UnixTypes.h>
|
||||||
|
@ -51,6 +53,9 @@ public:
|
||||||
void set_client(KeyboardClient* client);
|
void set_client(KeyboardClient* client);
|
||||||
void set_maps(NonnullOwnPtr<KString> character_map_name, Keyboard::CharacterMapData const& character_map);
|
void set_maps(NonnullOwnPtr<KString> character_map_name, Keyboard::CharacterMapData const& character_map);
|
||||||
|
|
||||||
|
void attach_standalone_hid_device(HIDDevice&);
|
||||||
|
void detach_standalone_hid_device(HIDDevice&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
size_t generate_minor_device_number_for_mouse();
|
size_t generate_minor_device_number_for_mouse();
|
||||||
size_t generate_minor_device_number_for_keyboard();
|
size_t generate_minor_device_number_for_keyboard();
|
||||||
|
@ -61,6 +66,10 @@ private:
|
||||||
KeyboardClient* m_client { nullptr };
|
KeyboardClient* m_client { nullptr };
|
||||||
|
|
||||||
SpinlockProtected<IntrusiveList<&SerialIOController::m_list_node>, LockRank::None> m_hid_serial_io_controllers;
|
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
|
||||||
|
// there's no specific serial IO controller to coordinate their usage).
|
||||||
|
SpinlockProtected<IntrusiveList<&HIDDevice::m_list_node>, LockRank::None> m_standalone_hid_devices;
|
||||||
Spinlock<LockRank::None> m_client_lock;
|
Spinlock<LockRank::None> m_client_lock;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue