fixed boot mouse for apple recovery

This commit is contained in:
Devaev Maxim 2021-07-10 08:07:22 +03:00
parent 70141f0fbb
commit 01514d2e6a
2 changed files with 28 additions and 7 deletions

View File

@ -41,4 +41,4 @@ _libs = _get_libs()
_patch(_libs["HID-Project"], "patches/hid-shut-up.patch")
_patch(_libs["HID-Project"], "patches/hid-no-singletones.patch")
_patch(_libs["HID-Project"], "patches/hid-abs-mouse-win-fix.patch")
_patch(_libs["HID-Project"], "patches/hid-boot-mouse-fix.patch")
_patch(_libs["HID-Project"], "patches/hid-boot-mouse-mac-fix.patch")

View File

@ -1,7 +1,27 @@
index 27aee63..2d7d6c0 100644
diff --git a/src/SingleReport/BootMouse.cpp b/src/SingleReport/BootMouse.cpp
index 27aee63..0de3644 100644
--- a/src/SingleReport/BootMouse.cpp
+++ b/src/SingleReport/BootMouse.cpp
@@ -73,18 +73,23 @@ int BootMouse_::getInterface(uint8_t* interfaceCount)
@@ -29,6 +29,10 @@ static const uint8_t _hidReportDescriptorMouse[] PROGMEM = {
0x09, 0x02, /* USAGE (Mouse) */
0xa1, 0x01, /* COLLECTION (Application) */
+ /* Pointer and Physical are required by Apple Recovery */
+ 0x09, 0x01, /* USAGE (Pointer) */
+ 0xa1, 0x00, /* COLLECTION (Physical) */
+
/* 8 Buttons */
0x05, 0x09, /* USAGE_PAGE (Button) */
0x19, 0x01, /* USAGE_MINIMUM (Button 1) */
@@ -51,6 +55,7 @@ static const uint8_t _hidReportDescriptorMouse[] PROGMEM = {
0x81, 0x06, /* INPUT (Data,Var,Rel) */
/* End */
+ 0xc0, /* END_COLLECTION (Physical) */
0xc0 /* END_COLLECTION */
};
@@ -73,18 +78,24 @@ int BootMouse_::getInterface(uint8_t* interfaceCount)
int BootMouse_::getDescriptor(USBSetup& setup)
{
@ -17,9 +37,9 @@ index 27aee63..2d7d6c0 100644
- protocol = HID_REPORT_PROTOCOL;
+ // Check if this is a HID Class Descriptor request
+ if (setup.bmRequestType != REQUEST_DEVICETOHOST_STANDARD_INTERFACE) { return 0; }
- return USB_SendControl(TRANSFER_PGM, _hidReportDescriptorMouse, sizeof(_hidReportDescriptorMouse));
+
+ if (setup.wValueH == HID_HID_DESCRIPTOR_TYPE) {
+ // Apple UEFI wants it
+ HIDDescDescriptor desc = D_HIDREPORT(sizeof(_hidReportDescriptorMouse));
+ return USB_SendControl(0, &desc, sizeof(desc));
+ } else if (setup.wValueH == HID_REPORT_DESCRIPTOR_TYPE) {
@ -28,12 +48,13 @@ index 27aee63..2d7d6c0 100644
+ protocol = HID_REPORT_PROTOCOL;
+ return USB_SendControl(TRANSFER_PGM, _hidReportDescriptorMouse, sizeof(_hidReportDescriptorMouse));
+ }
+
- return USB_SendControl(TRANSFER_PGM, _hidReportDescriptorMouse, sizeof(_hidReportDescriptorMouse));
+ return 0;
}
bool BootMouse_::setup(USBSetup& setup)
@@ -103,7 +108,17 @@ bool BootMouse_::setup(USBSetup& setup)
@@ -103,7 +114,17 @@ bool BootMouse_::setup(USBSetup& setup)
return true;
}
if (request == HID_GET_PROTOCOL) {