diff --git a/converter/adb_usb/matrix.c b/converter/adb_usb/matrix.c index fd33aaaa..e73a7505 100644 --- a/converter/adb_usb/matrix.c +++ b/converter/adb_usb/matrix.c @@ -392,6 +392,7 @@ void adb_mouse_task(void) } len = adb_host_talk_buf(ADB_ADDR_MOUSE_POLL, ADB_REG_0, buf, sizeof(buf)); + if (!len && adb_service_request()) len = adb_host_talk_buf(ADB_ADDR_MOUSE, ADB_REG_0, buf, sizeof(buf)); // If nothing received reset mouse acceleration, and quit. if (len < 2) { @@ -616,6 +617,7 @@ uint8_t matrix_scan(void) tick_ms = timer_read(); codes = adb_host_kbd_recv(ADB_ADDR_KBD_POLL); + if (!codes && adb_service_request()) codes = adb_host_kbd_recv(ADB_ADDR_KEYBOARD); if (codes) xprintf("%04X ", codes); // Adjustable keybaord media keys diff --git a/tmk_core/protocol/adb.c b/tmk_core/protocol/adb.c index e774680d..0b66da7b 100644 --- a/tmk_core/protocol/adb.c +++ b/tmk_core/protocol/adb.c @@ -104,6 +104,12 @@ void adb_mouse_task(void) { } #endif +static bool adb_srq = false; +bool adb_service_request(void) +{ + return adb_srq; +} + // This sends Talk command to read data from register and returns length of the data. uint8_t adb_host_talk_buf(uint8_t addr, uint8_t reg, uint8_t *buf, uint8_t len) { @@ -157,6 +163,7 @@ uint8_t adb_host_talk_buf(uint8_t addr, uint8_t reg, uint8_t *buf, uint8_t len) // portion of the stop bit of any command or data transaction. The device must lengthen // the stop by a minimum of 140 J.lS beyond its normal duration, as shown in Figure 8-15." // http://ww1.microchip.com/downloads/en/AppNotes/00591b.pdf + if (!data_in()) { adb_srq = true; } else { adb_srq = false; } if (!wait_data_hi(500)) { // Service Request(310us Adjustable Keyboard): just ignored xprintf("R"); sei(); @@ -227,7 +234,8 @@ void adb_host_listen_buf(uint8_t addr, uint8_t reg, uint8_t *buf, uint8_t len) attention(); send_byte((addr<<4) | ADB_CMD_LISTEN | reg); place_bit0(); // Stopbit(0) - // TODO: Service Request + if (!data_in()) { adb_srq = true; } else { adb_srq = false; } + wait_data_hi(500); // Service Request _delay_us(200); // Tlt/Stop to Start place_bit1(); // Startbit(1) for (int8_t i = 0; i < len; i++) { diff --git a/tmk_core/protocol/adb.h b/tmk_core/protocol/adb.h index 1c1ace5d..914f1085 100644 --- a/tmk_core/protocol/adb.h +++ b/tmk_core/protocol/adb.h @@ -121,6 +121,7 @@ void adb_host_kbd_led(uint8_t addr, uint8_t led); void adb_mouse_task(void); void adb_mouse_init(void); uint8_t adb_mouse_buttons(void); +bool adb_service_request(void); #endif