Skip to content

Commit

Permalink
Fix for Apple Magic Keyboard A1644
Browse files Browse the repository at this point in the history
The keyboard has boot keyboard on interface 1, not 0.
hidboot.h did not support device like that.
tmk/tmk_keyboard#606 (comment)
USB Descriptor: https://gist.github.com/tmk/0626b78f73575d5c1efa86470c4cdb18
  • Loading branch information
tmk committed Jan 23, 2023
1 parent 35606b2 commit 0a5b085
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions hidboot.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ class HIDBoot : public USBHID //public USBDeviceConfig, public UsbConfigXtracter
{
EpInfo epInfo[totalEndpoints(BOOT_PROTOCOL)];
HIDReportParser *pRptParser[epMUL(BOOT_PROTOCOL)];
uint8_t bootIf[epMUL(BOOT_PROTOCOL)]; // interface number of boot endpoint

uint8_t bConfNum; // configuration number
uint8_t bIfaceNum; // Interface Number
Expand Down Expand Up @@ -462,19 +463,19 @@ uint8_t HIDBoot<BOOT_PROTOCOL>::Init(uint8_t parent, uint8_t port, bool lowspeed

// Yes, mouse wants SetProtocol and SetIdle too!
for(uint8_t i = 0; i < epMUL(BOOT_PROTOCOL); i++) {
USBTRACE2("\r\nInterface:", i);
USBTRACE2("\r\nInterface:", bootIf[i]);

rcode = SetProtocol(i, bRptProtoEnable ? HID_RPT_PROTOCOL : USB_HID_BOOT_PROTOCOL);
rcode = SetProtocol(bootIf[i], bRptProtoEnable ? HID_RPT_PROTOCOL : USB_HID_BOOT_PROTOCOL);
USBTRACE2("SET_PROTOCOL: ", rcode);
if (rcode && rcode != hrSTALL) goto Fail;

rcode = SetIdle(i, 0, 0);
rcode = SetIdle(bootIf[i], 0, 0);
USBTRACE2("SET_IDLE: ", rcode);
if (rcode && rcode != hrSTALL) goto Fail;

// Get the RPIPE and just throw it away.
SinkParser<USBReadParser, uint16_t, uint16_t> sink;
rcode = GetReportDescr(i, &sink);
rcode = GetReportDescr(bootIf[i], &sink);
USBTRACE2("RPIPE: ", rcode);
}

Expand Down Expand Up @@ -551,6 +552,7 @@ void HIDBoot<BOOT_PROTOCOL>::EndpointXtract(uint8_t conf, uint8_t iface, uint8_t
epInfo[bNumEP].bmSndToggle = 0;
epInfo[bNumEP].bmRcvToggle = 0;
epInfo[bNumEP].bmNakPower = USB_NAK_NOWAIT;
bootIf[bNumEP - 1] = iface;
bNumEP++;

}
Expand Down

0 comments on commit 0a5b085

Please sign in to comment.