diff --git a/right/src/event_scheduler.h b/right/src/event_scheduler.h index e68a9e877..31a73f587 100644 --- a/right/src/event_scheduler.h +++ b/right/src/event_scheduler.h @@ -50,28 +50,29 @@ EventVector_Postponer = 1 << 5, EventVector_LayerHolds = 1 << 6, EventVector_SendUsbReports = 1 << 7, - EventVector_EventScheduler = 1 << 8, + EventVector_ResendUsbReports = 1 << 8, + EventVector_EventScheduler = 1 << 9, EventVector_MainTriggers = ((EventVector_EventScheduler << 1) - 1), // some other minor triggers - EventVector_KeyboardLedState = 1 << 9, - EventVector_UsbMacroCommandWaitingForExecution = 1 << 10, - EventVector_ProtocolChanged = 1 << 11, - EventVector_LedManagerFullUpdateNeeded = 1 << 12, - EventVector_KeymapReloadNeeded = 1 << 13, - EventVector_SegmentDisplayNeedsUpdate = 1 << 14, - EventVector_LedMapUpdateNeeded = 1 << 15, - EventVector_ApplyConfig = 1 << 16, - EventVector_NewMessage = 1 << 17, + EventVector_KeyboardLedState = 1 << 10, + EventVector_UsbMacroCommandWaitingForExecution = 1 << 11, + EventVector_ProtocolChanged = 1 << 12, + EventVector_LedManagerFullUpdateNeeded = 1 << 13, + EventVector_KeymapReloadNeeded = 1 << 14, + EventVector_SegmentDisplayNeedsUpdate = 1 << 15, + EventVector_LedMapUpdateNeeded = 1 << 16, + EventVector_ApplyConfig = 1 << 17, + EventVector_NewMessage = 1 << 18, EventVector_AuxiliaryTriggers = ((EventVector_NewMessage << 1) - 1), // events that are informational only - EventVector_NativeActionReportsUsed = 1 << 18, - EventVector_MacroReportsUsed = 1 << 19, - EventVector_MouseKeysReportsUsed = 1 << 20, - EventVector_MouseControllerMouseReportsUsed = 1 << 21, - EventVector_MouseControllerKeyboardReportsUsed = 1 << 22, + EventVector_NativeActionReportsUsed = 1 << 19, + EventVector_MacroReportsUsed = 1 << 20, + EventVector_MouseKeysReportsUsed = 1 << 21, + EventVector_MouseControllerMouseReportsUsed = 1 << 22, + EventVector_MouseControllerKeyboardReportsUsed = 1 << 23, EventVector_NativeActionsPostponing = 1 << 24, EventVector_KeystrokeDelayPostponing = 1 << 25, EventVector_MacroEnginePostponing = 1 << 26, diff --git a/right/src/usb_interfaces/usb_interface_basic_keyboard.c b/right/src/usb_interfaces/usb_interface_basic_keyboard.c index da2899f1e..a69acbd10 100644 --- a/right/src/usb_interfaces/usb_interface_basic_keyboard.c +++ b/right/src/usb_interfaces/usb_interface_basic_keyboard.c @@ -207,7 +207,7 @@ void UsbBasicKeyboardSendActiveReport(void) //This is *not* asynchronously safe as long as multiple reports of different type can be sent at the same time. //TODO: consider either making it atomic, or lowering semaphore reset delay UsbReportUpdateSemaphore &= ~(1 << USB_BASIC_KEYBOARD_INTERFACE_INDEX); - EventVector_Set(EventVector_SendUsbReports); + EventVector_Set(EventVector_ResendUsbReports); } #endif } diff --git a/right/src/usb_interfaces/usb_interface_mouse.c b/right/src/usb_interfaces/usb_interface_mouse.c index 05499dac0..b6ca9edf3 100644 --- a/right/src/usb_interfaces/usb_interface_mouse.c +++ b/right/src/usb_interfaces/usb_interface_mouse.c @@ -168,7 +168,7 @@ void UsbMouseSendActiveReport(void) usb_status_t status = UsbMouseAction(); if (status != kStatus_USB_Success) { UsbReportUpdateSemaphore &= ~(1 << USB_MOUSE_INTERFACE_INDEX); - EventVector_Set(EventVector_SendUsbReports); + EventVector_Set(EventVector_ResendUsbReports); } #endif } diff --git a/right/src/usb_report_updater.c b/right/src/usb_report_updater.c index 7dccaf30c..e9560491d 100644 --- a/right/src/usb_report_updater.c +++ b/right/src/usb_report_updater.c @@ -676,7 +676,7 @@ static void sendActiveReports() { bool usbReportsChangedByAnything = false; // in case of usb error, this gets set back again - EventVector_Unset(EventVector_SendUsbReports); + EventVector_Unset(EventVector_SendUsbReports | EventVector_ResendUsbReports); if (UsbBasicKeyboardCheckReportReady() == kStatus_USB_Success) { #ifdef __ZEPHYR__ @@ -718,7 +718,7 @@ static void sendActiveReports() { usb_status_t status = UsbMediaKeyboardAction(); if (status != kStatus_USB_Success) { UsbReportUpdateSemaphore &= ~(1 << USB_MEDIA_KEYBOARD_INTERFACE_INDEX); - EventVector_Set(EventVector_SendUsbReports); + EventVector_Set(EventVector_ResendUsbReports); } UsbReportUpdater_LastActivityTime = CurrentTime; usbReportsChangedByAction = true; @@ -730,7 +730,7 @@ static void sendActiveReports() { usb_status_t status = UsbSystemKeyboardAction(); if (status != kStatus_USB_Success) { UsbReportUpdateSemaphore &= ~(1 << USB_SYSTEM_KEYBOARD_INTERFACE_INDEX); - EventVector_Set(EventVector_SendUsbReports); + EventVector_Set(EventVector_ResendUsbReports); } UsbReportUpdater_LastActivityTime = CurrentTime; usbReportsChangedByAction = true; @@ -792,14 +792,16 @@ void UpdateUsbReports(void) UpdateUsbReports_LastUpdateTime = CurrentTime; UsbReportUpdateCounter++; - updateActiveUsbReports(); + if (!EventVector_IsSet(EventVector_ResendUsbReports)) { + updateActiveUsbReports(); + } - if (EventVector_IsSet(EventVector_SendUsbReports)) { + if (EventVector_IsSet(EventVector_SendUsbReports | EventVector_ResendUsbReports)) { if (CurrentPowerMode < PowerMode_DeepSleep) { mergeReports(); sendActiveReports(); } else { - EventVector_Unset(EventVector_SendUsbReports); + EventVector_Unset(EventVector_SendUsbReports | EventVector_ResendUsbReports); } }