Kernel: Fix USB code
Fix USB Keyboard scan code table for bottom row of keyboard Support multiple interfaces on a single USB device Add usb mouse to default qemu settings
This commit is contained in:
parent
75875d3a8f
commit
4cd9252ff6
|
@ -81,8 +81,7 @@ namespace Kernel
|
|||
DeviceDescriptor m_descriptor;
|
||||
BAN::UniqPtr<DMARegion> m_dma_buffer;
|
||||
|
||||
// FIXME: support more than one interface from a configuration
|
||||
BAN::UniqPtr<USBClassDriver> m_class_driver;
|
||||
BAN::Vector<BAN::UniqPtr<USBClassDriver>> m_class_drivers;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@ namespace Kernel
|
|||
break;
|
||||
case USB::InterfaceBaseClass::HID:
|
||||
if (auto result = USBHIDDriver::create(*this, interface, j); !result.is_error())
|
||||
m_class_driver = result.release_value();
|
||||
TRY(m_class_drivers.push_back(result.release_value()));
|
||||
break;
|
||||
case USB::InterfaceBaseClass::Physical:
|
||||
dprintln_if(DEBUG_USB, "Found Physical interface");
|
||||
|
@ -218,7 +218,7 @@ namespace Kernel
|
|||
break;
|
||||
}
|
||||
|
||||
if (m_class_driver)
|
||||
if (!m_class_drivers.empty())
|
||||
{
|
||||
dprintln("Successfully initialized USB interface");
|
||||
return {};
|
||||
|
@ -309,8 +309,8 @@ namespace Kernel
|
|||
|
||||
void USBDevice::handle_input_data(BAN::ConstByteSpan data, uint8_t endpoint_id)
|
||||
{
|
||||
if (m_class_driver)
|
||||
m_class_driver->handle_input_data(data, endpoint_id);
|
||||
for (auto& driver : m_class_drivers)
|
||||
driver->handle_input_data(data, endpoint_id);
|
||||
}
|
||||
|
||||
USB::SpeedClass USBDevice::determine_speed_class(uint64_t bits_per_second)
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <kernel/USB/HID/Mouse.h>
|
||||
|
||||
#define DEBUG_HID 0
|
||||
#define DUMP_HID_REPORT 0
|
||||
|
||||
namespace Kernel
|
||||
{
|
||||
|
@ -57,7 +58,7 @@ namespace Kernel
|
|||
|
||||
using namespace USBHID;
|
||||
|
||||
#if DEBUG_HID
|
||||
#if DUMP_HID_REPORT
|
||||
static void dump_hid_collection(const Collection& collection, size_t indent);
|
||||
#endif
|
||||
|
||||
|
@ -211,7 +212,7 @@ namespace Kernel
|
|||
return BAN::Error::from_errno(EFAULT);
|
||||
}
|
||||
|
||||
#if DEBUG_HID
|
||||
#if DUMP_HID_REPORT
|
||||
{
|
||||
SpinLockGuard _(Debug::s_debug_lock);
|
||||
dump_hid_collection(collection, 0);
|
||||
|
@ -222,9 +223,11 @@ namespace Kernel
|
|||
{
|
||||
case 0x02:
|
||||
m_hid_device = TRY(BAN::RefPtr<USBMouse>::create());
|
||||
dprintln("Initialized an USB Mouse");
|
||||
break;
|
||||
case 0x06:
|
||||
m_hid_device = TRY(BAN::RefPtr<USBKeyboard>::create());
|
||||
dprintln("Initialized an USB Keyboard");
|
||||
break;
|
||||
default:
|
||||
dwarnln("Unsupported generic descript page usage 0x{2H}", collection.usage_id);
|
||||
|
@ -326,7 +329,9 @@ namespace Kernel
|
|||
|
||||
void USBHIDDriver::handle_input_data(BAN::ConstByteSpan data, uint8_t endpoint_id)
|
||||
{
|
||||
ASSERT(m_endpoint_id == endpoint_id);
|
||||
// If this packet is not for us, skip it
|
||||
if (m_endpoint_id != endpoint_id)
|
||||
return;
|
||||
|
||||
if constexpr(DEBUG_HID)
|
||||
{
|
||||
|
@ -672,7 +677,7 @@ namespace Kernel
|
|||
return result.release_value();
|
||||
}
|
||||
|
||||
#if DEBUG_HID
|
||||
#if DUMP_HID_REPORT
|
||||
static void print_indent(size_t indent)
|
||||
{
|
||||
for (size_t i = 0; i < indent; i++)
|
||||
|
|
|
@ -155,10 +155,10 @@ namespace Kernel
|
|||
s_scancode_to_keycode[0x37] = keycode_normal(3, 10);
|
||||
s_scancode_to_keycode[0x38] = keycode_normal(3, 11);
|
||||
s_scancode_to_keycode[0xE5] = keycode_normal(3, 12);
|
||||
s_scancode_to_keycode[0xE0] = keycode_normal(4, 1);
|
||||
s_scancode_to_keycode[0xE3] = keycode_normal(4, 2);
|
||||
s_scancode_to_keycode[0xE2] = keycode_normal(4, 3);
|
||||
s_scancode_to_keycode[0x2C] = keycode_normal(4, 4);
|
||||
s_scancode_to_keycode[0xE0] = keycode_normal(4, 0);
|
||||
s_scancode_to_keycode[0xE3] = keycode_normal(4, 1);
|
||||
s_scancode_to_keycode[0xE2] = keycode_normal(4, 2);
|
||||
s_scancode_to_keycode[0x2C] = keycode_normal(4, 3);
|
||||
s_scancode_to_keycode[0xE6] = keycode_normal(4, 5);
|
||||
s_scancode_to_keycode[0xE4] = keycode_normal(4, 6);
|
||||
|
||||
|
|
|
@ -31,6 +31,6 @@ qemu-system-$QEMU_ARCH \
|
|||
-drive format=raw,id=disk,file=${BANAN_DISK_IMAGE_PATH},if=none \
|
||||
-device e1000e,netdev=net \
|
||||
-netdev user,id=net \
|
||||
-device qemu-xhci -device usb-kbd \
|
||||
-device qemu-xhci -device usb-kbd -device usb-mouse \
|
||||
$DISK_ARGS \
|
||||
$@ \
|
||||
|
|
Loading…
Reference in New Issue