Kernel: Add super basic support for USB keyboard LEDs

This is very hacky but it seems to mostly work. Also for some reason
this fixed my Razer Mamba mouse????
This commit is contained in:
2025-02-11 02:18:50 +02:00
parent 4dd6c85df2
commit 088f77a226
4 changed files with 113 additions and 8 deletions

View File

@@ -78,6 +78,9 @@ namespace Kernel
void handle_stall(uint8_t endpoint_id) override;
void handle_input_data(size_t byte_count, uint8_t endpoint_id) override;
USBDevice& device() { return m_device; }
const USBDevice::InterfaceDescriptor& interface() const { return m_interface; }
private:
USBHIDDriver(USBDevice&, const USBDevice::InterfaceDescriptor&);
~USBHIDDriver();

View File

@@ -20,12 +20,15 @@ namespace Kernel
void update() override;
private:
USBKeyboard()
: USBHIDDevice(InputDevice::Type::Keyboard)
{}
USBKeyboard(USBHIDDriver& driver, BAN::Vector<USBHID::Report>&& outputs);
~USBKeyboard() = default;
void set_leds(uint16_t mask);
void set_leds(uint8_t report_id, uint16_t mask);
private:
USBHIDDriver& m_driver;
SpinLock m_keyboard_lock;
InterruptState m_lock_state;
@@ -33,6 +36,9 @@ namespace Kernel
BAN::Array<bool, 0x100> m_keyboard_state_temp { false };
uint16_t m_toggle_mask { 0 };
uint16_t m_led_mask { 0 };
BAN::Vector<USBHID::Report> m_outputs;
BAN::Optional<uint8_t> m_repeat_scancode;
uint8_t m_repeat_modifier { 0 };
uint64_t m_next_repeat_event_ms { 0 };