Kernel: Implement key repeating for USB keyboard

USB keyboards don't send repeating keys automatically, so it has to be
emulated in software.
This commit is contained in:
2024-07-16 11:23:44 +03:00
parent fd8dc03ae9
commit e30952efee
2 changed files with 118 additions and 20 deletions

View File

@@ -17,6 +17,8 @@ namespace Kernel
void handle_variable(uint16_t usage_page, uint16_t usage, int64_t state) override;
void handle_array(uint16_t usage_page, uint16_t usage) override;
void update() override;
private:
USBKeyboard()
: USBHIDDevice(InputDevice::Type::Keyboard)
@@ -24,10 +26,17 @@ namespace Kernel
~USBKeyboard() = default;
private:
SpinLock m_keyboard_lock;
InterruptState m_lock_state;
BAN::Array<bool, 0x100> m_keyboard_state { false };
BAN::Array<bool, 0x100> m_keyboard_state_temp { false };
uint8_t m_toggle_mask { 0 };
BAN::Optional<uint8_t> m_repeat_scancode;
uint8_t m_repeat_modifier { 0 };
uint64_t m_next_repeat_event_ms { 0 };
friend class BAN::RefPtr<USBKeyboard>;
};