Loading services/inputflinger/reader/mapper/TouchpadInputMapper.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -206,6 +206,11 @@ uint32_t TouchpadInputMapper::getSources() const { return AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_TOUCHPAD; } void TouchpadInputMapper::populateDeviceInfo(InputDeviceInfo* info) { InputMapper::populateDeviceInfo(info); mGestureConverter.populateMotionRanges(*info); } void TouchpadInputMapper::dump(std::string& dump) { dump += INDENT2 "Touchpad Input Mapper:\n"; dump += INDENT3 "Gesture converter:\n"; Loading services/inputflinger/reader/mapper/TouchpadInputMapper.h +1 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ public: ~TouchpadInputMapper(); uint32_t getSources() const override; void populateDeviceInfo(InputDeviceInfo* deviceInfo) override; void dump(std::string& dump) override; [[nodiscard]] std::list<NotifyArgs> configure(nsecs_t when, Loading services/inputflinger/reader/mapper/gestures/GestureConverter.cpp +25 −5 Original line number Diff line number Diff line Loading @@ -16,13 +16,14 @@ #include "gestures/GestureConverter.h" #include <optional> #include <sstream> #include <android-base/stringprintf.h> #include <android/input.h> #include <ftl/enum.h> #include <linux/input-event-codes.h> #include <log/log_main.h> #include <ui/FloatRect.h> #include "TouchCursorInputMapperCommon.h" #include "input/Input.h" Loading Loading @@ -75,6 +76,28 @@ void GestureConverter::reset() { mButtonState = 0; } void GestureConverter::populateMotionRanges(InputDeviceInfo& info) const { info.addMotionRange(AMOTION_EVENT_AXIS_PRESSURE, SOURCE, 0.0f, 1.0f, 0, 0, 0); // TODO(b/259547750): set this using the raw axis ranges from the touchpad when pointer capture // is enabled. if (std::optional<FloatRect> rect = mPointerController->getBounds(); rect.has_value()) { info.addMotionRange(AMOTION_EVENT_AXIS_X, SOURCE, rect->left, rect->right, 0, 0, 0); info.addMotionRange(AMOTION_EVENT_AXIS_Y, SOURCE, rect->top, rect->bottom, 0, 0, 0); } info.addMotionRange(AMOTION_EVENT_AXIS_GESTURE_X_OFFSET, SOURCE, -1.0f, 1.0f, 0, 0, 0); info.addMotionRange(AMOTION_EVENT_AXIS_GESTURE_Y_OFFSET, SOURCE, -1.0f, 1.0f, 0, 0, 0); // The other axes that can be reported don't have ranges that are easy to define. RELATIVE_X/Y // and GESTURE_SCROLL_X/Y_DISTANCE are the result of acceleration functions being applied to // finger movements, so their maximum values can't simply be derived from the size of the // touchpad. GESTURE_PINCH_SCALE_FACTOR's maximum value depends on the minimum finger separation // that the pad can report, which cannot be determined from its raw axis information. (Assuming // a minimum finger separation of 1 unit would let us calculate a theoretical maximum, but it // would be orders of magnitude too high, so probably not very useful.) } std::list<NotifyArgs> GestureConverter::handleGesture(nsecs_t when, nsecs_t readTime, const Gesture& gesture) { switch (gesture.type) { Loading Loading @@ -418,10 +441,7 @@ NotifyMotionArgs GestureConverter::makeMotionArgs(nsecs_t when, nsecs_t readTime const PointerProperties* pointerProperties, const PointerCoords* pointerCoords, float xCursorPosition, float yCursorPosition) { // TODO(b/260226362): consider what the appropriate source for these events is. const uint32_t source = AINPUT_SOURCE_MOUSE; return NotifyMotionArgs(mReaderContext.getNextId(), when, readTime, mDeviceId, source, return NotifyMotionArgs(mReaderContext.getNextId(), when, readTime, mDeviceId, SOURCE, mPointerController->getDisplayId(), /* policyFlags= */ POLICY_FLAG_WAKE, action, /* actionButton= */ actionButton, /* flags= */ 0, mReaderContext.getGlobalMetaState(), buttonState, Loading services/inputflinger/reader/mapper/gestures/GestureConverter.h +6 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ #include <memory> #include <PointerControllerInterface.h> #include <android/input.h> #include <utils/Timers.h> #include "EventHub.h" Loading @@ -45,6 +46,8 @@ public: void setOrientation(ui::Rotation orientation) { mOrientation = orientation; } void reset(); void populateMotionRanges(InputDeviceInfo& info) const; [[nodiscard]] std::list<NotifyArgs> handleGesture(nsecs_t when, nsecs_t readTime, const Gesture& gesture); Loading Loading @@ -98,6 +101,9 @@ private: {.id = 3, .toolType = AMOTION_EVENT_TOOL_TYPE_FINGER}, }}; std::array<PointerCoords, MAX_FAKE_FINGERS> mFakeFingerCoords = {}; // TODO(b/260226362): consider what the appropriate source for these events is. static constexpr uint32_t SOURCE = AINPUT_SOURCE_MOUSE; }; } // namespace android Loading
services/inputflinger/reader/mapper/TouchpadInputMapper.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -206,6 +206,11 @@ uint32_t TouchpadInputMapper::getSources() const { return AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_TOUCHPAD; } void TouchpadInputMapper::populateDeviceInfo(InputDeviceInfo* info) { InputMapper::populateDeviceInfo(info); mGestureConverter.populateMotionRanges(*info); } void TouchpadInputMapper::dump(std::string& dump) { dump += INDENT2 "Touchpad Input Mapper:\n"; dump += INDENT3 "Gesture converter:\n"; Loading
services/inputflinger/reader/mapper/TouchpadInputMapper.h +1 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ public: ~TouchpadInputMapper(); uint32_t getSources() const override; void populateDeviceInfo(InputDeviceInfo* deviceInfo) override; void dump(std::string& dump) override; [[nodiscard]] std::list<NotifyArgs> configure(nsecs_t when, Loading
services/inputflinger/reader/mapper/gestures/GestureConverter.cpp +25 −5 Original line number Diff line number Diff line Loading @@ -16,13 +16,14 @@ #include "gestures/GestureConverter.h" #include <optional> #include <sstream> #include <android-base/stringprintf.h> #include <android/input.h> #include <ftl/enum.h> #include <linux/input-event-codes.h> #include <log/log_main.h> #include <ui/FloatRect.h> #include "TouchCursorInputMapperCommon.h" #include "input/Input.h" Loading Loading @@ -75,6 +76,28 @@ void GestureConverter::reset() { mButtonState = 0; } void GestureConverter::populateMotionRanges(InputDeviceInfo& info) const { info.addMotionRange(AMOTION_EVENT_AXIS_PRESSURE, SOURCE, 0.0f, 1.0f, 0, 0, 0); // TODO(b/259547750): set this using the raw axis ranges from the touchpad when pointer capture // is enabled. if (std::optional<FloatRect> rect = mPointerController->getBounds(); rect.has_value()) { info.addMotionRange(AMOTION_EVENT_AXIS_X, SOURCE, rect->left, rect->right, 0, 0, 0); info.addMotionRange(AMOTION_EVENT_AXIS_Y, SOURCE, rect->top, rect->bottom, 0, 0, 0); } info.addMotionRange(AMOTION_EVENT_AXIS_GESTURE_X_OFFSET, SOURCE, -1.0f, 1.0f, 0, 0, 0); info.addMotionRange(AMOTION_EVENT_AXIS_GESTURE_Y_OFFSET, SOURCE, -1.0f, 1.0f, 0, 0, 0); // The other axes that can be reported don't have ranges that are easy to define. RELATIVE_X/Y // and GESTURE_SCROLL_X/Y_DISTANCE are the result of acceleration functions being applied to // finger movements, so their maximum values can't simply be derived from the size of the // touchpad. GESTURE_PINCH_SCALE_FACTOR's maximum value depends on the minimum finger separation // that the pad can report, which cannot be determined from its raw axis information. (Assuming // a minimum finger separation of 1 unit would let us calculate a theoretical maximum, but it // would be orders of magnitude too high, so probably not very useful.) } std::list<NotifyArgs> GestureConverter::handleGesture(nsecs_t when, nsecs_t readTime, const Gesture& gesture) { switch (gesture.type) { Loading Loading @@ -418,10 +441,7 @@ NotifyMotionArgs GestureConverter::makeMotionArgs(nsecs_t when, nsecs_t readTime const PointerProperties* pointerProperties, const PointerCoords* pointerCoords, float xCursorPosition, float yCursorPosition) { // TODO(b/260226362): consider what the appropriate source for these events is. const uint32_t source = AINPUT_SOURCE_MOUSE; return NotifyMotionArgs(mReaderContext.getNextId(), when, readTime, mDeviceId, source, return NotifyMotionArgs(mReaderContext.getNextId(), when, readTime, mDeviceId, SOURCE, mPointerController->getDisplayId(), /* policyFlags= */ POLICY_FLAG_WAKE, action, /* actionButton= */ actionButton, /* flags= */ 0, mReaderContext.getGlobalMetaState(), buttonState, Loading
services/inputflinger/reader/mapper/gestures/GestureConverter.h +6 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ #include <memory> #include <PointerControllerInterface.h> #include <android/input.h> #include <utils/Timers.h> #include "EventHub.h" Loading @@ -45,6 +46,8 @@ public: void setOrientation(ui::Rotation orientation) { mOrientation = orientation; } void reset(); void populateMotionRanges(InputDeviceInfo& info) const; [[nodiscard]] std::list<NotifyArgs> handleGesture(nsecs_t when, nsecs_t readTime, const Gesture& gesture); Loading Loading @@ -98,6 +101,9 @@ private: {.id = 3, .toolType = AMOTION_EVENT_TOOL_TYPE_FINGER}, }}; std::array<PointerCoords, MAX_FAKE_FINGERS> mFakeFingerCoords = {}; // TODO(b/260226362): consider what the appropriate source for these events is. static constexpr uint32_t SOURCE = AINPUT_SOURCE_MOUSE; }; } // namespace android