Touchpad: Cleanup after PointerChoreographer refactor
Remove duplicated tests and references to PointerController.
Bug: 311416205
Test: atest inputflinger_tests
Change-Id: I02bd7c8f4c4126c9ae7d2fdffd94175b37478925
diff --git a/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp b/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp
index f558ba1..6a38aa7 100644
--- a/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp
@@ -47,8 +47,6 @@
namespace {
-static const bool ENABLE_POINTER_CHOREOGRAPHER = input_flags::enable_pointer_choreographer();
-
/**
* Log details of each gesture output by the gestures library.
* Enable this via "adb shell setprop log.tag.TouchpadInputMapperGestures DEBUG" (requires
@@ -237,20 +235,13 @@
TouchpadInputMapper::TouchpadInputMapper(InputDeviceContext& deviceContext,
const InputReaderConfiguration& readerConfig)
- : TouchpadInputMapper(deviceContext, readerConfig, ENABLE_POINTER_CHOREOGRAPHER) {}
-
-TouchpadInputMapper::TouchpadInputMapper(InputDeviceContext& deviceContext,
- const InputReaderConfiguration& readerConfig,
- bool enablePointerChoreographer)
: InputMapper(deviceContext, readerConfig),
mGestureInterpreter(NewGestureInterpreter(), DeleteGestureInterpreter),
- mPointerController(getContext()->getPointerController(getDeviceId())),
mTimerProvider(*getContext()),
mStateConverter(deviceContext, mMotionAccumulator),
mGestureConverter(*getContext(), deviceContext, getDeviceId()),
mCapturedEventConverter(*getContext(), deviceContext, mMotionAccumulator, getDeviceId()),
- mMetricsId(metricsIdFromInputDeviceIdentifier(deviceContext.getDeviceIdentifier())),
- mEnablePointerChoreographer(enablePointerChoreographer) {
+ mMetricsId(metricsIdFromInputDeviceIdentifier(deviceContext.getDeviceIdentifier())) {
RawAbsoluteAxisInfo slotAxisInfo;
deviceContext.getAbsoluteAxisInfo(ABS_MT_SLOT, &slotAxisInfo);
if (!slotAxisInfo.valid || slotAxisInfo.maxValue <= 0) {
@@ -277,10 +268,6 @@
}
TouchpadInputMapper::~TouchpadInputMapper() {
- if (mPointerController != nullptr) {
- mPointerController->fade(PointerControllerInterface::Transition::IMMEDIATE);
- }
-
// The gesture interpreter's destructor will try to free its property and timer providers,
// calling PropertyProvider::freeProperty and TimerProvider::freeTimer using a raw pointers.
// Depending on the declaration order in TouchpadInputMapper.h, those providers may have already
@@ -342,33 +329,12 @@
// Only generate events for the associated display.
mDisplayId = assocViewport->displayId;
resolvedViewport = *assocViewport;
- if (!mEnablePointerChoreographer) {
- const bool mismatchedPointerDisplay =
- (assocViewport->displayId != mPointerController->getDisplayId());
- if (mismatchedPointerDisplay) {
- ALOGW("Touchpad \"%s\" associated viewport display does not match pointer "
- "controller",
- mDeviceContext.getName().c_str());
- mDisplayId.reset();
- }
- }
} else {
// The InputDevice is not associated with a viewport, but it controls the mouse pointer.
- if (mEnablePointerChoreographer) {
- // Always use DISPLAY_ID_NONE for touchpad events.
- // PointerChoreographer will make it target the correct the displayId later.
- resolvedViewport =
- getContext()->getPolicy()->getPointerViewportForAssociatedDisplay();
- mDisplayId = resolvedViewport ? std::make_optional(ADISPLAY_ID_NONE) : std::nullopt;
- } else {
- mDisplayId = mPointerController->getDisplayId();
- if (auto v = config.getDisplayViewportById(*mDisplayId); v) {
- resolvedViewport = *v;
- }
- if (auto bounds = mPointerController->getBounds(); bounds) {
- boundsInLogicalDisplay = *bounds;
- }
- }
+ // Always use DISPLAY_ID_NONE for touchpad events.
+ // PointerChoreographer will make it target the correct the displayId later.
+ resolvedViewport = getContext()->getPolicy()->getPointerViewportForAssociatedDisplay();
+ mDisplayId = resolvedViewport ? std::make_optional(ADISPLAY_ID_NONE) : std::nullopt;
}
mGestureConverter.setDisplayId(mDisplayId);
@@ -422,7 +388,6 @@
// The touchpad is being captured, so we need to tidy up any fake fingers etc. that are
// still being reported for a gesture in progress.
out += reset(when);
- mPointerController->fade(PointerControllerInterface::Transition::IMMEDIATE);
} else {
// We're transitioning from captured to uncaptured.
mCapturedEventConverter.reset();
diff --git a/services/inputflinger/reader/mapper/TouchpadInputMapper.h b/services/inputflinger/reader/mapper/TouchpadInputMapper.h
index 9f272cf..9f685ec 100644
--- a/services/inputflinger/reader/mapper/TouchpadInputMapper.h
+++ b/services/inputflinger/reader/mapper/TouchpadInputMapper.h
@@ -72,10 +72,6 @@
void resetGestureInterpreter(nsecs_t when);
explicit TouchpadInputMapper(InputDeviceContext& deviceContext,
const InputReaderConfiguration& readerConfig);
- // Constructor for testing.
- explicit TouchpadInputMapper(InputDeviceContext& deviceContext,
- const InputReaderConfiguration& readerConfig,
- bool enablePointerChoreographer);
void updatePalmDetectionMetrics();
[[nodiscard]] std::list<NotifyArgs> sendHardwareState(nsecs_t when, nsecs_t readTime,
SelfContainedHardwareState schs);
@@ -83,7 +79,6 @@
std::unique_ptr<gestures::GestureInterpreter, void (*)(gestures::GestureInterpreter*)>
mGestureInterpreter;
- std::shared_ptr<PointerControllerInterface> mPointerController;
PropertyProvider mPropertyProvider;
TimerProvider mTimerProvider;
@@ -111,8 +106,6 @@
// Tracking IDs for touches that have at some point been reported as palms by the touchpad.
std::set<int32_t> mPalmTrackingIds;
- const bool mEnablePointerChoreographer;
-
// The display that events generated by this mapper should target. This can be set to
// ADISPLAY_ID_NONE to target the focused display. If there is no display target (i.e.
// std::nullopt), all events will be ignored.
diff --git a/services/inputflinger/reader/mapper/gestures/GestureConverter.cpp b/services/inputflinger/reader/mapper/gestures/GestureConverter.cpp
index 39a88e5..ff95857 100644
--- a/services/inputflinger/reader/mapper/gestures/GestureConverter.cpp
+++ b/services/inputflinger/reader/mapper/gestures/GestureConverter.cpp
@@ -66,7 +66,6 @@
const InputDeviceContext& deviceContext, int32_t deviceId)
: mDeviceId(deviceId),
mReaderContext(readerContext),
- mPointerController(readerContext.getPointerController(deviceId)),
mEnableFlingStop(input_flags::enable_touchpad_fling_stop()) {
deviceContext.getAbsoluteAxisInfo(ABS_MT_POSITION_X, &mXAxisInfo);
deviceContext.getAbsoluteAxisInfo(ABS_MT_POSITION_Y, &mYAxisInfo);
@@ -174,7 +173,6 @@
const Gesture& gesture) {
float deltaX = gesture.details.move.dx;
float deltaY = gesture.details.move.dy;
- const auto [oldXCursorPosition, oldYCursorPosition] = mPointerController->getPosition();
if (ENABLE_TOUCHPAD_PALM_REJECTION_V2) {
bool wasHoverCancelled = mIsHoverCancelled;
// Gesture will be cancelled if it started before the user started typing and
@@ -185,8 +183,7 @@
if (!wasHoverCancelled && mIsHoverCancelled) {
// This is the first event of the cancelled gesture, we won't return because we need to
// generate a HOVER_EXIT event
- mPointerController->fade(PointerControllerInterface::Transition::GRADUAL);
- return exitHover(when, readTime, oldXCursorPosition, oldYCursorPosition);
+ return exitHover(when, readTime);
} else if (mIsHoverCancelled) {
return {};
}
@@ -202,30 +199,23 @@
(std::abs(deltaX) > 0 || std::abs(deltaY) > 0)) {
enableTapToClick(when);
}
- mPointerController->setPresentation(PointerControllerInterface::Presentation::POINTER);
- mPointerController->move(deltaX, deltaY);
- mPointerController->unfade(PointerControllerInterface::Transition::IMMEDIATE);
}
std::list<NotifyArgs> out;
const bool down = isPointerDown(mButtonState);
if (!down) {
- out += enterHover(when, readTime, oldXCursorPosition, oldYCursorPosition);
+ out += enterHover(when, readTime);
}
- const auto [newXCursorPosition, newYCursorPosition] = mPointerController->getPosition();
PointerCoords coords;
coords.clear();
- coords.setAxisValue(AMOTION_EVENT_AXIS_X, newXCursorPosition);
- coords.setAxisValue(AMOTION_EVENT_AXIS_Y, newYCursorPosition);
coords.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X, deltaX);
coords.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y, deltaY);
coords.setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, down ? 1.0f : 0.0f);
const int32_t action = down ? AMOTION_EVENT_ACTION_MOVE : AMOTION_EVENT_ACTION_HOVER_MOVE;
out.push_back(makeMotionArgs(when, readTime, action, /*actionButton=*/0, mButtonState,
- /*pointerCount=*/1, &coords, newXCursorPosition,
- newYCursorPosition));
+ /*pointerCount=*/1, &coords));
return out;
}
@@ -233,15 +223,8 @@
const Gesture& gesture) {
std::list<NotifyArgs> out = {};
- mPointerController->setPresentation(PointerControllerInterface::Presentation::POINTER);
- mPointerController->unfade(PointerControllerInterface::Transition::IMMEDIATE);
-
- const auto [xCursorPosition, yCursorPosition] = mPointerController->getPosition();
-
PointerCoords coords;
coords.clear();
- coords.setAxisValue(AMOTION_EVENT_AXIS_X, xCursorPosition);
- coords.setAxisValue(AMOTION_EVENT_AXIS_Y, yCursorPosition);
coords.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X, 0);
coords.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y, 0);
@@ -274,16 +257,15 @@
newButtonState |= actionButton;
pressEvents.push_back(makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_BUTTON_PRESS,
actionButton, newButtonState,
- /*pointerCount=*/1, &coords, xCursorPosition,
- yCursorPosition));
+ /*pointerCount=*/1, &coords));
}
}
if (!isPointerDown(mButtonState) && isPointerDown(newButtonState)) {
mDownTime = when;
- out += exitHover(when, readTime, xCursorPosition, yCursorPosition);
+ out += exitHover(when, readTime);
out.push_back(makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_DOWN,
/* actionButton= */ 0, newButtonState, /* pointerCount= */ 1,
- &coords, xCursorPosition, yCursorPosition));
+ &coords));
}
out.splice(out.end(), pressEvents);
@@ -299,16 +281,15 @@
newButtonState &= ~actionButton;
out.push_back(makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_BUTTON_RELEASE,
actionButton, newButtonState, /* pointerCount= */ 1,
- &coords, xCursorPosition, yCursorPosition));
+ &coords));
}
}
if (isPointerDown(mButtonState) && !isPointerDown(newButtonState)) {
coords.setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, 0.0f);
out.push_back(makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_UP, /* actionButton= */ 0,
- newButtonState, /* pointerCount= */ 1, &coords,
- xCursorPosition, yCursorPosition));
+ newButtonState, /* pointerCount= */ 1, &coords));
mButtonState = newButtonState;
- out += enterHover(when, readTime, xCursorPosition, yCursorPosition);
+ out += enterHover(when, readTime);
}
mButtonState = newButtonState;
return out;
@@ -316,12 +297,9 @@
std::list<NotifyArgs> GestureConverter::releaseAllButtons(nsecs_t when, nsecs_t readTime) {
std::list<NotifyArgs> out;
- const auto [xCursorPosition, yCursorPosition] = mPointerController->getPosition();
PointerCoords coords;
coords.clear();
- coords.setAxisValue(AMOTION_EVENT_AXIS_X, xCursorPosition);
- coords.setAxisValue(AMOTION_EVENT_AXIS_Y, yCursorPosition);
coords.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X, 0);
coords.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y, 0);
const bool pointerDown = isPointerDown(mButtonState);
@@ -332,17 +310,15 @@
if (mButtonState & button) {
newButtonState &= ~button;
out.push_back(makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_BUTTON_RELEASE,
- button, newButtonState, /*pointerCount=*/1, &coords,
- xCursorPosition, yCursorPosition));
+ button, newButtonState, /*pointerCount=*/1, &coords));
}
}
mButtonState = 0;
if (pointerDown) {
coords.setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, 0.0f);
out.push_back(makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_UP, /*actionButton=*/0,
- mButtonState, /*pointerCount=*/1, &coords, xCursorPosition,
- yCursorPosition));
- out += enterHover(when, readTime, xCursorPosition, yCursorPosition);
+ mButtonState, /*pointerCount=*/1, &coords));
+ out += enterHover(when, readTime);
}
return out;
}
@@ -351,19 +327,15 @@
const Gesture& gesture) {
std::list<NotifyArgs> out;
PointerCoords& coords = mFakeFingerCoords[0];
- const auto [xCursorPosition, yCursorPosition] = mPointerController->getPosition();
if (mCurrentClassification != MotionClassification::TWO_FINGER_SWIPE) {
- out += exitHover(when, readTime, xCursorPosition, yCursorPosition);
+ out += exitHover(when, readTime);
mCurrentClassification = MotionClassification::TWO_FINGER_SWIPE;
- coords.setAxisValue(AMOTION_EVENT_AXIS_X, xCursorPosition);
- coords.setAxisValue(AMOTION_EVENT_AXIS_Y, yCursorPosition);
coords.setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, 1.0f);
mDownTime = when;
NotifyMotionArgs args =
makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_DOWN, /* actionButton= */ 0,
- mButtonState, /* pointerCount= */ 1, mFakeFingerCoords.data(),
- xCursorPosition, yCursorPosition);
+ mButtonState, /* pointerCount= */ 1, mFakeFingerCoords.data());
args.flags |= AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE;
out.push_back(args);
}
@@ -378,8 +350,7 @@
coords.setAxisValue(AMOTION_EVENT_AXIS_GESTURE_SCROLL_Y_DISTANCE, -gesture.details.scroll.dy);
NotifyMotionArgs args =
makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_MOVE, /* actionButton= */ 0,
- mButtonState, /* pointerCount= */ 1, mFakeFingerCoords.data(),
- xCursorPosition, yCursorPosition);
+ mButtonState, /* pointerCount= */ 1, mFakeFingerCoords.data());
args.flags |= AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE;
out.push_back(args);
return out;
@@ -409,28 +380,22 @@
// avoid side effects (e.g. activation of UI elements).
// TODO(b/326056750): add an API for fling stops.
mFlingMayBeInProgress = false;
- const auto [xCursorPosition, yCursorPosition] =
- mPointerController->getPosition();
PointerCoords coords;
coords.clear();
- coords.setAxisValue(AMOTION_EVENT_AXIS_X, xCursorPosition);
- coords.setAxisValue(AMOTION_EVENT_AXIS_Y, yCursorPosition);
coords.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X, 0);
coords.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y, 0);
std::list<NotifyArgs> out;
mDownTime = when;
mCurrentClassification = MotionClassification::TWO_FINGER_SWIPE;
- out += exitHover(when, readTime, xCursorPosition, yCursorPosition);
+ out += exitHover(when, readTime);
out.push_back(makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_DOWN,
/*actionButton=*/0, /*buttonState=*/0,
- /*pointerCount=*/1, &coords, xCursorPosition,
- yCursorPosition));
+ /*pointerCount=*/1, &coords));
out.push_back(makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_CANCEL,
/*actionButton=*/0, /*buttonState=*/0,
- /*pointerCount=*/1, &coords, xCursorPosition,
- yCursorPosition));
- out += enterHover(when, readTime, xCursorPosition, yCursorPosition);
+ /*pointerCount=*/1, &coords));
+ out += enterHover(when, readTime);
mCurrentClassification = MotionClassification::NONE;
return out;
} else {
@@ -455,17 +420,15 @@
std::list<NotifyArgs> GestureConverter::endScroll(nsecs_t when, nsecs_t readTime) {
std::list<NotifyArgs> out;
- const auto [xCursorPosition, yCursorPosition] = mPointerController->getPosition();
mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_GESTURE_SCROLL_X_DISTANCE, 0);
mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_GESTURE_SCROLL_Y_DISTANCE, 0);
NotifyMotionArgs args =
makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_UP, /* actionButton= */ 0,
- mButtonState, /* pointerCount= */ 1, mFakeFingerCoords.data(),
- xCursorPosition, yCursorPosition);
+ mButtonState, /* pointerCount= */ 1, mFakeFingerCoords.data());
args.flags |= AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE;
out.push_back(args);
mCurrentClassification = MotionClassification::NONE;
- out += enterHover(when, readTime, xCursorPosition, yCursorPosition);
+ out += enterHover(when, readTime);
return out;
}
@@ -475,26 +438,26 @@
float dx, float dy) {
std::list<NotifyArgs> out = {};
- const auto [xCursorPosition, yCursorPosition] = mPointerController->getPosition();
if (mCurrentClassification != MotionClassification::MULTI_FINGER_SWIPE) {
// If the user changes the number of fingers mid-way through a swipe (e.g. they start with
// three and then put a fourth finger down), the gesture library will treat it as two
// separate swipes with an appropriate lift event between them, so we don't have to worry
// about the finger count changing mid-swipe.
- out += exitHover(when, readTime, xCursorPosition, yCursorPosition);
+ out += exitHover(when, readTime);
mCurrentClassification = MotionClassification::MULTI_FINGER_SWIPE;
mSwipeFingerCount = fingerCount;
constexpr float FAKE_FINGER_SPACING = 100;
- float xCoord = xCursorPosition - FAKE_FINGER_SPACING * (mSwipeFingerCount - 1) / 2;
+ float xCoord = 0.f - FAKE_FINGER_SPACING * (mSwipeFingerCount - 1) / 2;
for (size_t i = 0; i < mSwipeFingerCount; i++) {
PointerCoords& coords = mFakeFingerCoords[i];
coords.clear();
+ // PointerChoreographer will add the cursor position to these pointers.
coords.setAxisValue(AMOTION_EVENT_AXIS_X, xCoord);
- coords.setAxisValue(AMOTION_EVENT_AXIS_Y, yCursorPosition);
+ coords.setAxisValue(AMOTION_EVENT_AXIS_Y, 0.f);
coords.setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, 1.0f);
xCoord += FAKE_FINGER_SPACING;
}
@@ -504,14 +467,13 @@
fingerCount);
out.push_back(makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_DOWN,
/* actionButton= */ 0, mButtonState, /* pointerCount= */ 1,
- mFakeFingerCoords.data(), xCursorPosition, yCursorPosition));
+ mFakeFingerCoords.data()));
for (size_t i = 1; i < mSwipeFingerCount; i++) {
out.push_back(makeMotionArgs(when, readTime,
AMOTION_EVENT_ACTION_POINTER_DOWN |
(i << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
/* actionButton= */ 0, mButtonState,
- /* pointerCount= */ i + 1, mFakeFingerCoords.data(),
- xCursorPosition, yCursorPosition));
+ /* pointerCount= */ i + 1, mFakeFingerCoords.data()));
}
}
float rotatedDeltaX = dx, rotatedDeltaY = -dy;
@@ -529,7 +491,7 @@
mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_GESTURE_Y_OFFSET, yOffset);
out.push_back(makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_MOVE, /* actionButton= */ 0,
mButtonState, /* pointerCount= */ mSwipeFingerCount,
- mFakeFingerCoords.data(), xCursorPosition, yCursorPosition));
+ mFakeFingerCoords.data()));
return out;
}
@@ -539,7 +501,6 @@
if (mCurrentClassification != MotionClassification::MULTI_FINGER_SWIPE) {
return out;
}
- const auto [xCursorPosition, yCursorPosition] = mPointerController->getPosition();
mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_GESTURE_X_OFFSET, 0);
mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_GESTURE_Y_OFFSET, 0);
@@ -548,22 +509,20 @@
AMOTION_EVENT_ACTION_POINTER_UP |
((i - 1) << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
/* actionButton= */ 0, mButtonState, /* pointerCount= */ i,
- mFakeFingerCoords.data(), xCursorPosition, yCursorPosition));
+ mFakeFingerCoords.data()));
}
out.push_back(makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_UP,
/* actionButton= */ 0, mButtonState, /* pointerCount= */ 1,
- mFakeFingerCoords.data(), xCursorPosition, yCursorPosition));
+ mFakeFingerCoords.data()));
mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_GESTURE_SWIPE_FINGER_COUNT, 0);
mCurrentClassification = MotionClassification::NONE;
- out += enterHover(when, readTime, xCursorPosition, yCursorPosition);
+ out += enterHover(when, readTime);
mSwipeFingerCount = 0;
return out;
}
[[nodiscard]] std::list<NotifyArgs> GestureConverter::handlePinch(nsecs_t when, nsecs_t readTime,
const Gesture& gesture) {
- const auto [xCursorPosition, yCursorPosition] = mPointerController->getPosition();
-
// Pinch gesture phases are reported a little differently from others, in that the same details
// struct is used for all phases of the gesture, just with different zoom_state values. When
// zoom_state is START or END, dz will always be 1, so we don't need to move the pointers in
@@ -575,28 +534,27 @@
gesture.details.pinch.zoom_state);
std::list<NotifyArgs> out;
- out += exitHover(when, readTime, xCursorPosition, yCursorPosition);
+ out += exitHover(when, readTime);
mCurrentClassification = MotionClassification::PINCH;
mPinchFingerSeparation = INITIAL_PINCH_SEPARATION_PX;
+ // PointerChoreographer will add the cursor position to these pointers.
mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_GESTURE_PINCH_SCALE_FACTOR, 1.0);
- mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_X,
- xCursorPosition - mPinchFingerSeparation / 2);
- mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_Y, yCursorPosition);
+ mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_X, 0.f - mPinchFingerSeparation / 2);
+ mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_Y, 0.f);
mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, 1.0f);
- mFakeFingerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_X,
- xCursorPosition + mPinchFingerSeparation / 2);
- mFakeFingerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_Y, yCursorPosition);
+ mFakeFingerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_X, 0.f + mPinchFingerSeparation / 2);
+ mFakeFingerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_Y, 0.f);
mFakeFingerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, 1.0f);
mDownTime = when;
out.push_back(makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_DOWN,
/* actionButton= */ 0, mButtonState, /* pointerCount= */ 1,
- mFakeFingerCoords.data(), xCursorPosition, yCursorPosition));
+ mFakeFingerCoords.data()));
out.push_back(makeMotionArgs(when, readTime,
AMOTION_EVENT_ACTION_POINTER_DOWN |
1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT,
/* actionButton= */ 0, mButtonState, /* pointerCount= */ 2,
- mFakeFingerCoords.data(), xCursorPosition, yCursorPosition));
+ mFakeFingerCoords.data()));
return out;
}
@@ -605,77 +563,65 @@
}
mPinchFingerSeparation *= gesture.details.pinch.dz;
+ // PointerChoreographer will add the cursor position to these pointers.
mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_GESTURE_PINCH_SCALE_FACTOR,
gesture.details.pinch.dz);
- mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_X,
- xCursorPosition - mPinchFingerSeparation / 2);
- mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_Y, yCursorPosition);
- mFakeFingerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_X,
- xCursorPosition + mPinchFingerSeparation / 2);
- mFakeFingerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_Y, yCursorPosition);
+ mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_X, 0.f - mPinchFingerSeparation / 2);
+ mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_Y, 0.f);
+ mFakeFingerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_X, 0.f + mPinchFingerSeparation / 2);
+ mFakeFingerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_Y, 0.f);
return {makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_MOVE, /*actionButton=*/0,
- mButtonState, /*pointerCount=*/2, mFakeFingerCoords.data(),
- xCursorPosition, yCursorPosition)};
+ mButtonState, /*pointerCount=*/2, mFakeFingerCoords.data())};
}
std::list<NotifyArgs> GestureConverter::endPinch(nsecs_t when, nsecs_t readTime) {
std::list<NotifyArgs> out;
- const auto [xCursorPosition, yCursorPosition] = mPointerController->getPosition();
mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_GESTURE_PINCH_SCALE_FACTOR, 1.0);
out.push_back(makeMotionArgs(when, readTime,
AMOTION_EVENT_ACTION_POINTER_UP |
1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT,
/*actionButton=*/0, mButtonState, /*pointerCount=*/2,
- mFakeFingerCoords.data(), xCursorPosition, yCursorPosition));
+ mFakeFingerCoords.data()));
out.push_back(makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_UP, /*actionButton=*/0,
- mButtonState, /*pointerCount=*/1, mFakeFingerCoords.data(),
- xCursorPosition, yCursorPosition));
+ mButtonState, /*pointerCount=*/1, mFakeFingerCoords.data()));
mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_GESTURE_PINCH_SCALE_FACTOR, 0);
mCurrentClassification = MotionClassification::NONE;
- out += enterHover(when, readTime, xCursorPosition, yCursorPosition);
+ out += enterHover(when, readTime);
return out;
}
-std::list<NotifyArgs> GestureConverter::enterHover(nsecs_t when, nsecs_t readTime,
- float xCursorPosition, float yCursorPosition) {
+std::list<NotifyArgs> GestureConverter::enterHover(nsecs_t when, nsecs_t readTime) {
if (!mIsHovering) {
mIsHovering = true;
- return {makeHoverEvent(when, readTime, AMOTION_EVENT_ACTION_HOVER_ENTER, xCursorPosition,
- yCursorPosition)};
+ return {makeHoverEvent(when, readTime, AMOTION_EVENT_ACTION_HOVER_ENTER)};
} else {
return {};
}
}
-std::list<NotifyArgs> GestureConverter::exitHover(nsecs_t when, nsecs_t readTime,
- float xCursorPosition, float yCursorPosition) {
+std::list<NotifyArgs> GestureConverter::exitHover(nsecs_t when, nsecs_t readTime) {
if (mIsHovering) {
mIsHovering = false;
- return {makeHoverEvent(when, readTime, AMOTION_EVENT_ACTION_HOVER_EXIT, xCursorPosition,
- yCursorPosition)};
+ return {makeHoverEvent(when, readTime, AMOTION_EVENT_ACTION_HOVER_EXIT)};
} else {
return {};
}
}
-NotifyMotionArgs GestureConverter::makeHoverEvent(nsecs_t when, nsecs_t readTime, int32_t action,
- float xCursorPosition, float yCursorPosition) {
+NotifyMotionArgs GestureConverter::makeHoverEvent(nsecs_t when, nsecs_t readTime, int32_t action) {
PointerCoords coords;
coords.clear();
- coords.setAxisValue(AMOTION_EVENT_AXIS_X, xCursorPosition);
- coords.setAxisValue(AMOTION_EVENT_AXIS_Y, yCursorPosition);
coords.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X, 0);
coords.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y, 0);
return makeMotionArgs(when, readTime, action, /*actionButton=*/0, mButtonState,
- /*pointerCount=*/1, &coords, xCursorPosition, yCursorPosition);
+ /*pointerCount=*/1, &coords);
}
NotifyMotionArgs GestureConverter::makeMotionArgs(nsecs_t when, nsecs_t readTime, int32_t action,
int32_t actionButton, int32_t buttonState,
uint32_t pointerCount,
- const PointerCoords* pointerCoords,
- float xCursorPosition, float yCursorPosition) {
+ const PointerCoords* pointerCoords) {
return {mReaderContext.getNextId(),
when,
readTime,
@@ -695,8 +641,8 @@
pointerCoords,
/* xPrecision= */ 1.0f,
/* yPrecision= */ 1.0f,
- xCursorPosition,
- yCursorPosition,
+ /* xCursorPosition= */ 0.f,
+ /* yCursorPosition= */ 0.f,
/* downTime= */ mDownTime,
/* videoFrames= */ {}};
}
diff --git a/services/inputflinger/reader/mapper/gestures/GestureConverter.h b/services/inputflinger/reader/mapper/gestures/GestureConverter.h
index c8f437e..e6ced0f 100644
--- a/services/inputflinger/reader/mapper/gestures/GestureConverter.h
+++ b/services/inputflinger/reader/mapper/gestures/GestureConverter.h
@@ -20,7 +20,6 @@
#include <list>
#include <memory>
-#include <PointerControllerInterface.h>
#include <android/input.h>
#include <utils/Timers.h>
@@ -41,8 +40,7 @@
*/
constexpr std::chrono::nanoseconds TAP_ENABLE_DELAY_NANOS = 400ms;
-// Converts Gesture structs from the gestures library into NotifyArgs and the appropriate
-// PointerController calls.
+// Converts Gesture structs from the gestures library into NotifyArgs.
class GestureConverter {
public:
GestureConverter(InputReaderContext& readerContext, const InputDeviceContext& deviceContext,
@@ -85,18 +83,14 @@
const Gesture& gesture);
[[nodiscard]] std::list<NotifyArgs> endPinch(nsecs_t when, nsecs_t readTime);
- [[nodiscard]] std::list<NotifyArgs> enterHover(nsecs_t when, nsecs_t readTime,
- float xCursorPosition, float yCursorPosition);
- [[nodiscard]] std::list<NotifyArgs> exitHover(nsecs_t when, nsecs_t readTime,
- float xCursorPosition, float yCursorPosition);
+ [[nodiscard]] std::list<NotifyArgs> enterHover(nsecs_t when, nsecs_t readTime);
+ [[nodiscard]] std::list<NotifyArgs> exitHover(nsecs_t when, nsecs_t readTime);
- NotifyMotionArgs makeHoverEvent(nsecs_t when, nsecs_t readTime, int32_t action,
- float xCursorPosition, float yCursorPosition);
+ NotifyMotionArgs makeHoverEvent(nsecs_t when, nsecs_t readTime, int32_t action);
NotifyMotionArgs makeMotionArgs(nsecs_t when, nsecs_t readTime, int32_t action,
int32_t actionButton, int32_t buttonState,
- uint32_t pointerCount, const PointerCoords* pointerCoords,
- float xCursorPosition, float yCursorPosition);
+ uint32_t pointerCount, const PointerCoords* pointerCoords);
void enableTapToClick(nsecs_t when);
bool mIsHoverCancelled{false};
@@ -104,7 +98,6 @@
const int32_t mDeviceId;
InputReaderContext& mReaderContext;
- std::shared_ptr<PointerControllerInterface> mPointerController;
const bool mEnableFlingStop;
std::optional<int32_t> mDisplayId;