fix: GUI and kernel fixes, Wikipedia app rewrite, among other things

This commit is contained in:
2026-02-21 11:08:11 +01:00
parent 9e191f64a9
commit 2130334779
96 changed files with 1844 additions and 662 deletions
+28 -2
View File
@@ -339,6 +339,7 @@ namespace Drivers::USB::UsbDevice {
uint16_t offset = 0;
bool foundHid = false;
bool foundEp = false;
uint16_t hidReportDescLen = 0;
while (offset + 2 <= totalLen) {
uint8_t len = cfgBuf[offset];
@@ -360,6 +361,12 @@ namespace Drivers::USB::UsbDevice {
}
}
// HID descriptor (0x21): extract report descriptor length
if (type == DESC_HID && foundHid && !foundEp && len >= 9 && offset + 8 < totalLen) {
hidReportDescLen = (uint16_t)cfgBuf[offset + 7]
| ((uint16_t)cfgBuf[offset + 8] << 8);
}
if (type == DESC_ENDPOINT && foundHid && !foundEp &&
offset + sizeof(EndpointDescriptor) <= totalLen) {
auto* ep = (EndpointDescriptor*)&cfgBuf[offset];
@@ -463,8 +470,9 @@ namespace Drivers::USB::UsbDevice {
// -----------------------------------------------------------------
// Step 10: SET_PROTOCOL -- Boot Protocol for keyboards only
// -----------------------------------------------------------------
// Boot Protocol constrains mice to 3-byte reports (no scroll wheel).
// Keep mice in Report Protocol (the default) so scroll data is included.
// Set Boot Protocol for keyboards only.
// Mice stay in Report Protocol (the default) for scroll wheel support;
// HidMouse parses the HID Report Descriptor to handle variable formats.
if (foundEp && dev->InterfaceProtocol == PROTOCOL_KEYBOARD) {
cc = Xhci::ControlTransfer(slotId, REQTYPE_CLASS_IFACE, REQ_SET_PROTOCOL,
0, 0, 0, nullptr, false);
@@ -474,6 +482,24 @@ namespace Drivers::USB::UsbDevice {
}
}
// -----------------------------------------------------------------
// Step 10b: Fetch HID Report Descriptor for mice
// -----------------------------------------------------------------
if (foundEp && dev->InterfaceProtocol == PROTOCOL_MOUSE && hidReportDescLen > 0) {
uint8_t rdBuf[256] = {};
uint16_t rdLen = hidReportDescLen;
if (rdLen > 256) rdLen = 256;
cc = Xhci::ControlTransfer(slotId, REQTYPE_STD_IFACE_IN, REQ_GET_DESCRIPTOR,
(DESC_HID_REPORT << 8), 0, rdLen,
rdBuf, true);
if (cc == Xhci::CC_SUCCESS || cc == Xhci::CC_SHORT_PACKET) {
HidMouse::ParseReportDescriptor(rdBuf, rdLen);
} else {
KernelLogStream(WARNING, "USB") << "GET_DESCRIPTOR(HID Report) failed, cc=" << (uint64_t)cc;
}
}
// -----------------------------------------------------------------
// Step 11: SET_IDLE(4) -- 16ms idle rate for software typematic
// -----------------------------------------------------------------