Skip to content

Commit

Permalink
ChibiOS: fix deadlocks when hammering mouse/extra keys
Browse files Browse the repository at this point in the history
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
  • Loading branch information
lactide committed Oct 8, 2017
1 parent f2ebf6d commit 5324dd3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions protocol/chibios/usb_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1189,14 +1189,15 @@ void send_mouse(report_mouse_t *report) {
osalSysUnlock();
return;
}
osalSysUnlock();

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

osalSysLock();
if(usbGetTransmitStatusI(&USB_DRIVER, MOUSE_ENDPOINT)) {
osalThreadSuspendS(&(&USB_DRIVER)->epc[MOUSE_ENDPOINT]->in_state->thread);
}
usbStartTransmitI(&USB_DRIVER, MOUSE_ENDPOINT, (uint8_t *)report, sizeof(report_mouse_t));
osalSysUnlock();
}
Expand Down Expand Up @@ -1233,6 +1234,9 @@ static void send_extra_report(uint8_t report_id, uint16_t data) {
.usage = data
};

if(usbGetTransmitStatusI(&USB_DRIVER, EXTRA_ENDPOINT)) {
osalThreadSuspendS(&(&USB_DRIVER)->epc[EXTRA_ENDPOINT]->in_state->thread);
}
usbStartTransmitI(&USB_DRIVER, EXTRA_ENDPOINT, (uint8_t *)&report, sizeof(report_extra_t));
osalSysUnlock();
}
Expand Down

0 comments on commit 5324dd3

Please sign in to comment.