Skip to content

Commit

Permalink
HID bot detect: 3 temporary lockouts = permanent lockout
Browse files Browse the repository at this point in the history
  • Loading branch information
robertfisk committed Apr 28, 2018
1 parent d2e3ab0 commit f3117a3
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions Upstream/Src/upstream_hid_botdetect.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@


//Variables common between keyboard and mouse bot detection:
uint32_t TemporaryLockoutTimeMs;
volatile LockoutStateTypeDef LockoutState = LOCKOUT_STATE_INACTIVE;

uint32_t TemporaryLockoutTimeMs;
uint8_t TemporaryLockoutCount = 0;


//Variables specific to keyboard bot detection:
Expand Down Expand Up @@ -201,6 +201,14 @@ static void Upstream_HID_BotDetectKeyboard_DoLockout(void)
return;
}

//Three (temporary) strikes -> you're out!
if (++TemporaryLockoutCount >= 3)
{
LockoutState = LOCKOUT_STATE_PERMANENT_ACTIVE;
LED_SetState(LED_STATUS_FLASH_BOTDETECT);
return;
}

//Otherwise, reset counters and give warning
for (i = 0; i < KEYBOARD_BOTDETECT_FAST_BIN_COUNT; i++)
{
Expand Down Expand Up @@ -572,6 +580,14 @@ static void Upstream_HID_BotDetectMouse_DoLockout(void)
return;
}

//Three (temporary) strikes -> you're out!
if (++TemporaryLockoutCount >= 3)
{
LockoutState = LOCKOUT_STATE_PERMANENT_ACTIVE;
LED_SetState(LED_STATUS_FLASH_BOTDETECT);
return;
}

//Otherwise, reset counters and give warning
for (i = 0; i < MOUSE_BOTDETECT_VELOCITY_HISTORY_SIZE; i++)
{
Expand Down

0 comments on commit f3117a3

Please sign in to comment.