Only set the semaphore if the report is successfully requested
This commit is contained in:
@@ -407,6 +407,8 @@ uint32_t UsbReportUpdateCounter;
|
||||
|
||||
void UpdateUsbReports(void)
|
||||
{
|
||||
usb_status_t status;
|
||||
|
||||
if (UsbReportUpdateSemaphore) {
|
||||
return;
|
||||
}
|
||||
@@ -430,24 +432,32 @@ void UpdateUsbReports(void)
|
||||
}
|
||||
|
||||
if (HasUsbBasicKeyboardReportChanged) {
|
||||
UsbReportUpdateSemaphore |= 1 << USB_BASIC_KEYBOARD_INTERFACE_INDEX;
|
||||
UsbBasicKeyboardAction();
|
||||
status = UsbBasicKeyboardAction();
|
||||
if (status == kStatus_USB_Success) {
|
||||
UsbReportUpdateSemaphore |= 1 << USB_BASIC_KEYBOARD_INTERFACE_INDEX;
|
||||
}
|
||||
}
|
||||
|
||||
if (HasUsbMediaKeyboardReportChanged) {
|
||||
UsbReportUpdateSemaphore |= 1 << USB_MEDIA_KEYBOARD_INTERFACE_INDEX;
|
||||
UsbMediaKeyboardAction();
|
||||
status = UsbMediaKeyboardAction();
|
||||
if (status == kStatus_USB_Success) {
|
||||
UsbReportUpdateSemaphore |= 1 << USB_MEDIA_KEYBOARD_INTERFACE_INDEX;
|
||||
}
|
||||
}
|
||||
|
||||
if (HasUsbSystemKeyboardReportChanged) {
|
||||
UsbReportUpdateSemaphore |= 1 << USB_SYSTEM_KEYBOARD_INTERFACE_INDEX;
|
||||
UsbSystemKeyboardAction();
|
||||
status = UsbSystemKeyboardAction();
|
||||
if (status == kStatus_USB_Success) {
|
||||
UsbReportUpdateSemaphore |= 1 << USB_SYSTEM_KEYBOARD_INTERFACE_INDEX;
|
||||
}
|
||||
}
|
||||
|
||||
// Send out the mouse position and wheel values continuously if the report is not zeros, but only send the mouse button states when they change.
|
||||
if (HasUsbMouseReportChanged || ActiveUsbMouseReport->x || ActiveUsbMouseReport->y ||
|
||||
ActiveUsbMouseReport->wheelX || ActiveUsbMouseReport->wheelY) {
|
||||
UsbReportUpdateSemaphore |= 1 << USB_MOUSE_INTERFACE_INDEX;
|
||||
UsbMouseAction();
|
||||
status = UsbMouseAction();
|
||||
if (status == kStatus_USB_Success) {
|
||||
UsbReportUpdateSemaphore |= 1 << USB_MOUSE_INTERFACE_INDEX;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user