Kernel: Implement USB Keyboard

This is kinda hacky, as I had disable the PS/2 initialization so that
usb keyboard gets /dev/keyboard0. I should add device hot plugging
support for TTY and GUI...
This commit is contained in:
2024-07-14 02:09:18 +03:00
parent 1efc6a1385
commit ac5c77ee2c
6 changed files with 256 additions and 3 deletions

View File

@@ -0,0 +1,34 @@
#pragma once
#include <kernel/USB/HID/HIDDriver.h>
namespace Kernel
{
class USBKeyboard final : public USBHIDDevice
{
BAN_NON_COPYABLE(USBKeyboard);
BAN_NON_MOVABLE(USBKeyboard);
public:
void start_report() override;
void stop_report() override;
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;
private:
USBKeyboard()
: USBHIDDevice(InputDevice::Type::Keyboard)
{}
~USBKeyboard() = default;
private:
BAN::Array<bool, 0x100> m_keyboard_state { false };
BAN::Array<bool, 0x100> m_keyboard_state_temp { false };
uint8_t m_toggle_mask { 0 };
friend class BAN::RefPtr<USBKeyboard>;
};
}