Adjust event location when two-finger dragging in TouchExplorer
To scroll on the screen when using TalkBack, a user need to dragging two finger pointers. If the dragging pointer are closer that a given distance we use the location of the primary one. Otherwise, we should adjust the event location to take the middle between the two finger pointers. Bug: 126354276 Test: atest TouchExplorerTest Change-Id: I9e95ccec964d7930498febdd02731b94826fbb7b
This commit is contained in:
@@ -703,12 +703,17 @@ class TouchExplorer extends BaseEventStreamTransformation
|
||||
final float secondPtrX = event.getX(1);
|
||||
final float secondPtrY = event.getY(1);
|
||||
|
||||
final float deltaX = firstPtrX - secondPtrX;
|
||||
final float deltaY = firstPtrY - secondPtrY;
|
||||
final int pointerIndex = event.findPointerIndex(mDraggingPointerId);
|
||||
final float deltaX =
|
||||
(pointerIndex == 0) ? (secondPtrX - firstPtrX)
|
||||
: (firstPtrX - secondPtrX);
|
||||
final float deltaY =
|
||||
(pointerIndex == 0) ? (secondPtrY - firstPtrY)
|
||||
: (firstPtrY - secondPtrY);
|
||||
final double distance = Math.hypot(deltaX, deltaY);
|
||||
|
||||
if (distance > mScaledMinPointerDistanceToUseMiddleLocation) {
|
||||
event.setLocation(deltaX / 2, deltaY / 2);
|
||||
event.offsetLocation(deltaX / 2, deltaY / 2);
|
||||
}
|
||||
|
||||
// If still dragging send a drag event.
|
||||
|
||||
Reference in New Issue
Block a user