Kernel: Update USB HID code to support multiple top-level collections

This allows me to use my laptops own keyboard!
This commit is contained in:
2024-07-16 00:01:53 +03:00
parent a5cb4057f9
commit a60b460701
2 changed files with 142 additions and 109 deletions

View File

@@ -67,6 +67,13 @@ namespace Kernel
BAN_NON_COPYABLE(USBHIDDriver);
BAN_NON_MOVABLE(USBHIDDriver);
public:
struct DeviceReport
{
BAN::Vector<USBHID::Report> inputs;
BAN::RefPtr<USBHIDDevice> device;
};
public:
static BAN::ErrorOr<BAN::UniqPtr<USBHIDDriver>> create(USBDevice&, const USBDevice::InterfaceDescriptor&, uint8_t interface_index);
@@ -78,7 +85,7 @@ namespace Kernel
BAN::ErrorOr<void> initialize();
void forward_collection_inputs(const USBHID::Collection&, BAN::Optional<uint8_t> report_id, BAN::ConstByteSpan& data, size_t bit_offset);
BAN::ErrorOr<BAN::Vector<DeviceReport>> initializes_device_reports(const BAN::Vector<USBHID::Collection>&);
private:
USBDevice& m_device;
@@ -88,8 +95,7 @@ namespace Kernel
bool m_uses_report_id { false };
uint8_t m_endpoint_id { 0 };
BAN::Vector<USBHID::Collection> m_collections;
BAN::RefPtr<USBHIDDevice> m_hid_device;
BAN::Vector<DeviceReport> m_device_inputs;
friend class BAN::UniqPtr<USBHIDDriver>;
};