diff options
| author | 2018-02-01 12:28:50 -0800 | |
|---|---|---|
| committer | 2018-02-01 12:28:50 -0800 | |
| commit | 2bc43cadc2cca889229b210f9938e815997d728b (patch) | |
| tree | 012ec71810705367b7e195f2d950194b8626e4eb | |
| parent | 0b26710528eb69f3883f295f3e6146e6466fd082 (diff) | |
Use raw coordinates in VelocityTracker
Currently, VelocityTracker uses the "default" motionevent coordinates in
order to estimate the liftoff velocity of a pointer. When a view
receives a MotionEvent, the coordinates are getting adjusted relative to
the top left corner of the view. In a situation where a view itself is
moving while the user is interacting with the screen, and the view is
trying to estimate the fling velocity for a finger, this would cause
velocitytracker to use dynamic view coordinates. When these dynamically
adjusted coordinates are used in VelocityTracker, the resulting estimate
no longer accurately represents the liftoff velocity of a finger, since
the received data does not have a common origin.
Instead of using the offset-adjusted coordinates of a MotionEvent, use
the raw coordinates that are relative to the display itself and
independent of the view hierarchy.
Bug: 72263561
Test: m -j inputflinger_tests_InputReader_test
inputflinger_tests_InputDispatcher_test libinput_tests_InputChannel_test
libinput_tests_InputEvent_test
libinput_tests_InputPublisherAndConsumer_test
libinput_tests_VelocityTracker_test && adb push
out/target/product/$TARGET_PRODUCT/data/nativetest64/*
/data/nativetest64/
then run the tests on the device.
When "impulse" strategy is enabled, the velocitytracker test fails
because the flings need to be re-recorded.
Also manual fling in Google Maps (one and two finger), youtube, settings.
Change-Id: Id4d152dae00c2e6a342a71f5c89cbb5426c169ff
| -rw-r--r-- | libs/input/VelocityTracker.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/libs/input/VelocityTracker.cpp b/libs/input/VelocityTracker.cpp index e54f147621..e0d2113233 100644 --- a/libs/input/VelocityTracker.cpp +++ b/libs/input/VelocityTracker.cpp @@ -325,8 +325,8 @@ void VelocityTracker::addMovement(const MotionEvent* event) { eventTime = event->getHistoricalEventTime(h); for (size_t i = 0; i < pointerCount; i++) { uint32_t index = pointerIndex[i]; - positions[index].x = event->getHistoricalX(i, h); - positions[index].y = event->getHistoricalY(i, h); + positions[index].x = event->getHistoricalRawX(i, h); + positions[index].y = event->getHistoricalRawY(i, h); } addMovement(eventTime, idBits, positions); } @@ -334,8 +334,8 @@ void VelocityTracker::addMovement(const MotionEvent* event) { eventTime = event->getEventTime(); for (size_t i = 0; i < pointerCount; i++) { uint32_t index = pointerIndex[i]; - positions[index].x = event->getX(i); - positions[index].y = event->getY(i); + positions[index].x = event->getRawX(i); + positions[index].y = event->getRawY(i); } addMovement(eventTime, idBits, positions); } |