Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved compatibility with Mac #305

Merged
merged 1 commit into from
Jul 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 30 additions & 9 deletions src/SingleReport/BootMouse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) */
Expand All @@ -51,6 +55,7 @@ static const uint8_t _hidReportDescriptorMouse[] PROGMEM = {
0x81, 0x06, /* INPUT (Data,Var,Rel) */

/* End */
0xc0, /* END_COLLECTION (Physical) */
0xc0 /* END_COLLECTION */
};

Expand All @@ -73,18 +78,24 @@ int BootMouse_::getInterface(uint8_t* interfaceCount)

int BootMouse_::getDescriptor(USBSetup& setup)
{
// Check if this is a HID Class Descriptor request
if (setup.bmRequestType != REQUEST_DEVICETOHOST_STANDARD_INTERFACE) { return 0; }
if (setup.wValueH != HID_REPORT_DESCRIPTOR_TYPE) { return 0; }

// In a HID Class Descriptor wIndex cointains the interface number
if (setup.wIndex != pluggedInterface) { return 0; }

// Reset the protocol on reenumeration. Normally the host should not assume the state of the protocol
// due to the USB specs, but Windows and Linux just assumes its in report mode.
protocol = HID_REPORT_PROTOCOL;
// Check if this is a HID Class Descriptor request
if (setup.bmRequestType != REQUEST_DEVICETOHOST_STANDARD_INTERFACE) { return 0; }
NicoHood marked this conversation as resolved.
Show resolved Hide resolved

if (setup.wValueH == HID_HID_DESCRIPTOR_TYPE) {
// Apple UEFI wants it
HIDDescDescriptor desc = D_HIDREPORT(sizeof(_hidReportDescriptorMouse));
return USB_SendControl(0, &desc, sizeof(desc));
NicoHood marked this conversation as resolved.
Show resolved Hide resolved
} else if (setup.wValueH == HID_REPORT_DESCRIPTOR_TYPE) {
// Reset the protocol on reenumeration. Normally the host should not assume the state of the protocol
// due to the USB specs, but Windows and Linux just assumes its in report mode.
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)
Expand All @@ -103,7 +114,17 @@ bool BootMouse_::setup(USBSetup& setup)
return true;
}
if (request == HID_GET_PROTOCOL) {
// TODO: Send8(protocol);
// TODO improve
#ifdef __AVR__
UEDATX = protocol;
#endif
return true;
}
if (request == HID_GET_IDLE) {
// TODO improve
#ifdef __AVR__
UEDATX = idle;
#endif
return true;
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/SingleReport/SingleAbsoluteMouse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ static const uint8_t _hidSingleReportDescriptorAbsoluteMouse[] 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) */
Expand Down Expand Up @@ -58,6 +62,7 @@ static const uint8_t _hidSingleReportDescriptorAbsoluteMouse[] PROGMEM = {
0x81, 0x06, /* INPUT (Data,Var,Rel) */

/* End */
0xc0, /* END_COLLECTION (Physical) */
0xc0 /* END_COLLECTION */
};

Expand Down