diff --git a/converter/adb_usb/config.h b/converter/adb_usb/config.h index 4de354db..70e09e2e 100644 --- a/converter/adb_usb/config.h +++ b/converter/adb_usb/config.h @@ -47,6 +47,9 @@ along with this program. If not, see . // https://github.com/tmk/tmk_keyboard/issues/724 #define ADB_MOUSE_2ND_BUTTON_QUIRK +// Scan unsupported devices with register0 when SRQ is asserted +#define ADB_SRQ_SCAN_REG0 + /* ADB port setting */ #define ADB_PORT PORTD diff --git a/converter/adb_usb/matrix.c b/converter/adb_usb/matrix.c index 76400bf9..f6fecfd2 100644 --- a/converter/adb_usb/matrix.c +++ b/converter/adb_usb/matrix.c @@ -762,3 +762,37 @@ void led_set(uint8_t usb_led) { adb_host_kbd_led(ADB_ADDR_KBD_POLL, ~usb_led); } + +#ifdef ADB_SRQ_SCAN_REG0 +void hook_main_loop(void) +{ + // Scan unsupported devices when Service Request(SRQ) is asserted + uint8_t len; + uint8_t buf[16]; + static uint8_t addr = 0; + if (!adb_service_request()) return; + for (addr = addr % 16; addr < 16; addr++) { + if (addr == ADB_ADDR_KEYBOARD || + addr == ADB_ADDR_KBD_POLL || + addr == ADB_ADDR_KBD_TMP || + #ifdef ADB_MOUSE_ENABLE + addr == ADB_ADDR_MOUSE || + addr == ADB_ADDR_MOUSE_POLL || + addr == ADB_ADDR_MOUSE_TMP || + #endif + addr == ADB_ADDR_APPLIANCE) { + continue; + } + len = adb_host_talk_buf(addr, ADB_REG_0, buf, sizeof(buf)); + if (len) { + xprintf("addr%d reg0: [ ", addr); + for (uint8_t i = 0; i < len; i++) { + xprintf("%02X ", buf[i]); + } + xprintf("]\n"); + break; + } + if (!adb_service_request()) return; + } +} +#endif