Temporarily allow the USB stack test to be activated through USB

This commit is contained in:
Eric Tang
2018-07-20 17:23:44 -07:00
parent 8c50192d6c
commit a2866feb77
4 changed files with 9 additions and 5 deletions

View File

@@ -2,6 +2,7 @@
#include "usb_commands/usb_command_get_variable.h" #include "usb_commands/usb_command_get_variable.h"
#include "key_matrix.h" #include "key_matrix.h"
#include "test_mode.h" #include "test_mode.h"
#include "usb_report_updater.h"
void UsbCommand_GetVariable(void) void UsbCommand_GetVariable(void)
{ {
@@ -12,6 +13,7 @@ void UsbCommand_GetVariable(void)
SetUsbTxBufferUint8(1, TestModeActive); SetUsbTxBufferUint8(1, TestModeActive);
break; break;
case UsbVariable_TestUsbStack: case UsbVariable_TestUsbStack:
SetUsbTxBufferUint8(1, TestUsbStack);
break; break;
case UsbVariable_DebounceTimePress: case UsbVariable_DebounceTimePress:
SetUsbTxBufferUint8(1, DebounceTimePress); SetUsbTxBufferUint8(1, DebounceTimePress);

View File

@@ -2,6 +2,7 @@
#include "usb_commands/usb_command_set_variable.h" #include "usb_commands/usb_command_set_variable.h"
#include "key_matrix.h" #include "key_matrix.h"
#include "test_mode.h" #include "test_mode.h"
#include "usb_report_updater.h"
void UsbCommand_SetVariable(void) void UsbCommand_SetVariable(void)
{ {
@@ -15,6 +16,7 @@ void UsbCommand_SetVariable(void)
} }
break; break;
case UsbVariable_TestUsbStack: case UsbVariable_TestUsbStack:
TestUsbStack = GetUsbRxBufferUint8(2);
break; break;
case UsbVariable_DebounceTimePress: case UsbVariable_DebounceTimePress:
DebounceTimePress = GetUsbRxBufferUint8(2); DebounceTimePress = GetUsbRxBufferUint8(2);

View File

@@ -24,6 +24,7 @@ uint16_t DoubleTapSwitchLayerTimeout = 150;
static uint16_t DoubleTapSwitchLayerReleaseTimeout = 100; static uint16_t DoubleTapSwitchLayerReleaseTimeout = 100;
static bool activeMouseStates[ACTIVE_MOUSE_STATES_COUNT]; static bool activeMouseStates[ACTIVE_MOUSE_STATES_COUNT];
bool TestUsbStack = false;
volatile uint8_t UsbReportUpdateSemaphore = 0; volatile uint8_t UsbReportUpdateSemaphore = 0;
@@ -322,18 +323,17 @@ static void updateActiveUsbReports(void)
bool layerGotReleased = previousLayer != LayerId_Base && activeLayer == LayerId_Base; bool layerGotReleased = previousLayer != LayerId_Base && activeLayer == LayerId_Base;
LedDisplay_SetLayer(activeLayer); 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 isEven = false;
static bool isEvenMedia = false; static bool isEvenMedia = false;
static uint32_t mediaCounter = 0; static uint32_t mediaCounter = 0;
key_state_t *testKeyState = &KeyStates[SlotId_LeftKeyboardHalf][0]; key_state_t *testKeyState = &KeyStates[SlotId_LeftKeyboardHalf][0];
if (!testKeyState->previous && testKeyState->current && activeLayer == LayerId_Fn) { if (!testKeyState->previous && testKeyState->current && activeLayer == LayerId_Fn) {
simulateKeypresses = !simulateKeypresses; TestUsbStack = !TestUsbStack;
} }
if (simulateKeypresses) { if (TestUsbStack) {
isEven = !isEven; isEven = !isEven;
ActiveUsbBasicKeyboardReport->scancodes[basicScancodeIndex++] = isEven ? HID_KEYBOARD_SC_A : HID_KEYBOARD_SC_BACKSPACE; ActiveUsbBasicKeyboardReport->scancodes[basicScancodeIndex++] = isEven ? HID_KEYBOARD_SC_A : HID_KEYBOARD_SC_BACKSPACE;
if (++mediaCounter % 200 == 0) { if (++mediaCounter % 200 == 0) {
@@ -342,7 +342,6 @@ static void updateActiveUsbReports(void)
} }
MouseMoveState.xOut = isEven ? -1 : 1; MouseMoveState.xOut = isEven ? -1 : 1;
} }
#endif
for (uint8_t slotId=0; slotId<SLOT_COUNT; slotId++) { for (uint8_t slotId=0; slotId<SLOT_COUNT; slotId++) {
for (uint8_t keyId=0; keyId<MAX_KEY_COUNT_PER_MODULE; keyId++) { for (uint8_t keyId=0; keyId<MAX_KEY_COUNT_PER_MODULE; keyId++) {

View File

@@ -71,6 +71,7 @@
extern mouse_kinetic_state_t MouseScrollState; extern mouse_kinetic_state_t MouseScrollState;
extern uint32_t UsbReportUpdateCounter; extern uint32_t UsbReportUpdateCounter;
extern volatile uint8_t UsbReportUpdateSemaphore; extern volatile uint8_t UsbReportUpdateSemaphore;
extern bool TestUsbStack;
// Functions: // Functions: