From 87032a9ee64b193b113c4870df2a37dc6a4b8533 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Tu=C4=8Dek?= Date: Sat, 14 Dec 2024 17:31:52 +0100 Subject: [PATCH] Fix resending logic that broke some macros. --- right/src/event_scheduler.h | 7 ++++--- .../usb_interfaces/usb_interface_basic_keyboard.c | 2 +- right/src/usb_interfaces/usb_interface_mouse.c | 2 +- right/src/usb_report_updater.c | 14 ++++++++------ 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/right/src/event_scheduler.h b/right/src/event_scheduler.h index b11bd971b..cc2b81c82 100644 --- a/right/src/event_scheduler.h +++ b/right/src/event_scheduler.h @@ -72,9 +72,10 @@ EventVector_MouseControllerMouseReportsUsed = 1 << 21, EventVector_MouseControllerKeyboardReportsUsed = 1 << 22, EventVector_SendUsbReports = 1 << 23, - EventVector_NativeActionsPostponing = 1 << 24, - EventVector_MacroEnginePostponing = 1 << 25, - EventVector_MouseControllerPostponing = 1 << 26, + EventVector_ResendUsbReports = 1 << 24, + EventVector_NativeActionsPostponing = 1 << 25, + EventVector_MacroEnginePostponing = 1 << 26, + EventVector_MouseControllerPostponing = 1 << 27, // helper masks EventVector_ReportUpdateMask = EventVector_MainTriggers & ~EventVector_EventScheduler, 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 6baecb614..3a57ed68f 100644 --- a/right/src/usb_report_updater.c +++ b/right/src/usb_report_updater.c @@ -678,7 +678,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__ @@ -720,7 +720,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; @@ -732,7 +732,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; @@ -773,14 +773,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); } }