Skip to content

Commit

Permalink
Merge pull request #1027 from UltimateHackingKeyboard/stuck_keys_fixes
Browse files Browse the repository at this point in the history
Fix resending logic that broke some macros.
  • Loading branch information
mondalaci authored Dec 14, 2024
2 parents 81d852d + 87032a9 commit 2734a11
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
7 changes: 4 additions & 3 deletions right/src/event_scheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
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 @@ -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__
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 2734a11

Please sign in to comment.