Open tmk opened 2 years ago
USB Descriptor of Griffin Technology iMate, ADB Adapter - 077d:0405: https://gist.github.com/tmk/472e52c9502302be173790c5e5fa0829
Griffin iMate doesn't send any keyboard report without polling mouse interface.
This patch may be needed for this.
Author: Jun Wako <wakojun@gmail.com>
Date: Sun Sep 26 23:35:13 2021 +0900
hidboot: Use actual number of interface and endpoint
When supporting both keyboard and mouse protocol we should
handle cases that number of interface and endpoint is 1 or 2
This change is required to support Griffin iMate, which
doesn't any keyboard report without polling mouse interface
diff --git a/hidboot.h b/hidboot.h
index 1effc6c..c51a3dc 100644
--- a/hidboot.h
+++ b/hidboot.h
@@ -437,7 +437,7 @@ uint8_t HIDBoot<BOOT_PROTOCOL>::Init(uint8_t parent, uint8_t port, bool lowspeed
}
USBTRACE2("bNumEP:", bNumEP);
- if(bNumEP != (uint8_t)(totalEndpoints(BOOT_PROTOCOL))) {
+ if(bNumEP == 1) { // Not found any Interrupt-IN Endpoint
rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
goto Fail;
}
@@ -461,7 +461,7 @@ uint8_t HIDBoot<BOOT_PROTOCOL>::Init(uint8_t parent, uint8_t port, bool lowspeed
USBTRACE2("bNumIface:", bNumIface);
// Yes, mouse wants SetProtocol and SetIdle too!
- for(uint8_t i = 0; i < epMUL(BOOT_PROTOCOL); i++) {
+ for(uint8_t i = 0; i <= bIfaceNum; i++) { // Assuming bIfaceNum indicates the last interface
USBTRACE2("\r\nInterface:", i);
rcode = SetProtocol(i, bRptProtoEnable ? HID_RPT_PROTOCOL : USB_HID_BOOT_PROTOCOL);
if(rcode) goto FailSetProtocol;
@@ -587,7 +587,8 @@ uint8_t HIDBoot<BOOT_PROTOCOL>::Poll() {
if(bPollEnable && ((int32_t)((uint32_t)millis() - qNextPollTime) >= 0L)) {
// To-do: optimize manually, using the for loop only if needed.
- for(int i = 0; i < epMUL(BOOT_PROTOCOL); i++) {
+ for(int i = 0; i < (bNumEP - 1); i++) { // bNumEP is number of interrupt-IN EP + EP0
+ if (epInfo[epInterruptInIndex + i].epAddr == 0) continue; // EP is not registered
const uint16_t const_buff_len = 64;
USBTRACE3("(hidboot.h) i=", i, 0x81);