Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into fix_keystroke_delay…
Browse files Browse the repository at this point in the history
…_issues
  • Loading branch information
kareltucek committed Dec 14, 2024
2 parents 84bb0ba + 2734a11 commit 082cdaf
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 23 deletions.
31 changes: 16 additions & 15 deletions right/src/event_scheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion right/src/usb_interfaces/usb_interface_basic_keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion right/src/usb_interfaces/usb_interface_mouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
14 changes: 8 additions & 6 deletions right/src/usb_report_updater.c
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 082cdaf

Please sign in to comment.