Loading services/inputflinger/reader/mapper/gestures/GestureConverter.cpp +17 −11 Original line number Diff line number Diff line Loading @@ -210,10 +210,12 @@ std::list<NotifyArgs> GestureConverter::handleScroll(nsecs_t when, nsecs_t readT coords.setAxisValue(AMOTION_EVENT_AXIS_Y, yCursorPosition); coords.setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, 1.0f); mDownTime = when; out.push_back(makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_DOWN, /* actionButton= */ 0, mButtonState, /* pointerCount= */ 1, mFingerProps.data(), mFakeFingerCoords.data(), xCursorPosition, yCursorPosition)); NotifyMotionArgs args = makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_DOWN, /* actionButton= */ 0, mButtonState, /* pointerCount= */ 1, mFingerProps.data(), mFakeFingerCoords.data(), xCursorPosition, yCursorPosition); args.flags |= AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE; out.push_back(args); } float deltaX = gesture.details.scroll.dx; float deltaY = gesture.details.scroll.dy; Loading @@ -224,9 +226,12 @@ std::list<NotifyArgs> GestureConverter::handleScroll(nsecs_t when, nsecs_t readT // TODO(b/262876643): set AXIS_GESTURE_{X,Y}_OFFSET. coords.setAxisValue(AMOTION_EVENT_AXIS_GESTURE_SCROLL_X_DISTANCE, -gesture.details.scroll.dx); coords.setAxisValue(AMOTION_EVENT_AXIS_GESTURE_SCROLL_Y_DISTANCE, -gesture.details.scroll.dy); out.push_back(makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_MOVE, /* actionButton= */ 0, NotifyMotionArgs args = makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_MOVE, /* actionButton= */ 0, mButtonState, /* pointerCount= */ 1, mFingerProps.data(), mFakeFingerCoords.data(), xCursorPosition, yCursorPosition)); mFakeFingerCoords.data(), xCursorPosition, yCursorPosition); args.flags |= AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE; out.push_back(args); return out; } Loading @@ -243,10 +248,11 @@ NotifyArgs GestureConverter::handleFling(nsecs_t when, nsecs_t readTime, const G mPointerController->getPosition(&xCursorPosition, &yCursorPosition); mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_GESTURE_SCROLL_X_DISTANCE, 0); mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_GESTURE_SCROLL_Y_DISTANCE, 0); NotifyArgs args = makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_UP, /* actionButton= */ 0, mButtonState, /* pointerCount= */ 1, mFingerProps.data(), mFakeFingerCoords.data(), xCursorPosition, yCursorPosition); NotifyMotionArgs args = makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_UP, /* actionButton= */ 0, mButtonState, /* pointerCount= */ 1, mFingerProps.data(), mFakeFingerCoords.data(), xCursorPosition, yCursorPosition); args.flags |= AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE; mCurrentClassification = MotionClassification::NONE; return args; } Loading services/inputflinger/tests/GestureConverter_test.cpp +8 −4 Original line number Diff line number Diff line Loading @@ -252,14 +252,16 @@ TEST_F(GestureConverterTest, Scroll) { AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN), WithCoords(POINTER_X, POINTER_Y), WithGestureScrollDistance(0, 0, EPSILON), WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE), WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER), WithDownTime(downTime))); WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER), WithDownTime(downTime), WithFlags(AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE))); args.pop_front(); ASSERT_THAT(std::get<NotifyMotionArgs>(args.front()), AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE), WithCoords(POINTER_X, POINTER_Y - 10), WithGestureScrollDistance(0, 10, EPSILON), WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE), WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER))); WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER), WithFlags(AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE))); Gesture continueGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -5); args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, continueGesture); Loading @@ -269,7 +271,8 @@ TEST_F(GestureConverterTest, Scroll) { WithCoords(POINTER_X, POINTER_Y - 15), WithGestureScrollDistance(0, 5, EPSILON), WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE), WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER))); WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER), WithFlags(AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE))); Gesture flingGesture(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 1, 1, GESTURES_FLING_START); Loading @@ -280,7 +283,8 @@ TEST_F(GestureConverterTest, Scroll) { WithCoords(POINTER_X, POINTER_Y - 15), WithGestureScrollDistance(0, 0, EPSILON), WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE), WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER))); WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER), WithFlags(AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE))); } TEST_F(GestureConverterTest, Scroll_Rotated) { Loading services/inputflinger/tests/TestInputListenerMatchers.h +1 −1 Original line number Diff line number Diff line Loading @@ -145,7 +145,7 @@ MATCHER_P(WithToolType, toolType, "InputEvent with specified tool type") { MATCHER_P(WithFlags, flags, "InputEvent with specified flags") { *result_listener << "expected flags " << flags << ", but got " << arg.flags; return arg.flags == flags; return arg.flags == static_cast<int32_t>(flags); } MATCHER_P(WithMotionClassification, classification, Loading Loading
services/inputflinger/reader/mapper/gestures/GestureConverter.cpp +17 −11 Original line number Diff line number Diff line Loading @@ -210,10 +210,12 @@ std::list<NotifyArgs> GestureConverter::handleScroll(nsecs_t when, nsecs_t readT coords.setAxisValue(AMOTION_EVENT_AXIS_Y, yCursorPosition); coords.setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, 1.0f); mDownTime = when; out.push_back(makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_DOWN, /* actionButton= */ 0, mButtonState, /* pointerCount= */ 1, mFingerProps.data(), mFakeFingerCoords.data(), xCursorPosition, yCursorPosition)); NotifyMotionArgs args = makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_DOWN, /* actionButton= */ 0, mButtonState, /* pointerCount= */ 1, mFingerProps.data(), mFakeFingerCoords.data(), xCursorPosition, yCursorPosition); args.flags |= AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE; out.push_back(args); } float deltaX = gesture.details.scroll.dx; float deltaY = gesture.details.scroll.dy; Loading @@ -224,9 +226,12 @@ std::list<NotifyArgs> GestureConverter::handleScroll(nsecs_t when, nsecs_t readT // TODO(b/262876643): set AXIS_GESTURE_{X,Y}_OFFSET. coords.setAxisValue(AMOTION_EVENT_AXIS_GESTURE_SCROLL_X_DISTANCE, -gesture.details.scroll.dx); coords.setAxisValue(AMOTION_EVENT_AXIS_GESTURE_SCROLL_Y_DISTANCE, -gesture.details.scroll.dy); out.push_back(makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_MOVE, /* actionButton= */ 0, NotifyMotionArgs args = makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_MOVE, /* actionButton= */ 0, mButtonState, /* pointerCount= */ 1, mFingerProps.data(), mFakeFingerCoords.data(), xCursorPosition, yCursorPosition)); mFakeFingerCoords.data(), xCursorPosition, yCursorPosition); args.flags |= AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE; out.push_back(args); return out; } Loading @@ -243,10 +248,11 @@ NotifyArgs GestureConverter::handleFling(nsecs_t when, nsecs_t readTime, const G mPointerController->getPosition(&xCursorPosition, &yCursorPosition); mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_GESTURE_SCROLL_X_DISTANCE, 0); mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_GESTURE_SCROLL_Y_DISTANCE, 0); NotifyArgs args = makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_UP, /* actionButton= */ 0, mButtonState, /* pointerCount= */ 1, mFingerProps.data(), mFakeFingerCoords.data(), xCursorPosition, yCursorPosition); NotifyMotionArgs args = makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_UP, /* actionButton= */ 0, mButtonState, /* pointerCount= */ 1, mFingerProps.data(), mFakeFingerCoords.data(), xCursorPosition, yCursorPosition); args.flags |= AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE; mCurrentClassification = MotionClassification::NONE; return args; } Loading
services/inputflinger/tests/GestureConverter_test.cpp +8 −4 Original line number Diff line number Diff line Loading @@ -252,14 +252,16 @@ TEST_F(GestureConverterTest, Scroll) { AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN), WithCoords(POINTER_X, POINTER_Y), WithGestureScrollDistance(0, 0, EPSILON), WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE), WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER), WithDownTime(downTime))); WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER), WithDownTime(downTime), WithFlags(AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE))); args.pop_front(); ASSERT_THAT(std::get<NotifyMotionArgs>(args.front()), AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE), WithCoords(POINTER_X, POINTER_Y - 10), WithGestureScrollDistance(0, 10, EPSILON), WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE), WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER))); WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER), WithFlags(AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE))); Gesture continueGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -5); args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, continueGesture); Loading @@ -269,7 +271,8 @@ TEST_F(GestureConverterTest, Scroll) { WithCoords(POINTER_X, POINTER_Y - 15), WithGestureScrollDistance(0, 5, EPSILON), WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE), WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER))); WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER), WithFlags(AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE))); Gesture flingGesture(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 1, 1, GESTURES_FLING_START); Loading @@ -280,7 +283,8 @@ TEST_F(GestureConverterTest, Scroll) { WithCoords(POINTER_X, POINTER_Y - 15), WithGestureScrollDistance(0, 0, EPSILON), WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE), WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER))); WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER), WithFlags(AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE))); } TEST_F(GestureConverterTest, Scroll_Rotated) { Loading
services/inputflinger/tests/TestInputListenerMatchers.h +1 −1 Original line number Diff line number Diff line Loading @@ -145,7 +145,7 @@ MATCHER_P(WithToolType, toolType, "InputEvent with specified tool type") { MATCHER_P(WithFlags, flags, "InputEvent with specified flags") { *result_listener << "expected flags " << flags << ", but got " << arg.flags; return arg.flags == flags; return arg.flags == static_cast<int32_t>(flags); } MATCHER_P(WithMotionClassification, classification, Loading