Loading services/inputflinger/include/PointerControllerInterface.h +16 −3 Original line number Diff line number Diff line Loading @@ -22,6 +22,20 @@ namespace android { struct FloatPoint { float x; float y; inline FloatPoint(float x, float y) : x(x), y(y) {} inline explicit FloatPoint(vec2 p) : x(p.x), y(p.y) {} template <typename T, typename U> operator std::tuple<T, U>() { return {x, y}; } }; /** * Interface for tracking a mouse / touch pad pointer and touch pad spots. * Loading @@ -40,8 +54,7 @@ protected: public: /* Gets the bounds of the region that the pointer can traverse. * Returns true if the bounds are available. */ virtual bool getBounds(float* outMinX, float* outMinY, float* outMaxX, float* outMaxY) const = 0; virtual std::optional<FloatRect> getBounds() const = 0; /* Move the pointer. */ virtual void move(float deltaX, float deltaY) = 0; Loading @@ -56,7 +69,7 @@ public: virtual void setPosition(float x, float y) = 0; /* Gets the absolute location of the pointer. */ virtual void getPosition(float* outX, float* outY) const = 0; virtual FloatPoint getPosition() const = 0; enum class Transition { // Fade/unfade immediately. Loading services/inputflinger/reader/mapper/CursorInputMapper.cpp +6 −5 Original line number Diff line number Diff line Loading @@ -83,10 +83,11 @@ void CursorInputMapper::populateDeviceInfo(InputDeviceInfo* info) { InputMapper::populateDeviceInfo(info); if (mParameters.mode == Parameters::Mode::POINTER) { float minX, minY, maxX, maxY; if (mPointerController->getBounds(&minX, &minY, &maxX, &maxY)) { info->addMotionRange(AMOTION_EVENT_AXIS_X, mSource, minX, maxX, 0.0f, 0.0f, 0.0f); info->addMotionRange(AMOTION_EVENT_AXIS_Y, mSource, minY, maxY, 0.0f, 0.0f, 0.0f); if (const auto bounds = mPointerController->getBounds(); bounds) { info->addMotionRange(AMOTION_EVENT_AXIS_X, mSource, bounds->left, bounds->right, 0.0f, 0.0f, 0.0f); info->addMotionRange(AMOTION_EVENT_AXIS_Y, mSource, bounds->top, bounds->bottom, 0.0f, 0.0f, 0.0f); } } else { info->addMotionRange(AMOTION_EVENT_AXIS_X, mSource, -1.0f, 1.0f, 0.0f, mXScale, 0.0f); Loading Loading @@ -379,7 +380,7 @@ std::list<NotifyArgs> CursorInputMapper::sync(nsecs_t when, nsecs_t readTime) { mPointerController->unfade(PointerControllerInterface::Transition::IMMEDIATE); } mPointerController->getPosition(&xCursorPosition, &yCursorPosition); std::tie(xCursorPosition, yCursorPosition) = mPointerController->getPosition(); pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_X, xCursorPosition); pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_Y, yCursorPosition); Loading services/inputflinger/reader/mapper/TouchInputMapper.cpp +12 −20 Original line number Diff line number Diff line Loading @@ -2691,8 +2691,7 @@ std::list<NotifyArgs> TouchInputMapper::dispatchPointerGestures(nsecs_t when, ns // the pointer is hovering again even if the user is not currently touching // the touch pad. This ensures that a view will receive a fresh hover enter // event after a tap. float x, y; mPointerController->getPosition(&x, &y); const auto [x, y] = mPointerController->getPosition(); PointerProperties pointerProperties; pointerProperties.clear(); Loading Loading @@ -2898,8 +2897,7 @@ bool TouchInputMapper::preparePointerGestures(nsecs_t when, bool* outCancelPrevi mPointerVelocityControl.reset(); } float x, y; mPointerController->getPosition(&x, &y); const auto [x, y] = mPointerController->getPosition(); mPointerGesture.currentGestureMode = PointerGesture::Mode::BUTTON_CLICK_OR_DRAG; mPointerGesture.currentGestureIdBits.clear(); Loading @@ -2925,8 +2923,7 @@ bool TouchInputMapper::preparePointerGestures(nsecs_t when, bool* outCancelPrevi mPointerGesture.lastGestureMode == PointerGesture::Mode::TAP_DRAG) && lastFingerCount == 1) { if (when <= mPointerGesture.tapDownTime + mConfig.pointerGestureTapInterval) { float x, y; mPointerController->getPosition(&x, &y); const auto [x, y] = mPointerController->getPosition(); if (fabs(x - mPointerGesture.tapX) <= mConfig.pointerGestureTapSlop && fabs(y - mPointerGesture.tapY) <= mConfig.pointerGestureTapSlop) { ALOGD_IF(DEBUG_GESTURES, "Gestures: TAP"); Loading Loading @@ -2988,8 +2985,7 @@ bool TouchInputMapper::preparePointerGestures(nsecs_t when, bool* outCancelPrevi mPointerGesture.currentGestureMode = PointerGesture::Mode::HOVER; if (mPointerGesture.lastGestureMode == PointerGesture::Mode::TAP) { if (when <= mPointerGesture.tapUpTime + mConfig.pointerGestureTapDragInterval) { float x, y; mPointerController->getPosition(&x, &y); const auto [x, y] = mPointerController->getPosition(); if (fabs(x - mPointerGesture.tapX) <= mConfig.pointerGestureTapSlop && fabs(y - mPointerGesture.tapY) <= mConfig.pointerGestureTapSlop) { mPointerGesture.currentGestureMode = PointerGesture::Mode::TAP_DRAG; Loading Loading @@ -3025,8 +3021,7 @@ bool TouchInputMapper::preparePointerGestures(nsecs_t when, bool* outCancelPrevi down = false; } float x, y; mPointerController->getPosition(&x, &y); const auto [x, y] = mPointerController->getPosition(); mPointerGesture.currentGestureIdBits.clear(); mPointerGesture.currentGestureIdBits.markBit(mPointerGesture.activeGestureId); Loading Loading @@ -3193,8 +3188,8 @@ void TouchInputMapper::prepareMultiFingerPointerGestures(nsecs_t when, bool* can mCurrentRawState.rawPointerData .getCentroidOfTouchingPointers(&mPointerGesture.referenceTouchX, &mPointerGesture.referenceTouchY); mPointerController->getPosition(&mPointerGesture.referenceGestureX, &mPointerGesture.referenceGestureY); std::tie(mPointerGesture.referenceGestureX, mPointerGesture.referenceGestureY) = mPointerController->getPosition(); } // Clear the reference deltas for fingers not yet included in the reference calculation. Loading Loading @@ -3509,8 +3504,7 @@ std::list<NotifyArgs> TouchInputMapper::dispatchPointerStylus(nsecs_t when, nsec hovering = mCurrentCookedState.cookedPointerData.hoveringIdBits.hasBit(id); down = !hovering; float x, y; mPointerController->getPosition(&x, &y); const auto [x, y] = mPointerController->getPosition(); mPointerSimple.currentCoords.copyFrom( mCurrentCookedState.cookedPointerData.pointerCoords[index]); mPointerSimple.currentCoords.setAxisValue(AMOTION_EVENT_AXIS_X, x); Loading Loading @@ -3548,9 +3542,8 @@ std::list<NotifyArgs> TouchInputMapper::dispatchPointerMouse(nsecs_t when, nsecs down = isPointerDown(mCurrentRawState.buttonState); hovering = !down; float x, y; mPointerController->getPosition(&x, &y); uint32_t currentIndex = mCurrentRawState.rawPointerData.idToIndex[id]; const auto [x, y] = mPointerController->getPosition(); const uint32_t currentIndex = mCurrentRawState.rawPointerData.idToIndex[id]; mPointerSimple.currentCoords.copyFrom( mCurrentCookedState.cookedPointerData.pointerCoords[currentIndex]); mPointerSimple.currentCoords.setAxisValue(AMOTION_EVENT_AXIS_X, x); Loading Loading @@ -3597,8 +3590,7 @@ std::list<NotifyArgs> TouchInputMapper::dispatchPointerSimple(nsecs_t when, nsec } int32_t displayId = mPointerController->getDisplayId(); float xCursorPosition, yCursorPosition; mPointerController->getPosition(&xCursorPosition, &yCursorPosition); const auto [xCursorPosition, yCursorPosition] = mPointerController->getPosition(); if (mPointerSimple.down && !down) { mPointerSimple.down = false; Loading Loading @@ -3819,7 +3811,7 @@ NotifyMotionArgs TouchInputMapper::dispatchMotion( float xCursorPosition = AMOTION_EVENT_INVALID_CURSOR_POSITION; float yCursorPosition = AMOTION_EVENT_INVALID_CURSOR_POSITION; if (mDeviceMode == DeviceMode::POINTER) { mPointerController->getPosition(&xCursorPosition, &yCursorPosition); std::tie(xCursorPosition, yCursorPosition) = mPointerController->getPosition(); } const int32_t deviceId = getDeviceId(); std::vector<TouchVideoFrame> frames = getDeviceContext().getVideoFrames(); Loading services/inputflinger/reader/mapper/gestures/GestureConverter.cpp +10 −14 Original line number Diff line number Diff line Loading @@ -111,8 +111,8 @@ NotifyArgs GestureConverter::handleMove(nsecs_t when, nsecs_t readTime, const Ge mPointerController->setPresentation(PointerControllerInterface::Presentation::POINTER); mPointerController->move(deltaX, deltaY); mPointerController->unfade(PointerControllerInterface::Transition::IMMEDIATE); float xCursorPosition, yCursorPosition; mPointerController->getPosition(&xCursorPosition, &yCursorPosition); const auto [xCursorPosition, yCursorPosition] = mPointerController->getPosition(); PointerCoords coords; coords.clear(); Loading @@ -136,8 +136,7 @@ std::list<NotifyArgs> GestureConverter::handleButtonsChange(nsecs_t when, nsecs_ mPointerController->setPresentation(PointerControllerInterface::Presentation::POINTER); mPointerController->unfade(PointerControllerInterface::Transition::IMMEDIATE); float xCursorPosition, yCursorPosition; mPointerController->getPosition(&xCursorPosition, &yCursorPosition); const auto [xCursorPosition, yCursorPosition] = mPointerController->getPosition(); PointerCoords coords; coords.clear(); Loading Loading @@ -202,8 +201,7 @@ std::list<NotifyArgs> GestureConverter::handleScroll(nsecs_t when, nsecs_t readT const Gesture& gesture) { std::list<NotifyArgs> out; PointerCoords& coords = mFakeFingerCoords[0]; float xCursorPosition, yCursorPosition; mPointerController->getPosition(&xCursorPosition, &yCursorPosition); const auto [xCursorPosition, yCursorPosition] = mPointerController->getPosition(); if (mCurrentClassification != MotionClassification::TWO_FINGER_SWIPE) { mCurrentClassification = MotionClassification::TWO_FINGER_SWIPE; coords.setAxisValue(AMOTION_EVENT_AXIS_X, xCursorPosition); Loading Loading @@ -244,8 +242,7 @@ NotifyArgs GestureConverter::handleFling(nsecs_t when, nsecs_t readTime, const G return {}; } float xCursorPosition, yCursorPosition; mPointerController->getPosition(&xCursorPosition, &yCursorPosition); 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 = Loading @@ -262,8 +259,8 @@ NotifyArgs GestureConverter::handleFling(nsecs_t when, nsecs_t readTime, const G uint32_t fingerCount, float dx, float dy) { std::list<NotifyArgs> out = {}; float xCursorPosition, yCursorPosition; mPointerController->getPosition(&xCursorPosition, &yCursorPosition); 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 Loading Loading @@ -328,8 +325,7 @@ NotifyArgs GestureConverter::handleFling(nsecs_t when, nsecs_t readTime, const G if (mCurrentClassification != MotionClassification::MULTI_FINGER_SWIPE) { return out; } float xCursorPosition, yCursorPosition; mPointerController->getPosition(&xCursorPosition, &yCursorPosition); 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); Loading @@ -353,8 +349,8 @@ NotifyArgs GestureConverter::handleFling(nsecs_t when, nsecs_t readTime, const G [[nodiscard]] std::list<NotifyArgs> GestureConverter::handlePinch(nsecs_t when, nsecs_t readTime, const Gesture& gesture) { std::list<NotifyArgs> out; float xCursorPosition, yCursorPosition; mPointerController->getPosition(&xCursorPosition, &yCursorPosition); 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 Loading services/inputflinger/tests/FakePointerController.cpp +5 −12 Original line number Diff line number Diff line Loading @@ -45,9 +45,8 @@ int32_t FakePointerController::getButtonState() const { return mButtonState; } void FakePointerController::getPosition(float* outX, float* outY) const { *outX = mX; *outY = mY; FloatPoint FakePointerController::getPosition() const { return {mX, mY}; } int32_t FakePointerController::getDisplayId() const { Loading @@ -59,8 +58,7 @@ void FakePointerController::setDisplayViewport(const DisplayViewport& viewport) } void FakePointerController::assertPosition(float x, float y) { float actualX, actualY; getPosition(&actualX, &actualY); const auto [actualX, actualY] = getPosition(); ASSERT_NEAR(x, actualX, 1); ASSERT_NEAR(y, actualY, 1); } Loading @@ -69,13 +67,8 @@ bool FakePointerController::isPointerShown() { return mIsPointerShown; } bool FakePointerController::getBounds(float* outMinX, float* outMinY, float* outMaxX, float* outMaxY) const { *outMinX = mMinX; *outMinY = mMinY; *outMaxX = mMaxX; *outMaxY = mMaxY; return mHaveBounds; std::optional<FloatRect> FakePointerController::getBounds() const { return mHaveBounds ? std::make_optional<FloatRect>(mMinX, mMinY, mMaxX, mMaxY) : std::nullopt; } void FakePointerController::move(float deltaX, float deltaY) { Loading Loading
services/inputflinger/include/PointerControllerInterface.h +16 −3 Original line number Diff line number Diff line Loading @@ -22,6 +22,20 @@ namespace android { struct FloatPoint { float x; float y; inline FloatPoint(float x, float y) : x(x), y(y) {} inline explicit FloatPoint(vec2 p) : x(p.x), y(p.y) {} template <typename T, typename U> operator std::tuple<T, U>() { return {x, y}; } }; /** * Interface for tracking a mouse / touch pad pointer and touch pad spots. * Loading @@ -40,8 +54,7 @@ protected: public: /* Gets the bounds of the region that the pointer can traverse. * Returns true if the bounds are available. */ virtual bool getBounds(float* outMinX, float* outMinY, float* outMaxX, float* outMaxY) const = 0; virtual std::optional<FloatRect> getBounds() const = 0; /* Move the pointer. */ virtual void move(float deltaX, float deltaY) = 0; Loading @@ -56,7 +69,7 @@ public: virtual void setPosition(float x, float y) = 0; /* Gets the absolute location of the pointer. */ virtual void getPosition(float* outX, float* outY) const = 0; virtual FloatPoint getPosition() const = 0; enum class Transition { // Fade/unfade immediately. Loading
services/inputflinger/reader/mapper/CursorInputMapper.cpp +6 −5 Original line number Diff line number Diff line Loading @@ -83,10 +83,11 @@ void CursorInputMapper::populateDeviceInfo(InputDeviceInfo* info) { InputMapper::populateDeviceInfo(info); if (mParameters.mode == Parameters::Mode::POINTER) { float minX, minY, maxX, maxY; if (mPointerController->getBounds(&minX, &minY, &maxX, &maxY)) { info->addMotionRange(AMOTION_EVENT_AXIS_X, mSource, minX, maxX, 0.0f, 0.0f, 0.0f); info->addMotionRange(AMOTION_EVENT_AXIS_Y, mSource, minY, maxY, 0.0f, 0.0f, 0.0f); if (const auto bounds = mPointerController->getBounds(); bounds) { info->addMotionRange(AMOTION_EVENT_AXIS_X, mSource, bounds->left, bounds->right, 0.0f, 0.0f, 0.0f); info->addMotionRange(AMOTION_EVENT_AXIS_Y, mSource, bounds->top, bounds->bottom, 0.0f, 0.0f, 0.0f); } } else { info->addMotionRange(AMOTION_EVENT_AXIS_X, mSource, -1.0f, 1.0f, 0.0f, mXScale, 0.0f); Loading Loading @@ -379,7 +380,7 @@ std::list<NotifyArgs> CursorInputMapper::sync(nsecs_t when, nsecs_t readTime) { mPointerController->unfade(PointerControllerInterface::Transition::IMMEDIATE); } mPointerController->getPosition(&xCursorPosition, &yCursorPosition); std::tie(xCursorPosition, yCursorPosition) = mPointerController->getPosition(); pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_X, xCursorPosition); pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_Y, yCursorPosition); Loading
services/inputflinger/reader/mapper/TouchInputMapper.cpp +12 −20 Original line number Diff line number Diff line Loading @@ -2691,8 +2691,7 @@ std::list<NotifyArgs> TouchInputMapper::dispatchPointerGestures(nsecs_t when, ns // the pointer is hovering again even if the user is not currently touching // the touch pad. This ensures that a view will receive a fresh hover enter // event after a tap. float x, y; mPointerController->getPosition(&x, &y); const auto [x, y] = mPointerController->getPosition(); PointerProperties pointerProperties; pointerProperties.clear(); Loading Loading @@ -2898,8 +2897,7 @@ bool TouchInputMapper::preparePointerGestures(nsecs_t when, bool* outCancelPrevi mPointerVelocityControl.reset(); } float x, y; mPointerController->getPosition(&x, &y); const auto [x, y] = mPointerController->getPosition(); mPointerGesture.currentGestureMode = PointerGesture::Mode::BUTTON_CLICK_OR_DRAG; mPointerGesture.currentGestureIdBits.clear(); Loading @@ -2925,8 +2923,7 @@ bool TouchInputMapper::preparePointerGestures(nsecs_t when, bool* outCancelPrevi mPointerGesture.lastGestureMode == PointerGesture::Mode::TAP_DRAG) && lastFingerCount == 1) { if (when <= mPointerGesture.tapDownTime + mConfig.pointerGestureTapInterval) { float x, y; mPointerController->getPosition(&x, &y); const auto [x, y] = mPointerController->getPosition(); if (fabs(x - mPointerGesture.tapX) <= mConfig.pointerGestureTapSlop && fabs(y - mPointerGesture.tapY) <= mConfig.pointerGestureTapSlop) { ALOGD_IF(DEBUG_GESTURES, "Gestures: TAP"); Loading Loading @@ -2988,8 +2985,7 @@ bool TouchInputMapper::preparePointerGestures(nsecs_t when, bool* outCancelPrevi mPointerGesture.currentGestureMode = PointerGesture::Mode::HOVER; if (mPointerGesture.lastGestureMode == PointerGesture::Mode::TAP) { if (when <= mPointerGesture.tapUpTime + mConfig.pointerGestureTapDragInterval) { float x, y; mPointerController->getPosition(&x, &y); const auto [x, y] = mPointerController->getPosition(); if (fabs(x - mPointerGesture.tapX) <= mConfig.pointerGestureTapSlop && fabs(y - mPointerGesture.tapY) <= mConfig.pointerGestureTapSlop) { mPointerGesture.currentGestureMode = PointerGesture::Mode::TAP_DRAG; Loading Loading @@ -3025,8 +3021,7 @@ bool TouchInputMapper::preparePointerGestures(nsecs_t when, bool* outCancelPrevi down = false; } float x, y; mPointerController->getPosition(&x, &y); const auto [x, y] = mPointerController->getPosition(); mPointerGesture.currentGestureIdBits.clear(); mPointerGesture.currentGestureIdBits.markBit(mPointerGesture.activeGestureId); Loading Loading @@ -3193,8 +3188,8 @@ void TouchInputMapper::prepareMultiFingerPointerGestures(nsecs_t when, bool* can mCurrentRawState.rawPointerData .getCentroidOfTouchingPointers(&mPointerGesture.referenceTouchX, &mPointerGesture.referenceTouchY); mPointerController->getPosition(&mPointerGesture.referenceGestureX, &mPointerGesture.referenceGestureY); std::tie(mPointerGesture.referenceGestureX, mPointerGesture.referenceGestureY) = mPointerController->getPosition(); } // Clear the reference deltas for fingers not yet included in the reference calculation. Loading Loading @@ -3509,8 +3504,7 @@ std::list<NotifyArgs> TouchInputMapper::dispatchPointerStylus(nsecs_t when, nsec hovering = mCurrentCookedState.cookedPointerData.hoveringIdBits.hasBit(id); down = !hovering; float x, y; mPointerController->getPosition(&x, &y); const auto [x, y] = mPointerController->getPosition(); mPointerSimple.currentCoords.copyFrom( mCurrentCookedState.cookedPointerData.pointerCoords[index]); mPointerSimple.currentCoords.setAxisValue(AMOTION_EVENT_AXIS_X, x); Loading Loading @@ -3548,9 +3542,8 @@ std::list<NotifyArgs> TouchInputMapper::dispatchPointerMouse(nsecs_t when, nsecs down = isPointerDown(mCurrentRawState.buttonState); hovering = !down; float x, y; mPointerController->getPosition(&x, &y); uint32_t currentIndex = mCurrentRawState.rawPointerData.idToIndex[id]; const auto [x, y] = mPointerController->getPosition(); const uint32_t currentIndex = mCurrentRawState.rawPointerData.idToIndex[id]; mPointerSimple.currentCoords.copyFrom( mCurrentCookedState.cookedPointerData.pointerCoords[currentIndex]); mPointerSimple.currentCoords.setAxisValue(AMOTION_EVENT_AXIS_X, x); Loading Loading @@ -3597,8 +3590,7 @@ std::list<NotifyArgs> TouchInputMapper::dispatchPointerSimple(nsecs_t when, nsec } int32_t displayId = mPointerController->getDisplayId(); float xCursorPosition, yCursorPosition; mPointerController->getPosition(&xCursorPosition, &yCursorPosition); const auto [xCursorPosition, yCursorPosition] = mPointerController->getPosition(); if (mPointerSimple.down && !down) { mPointerSimple.down = false; Loading Loading @@ -3819,7 +3811,7 @@ NotifyMotionArgs TouchInputMapper::dispatchMotion( float xCursorPosition = AMOTION_EVENT_INVALID_CURSOR_POSITION; float yCursorPosition = AMOTION_EVENT_INVALID_CURSOR_POSITION; if (mDeviceMode == DeviceMode::POINTER) { mPointerController->getPosition(&xCursorPosition, &yCursorPosition); std::tie(xCursorPosition, yCursorPosition) = mPointerController->getPosition(); } const int32_t deviceId = getDeviceId(); std::vector<TouchVideoFrame> frames = getDeviceContext().getVideoFrames(); Loading
services/inputflinger/reader/mapper/gestures/GestureConverter.cpp +10 −14 Original line number Diff line number Diff line Loading @@ -111,8 +111,8 @@ NotifyArgs GestureConverter::handleMove(nsecs_t when, nsecs_t readTime, const Ge mPointerController->setPresentation(PointerControllerInterface::Presentation::POINTER); mPointerController->move(deltaX, deltaY); mPointerController->unfade(PointerControllerInterface::Transition::IMMEDIATE); float xCursorPosition, yCursorPosition; mPointerController->getPosition(&xCursorPosition, &yCursorPosition); const auto [xCursorPosition, yCursorPosition] = mPointerController->getPosition(); PointerCoords coords; coords.clear(); Loading @@ -136,8 +136,7 @@ std::list<NotifyArgs> GestureConverter::handleButtonsChange(nsecs_t when, nsecs_ mPointerController->setPresentation(PointerControllerInterface::Presentation::POINTER); mPointerController->unfade(PointerControllerInterface::Transition::IMMEDIATE); float xCursorPosition, yCursorPosition; mPointerController->getPosition(&xCursorPosition, &yCursorPosition); const auto [xCursorPosition, yCursorPosition] = mPointerController->getPosition(); PointerCoords coords; coords.clear(); Loading Loading @@ -202,8 +201,7 @@ std::list<NotifyArgs> GestureConverter::handleScroll(nsecs_t when, nsecs_t readT const Gesture& gesture) { std::list<NotifyArgs> out; PointerCoords& coords = mFakeFingerCoords[0]; float xCursorPosition, yCursorPosition; mPointerController->getPosition(&xCursorPosition, &yCursorPosition); const auto [xCursorPosition, yCursorPosition] = mPointerController->getPosition(); if (mCurrentClassification != MotionClassification::TWO_FINGER_SWIPE) { mCurrentClassification = MotionClassification::TWO_FINGER_SWIPE; coords.setAxisValue(AMOTION_EVENT_AXIS_X, xCursorPosition); Loading Loading @@ -244,8 +242,7 @@ NotifyArgs GestureConverter::handleFling(nsecs_t when, nsecs_t readTime, const G return {}; } float xCursorPosition, yCursorPosition; mPointerController->getPosition(&xCursorPosition, &yCursorPosition); 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 = Loading @@ -262,8 +259,8 @@ NotifyArgs GestureConverter::handleFling(nsecs_t when, nsecs_t readTime, const G uint32_t fingerCount, float dx, float dy) { std::list<NotifyArgs> out = {}; float xCursorPosition, yCursorPosition; mPointerController->getPosition(&xCursorPosition, &yCursorPosition); 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 Loading Loading @@ -328,8 +325,7 @@ NotifyArgs GestureConverter::handleFling(nsecs_t when, nsecs_t readTime, const G if (mCurrentClassification != MotionClassification::MULTI_FINGER_SWIPE) { return out; } float xCursorPosition, yCursorPosition; mPointerController->getPosition(&xCursorPosition, &yCursorPosition); 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); Loading @@ -353,8 +349,8 @@ NotifyArgs GestureConverter::handleFling(nsecs_t when, nsecs_t readTime, const G [[nodiscard]] std::list<NotifyArgs> GestureConverter::handlePinch(nsecs_t when, nsecs_t readTime, const Gesture& gesture) { std::list<NotifyArgs> out; float xCursorPosition, yCursorPosition; mPointerController->getPosition(&xCursorPosition, &yCursorPosition); 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 Loading
services/inputflinger/tests/FakePointerController.cpp +5 −12 Original line number Diff line number Diff line Loading @@ -45,9 +45,8 @@ int32_t FakePointerController::getButtonState() const { return mButtonState; } void FakePointerController::getPosition(float* outX, float* outY) const { *outX = mX; *outY = mY; FloatPoint FakePointerController::getPosition() const { return {mX, mY}; } int32_t FakePointerController::getDisplayId() const { Loading @@ -59,8 +58,7 @@ void FakePointerController::setDisplayViewport(const DisplayViewport& viewport) } void FakePointerController::assertPosition(float x, float y) { float actualX, actualY; getPosition(&actualX, &actualY); const auto [actualX, actualY] = getPosition(); ASSERT_NEAR(x, actualX, 1); ASSERT_NEAR(y, actualY, 1); } Loading @@ -69,13 +67,8 @@ bool FakePointerController::isPointerShown() { return mIsPointerShown; } bool FakePointerController::getBounds(float* outMinX, float* outMinY, float* outMaxX, float* outMaxY) const { *outMinX = mMinX; *outMinY = mMinY; *outMaxX = mMaxX; *outMaxY = mMaxY; return mHaveBounds; std::optional<FloatRect> FakePointerController::getBounds() const { return mHaveBounds ? std::make_optional<FloatRect>(mMinX, mMinY, mMaxX, mMaxY) : std::nullopt; } void FakePointerController::move(float deltaX, float deltaY) { Loading