Tweaks to mouse jump detection

USG_1.0
Robert Fisk 7 years ago
parent b052645faa
commit 8c6d54d110

@ -43,7 +43,7 @@
#ifdef CONFIG_MOUSE_BOT_DETECT_ENABLED
//-----------------------------------------------------------
//Adjust this threshold first to tune mouse bot detection. Lower values = more sensitive
#define MOUSE_BOTDETECT_LOCKOUT_CONSTANT_ACCEL_COUNT 20
#define MOUSE_BOTDETECT_LOCKOUT_CONSTANT_ACCEL_COUNT 10
//???????
//-----------------------------------------------------------
@ -53,7 +53,7 @@
#define MOUSE_BOTDETECT_VELOCITY_MATCH_ERROR 6
#define MOUSE_BOTDETECT_MOVEMENT_STOP_PERIODS 5
#define MOUSE_BOTDETECT_MOVEMENT_VELOCITY_THRESHOLD (5 * MOUSE_BOTDETECT_VELOCITY_MULTIPLIER)
#define MOUSE_BOTDETECT_MOVEMENT_VELOCITY_THRESHOLD (10 * MOUSE_BOTDETECT_VELOCITY_MULTIPLIER)
#endif
//Configuration common to all bot detectors

@ -387,7 +387,6 @@ void Upstream_HID_BotDetectMouse(uint8_t* mouseInData)
{
uint32_t i;
uint32_t now = HAL_GetTick();
uint32_t moveDelayPeriods;
uint32_t velocity;
int8_t mouseX;
int8_t mouseY;
@ -403,29 +402,26 @@ void Upstream_HID_BotDetectMouse(uint8_t* mouseInData)
mouseY = mouseInData[2];
velocity = (sqrtf(((int32_t)mouseX * mouseX) +
((int32_t)mouseY * mouseY))) * MOUSE_BOTDETECT_VELOCITY_MULTIPLIER; //Multiply floating-point sqrt result to avoid integer rounding errors
moveDelayPeriods = (now - LastMouseMoveTime + (HID_FS_BINTERVAL / 2)) / HID_FS_BINTERVAL; //Number of poll intervals since last movement
if (moveDelayPeriods > MOUSE_BOTDETECT_MOVEMENT_STOP_PERIODS) //Did the mouse stop moving?
//Jump detection
if (MouseIsMoving)
{
moveDelayPeriods = MOUSE_BOTDETECT_MOVEMENT_STOP_PERIODS;
if (MouseIsMoving) //Jump detection
if ((now - LastMouseMoveTime) > ((MOUSE_BOTDETECT_MOVEMENT_STOP_PERIODS * HID_FS_BINTERVAL) - (HID_FS_BINTERVAL / 2))) //Did the mouse stop moving?
{
MouseIsMoving = 0;
if (((LastMouseMoveTime - LastMouseMoveBeginTime + (HID_FS_BINTERVAL / 2)) / HID_FS_BINTERVAL) < MOUSE_BOTDETECT_MOVEMENT_STOP_PERIODS)
if ((LastMouseMoveTime - LastMouseMoveBeginTime) < ((MOUSE_BOTDETECT_MOVEMENT_STOP_PERIODS * HID_FS_BINTERVAL) - (HID_FS_BINTERVAL / 2)))
{
Upstream_HID_BotDetectMouse_DoLockout();
}
}
}
velocity = velocity / moveDelayPeriods;
if (velocity != 0)
{
LastMouseMoveTime = now;
//Jump detection
LastMouseMoveTime = now;
if ((MouseIsMoving == 0) && (velocity > MOUSE_BOTDETECT_MOVEMENT_VELOCITY_THRESHOLD))
{
MouseIsMoving = 1;

Loading…
Cancel
Save