Just compare the active report with the inactive report stored in each interface driver
This commit is contained in:
@@ -4,14 +4,14 @@ uint32_t UsbSystemKeyboardActionCounter;
|
||||
static usb_system_keyboard_report_t usbSystemKeyboardReports[2];
|
||||
usb_system_keyboard_report_t* ActiveUsbSystemKeyboardReport = usbSystemKeyboardReports;
|
||||
|
||||
static usb_system_keyboard_report_t* getInactiveUsbSystemKeyboardReport()
|
||||
usb_system_keyboard_report_t* GetInactiveUsbSystemKeyboardReport()
|
||||
{
|
||||
return ActiveUsbSystemKeyboardReport == usbSystemKeyboardReports ? usbSystemKeyboardReports+1 : usbSystemKeyboardReports;
|
||||
}
|
||||
|
||||
void SwitchActiveUsbSystemKeyboardReport(void)
|
||||
static void SwitchActiveUsbSystemKeyboardReport(void)
|
||||
{
|
||||
ActiveUsbSystemKeyboardReport = getInactiveUsbSystemKeyboardReport();
|
||||
ActiveUsbSystemKeyboardReport = GetInactiveUsbSystemKeyboardReport();
|
||||
}
|
||||
|
||||
void ResetActiveUsbSystemKeyboardReport(void)
|
||||
@@ -22,9 +22,12 @@ void ResetActiveUsbSystemKeyboardReport(void)
|
||||
usb_status_t UsbSystemKeyboardAction(void)
|
||||
{
|
||||
UsbSystemKeyboardActionCounter++;
|
||||
return USB_DeviceHidSend(
|
||||
usb_status_t usb_status = USB_DeviceHidSend(
|
||||
UsbCompositeDevice.systemKeyboardHandle, USB_SYSTEM_KEYBOARD_ENDPOINT_INDEX,
|
||||
(uint8_t*)getInactiveUsbSystemKeyboardReport(), USB_SYSTEM_KEYBOARD_REPORT_LENGTH);
|
||||
(uint8_t*)ActiveUsbSystemKeyboardReport, USB_SYSTEM_KEYBOARD_REPORT_LENGTH);
|
||||
if (usb_status == kStatus_USB_Success)
|
||||
SwitchActiveUsbSystemKeyboardReport(); // Switch the active report if the data was sent successfully
|
||||
return usb_status;
|
||||
}
|
||||
|
||||
usb_status_t UsbSystemKeyboardCallback(class_handle_t handle, uint32_t event, void *param)
|
||||
|
||||
Reference in New Issue
Block a user