summaryrefslogtreecommitdiff
path: root/libs/input/VelocityControl.cpp
diff options
context:
space:
mode:
author Siarhei Vishniakou <svv@google.com> 2023-01-11 08:17:21 -0800
committer Siarhei Vishniakou <svv@google.com> 2023-01-12 18:23:20 -0800
commit8d23203ec6d923aaf7d44f77faea2ac42a963227 (patch)
tree555991e72327fe2f5de9ec80ce3c109216d35077 /libs/input/VelocityControl.cpp
parent657a17320045f45ce4a71a6d4ea5daddc302d223 (diff)
Per-pointer processing in VelocityTracker
We would like to skip resampled data in VelocityTracker when the velocity is being computed. To make this happen, we need to first process the data per-pointer. This will then allow us to skip individual data points. To minimize the impact to older VT strategies that are largely untested, the main change here is to make 'mMovements' and 'mIndex' become per-pointer, rather than converting to a vector. Also, use std::array instead of [] because [] cannot be used inside a std::map easily. There should be no functional change in this CL. The actual skipping of resampled values will be done in a separate CL. Bug: 167946721 Test: m libinput_tests && $ANDROID_HOST_OUT/nativetest64/libinput_tests/libinput_tests Change-Id: I1c3c845bca0d4bb7d2c3973bfe84462139ac36f3
Diffstat (limited to 'libs/input/VelocityControl.cpp')
-rw-r--r--libs/input/VelocityControl.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/libs/input/VelocityControl.cpp b/libs/input/VelocityControl.cpp
index 5c008b1158..5720099033 100644
--- a/libs/input/VelocityControl.cpp
+++ b/libs/input/VelocityControl.cpp
@@ -70,9 +70,10 @@ void VelocityControl::move(nsecs_t eventTime, float* deltaX, float* deltaY) {
if (deltaY) {
mRawPositionY += *deltaY;
}
- mVelocityTracker.addMovement(eventTime, BitSet32(BitSet32::valueForBit(0)),
- {{AMOTION_EVENT_AXIS_X, {mRawPositionX}},
- {AMOTION_EVENT_AXIS_Y, {mRawPositionY}}});
+ mVelocityTracker.addMovement(eventTime, /*pointerId=*/0, AMOTION_EVENT_AXIS_X,
+ mRawPositionX);
+ mVelocityTracker.addMovement(eventTime, /*pointerId=*/0, AMOTION_EVENT_AXIS_Y,
+ mRawPositionY);
std::optional<float> vx = mVelocityTracker.getVelocity(AMOTION_EVENT_AXIS_X, 0);
std::optional<float> vy = mVelocityTracker.getVelocity(AMOTION_EVENT_AXIS_Y, 0);