Loading services/inputflinger/InputReaderBase.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -73,6 +73,9 @@ std::string InputReaderConfiguration::changesToString(uint32_t changes) { if (changes & CHANGE_ENABLED_STATE) { result += "ENABLED_STATE | "; } if (changes & CHANGE_TOUCHPAD_SETTINGS) { result += "TOUCHPAD_SETTINGS | "; } if (changes & CHANGE_MUST_REOPEN) { result += "MUST_REOPEN | "; } Loading services/inputflinger/include/InputReaderBase.h +22 −1 Original line number Diff line number Diff line Loading @@ -161,7 +161,7 @@ public: struct InputReaderConfiguration { // Describes changes that have occurred. enum { // The pointer speed changed. // The mouse pointer speed changed. CHANGE_POINTER_SPEED = 1 << 0, // The pointer gesture control changed. Loading Loading @@ -200,6 +200,9 @@ struct InputReaderConfiguration { // The stylus button reporting configurations has changed. CHANGE_STYLUS_BUTTON_REPORTING = 1 << 12, // The touchpad settings changed. CHANGE_TOUCHPAD_SETTINGS = 1 << 13, // All devices must be reopened. CHANGE_MUST_REOPEN = 1 << 31, }; Loading Loading @@ -309,6 +312,20 @@ struct InputReaderConfiguration { // The latest request to enable or disable Pointer Capture. PointerCaptureRequest pointerCaptureRequest; // The touchpad pointer speed, as a number from -7 (slowest) to 7 (fastest). int32_t touchpadPointerSpeed; // True to invert the touchpad scrolling direction, so that moving two fingers downwards on the // touchpad scrolls the content upwards. bool touchpadNaturalScrollingEnabled; // True to enable tap-to-click on touchpads. bool touchpadTapToClickEnabled; // True to enable a zone on the right-hand side of touchpads where clicks will be turned into // context (a.k.a. "right") clicks. bool touchpadRightClickZoneEnabled; // The set of currently disabled input devices. std::set<int32_t> disabledDevices; Loading Loading @@ -337,6 +354,10 @@ struct InputReaderConfiguration { pointerGestureZoomSpeedRatio(0.3f), showTouches(false), pointerCaptureRequest(), touchpadPointerSpeed(0), touchpadNaturalScrollingEnabled(true), touchpadTapToClickEnabled(true), touchpadRightClickZoneEnabled(false), stylusButtonMotionEventsEnabled(true) {} static std::string changesToString(uint32_t changes); Loading services/inputflinger/reader/mapper/TouchpadInputMapper.cpp +12 −0 Original line number Diff line number Diff line Loading @@ -146,6 +146,18 @@ std::list<NotifyArgs> TouchpadInputMapper::configure(nsecs_t when, } mGestureConverter.setOrientation(orientation); } if (!changes || (changes & InputReaderConfiguration::CHANGE_TOUCHPAD_SETTINGS)) { // TODO(b/265798483): load an Android-specific acceleration curve instead of mapping to one // of five ChromeOS curves. const int pointerSensitivity = (config->touchpadPointerSpeed + 7) / 3 + 1; mPropertyProvider.getProperty("Pointer Sensitivity").setIntValues({pointerSensitivity}); mPropertyProvider.getProperty("Invert Scrolling") .setBoolValues({config->touchpadNaturalScrollingEnabled}); mPropertyProvider.getProperty("Tap Enable") .setBoolValues({config->touchpadTapToClickEnabled}); mPropertyProvider.getProperty("Button Right Click Zone Enable") .setBoolValues({config->touchpadRightClickZoneEnabled}); } return {}; } Loading services/inputflinger/reader/mapper/gestures/GestureConverter.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -219,11 +219,11 @@ std::list<NotifyArgs> GestureConverter::handleScroll(nsecs_t when, nsecs_t readT float deltaY = gesture.details.scroll.dy; rotateDelta(mOrientation, &deltaX, &deltaY); coords.setAxisValue(AMOTION_EVENT_AXIS_X, coords.getAxisValue(AMOTION_EVENT_AXIS_X) - deltaX); coords.setAxisValue(AMOTION_EVENT_AXIS_Y, coords.getAxisValue(AMOTION_EVENT_AXIS_Y) - deltaY); coords.setAxisValue(AMOTION_EVENT_AXIS_X, coords.getAxisValue(AMOTION_EVENT_AXIS_X) + deltaX); coords.setAxisValue(AMOTION_EVENT_AXIS_Y, coords.getAxisValue(AMOTION_EVENT_AXIS_Y) + deltaY); // 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); 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, mButtonState, /* pointerCount= */ 1, mFingerProps.data(), mFakeFingerCoords.data(), xCursorPosition, yCursorPosition)); Loading services/inputflinger/tests/GestureConverter_test.cpp +6 −6 Original line number Diff line number Diff line Loading @@ -244,7 +244,7 @@ TEST_F(GestureConverterTest, Scroll) { InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); Gesture startGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, 10); Gesture startGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -10); std::list<NotifyArgs> args = converter.handleGesture(downTime, READ_TIME, startGesture); ASSERT_EQ(2u, args.size()); Loading @@ -261,7 +261,7 @@ TEST_F(GestureConverterTest, Scroll) { WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE), WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER))); Gesture continueGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, 5); Gesture continueGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -5); args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, continueGesture); ASSERT_EQ(1u, args.size()); ASSERT_THAT(std::get<NotifyMotionArgs>(args.front()), Loading Loading @@ -289,7 +289,7 @@ TEST_F(GestureConverterTest, Scroll_Rotated) { GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); converter.setOrientation(ui::ROTATION_90); Gesture startGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, 10); Gesture startGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -10); std::list<NotifyArgs> args = converter.handleGesture(downTime, READ_TIME, startGesture); ASSERT_EQ(2u, args.size()); Loading @@ -306,7 +306,7 @@ TEST_F(GestureConverterTest, Scroll_Rotated) { WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE), WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER))); Gesture continueGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, 5); Gesture continueGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -5); args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, continueGesture); ASSERT_EQ(1u, args.size()); ASSERT_THAT(std::get<NotifyMotionArgs>(args.front()), Loading @@ -332,10 +332,10 @@ TEST_F(GestureConverterTest, Scroll_ClearsClassificationAndOffsetsAfterGesture) InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); Gesture startGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, 10); Gesture startGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -10); std::list<NotifyArgs> args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, startGesture); Gesture continueGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, 5); Gesture continueGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -5); args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, continueGesture); Gesture flingGesture(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 1, 1, Loading Loading
services/inputflinger/InputReaderBase.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -73,6 +73,9 @@ std::string InputReaderConfiguration::changesToString(uint32_t changes) { if (changes & CHANGE_ENABLED_STATE) { result += "ENABLED_STATE | "; } if (changes & CHANGE_TOUCHPAD_SETTINGS) { result += "TOUCHPAD_SETTINGS | "; } if (changes & CHANGE_MUST_REOPEN) { result += "MUST_REOPEN | "; } Loading
services/inputflinger/include/InputReaderBase.h +22 −1 Original line number Diff line number Diff line Loading @@ -161,7 +161,7 @@ public: struct InputReaderConfiguration { // Describes changes that have occurred. enum { // The pointer speed changed. // The mouse pointer speed changed. CHANGE_POINTER_SPEED = 1 << 0, // The pointer gesture control changed. Loading Loading @@ -200,6 +200,9 @@ struct InputReaderConfiguration { // The stylus button reporting configurations has changed. CHANGE_STYLUS_BUTTON_REPORTING = 1 << 12, // The touchpad settings changed. CHANGE_TOUCHPAD_SETTINGS = 1 << 13, // All devices must be reopened. CHANGE_MUST_REOPEN = 1 << 31, }; Loading Loading @@ -309,6 +312,20 @@ struct InputReaderConfiguration { // The latest request to enable or disable Pointer Capture. PointerCaptureRequest pointerCaptureRequest; // The touchpad pointer speed, as a number from -7 (slowest) to 7 (fastest). int32_t touchpadPointerSpeed; // True to invert the touchpad scrolling direction, so that moving two fingers downwards on the // touchpad scrolls the content upwards. bool touchpadNaturalScrollingEnabled; // True to enable tap-to-click on touchpads. bool touchpadTapToClickEnabled; // True to enable a zone on the right-hand side of touchpads where clicks will be turned into // context (a.k.a. "right") clicks. bool touchpadRightClickZoneEnabled; // The set of currently disabled input devices. std::set<int32_t> disabledDevices; Loading Loading @@ -337,6 +354,10 @@ struct InputReaderConfiguration { pointerGestureZoomSpeedRatio(0.3f), showTouches(false), pointerCaptureRequest(), touchpadPointerSpeed(0), touchpadNaturalScrollingEnabled(true), touchpadTapToClickEnabled(true), touchpadRightClickZoneEnabled(false), stylusButtonMotionEventsEnabled(true) {} static std::string changesToString(uint32_t changes); Loading
services/inputflinger/reader/mapper/TouchpadInputMapper.cpp +12 −0 Original line number Diff line number Diff line Loading @@ -146,6 +146,18 @@ std::list<NotifyArgs> TouchpadInputMapper::configure(nsecs_t when, } mGestureConverter.setOrientation(orientation); } if (!changes || (changes & InputReaderConfiguration::CHANGE_TOUCHPAD_SETTINGS)) { // TODO(b/265798483): load an Android-specific acceleration curve instead of mapping to one // of five ChromeOS curves. const int pointerSensitivity = (config->touchpadPointerSpeed + 7) / 3 + 1; mPropertyProvider.getProperty("Pointer Sensitivity").setIntValues({pointerSensitivity}); mPropertyProvider.getProperty("Invert Scrolling") .setBoolValues({config->touchpadNaturalScrollingEnabled}); mPropertyProvider.getProperty("Tap Enable") .setBoolValues({config->touchpadTapToClickEnabled}); mPropertyProvider.getProperty("Button Right Click Zone Enable") .setBoolValues({config->touchpadRightClickZoneEnabled}); } return {}; } Loading
services/inputflinger/reader/mapper/gestures/GestureConverter.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -219,11 +219,11 @@ std::list<NotifyArgs> GestureConverter::handleScroll(nsecs_t when, nsecs_t readT float deltaY = gesture.details.scroll.dy; rotateDelta(mOrientation, &deltaX, &deltaY); coords.setAxisValue(AMOTION_EVENT_AXIS_X, coords.getAxisValue(AMOTION_EVENT_AXIS_X) - deltaX); coords.setAxisValue(AMOTION_EVENT_AXIS_Y, coords.getAxisValue(AMOTION_EVENT_AXIS_Y) - deltaY); coords.setAxisValue(AMOTION_EVENT_AXIS_X, coords.getAxisValue(AMOTION_EVENT_AXIS_X) + deltaX); coords.setAxisValue(AMOTION_EVENT_AXIS_Y, coords.getAxisValue(AMOTION_EVENT_AXIS_Y) + deltaY); // 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); 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, mButtonState, /* pointerCount= */ 1, mFingerProps.data(), mFakeFingerCoords.data(), xCursorPosition, yCursorPosition)); Loading
services/inputflinger/tests/GestureConverter_test.cpp +6 −6 Original line number Diff line number Diff line Loading @@ -244,7 +244,7 @@ TEST_F(GestureConverterTest, Scroll) { InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); Gesture startGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, 10); Gesture startGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -10); std::list<NotifyArgs> args = converter.handleGesture(downTime, READ_TIME, startGesture); ASSERT_EQ(2u, args.size()); Loading @@ -261,7 +261,7 @@ TEST_F(GestureConverterTest, Scroll) { WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE), WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER))); Gesture continueGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, 5); Gesture continueGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -5); args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, continueGesture); ASSERT_EQ(1u, args.size()); ASSERT_THAT(std::get<NotifyMotionArgs>(args.front()), Loading Loading @@ -289,7 +289,7 @@ TEST_F(GestureConverterTest, Scroll_Rotated) { GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); converter.setOrientation(ui::ROTATION_90); Gesture startGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, 10); Gesture startGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -10); std::list<NotifyArgs> args = converter.handleGesture(downTime, READ_TIME, startGesture); ASSERT_EQ(2u, args.size()); Loading @@ -306,7 +306,7 @@ TEST_F(GestureConverterTest, Scroll_Rotated) { WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE), WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER))); Gesture continueGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, 5); Gesture continueGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -5); args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, continueGesture); ASSERT_EQ(1u, args.size()); ASSERT_THAT(std::get<NotifyMotionArgs>(args.front()), Loading @@ -332,10 +332,10 @@ TEST_F(GestureConverterTest, Scroll_ClearsClassificationAndOffsetsAfterGesture) InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); Gesture startGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, 10); Gesture startGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -10); std::list<NotifyArgs> args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, startGesture); Gesture continueGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, 5); Gesture continueGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -5); args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, continueGesture); Gesture flingGesture(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 1, 1, Loading