Fix “janky scrolling” with BT mice

User reported that when slowly scrolling on a website, the amount the
page would scroll would intermittently be very large compared to

This unexpected excessive motion is due to the BT connection going to
sleep, and the initial BT packet on wakeup being delayed. The timestamp
between the first and second packets is then arbitrarily short, causing
the acceleration algorithm to treat the two packets as a very rapid
motion, resulting in excessive acceleration and page scroll.

Clipping the time delta between any two BT packets to a reasonable
minimum (8ms based on 125Hz data rates) prevents the gestures algorithm
from applying excessive acceleration.

Add a unit test to verify that time deltas of less than 8ms between
scroll events produce the same output as time deltas of equal to 8ms.

TEST=Ensure all current and new touchtests pass (src/platform/touchpad-tests)
Ensure all current and new unit tests pass
Manually verify functional scroll with the following mice:
Microsoft Surface Precision BT Mouse
Logitech G604 (via 2.4GHz receiver)
Razer Atheris BT Mouse
Redragon M801 (via USB and 2.4GHz receiver)

Change-Id: I63e893dff314bbf1b127045b36f4556e4bf829c5
Reviewed-by: Sean O'Brien <>
Reviewed-by: Harry Cutts <>
Tested-by: Jora Jacobi <>
Commit-Queue: Jora Jacobi <>
3 files changed