Loading services/inputflinger/include/InputReaderBase.h +7 −0 Original line number Diff line number Diff line Loading @@ -242,6 +242,9 @@ struct InputReaderConfiguration { // context (a.k.a. "right") clicks. bool touchpadRightClickZoneEnabled; // True to use three-finger tap as a customizable shortcut; false to use it as a middle-click. bool touchpadThreeFingerTapShortcutEnabled; // The set of currently disabled input devices. std::set<int32_t> disabledDevices; Loading Loading @@ -293,6 +296,7 @@ struct InputReaderConfiguration { touchpadTapDraggingEnabled(false), shouldNotifyTouchpadHardwareState(false), touchpadRightClickZoneEnabled(false), touchpadThreeFingerTapShortcutEnabled(false), stylusButtonMotionEventsEnabled(true), stylusPointerIconEnabled(false), mouseReverseVerticalScrollingEnabled(false), Loading Loading @@ -496,6 +500,9 @@ public: /* Sends the Info of gestures that happen on the touchpad. */ virtual void notifyTouchpadGestureInfo(GestureType type, int32_t deviceId) = 0; /* Notifies the policy that the user has performed a three-finger touchpad tap. */ virtual void notifyTouchpadThreeFingerTap() = 0; /* Gets the keyboard layout for a particular input device. */ virtual std::shared_ptr<KeyCharacterMap> getKeyboardLayoutOverlay( const InputDeviceIdentifier& identifier, Loading services/inputflinger/reader/mapper/TouchpadInputMapper.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -375,6 +375,9 @@ std::list<NotifyArgs> TouchpadInputMapper::reconfigure(nsecs_t when, mPropertyProvider.getProperty("Button Right Click Zone Enable") .setBoolValues({config.touchpadRightClickZoneEnabled}); mTouchpadHardwareStateNotificationsEnabled = config.shouldNotifyTouchpadHardwareState; mGestureConverter.setThreeFingerTapShortcutEnabled( config.touchpadThreeFingerTapShortcutEnabled); } std::list<NotifyArgs> out; if ((!changes.any() && config.pointerCaptureRequest.isEnable()) || Loading services/inputflinger/reader/mapper/gestures/GestureConverter.cpp +8 −1 Original line number Diff line number Diff line Loading @@ -261,6 +261,14 @@ std::list<NotifyArgs> GestureConverter::handleButtonsChange(nsecs_t when, nsecs_ } const uint32_t buttonsPressed = gesture.details.buttons.down; const uint32_t buttonsReleased = gesture.details.buttons.up; if (mThreeFingerTapShortcutEnabled && gesture.details.buttons.is_tap && buttonsPressed == GESTURES_BUTTON_MIDDLE && buttonsReleased == GESTURES_BUTTON_MIDDLE) { mReaderContext.getPolicy()->notifyTouchpadThreeFingerTap(); return out; } bool pointerDown = isPointerDown(mButtonState) || buttonsPressed & (GESTURES_BUTTON_LEFT | GESTURES_BUTTON_MIDDLE | GESTURES_BUTTON_RIGHT); Loading Loading @@ -291,7 +299,6 @@ std::list<NotifyArgs> GestureConverter::handleButtonsChange(nsecs_t when, nsecs_ // changes: a set of buttons going down, followed by a set of buttons going up. mButtonState = newButtonState; const uint32_t buttonsReleased = gesture.details.buttons.up; for (uint32_t button = 1; button <= GESTURES_BUTTON_FORWARD; button <<= 1) { if (buttonsReleased & button) { uint32_t actionButton = gesturesButtonToMotionEventButton(button); Loading services/inputflinger/reader/mapper/gestures/GestureConverter.h +6 −0 Original line number Diff line number Diff line Loading @@ -55,6 +55,10 @@ public: void setBoundsInLogicalDisplay(FloatRect bounds) { mBoundsInLogicalDisplay = bounds; } void setThreeFingerTapShortcutEnabled(bool enabled) { mThreeFingerTapShortcutEnabled = enabled; } void populateMotionRanges(InputDeviceInfo& info) const; [[nodiscard]] std::list<NotifyArgs> handleGesture(nsecs_t when, nsecs_t readTime, Loading Loading @@ -101,6 +105,8 @@ private: const bool mEnableFlingStop; const bool mEnableNoFocusChange; bool mThreeFingerTapShortcutEnabled; std::optional<ui::LogicalDisplayId> mDisplayId; FloatRect mBoundsInLogicalDisplay{}; ui::Rotation mOrientation = ui::ROTATION_0; Loading services/inputflinger/tests/FakeInputReaderPolicy.cpp +17 −0 Original line number Diff line number Diff line Loading @@ -80,6 +80,17 @@ void FakeInputReaderPolicy::assertTouchpadHardwareStateNotified() { ASSERT_TRUE(success) << "Timed out waiting for hardware state to be notified"; } void FakeInputReaderPolicy::assertTouchpadThreeFingerTapNotified() { std::unique_lock lock(mLock); base::ScopedLockAssertion assumeLocked(mLock); const bool success = mTouchpadThreeFingerTapNotified.wait_for(lock, WAIT_TIMEOUT, [this]() REQUIRES(mLock) { return mTouchpadThreeFingerTapHasBeenReported; }); ASSERT_TRUE(success) << "Timed out waiting for three-finger tap to be notified"; } void FakeInputReaderPolicy::clearViewports() { mViewports.clear(); mConfig.setDisplayViewports(mViewports); Loading Loading @@ -259,6 +270,12 @@ void FakeInputReaderPolicy::notifyTouchpadGestureInfo(GestureType type, int32_t std::scoped_lock lock(mLock); } void FakeInputReaderPolicy::notifyTouchpadThreeFingerTap() { std::scoped_lock lock(mLock); mTouchpadThreeFingerTapHasBeenReported = true; mTouchpadThreeFingerTapNotified.notify_all(); } std::shared_ptr<KeyCharacterMap> FakeInputReaderPolicy::getKeyboardLayoutOverlay( const InputDeviceIdentifier&, const std::optional<KeyboardLayoutInfo>) { return nullptr; Loading Loading
services/inputflinger/include/InputReaderBase.h +7 −0 Original line number Diff line number Diff line Loading @@ -242,6 +242,9 @@ struct InputReaderConfiguration { // context (a.k.a. "right") clicks. bool touchpadRightClickZoneEnabled; // True to use three-finger tap as a customizable shortcut; false to use it as a middle-click. bool touchpadThreeFingerTapShortcutEnabled; // The set of currently disabled input devices. std::set<int32_t> disabledDevices; Loading Loading @@ -293,6 +296,7 @@ struct InputReaderConfiguration { touchpadTapDraggingEnabled(false), shouldNotifyTouchpadHardwareState(false), touchpadRightClickZoneEnabled(false), touchpadThreeFingerTapShortcutEnabled(false), stylusButtonMotionEventsEnabled(true), stylusPointerIconEnabled(false), mouseReverseVerticalScrollingEnabled(false), Loading Loading @@ -496,6 +500,9 @@ public: /* Sends the Info of gestures that happen on the touchpad. */ virtual void notifyTouchpadGestureInfo(GestureType type, int32_t deviceId) = 0; /* Notifies the policy that the user has performed a three-finger touchpad tap. */ virtual void notifyTouchpadThreeFingerTap() = 0; /* Gets the keyboard layout for a particular input device. */ virtual std::shared_ptr<KeyCharacterMap> getKeyboardLayoutOverlay( const InputDeviceIdentifier& identifier, Loading
services/inputflinger/reader/mapper/TouchpadInputMapper.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -375,6 +375,9 @@ std::list<NotifyArgs> TouchpadInputMapper::reconfigure(nsecs_t when, mPropertyProvider.getProperty("Button Right Click Zone Enable") .setBoolValues({config.touchpadRightClickZoneEnabled}); mTouchpadHardwareStateNotificationsEnabled = config.shouldNotifyTouchpadHardwareState; mGestureConverter.setThreeFingerTapShortcutEnabled( config.touchpadThreeFingerTapShortcutEnabled); } std::list<NotifyArgs> out; if ((!changes.any() && config.pointerCaptureRequest.isEnable()) || Loading
services/inputflinger/reader/mapper/gestures/GestureConverter.cpp +8 −1 Original line number Diff line number Diff line Loading @@ -261,6 +261,14 @@ std::list<NotifyArgs> GestureConverter::handleButtonsChange(nsecs_t when, nsecs_ } const uint32_t buttonsPressed = gesture.details.buttons.down; const uint32_t buttonsReleased = gesture.details.buttons.up; if (mThreeFingerTapShortcutEnabled && gesture.details.buttons.is_tap && buttonsPressed == GESTURES_BUTTON_MIDDLE && buttonsReleased == GESTURES_BUTTON_MIDDLE) { mReaderContext.getPolicy()->notifyTouchpadThreeFingerTap(); return out; } bool pointerDown = isPointerDown(mButtonState) || buttonsPressed & (GESTURES_BUTTON_LEFT | GESTURES_BUTTON_MIDDLE | GESTURES_BUTTON_RIGHT); Loading Loading @@ -291,7 +299,6 @@ std::list<NotifyArgs> GestureConverter::handleButtonsChange(nsecs_t when, nsecs_ // changes: a set of buttons going down, followed by a set of buttons going up. mButtonState = newButtonState; const uint32_t buttonsReleased = gesture.details.buttons.up; for (uint32_t button = 1; button <= GESTURES_BUTTON_FORWARD; button <<= 1) { if (buttonsReleased & button) { uint32_t actionButton = gesturesButtonToMotionEventButton(button); Loading
services/inputflinger/reader/mapper/gestures/GestureConverter.h +6 −0 Original line number Diff line number Diff line Loading @@ -55,6 +55,10 @@ public: void setBoundsInLogicalDisplay(FloatRect bounds) { mBoundsInLogicalDisplay = bounds; } void setThreeFingerTapShortcutEnabled(bool enabled) { mThreeFingerTapShortcutEnabled = enabled; } void populateMotionRanges(InputDeviceInfo& info) const; [[nodiscard]] std::list<NotifyArgs> handleGesture(nsecs_t when, nsecs_t readTime, Loading Loading @@ -101,6 +105,8 @@ private: const bool mEnableFlingStop; const bool mEnableNoFocusChange; bool mThreeFingerTapShortcutEnabled; std::optional<ui::LogicalDisplayId> mDisplayId; FloatRect mBoundsInLogicalDisplay{}; ui::Rotation mOrientation = ui::ROTATION_0; Loading
services/inputflinger/tests/FakeInputReaderPolicy.cpp +17 −0 Original line number Diff line number Diff line Loading @@ -80,6 +80,17 @@ void FakeInputReaderPolicy::assertTouchpadHardwareStateNotified() { ASSERT_TRUE(success) << "Timed out waiting for hardware state to be notified"; } void FakeInputReaderPolicy::assertTouchpadThreeFingerTapNotified() { std::unique_lock lock(mLock); base::ScopedLockAssertion assumeLocked(mLock); const bool success = mTouchpadThreeFingerTapNotified.wait_for(lock, WAIT_TIMEOUT, [this]() REQUIRES(mLock) { return mTouchpadThreeFingerTapHasBeenReported; }); ASSERT_TRUE(success) << "Timed out waiting for three-finger tap to be notified"; } void FakeInputReaderPolicy::clearViewports() { mViewports.clear(); mConfig.setDisplayViewports(mViewports); Loading Loading @@ -259,6 +270,12 @@ void FakeInputReaderPolicy::notifyTouchpadGestureInfo(GestureType type, int32_t std::scoped_lock lock(mLock); } void FakeInputReaderPolicy::notifyTouchpadThreeFingerTap() { std::scoped_lock lock(mLock); mTouchpadThreeFingerTapHasBeenReported = true; mTouchpadThreeFingerTapNotified.notify_all(); } std::shared_ptr<KeyCharacterMap> FakeInputReaderPolicy::getKeyboardLayoutOverlay( const InputDeviceIdentifier&, const std::optional<KeyboardLayoutInfo>) { return nullptr; Loading