From 84bb0ba3aa52969881e67e532ecc0b14d7efceea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Tu=C4=8Dek?= Date: Sat, 14 Dec 2024 19:59:21 +0100 Subject: [PATCH] Fix key stucks caused by (high) keystroke delays. --- right/src/event_scheduler.h | 11 ++++++----- right/src/postponer.c | 2 +- right/src/usb_report_updater.c | 29 ++++++++++++++++++++++++----- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/right/src/event_scheduler.h b/right/src/event_scheduler.h index b11bd971b..e68a9e877 100644 --- a/right/src/event_scheduler.h +++ b/right/src/event_scheduler.h @@ -49,7 +49,8 @@ EventVector_MouseController = 1 << 4, EventVector_Postponer = 1 << 5, EventVector_LayerHolds = 1 << 6, - EventVector_EventScheduler = 1 << 7, + EventVector_SendUsbReports = 1 << 7, + EventVector_EventScheduler = 1 << 8, EventVector_MainTriggers = ((EventVector_EventScheduler << 1) - 1), @@ -71,15 +72,15 @@ EventVector_MouseKeysReportsUsed = 1 << 20, 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_KeystrokeDelayPostponing = 1 << 25, + EventVector_MacroEnginePostponing = 1 << 26, + EventVector_MouseControllerPostponing = 1 << 27, // helper masks EventVector_ReportUpdateMask = EventVector_MainTriggers & ~EventVector_EventScheduler, EventVector_UserLogicUpdateMask = EventVector_AuxiliaryTriggers & ~EventVector_EventScheduler, - EventVector_SomeonePostponing = EventVector_NativeActionsPostponing | EventVector_MacroEnginePostponing | EventVector_MouseControllerPostponing, + EventVector_SomeonePostponing = EventVector_KeystrokeDelayPostponing | EventVector_NativeActionsPostponing | EventVector_MacroEnginePostponing | EventVector_MouseControllerPostponing, } event_vector_event_t; /** diff --git a/right/src/postponer.c b/right/src/postponer.c index 040f52cdd..5f70f1361 100644 --- a/right/src/postponer.c +++ b/right/src/postponer.c @@ -192,7 +192,7 @@ static void appendEvent(postponer_event_t event) bool PostponerCore_EventsShouldBeQueued(void) { - return runState.eventsShouldBeQueued || (EventScheduler_Vector & EventVector_NativeActionsPostponing) || (EventScheduler_Vector & EventVector_MacroEnginePostponing); + return runState.eventsShouldBeQueued || (EventScheduler_Vector & (EventVector_KeystrokeDelayPostponing | EventVector_NativeActionsPostponing | EventVector_MacroEnginePostponing /* should here be mouse controller too? */)); } bool PostponerCore_IsActive(void) diff --git a/right/src/usb_report_updater.c b/right/src/usb_report_updater.c index 6baecb614..7dccaf30c 100644 --- a/right/src/usb_report_updater.c +++ b/right/src/usb_report_updater.c @@ -1,4 +1,5 @@ #include +#include "atomicity.h" #include "event_scheduler.h" #include "key_action.h" #include "led_display.h" @@ -656,9 +657,6 @@ static void updateActiveUsbReports(void) } void justPreprocessInput(void) { - // Make preprocessKeyState push new events into postponer queue. - EventVector_Set(EventVector_NativeActionsPostponing); - for (uint8_t slotId=0; slotId