Skip to content
This repository has been archived by the owner on Dec 18, 2024. It is now read-only.

Commit

Permalink
Merge pull request #374 from UltimateHackingKeyboard/always_send_0_re…
Browse files Browse the repository at this point in the history
…port

Always send zero report.
  • Loading branch information
mondalaci authored Dec 4, 2024
2 parents df8d17b + 1cd88da commit 790865a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 30 deletions.
45 changes: 23 additions & 22 deletions right/src/event_scheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,33 +49,34 @@
EventVector_MouseController = 1 << 4,
EventVector_Postponer = 1 << 5,
EventVector_LayerHolds = 1 << 6,
EventVector_EventScheduler = 1 << 7,
EventVector_ZeroScan = 1 << 7,
EventVector_EventScheduler = 1 << 8,


// some other minor triggers
EventVector_KeyboardLedState = 1 << 8,
EventVector_UsbMacroCommandWaitingForExecution = 1 << 9,
EventVector_ProtocolChanged = 1 << 10,
EventVector_LedManagerFullUpdateNeeded = 1 << 11,
EventVector_KeymapReloadNeeded = 1 << 12,
EventVector_SegmentDisplayNeedsUpdate = 1 << 13,
EventVector_LedMapUpdateNeeded = 1 << 14,
EventVector_ApplyConfig = 1 << 15,
EventVector_NewMessage = 1 << 16,

EventVector_ReportUpdateMask = ((1 << 8) - 1) & ~EventVector_EventScheduler,
EventVector_UserLogicUpdateMask = ((1 << 17) - 1) & ~EventVector_EventScheduler,
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_ReportUpdateMask = ((1 << 9) - 1) & ~EventVector_EventScheduler,
EventVector_UserLogicUpdateMask = ((1 << 18) - 1) & ~EventVector_EventScheduler,

// events that are informational only
EventVector_NativeActionReportsUsed = 1 << 17,
EventVector_MacroReportsUsed = 1 << 18,
EventVector_MouseKeysReportsUsed = 1 << 19,
EventVector_MouseControllerMouseReportsUsed = 1 << 20,
EventVector_MouseControllerKeyboardReportsUsed = 1 << 21,
EventVector_ReportsChanged = 1 << 22,
EventVector_NativeActionsPostponing = 1 << 23,
EventVector_MacroEnginePostponing = 1 << 24,
EventVector_MouseControllerPostponing = 1 << 25,
EventVector_NativeActionReportsUsed = 1 << 18,
EventVector_MacroReportsUsed = 1 << 19,
EventVector_MouseKeysReportsUsed = 1 << 20,
EventVector_MouseControllerMouseReportsUsed = 1 << 21,
EventVector_MouseControllerKeyboardReportsUsed = 1 << 22,
EventVector_ReportsChanged = 1 << 23,
EventVector_NativeActionsPostponing = 1 << 24,
EventVector_MacroEnginePostponing = 1 << 25,
EventVector_MouseControllerPostponing = 1 << 26,

// helpers
EventVector_SomeonePostponing = EventVector_NativeActionsPostponing | EventVector_MacroEnginePostponing | EventVector_MouseControllerPostponing,
Expand Down
23 changes: 15 additions & 8 deletions right/src/usb_report_updater.c
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,8 @@ uint32_t UpdateUsbReports_LastUpdateTime = 0;
uint32_t lastBasicReportTime = 0;

static void sendActiveReports() {
bool usbReportsChanged = false;
bool usbReportsChangedByAction = false;
bool usbReportsChangedByAnything = false;

if (UsbBasicKeyboardCheckReportReady() == kStatus_USB_Success) {
#ifdef __ZEPHYR__
Expand All @@ -695,7 +696,8 @@ static void sendActiveReports() {
} else {
UsbBasicKeyboardSendActiveReport();
}
usbReportsChanged = true;
usbReportsChangedByAction = true;
usbReportsChangedByAnything = true;
lastBasicReportTime = CurrentTime;
UsbReportUpdater_LastActivityTime = CurrentTime;
}
Expand All @@ -707,7 +709,8 @@ static void sendActiveReports() {
SwitchActiveUsbMediaKeyboardReport();
SwitchActiveUsbSystemKeyboardReport();
UsbReportUpdater_LastActivityTime = CurrentTime;
usbReportsChanged = true;
usbReportsChangedByAction = true;
usbReportsChangedByAnything = true;
}
#else
if (UsbMediaKeyboardCheckReportReady() == kStatus_USB_Success) {
Expand All @@ -717,7 +720,8 @@ static void sendActiveReports() {
UsbReportUpdateSemaphore &= ~(1 << USB_MEDIA_KEYBOARD_INTERFACE_INDEX);
}
UsbReportUpdater_LastActivityTime = CurrentTime;
usbReportsChanged = true;
usbReportsChangedByAction = true;
usbReportsChangedByAnything = true;
}

if (UsbSystemKeyboardCheckReportReady() == kStatus_USB_Success) {
Expand All @@ -727,20 +731,23 @@ static void sendActiveReports() {
UsbReportUpdateSemaphore &= ~(1 << USB_SYSTEM_KEYBOARD_INTERFACE_INDEX);
}
UsbReportUpdater_LastActivityTime = CurrentTime;
usbReportsChanged = true;
usbReportsChangedByAction = true;
usbReportsChangedByAnything = true;
}
#endif

bool usbMouseButtonsChanged = false;
if (UsbMouseCheckReportReady(&usbMouseButtonsChanged) == kStatus_USB_Success) {
UsbMouseSendActiveReport();
UsbReportUpdater_LastActivityTime = CurrentTime;
usbReportsChanged |= usbMouseButtonsChanged;
usbReportsChangedByAction |= usbMouseButtonsChanged;
usbReportsChangedByAnything = true;
}

if (usbReportsChanged) {
if (usbReportsChangedByAction) {
Macros_SignalUsbReportsChange();
}
EventVector_SetValue(EventVector_ZeroScan, usbReportsChangedByAnything);
}

void UpdateUsbReports(void)
Expand All @@ -759,7 +766,7 @@ void UpdateUsbReports(void)

updateActiveUsbReports();

if (EventVector_IsSet(EventVector_ReportsChanged) && CurrentPowerMode < PowerMode_DeepSleep) {
if (EventVector_IsSet(EventVector_ReportsChanged | EventVector_ZeroScan) && CurrentPowerMode < PowerMode_DeepSleep) {
mergeReports();
sendActiveReports();
} else {
Expand Down

0 comments on commit 790865a

Please sign in to comment.