HID BotDetect functionality debugged and working:

- Implement advanced LED flash support
 - Tweak HAL_SPI_TransmitReceive to tolerate a longer SysTick interrupt
 - Tune KEYBOARD_BOTDETECT parameters
 - L-shift and R-shift are now high-speed alphanumeric keys
USG_1.0
Robert Fisk 7 years ago
parent 02f6842723
commit fa00fd95dd

@ -32,7 +32,7 @@ typedef enum
#define DOWNSTREAM_STATEMACHINE_FREAKOUT \
do { \
USB_Host_Disconnect(); \
LED_Fault_SetBlinkRate(LED_FAST_BLINK_RATE); \
LED_SetState(LED_STATUS_FLASH_ERROR); \
/*DownstreamState = STATE_ERROR; */ \
while (1); \
} while (0);

@ -16,17 +16,28 @@
#include "stm32f4xx_hal.h"
void LED_Init(void);
void LED_Fault_SetBlinkRate(uint16_t newBlinkRate);
void LED_DoBlinks(void);
typedef enum
{
LED_STATUS_STARTUP,
LED_STATUS_OFF,
LED_STATUS_FLASH_ERROR,
LED_STATUS_FLASH_UNSUPPORTED,
LED_STATUS_FLASH_BOTDETECT
}
LedStatusTypeDef;
void LED_Init(void);
void LED_SetState(LedStatusTypeDef newState);
void LED_Tick(void);
#define STARTUP_FLASH_DELAY 500 //units = ticks = ms
#define STARTUP_FLASH_DELAY_MS 500
//LEDs are on for BLINK_RATE ticks, then off for BLINK_RATE ticks
#define LED_FAST_BLINK_RATE 100
#define LED_SLOW_BLINK_RATE 500
#define LED_ERROR_BLINK_MS 100
#define LED_UNSUPPORTED_BLINK_MS 500
#define LED_BOTDETECT_BLINK_MS 100
#define LED_BOTDETECT_OFF_MS (1000 - (LED_BOTDETECT_BLINK_MS * 3)) //Two flashes, total period = 1 sec

@ -264,7 +264,7 @@ void Downstream_HostUserCallback(USBH_HandleTypeDef *phost, uint8_t id)
if (newActiveClass == COMMAND_CLASS_INTERFACE)
{
USB_Host_Disconnect();
LED_Fault_SetBlinkRate(LED_SLOW_BLINK_RATE);
LED_SetState(LED_STATUS_FLASH_UNSUPPORTED);
DownstreamState = STATE_ERROR;
return;
}
@ -303,7 +303,7 @@ void Downstream_HostUserCallback(USBH_HandleTypeDef *phost, uint8_t id)
//Unsupported device classes will cause a slow fault flash.
//This is distinct from the fast freakout flash caused by internal errors or attacks.
USB_Host_Disconnect();
LED_Fault_SetBlinkRate(LED_SLOW_BLINK_RATE);
LED_SetState(LED_STATUS_FLASH_UNSUPPORTED);
DownstreamState = STATE_ERROR;
return;
}

@ -61,7 +61,7 @@ uint8_t BusFaultAllowed = 0;
void SysTick_Handler(void)
{
HAL_IncTick();
LED_DoBlinks();
LED_Tick();
}
/******************************************************************************/

