diff --git a/right/src/usb_commands/usb_command_get_variable.c b/right/src/usb_commands/usb_command_get_variable.c index 46cd2b1..e3433d8 100644 --- a/right/src/usb_commands/usb_command_get_variable.c +++ b/right/src/usb_commands/usb_command_get_variable.c @@ -2,6 +2,7 @@ #include "usb_commands/usb_command_get_variable.h" #include "key_matrix.h" #include "test_mode.h" +#include "usb_report_updater.h" void UsbCommand_GetVariable(void) { @@ -12,6 +13,7 @@ void UsbCommand_GetVariable(void) SetUsbTxBufferUint8(1, TestModeActive); break; case UsbVariable_TestUsbStack: + SetUsbTxBufferUint8(1, TestUsbStack); break; case UsbVariable_DebounceTimePress: SetUsbTxBufferUint8(1, DebounceTimePress); diff --git a/right/src/usb_commands/usb_command_set_variable.c b/right/src/usb_commands/usb_command_set_variable.c index 0ee9c37..0927e87 100644 --- a/right/src/usb_commands/usb_command_set_variable.c +++ b/right/src/usb_commands/usb_command_set_variable.c @@ -2,6 +2,7 @@ #include "usb_commands/usb_command_set_variable.h" #include "key_matrix.h" #include "test_mode.h" +#include "usb_report_updater.h" void UsbCommand_SetVariable(void) { @@ -15,6 +16,7 @@ void UsbCommand_SetVariable(void) } break; case UsbVariable_TestUsbStack: + TestUsbStack = GetUsbRxBufferUint8(2); break; case UsbVariable_DebounceTimePress: DebounceTimePress = GetUsbRxBufferUint8(2); diff --git a/right/src/usb_report_updater.c b/right/src/usb_report_updater.c index 5ebc64f..dd7d15d 100644 --- a/right/src/usb_report_updater.c +++ b/right/src/usb_report_updater.c @@ -24,6 +24,7 @@ uint16_t DoubleTapSwitchLayerTimeout = 150; static uint16_t DoubleTapSwitchLayerReleaseTimeout = 100; static bool activeMouseStates[ACTIVE_MOUSE_STATES_COUNT]; +bool TestUsbStack = false; volatile uint8_t UsbReportUpdateSemaphore = 0; @@ -322,18 +323,17 @@ static void updateActiveUsbReports(void) bool layerGotReleased = previousLayer != LayerId_Base && activeLayer == LayerId_Base; LedDisplay_SetLayer(activeLayer); -#if 0 // Used to toggle key presses at the maximum rate - this was used to reproduce: https://github.com/UltimateHackingKeyboard/firmware/issues/122 - static bool simulateKeypresses = false; + static bool isEven = false; static bool isEvenMedia = false; static uint32_t mediaCounter = 0; key_state_t *testKeyState = &KeyStates[SlotId_LeftKeyboardHalf][0]; if (!testKeyState->previous && testKeyState->current && activeLayer == LayerId_Fn) { - simulateKeypresses = !simulateKeypresses; + TestUsbStack = !TestUsbStack; } - if (simulateKeypresses) { + if (TestUsbStack) { isEven = !isEven; ActiveUsbBasicKeyboardReport->scancodes[basicScancodeIndex++] = isEven ? HID_KEYBOARD_SC_A : HID_KEYBOARD_SC_BACKSPACE; if (++mediaCounter % 200 == 0) { @@ -342,7 +342,6 @@ static void updateActiveUsbReports(void) } MouseMoveState.xOut = isEven ? -1 : 1; } -#endif for (uint8_t slotId=0; slotId