Skip to content

Commit 809b59d

Browse files
committed
Add diagnostics info.
1 parent 3408734 commit 809b59d

3 files changed

Lines changed: 14 additions & 4 deletions

File tree

right/src/debug.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,23 @@ typedef struct {
4040
uint32_t applied;
4141
uint32_t action;
4242
uint32_t delivered;
43+
uint8_t scanActive; // target state (1=press, 0=release) of the last scan change
4344
} key_life_times_t;
4445

4546
extern key_life_times_t KeyLifeTimes;
4647

4748
#define DEBUG_KEY_LIFE_ENABLED true
4849
#if DEBUG_KEY_LIFE_ENABLED
4950
#define DEBUG_KEY_LIFE(STAGE) (KeyLifeTimes.STAGE = Timer_GetCurrentTime())
51+
// Like DEBUG_KEY_LIFE(scan), but also records whether the change was into an
52+
// active (pressed) or inactive (released) state.
53+
#define DEBUG_KEY_LIFE_SCAN(ACTIVE) do { \
54+
KeyLifeTimes.scan = Timer_GetCurrentTime(); \
55+
KeyLifeTimes.scanActive = (ACTIVE) ? 1 : 0; \
56+
} while (0)
5057
#else
5158
#define DEBUG_KEY_LIFE(STAGE)
59+
#define DEBUG_KEY_LIFE_SCAN(ACTIVE)
5260
#endif
5361

5462
// Last-seen state of blockedByReportThrottle(); printed by Hid_DumpTransportState.

right/src/hid/transport.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,11 @@ extern "C" void Hid_DumpTransportState(void)
7070
c2usb_log(" powerMode=%d usbUp=%d usbAwake=%d\n",
7171
(int)CurrentPowerMode, (int)UsbState_IsTransportUp(), (int)UsbState_IsAwake());
7272
uint32_t now = Timer_GetCurrentTime();
73-
c2usb_log(" key life (ms ago): scan=%u queued=%u/forceQueued=%u/applied=%u action=%u delivered=%u\n",
74-
now - KeyLifeTimes.scan, now - KeyLifeTimes.queued, now - KeyLifeTimes.forceQueued,
75-
now - KeyLifeTimes.applied, now - KeyLifeTimes.action, now - KeyLifeTimes.delivered);
73+
c2usb_log(" key life (ms ago): scan(%d)=%u queued=%u/forceQueued=%u/applied=%u action=%u delivered=%u\n",
74+
(int)KeyLifeTimes.scanActive, now - KeyLifeTimes.scan, now - KeyLifeTimes.queued,
75+
now - KeyLifeTimes.forceQueued, now - KeyLifeTimes.applied, now - KeyLifeTimes.action,
76+
now - KeyLifeTimes.delivered);
77+
c2usb_log(" inactive kb report: %s\n", Utils_GetUsbReportString(GetInactiveKeyboardReport()));
7678
c2usb_log(" semaphore (inFlight/retries/needsResend): kb=%d/%d/%d ctl=%d/%d/%d mouse=%d/%d/%d givenUp=%d\n",
7779
(int)UsbSemaphore.keyboard.inFlight, (int)UsbSemaphore.keyboard.retries, (int)UsbSemaphore.keyboard.needsResending,
7880
(int)UsbSemaphore.controls.inFlight, (int)UsbSemaphore.controls.retries, (int)UsbSemaphore.controls.needsResending,

right/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ void CopyRightKeystateMatrix(void)
116116
}
117117

118118
if (KeyStates[SlotId_RightKeyboardHalf][targetKeyId].hardwareSwitchState != RightKeyMatrix.keyStates[keyId]) {
119-
DEBUG_KEY_LIFE(scan);
119+
DEBUG_KEY_LIFE_SCAN(RightKeyMatrix.keyStates[keyId]);
120120
KeyStates[SlotId_RightKeyboardHalf][targetKeyId].hardwareSwitchState = RightKeyMatrix.keyStates[keyId];
121121
stateChanged = true;
122122
}

0 commit comments

Comments
 (0)