Skip to content

Commit 5324dd3

Browse files
author
lactide
committed
ChibiOS: fix deadlocks when hammering mouse/extra keys
When hammering on the mouse or extra keys, tmk will deadlock. To fix that, i've copied the fix from the keyboard endpoint [1] [1] tmk/tmk_keyboard@72c52d3
1 parent f2ebf6d commit 5324dd3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

protocol/chibios/usb_main.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,14 +1189,15 @@ void send_mouse(report_mouse_t *report) {
11891189
osalSysUnlock();
11901190
return;
11911191
}
1192-
osalSysUnlock();
11931192

11941193
/* TODO: LUFA manually waits for the endpoint to become ready
11951194
* for about 10ms for mouse, kbd, system; 1ms for nkro
11961195
* is this really needed?
11971196
*/
11981197

1199-
osalSysLock();
1198+
if(usbGetTransmitStatusI(&USB_DRIVER, MOUSE_ENDPOINT)) {
1199+
osalThreadSuspendS(&(&USB_DRIVER)->epc[MOUSE_ENDPOINT]->in_state->thread);
1200+
}
12001201
usbStartTransmitI(&USB_DRIVER, MOUSE_ENDPOINT, (uint8_t *)report, sizeof(report_mouse_t));
12011202
osalSysUnlock();
12021203
}
@@ -1233,6 +1234,9 @@ static void send_extra_report(uint8_t report_id, uint16_t data) {
12331234
.usage = data
12341235
};
12351236

1237+
if(usbGetTransmitStatusI(&USB_DRIVER, EXTRA_ENDPOINT)) {
1238+
osalThreadSuspendS(&(&USB_DRIVER)->epc[EXTRA_ENDPOINT]->in_state->thread);
1239+
}
12361240
usbStartTransmitI(&USB_DRIVER, EXTRA_ENDPOINT, (uint8_t *)&report, sizeof(report_extra_t));
12371241
osalSysUnlock();
12381242
}

0 commit comments

Comments
 (0)