@ -13,60 +13,100 @@
#include "led.h"
#include "board_config.h"
uint32_t FaultLedCounter;
LedStatusTypeDef FaultLedState;
uint16_t FaultLedOnMs;
uint16_t FaultLedOffMs;
uint8_t FaultLedBlinkCount;
uint16_t FaultLedBlinkRate = 0;
uint16_t FaultLedBlinkCounter = 0;
uint8_t FaultLedState = 0;
uint8_t StartupBlinkActive;
uint8_t FaultLedBlinkCountState;
uint8_t FaultLedOutputState;
void LED_Init(void)
{
FAULT_LED_ON;
StartupBlinkActive = 1;
FaultLedState = LED_STATUS_STARTUP;
}
void LED_Fault_SetBlinkRate(uint16_t newBlinkRate)
void LED_SetState(LedStatusTypeDef newState)
{
FaultLedBlinkRate = newBlinkRate;
if (newBlinkRate == 0)
FaultLedState = newState;
switch (FaultLedState)
{
FaultLedState = 0;
case LED_STATUS_OFF:
FaultLedCounter = UINT32_MAX;
FaultLedBlinkCountState = 0;
FaultLedOutputState = 0;
FAULT_LED_OFF;
break;
case LED_STATUS_FLASH_UNSUPPORTED:
FaultLedOnMs = LED_UNSUPPORTED_BLINK_MS;
FaultLedOffMs = LED_UNSUPPORTED_BLINK_MS;
FaultLedBlinkCount = 1;
break;
case LED_STATUS_FLASH_BOTDETECT:
FaultLedOnMs = LED_BOTDETECT_BLINK_MS;
FaultLedOffMs = LED_BOTDETECT_OFF_MS;
FaultLedBlinkCount = 2;
break;
default:
FaultLedOnMs = LED_ERROR_BLINK_MS; //Everything else is LED_STATUS_ERROR
FaultLedOffMs = LED_ERROR_BLINK_MS;
FaultLedBlinkCount = 1;
}
}
void LED_DoBlinks(void)
void LED_Tick(void)
{
if (StartupBlinkActive)
if (FaultLedState == LED_STATUS_OFF) return;
if (FaultLedState == LED_STATUS_STARTUP)
{
if (HAL_GetTick() >= STARTUP_FLASH_DELAY)
if (HAL_GetTick() >= STARTUP_FLASH_DELAY_MS)
{
FAULT_LED_OFF;
StartupBlinkActive = 0;
LED_SetState(LED_STATUS_OFF);
}
return;
}
if (FaultLedBlinkRate > 0)
{
FaultLedBlinkCounter++;
if (FaultLedBlinkCounter >= FaultLedBlinkRate)
if (FaultLedOutputState)
{
FaultLedBlinkCounter = 0;
if (FaultLedState)
if (FaultLedCounter++ >= FaultLedOnMs) //Check to turn LED off
{
FaultLedState = 0;
FaultLedBlinkCountState++;
FaultLedCounter = 0;
FaultLedOutputState = 0;
FAULT_LED_OFF;
}
}
else
{
FaultLedState = 1;
if (FaultLedBlinkCountState >= FaultLedBlinkCount) //Checks to turn LED on...
{
if (FaultLedCounter++ >= FaultLedOffMs) //Last flash may have longer off-time
{
FaultLedBlinkCountState = 0;
FaultLedCounter = 0;
FaultLedOutputState = 1;
FAULT_LED_ON;
}
}
else
{
if (FaultLedCounter++ >= FaultLedOnMs) //Flash sequence uses on-time as intermediate off-time
{
FaultLedCounter = 0;
FaultLedOutputState = 1;
FAULT_LED_ON;
}
}
}
}

@ -738,6 +738,7 @@ HAL_StatusTypeDef HAL_SPI_TransmitReceive(SPI_HandleTypeDef *hspi, uint8_t *pTxD
return HAL_TIMEOUT;
}
__disable_irq(); //Don't let systick interrupt delay our CRCNEXT flag
hspi->Instance->DR = *((uint16_t*)hspi->pTxBuffPtr);
hspi->pTxBuffPtr+=2;
hspi->TxXferCount--;
@ -757,6 +758,8 @@ HAL_StatusTypeDef HAL_SPI_TransmitReceive(SPI_HandleTypeDef *hspi, uint8_t *pTxD
*((uint16_t*)hspi->pRxBuffPtr) = hspi->Instance->DR;
hspi->pRxBuffPtr+=2;
hspi->RxXferCount--;
__enable_irq();
}
/* Receive the last byte */
if(hspi->Init.Mode == SPI_MODE_SLAVE)

@ -25,17 +25,17 @@
//Configure keyboard rate-limiting (bot detection) here:
#ifdef CONFIG_KEYBOARD_BOT_DETECT_ENABLED
#define KEYBOARD_BOTDETECT_ALPHANUM_TIME_MS 170 //Alphanumeric keys (and space), used for high-speed typing. Limit 6 per second, 360 keys per minute
#define KEYBOARD_BOTDETECT_NON_ALPHANUM_DIFFERENT_TIME_MS 250 //Non-alphanumeric keys. Limit 4 per second.
#define KEYBOARD_BOTDETECT_ALPHANUM_TIME_MS 125 //Alphanumeric keys (& space & shift), used for high-speed typing. Limit 8 per second
#define KEYBOARD_BOTDETECT_NON_ALPHANUM_DIFFERENT_TIME_MS 200 //Non-alphanumeric keys. Limit 5 per second.
#define KEYBOARD_BOTDETECT_NON_ALPHANUM_REPEATED_TIME_MS 170 //Non-alphanumeric key, pressed repeatedly. Limit 6 keys per second.
#define KEYBOARD_BOTDETECT_MINIMUM_KEYDOWN_TIME_MS 100 //Key pressed for less than 100ms indicates bot.
#define KEYBOARD_BOTDETECT_MINIMUM_KEYDOWN_TIME_MS 30 //Key pressed less than this indicates bot. This value must be less than the smallest of the above ratelimit key times for the code to work correctly!
#define KEYBOARD_BOTDETECT_TEMPORARY_LOCKOUT_KEY_COUNT 2 //'Burst' = maximum number of keys with active timer before triggering temporary lockout
#define KEYBOARD_BOTDETECT_PERMANENT_LOCKOUT_KEY_COUNT 4 //'Burst' = maximum number of keys with active timer before triggering permanent lockout
#define KEYBOARD_BOTDETECT_TEMPORARY_LOCKOUT_KEY_COUNT 3 //'Burst' = maximum number of keys with active timer before triggering temporary lockout
#define KEYBOARD_BOTDETECT_PERMANENT_LOCKOUT_KEY_COUNT 5 //'Burst' = maximum number of keys with active timer before triggering permanent lockout
#define KEYBOARD_BOTDETECT_PERMANENT_LOCKOUT_SHORT_COUNT 3 //One short keypress causes temporary lockout. 3 short keypresses within the temporary lockout time triggers permanent lockout
#define KEYBOARD_BOTDETECT_TEMPORARY_LOCKOUT_TIME_MS 5000 //Lockout for 5 seconds when temporary lockout threshold reached
#define KEYBOARD_BOTDETECT_TEMPORARY_LOCKOUT_LED_TIME_MS 60000 //Flash fault LED for 60 seconds after temporary lockout
#define KEYBOARD_BOTDETECT_TEMPORARY_LOCKOUT_FLASH_TIME_MS 60000 //Flash fault LED for 60 seconds after temporary lockout
#endif

@ -16,18 +16,28 @@
#include "stm32f4xx_hal.h"
void LED_Init(void);
void LED_Fault_SetBlinkRate(uint16_t newBlinkRate);
void LED_DoBlinks(void);
typedef enum
{
LED_STATUS_STARTUP,
LED_STATUS_OFF,
LED_STATUS_FLASH_ERROR,
LED_STATUS_FLASH_UNSUPPORTED,
LED_STATUS_FLASH_BOTDETECT
}
LedStatusTypeDef;
void LED_Init(void);
void LED_SetState(LedStatusTypeDef newState);
void LED_Tick(void);
#define STARTUP_FLASH_DELAY 500 //units = ticks = ms
//LEDs are on for BLINK_RATE ticks, then off for BLINK_RATE ticks
#define LED_FAST_BLINK_RATE 100
#define LED_SLOW_BLINK_RATE 500
#define STARTUP_FLASH_DELAY_MS 500 //units = ticks = ms
#define LED_ERROR_BLINK_MS 100
#define LED_UNSUPPORTED_BLINK_MS 500
#define LED_BOTDETECT_BLINK_MS 100
#define LED_BOTDETECT_OFF_MS (1000 - (LED_BOTDETECT_BLINK_MS * 3)) //Two flashes, total period = 1 sec
#endif /* INC_LED_H_ */

@ -21,13 +21,16 @@
#define KEY_PAD_1 0x59
#define KEY_PAD_0 0x62
#define KEY_MODIFIER_BASE 0xE0 //First modifier key is L-Ctl
#define KEY_MODIFIER_SHIFT_L 0xE1
#define KEY_MODIFIER_SHIFT_R 0xE5
typedef enum
{
LOCKOUT_STATE_INACTIVE = 0,
LOCKOUT_STATE_ACTIVE,
LOCKOUT_STATE_FLASHING
LOCKOUT_STATE_TEMPORARY_ACTIVE,
LOCKOUT_STATE_TEMPORARY_FLASHING,
LOCKOUT_STATE_PERMANENT_ACTIVE
}
LockoutStateTypeDef;
@ -36,7 +39,7 @@ typedef struct
{
uint8_t KeyCode;
uint32_t KeyDownTime;
int32_t KeyActiveTimer;
uint32_t KeyActiveTimer;
}
KeyTimerLogTypeDef;

@ -30,7 +30,7 @@
#define UPSTREAM_SPI_FREAKOUT \
do { \
LED_Fault_SetBlinkRate(LED_FAST_BLINK_RATE); \
LED_SetState(LED_STATUS_FLASH_ERROR); \
/*UpstreamInterfaceState = UPSTREAM_INTERFACE_ERROR; */ \
Upstream_StateMachine_SetErrorState(); \
while (1); \

@ -31,7 +31,7 @@ typedef enum
#define UPSTREAM_STATEMACHINE_FREAKOUT \
do { \
LED_Fault_SetBlinkRate(LED_FAST_BLINK_RATE); \
LED_SetState(LED_STATUS_FLASH_ERROR); \
Upstream_StateMachine_SetErrorState(); \
while (1); \
} while (0);

@ -62,7 +62,7 @@ uint8_t BusFaultAllowed = 0;
void SysTick_Handler(void)
{
HAL_IncTick();
LED_DoBlinks();
LED_Tick();
#if (defined (CONFIG_KEYBOARD_ENABLED) && defined (CONFIG_KEYBOARD_BOT_DETECT_ENABLED)) || \
(defined (CONFIG_MOUSE_ENABLED) && defined (CONFIG_MOUSE_BOT_DETECT_ENABLED))

@ -13,57 +13,98 @@
#include "led.h"
#include "board_config.h"
uint32_t FaultLedCounter;
LedStatusTypeDef FaultLedState;
uint16_t FaultLedOnMs;
uint16_t FaultLedOffMs;
uint8_t FaultLedBlinkCount;
uint16_t FaultLedBlinkRate = 0;
uint16_t FaultLedBlinkCounter = 0;
uint8_t FaultLedState = 0;
uint8_t StartupBlinkActive;
uint8_t FaultLedBlinkCountState;
uint8_t FaultLedOutputState;
void LED_Init(void)
{
FAULT_LED_ON;
StartupBlinkActive = 1;
FaultLedState = LED_STATUS_STARTUP;
}
void LED_Fault_SetBlinkRate(uint16_t newBlinkRate)
void LED_SetState(LedStatusTypeDef newState)
{
FaultLedBlinkRate = newBlinkRate;
if (newBlinkRate == 0)
FaultLedState = newState;
switch (FaultLedState)
{
FaultLedState = 0;
case LED_STATUS_OFF:
FaultLedCounter = UINT32_MAX;
FaultLedBlinkCountState = 0;
FaultLedOutputState = 0;
FAULT_LED_OFF;
break;
case LED_STATUS_FLASH_UNSUPPORTED:
FaultLedOnMs = LED_UNSUPPORTED_BLINK_MS;
FaultLedOffMs = LED_UNSUPPORTED_BLINK_MS;
FaultLedBlinkCount = 1;
break;
case LED_STATUS_FLASH_BOTDETECT:
FaultLedOnMs = LED_BOTDETECT_BLINK_MS;
FaultLedOffMs = LED_BOTDETECT_OFF_MS;
FaultLedBlinkCount = 2;
break;
default:
FaultLedOnMs = LED_ERROR_BLINK_MS; //Everything else is LED_STATUS_ERROR
FaultLedOffMs = LED_ERROR_BLINK_MS;
FaultLedBlinkCount = 1;
}
}
void LED_DoBlinks(void)
void LED_Tick(void)
{
if (StartupBlinkActive)
if (FaultLedState == LED_STATUS_OFF) return;
if (FaultLedState == LED_STATUS_STARTUP)
{
if (HAL_GetTick() >= STARTUP_FLASH_DELAY)
if (HAL_GetTick() >= STARTUP_FLASH_DELAY_MS)
{
FAULT_LED_OFF;
StartupBlinkActive = 0;
LED_SetState(LED_STATUS_OFF);
}
return;
}
if (FaultLedBlinkRate > 0)
if (FaultLedOutputState)
{
FaultLedBlinkCounter++;
if (FaultLedBlinkCounter >= FaultLedBlinkRate)
if (FaultLedCounter++ >= FaultLedOnMs) //Check to turn LED off
{
FaultLedBlinkCounter = 0;
if (FaultLedState)
{
FaultLedState = 0;
FaultLedBlinkCountState++;
FaultLedCounter = 0;
FaultLedOutputState = 0;
FAULT_LED_OFF;
}
}
else
{
FaultLedState = 1;
if (FaultLedBlinkCountState >= FaultLedBlinkCount) //Checks to turn LED on...
{
if (FaultLedCounter++ >= FaultLedOffMs) //Last flash may have longer off-time
{
FaultLedBlinkCountState = 0;
FaultLedCounter = 0;
FaultLedOutputState = 1;
FAULT_LED_ON;
}
}
else
{
if (FaultLedCounter++ >= FaultLedOnMs) //Flash sequence uses on-time as intermediate off-time
{
FaultLedCounter = 0;
FaultLedOutputState = 1;
FAULT_LED_ON;
}
}

@ -18,8 +18,7 @@
//Variables common between keyboard and mouse bot detection:
uint32_t TemporaryLockoutStartTime;
LockoutStateTypeDef PermanentLockoutState = LOCKOUT_STATE_INACTIVE;
volatile LockoutStateTypeDef TemporaryLockoutState = LOCKOUT_STATE_INACTIVE;
volatile LockoutStateTypeDef LockoutState = LOCKOUT_STATE_INACTIVE;
@ -56,25 +55,23 @@ void Upstream_HID_BotDetectKeyboard(uint8_t* keyboardInData)
{
uint32_t i;
uint32_t j;
uint8_t tempByte;
uint8_t tempModifier;
if (Upstream_HID_BotDetectKeyboard_RolloverCheck(keyboardInData)) return;
//Process modifier keys in first byte
tempByte = keyboardInData[0];
tempModifier = keyboardInData[0];
for (i = 0; i < 8; i++)
{
if ((tempByte & 1) && !(OldKeyboardInData[0] & 1))
if ((tempModifier & 1) && !(OldKeyboardInData[0] & 1))
{
Upstream_HID_BotDetectKeyboard_KeyDown(KEY_MODIFIER_BASE + i);
}
if (!(tempByte & 1) && (OldKeyboardInData[0] & 1))
if (!(tempModifier & 1) && (OldKeyboardInData[0] & 1))
{
Upstream_HID_BotDetectKeyboard_KeyDown(KEY_MODIFIER_BASE + i);
Upstream_HID_BotDetectKeyboard_KeyUp(KEY_MODIFIER_BASE + i);
}
tempByte >>= 1;
tempModifier >>= 1;
OldKeyboardInData[0] >>= 1;
}
@ -102,7 +99,7 @@ void Upstream_HID_BotDetectKeyboard(uint8_t* keyboardInData)
{
for (j = 2; j < HID_KEYBOARD_INPUT_DATA_LEN; j++)
{
if (keyboardInData[i] == OldKeyboardInData[j]) break;
if (OldKeyboardInData[i] == keyboardInData[j]) break;
}
if (j >= HID_KEYBOARD_INPUT_DATA_LEN)
{
@ -118,15 +115,17 @@ void Upstream_HID_BotDetectKeyboard(uint8_t* keyboardInData)
}
//Final checks
if (KeyTimerCount >= KEYBOARD_BOTDETECT_TEMPORARY_LOCKOUT_KEY_COUNT)
if ((KeyTimerCount > KEYBOARD_BOTDETECT_TEMPORARY_LOCKOUT_KEY_COUNT) &&
(LockoutState != LOCKOUT_STATE_PERMANENT_ACTIVE))
{
TemporaryLockoutStartTime = HAL_GetTick();
TemporaryLockoutState = LOCKOUT_STATE_ACTIVE;
////////////Set LED state
LockoutState = LOCKOUT_STATE_TEMPORARY_ACTIVE;
LED_SetState(LED_STATUS_FLASH_BOTDETECT);
}
//Host receives no data if we are locked
if ((TemporaryLockoutState == LOCKOUT_STATE_ACTIVE) || (PermanentLockoutState == LOCKOUT_STATE_ACTIVE))
if ((LockoutState == LOCKOUT_STATE_TEMPORARY_ACTIVE) ||
(LockoutState == LOCKOUT_STATE_PERMANENT_ACTIVE))
{
for (i = 0; i < HID_KEYBOARD_INPUT_DATA_LEN; i++)
{
@ -153,7 +152,8 @@ static uint32_t Upstream_HID_BotDetectKeyboard_RolloverCheck(uint8_t* keyboardIn
//This ensures the host interprets a rollover event exactly the way we do!
//Host receives no data if we are locked
if ((TemporaryLockoutState == LOCKOUT_STATE_ACTIVE) || (PermanentLockoutState == LOCKOUT_STATE_ACTIVE))
if ((LockoutState == LOCKOUT_STATE_TEMPORARY_ACTIVE) ||
(LockoutState == LOCKOUT_STATE_PERMANENT_ACTIVE))
{
for (i = 0; i < HID_KEYBOARD_INPUT_DATA_LEN; i++)
{
@ -178,8 +178,8 @@ static void Upstream_HID_BotDetectKeyboard_KeyDown(uint8_t keyCode)
if (KeyTimerCount >= KEYBOARD_BOTDETECT_PERMANENT_LOCKOUT_KEY_COUNT)
{
PermanentLockoutState = LOCKOUT_STATE_ACTIVE;
////////////Set LED state
LockoutState = LOCKOUT_STATE_PERMANENT_ACTIVE;
LED_SetState(LED_STATUS_FLASH_BOTDETECT);
return;
}
@ -204,7 +204,8 @@ static void Upstream_HID_BotDetectKeyboard_KeyDown(uint8_t keyCode)
__disable_irq();
KeyTimerLog[KeyTimerCount].KeyCode = keyCode;
KeyTimerLog[KeyTimerCount].KeyDownTime = HAL_GetTick();
KeyTimerLog[KeyTimerCount++].KeyActiveTimer = tempKeyActiveTime;
KeyTimerLog[KeyTimerCount].KeyActiveTimer = tempKeyActiveTime;
KeyTimerCount++;
__enable_irq();
}
@ -215,6 +216,7 @@ static uint32_t Upstream_HID_BotDetectKeyboard_KeyIsAlphanum(uint8_t keyCode)
if ((keyCode >= KEY_A) && (keyCode <= KEY_Z)) return 1;
if ((keyCode >= KEY_1) && (keyCode <= KEY_0)) return 1;
if ((keyCode >= KEY_PAD_1) && (keyCode <= KEY_PAD_0)) return 1;
if ((keyCode == KEY_MODIFIER_SHIFT_L) || (keyCode == KEY_MODIFIER_SHIFT_R)) return 1;
if (keyCode == KEY_SPACE) return 1;
//else:
@ -242,16 +244,20 @@ static void Upstream_HID_BotDetectKeyboard_KeyUp(uint8_t keyCode)
//Was this is a short keypress?
if ((int32_t)(HAL_GetTick() - KeyTimerLog[i].KeyDownTime) < KEYBOARD_BOTDETECT_MINIMUM_KEYDOWN_TIME_MS)
{
__enable_irq();
ShortKeypressCount++;
////////////Set LED state
LED_SetState(LED_STATUS_FLASH_BOTDETECT);
if (ShortKeypressCount >= KEYBOARD_BOTDETECT_PERMANENT_LOCKOUT_SHORT_COUNT)
{
PermanentLockoutState = LOCKOUT_STATE_ACTIVE;
LockoutState = LOCKOUT_STATE_PERMANENT_ACTIVE;
}
else
{
if (LockoutState != LOCKOUT_STATE_PERMANENT_ACTIVE)
{
TemporaryLockoutStartTime = HAL_GetTick();
TemporaryLockoutState = LOCKOUT_STATE_ACTIVE;
LockoutState = LOCKOUT_STATE_TEMPORARY_ACTIVE;
}
}
}
__enable_irq();
@ -272,8 +278,7 @@ void Upstream_HID_BotDetect_Systick(void)
#if defined (CONFIG_KEYBOARD_ENABLED) && defined (CONFIG_KEYBOARD_BOT_DETECT_ENABLED)
if (KeyTimerCount > 0) //Check if current active key has timed out
{
KeyTimerLog[0].KeyActiveTimer--;
if (KeyTimerLog[0].KeyActiveTimer <= 0)
if (KeyTimerLog[0].KeyActiveTimer-- == 0)
{
KeyTimerCount--;
for (i = 0; i < KeyTimerCount; i++) //Shuffle other keys down
@ -286,19 +291,19 @@ void Upstream_HID_BotDetect_Systick(void)
}
//Check if temporary lockout has expired
if (TemporaryLockoutState == LOCKOUT_STATE_ACTIVE)
if (LockoutState == LOCKOUT_STATE_TEMPORARY_ACTIVE)
{
if ((int32_t)(HAL_GetTick() - TemporaryLockoutStartTime) > KEYBOARD_BOTDETECT_TEMPORARY_LOCKOUT_TIME_MS)
{
TemporaryLockoutState = LOCKOUT_STATE_FLASHING;
LockoutState = LOCKOUT_STATE_TEMPORARY_FLASHING;
}
}
else if (TemporaryLockoutState == LOCKOUT_STATE_FLASHING)
else if (LockoutState == LOCKOUT_STATE_TEMPORARY_FLASHING)
{
if ((int32_t)(HAL_GetTick() - TemporaryLockoutStartTime) > KEYBOARD_BOTDETECT_TEMPORARY_LOCKOUT_LED_TIME_MS)
if ((int32_t)(HAL_GetTick() - TemporaryLockoutStartTime) > KEYBOARD_BOTDETECT_TEMPORARY_LOCKOUT_FLASH_TIME_MS)
{
////////////Set LEDs off
TemporaryLockoutState = LOCKOUT_STATE_INACTIVE;
LED_SetState(LED_STATUS_OFF);
LockoutState = LOCKOUT_STATE_INACTIVE;
}
}
#endif

Loading…
Cancel
Save