Ignore resampled values when computing velocity
VelocityTracker should only operate on the actual data produced by the
touchscreen. It should not use the fake, synthesized data during the
computation.
Using such data can cause unwanted artifacts such as backwards fling,
etc.
Bug: 167946721
Test: m libinput_tests && $ANDROID_HOST_OUT/nativetest64/libinput_tests/libinput_tests
Change-Id: I1ffdc1d38b0b335419f20c7bdd0d4473942bbf57
diff --git a/libs/input/VelocityTracker.cpp b/libs/input/VelocityTracker.cpp
index 1cd782d..3632914 100644
--- a/libs/input/VelocityTracker.cpp
+++ b/libs/input/VelocityTracker.cpp
@@ -332,11 +332,13 @@
return;
}
- size_t historySize = event->getHistorySize();
+ const size_t historySize = event->getHistorySize();
for (size_t h = 0; h <= historySize; h++) {
- nsecs_t eventTime = event->getHistoricalEventTime(h);
+ const nsecs_t eventTime = event->getHistoricalEventTime(h);
for (size_t i = 0; i < event->getPointerCount(); i++) {
- // TODO(b/167946721): skip resampled samples
+ if (event->isResampled(i, h)) {
+ continue; // skip resampled samples
+ }
const int32_t pointerId = event->getPointerId(i);
for (int32_t axis : axesToProcess) {
const float position = event->getHistoricalAxisValue(axis, i, h);