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
expected.

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.

BUG=b:149932225
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-on: https://chromium-review.googlesource.com/c/chromiumos/platform/gestures/+/2195622
Reviewed-by: Sean O'Brien <seobrien@chromium.org>
Reviewed-by: Harry Cutts <hcutts@chromium.org>
Tested-by: Jora Jacobi <jora@google.com>
Commit-Queue: Jora Jacobi <jora@google.com>
3 files changed