Loading services/inputflinger/reader/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -71,6 +71,7 @@ cc_defaults { "libstatslog", "libui", "libutils", "PlatformProperties", ], static_libs: [ "libc++fs", Loading services/inputflinger/reader/mapper/MultiTouchInputMapper.cpp +15 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,8 @@ #include "MultiTouchInputMapper.h" #include <android/sysprop/InputProperties.sysprop.h> namespace android { // --- Constants --- Loading Loading @@ -309,6 +311,10 @@ void MultiTouchInputMapper::syncTouch(nsecs_t when, RawState* outState) { outPointer.toolType = AMOTION_EVENT_TOOL_TYPE_FINGER; } } if (shouldSimulateStylusWithTouch() && outPointer.toolType == AMOTION_EVENT_TOOL_TYPE_FINGER) { outPointer.toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS; } bool isHovering = mTouchButtonAccumulator.getToolType() != AMOTION_EVENT_TOOL_TYPE_MOUSE && (mTouchButtonAccumulator.isHovering() || Loading Loading @@ -385,7 +391,15 @@ void MultiTouchInputMapper::configureRawPointerAxes() { } bool MultiTouchInputMapper::hasStylus() const { return mMultiTouchMotionAccumulator.hasStylus() || mTouchButtonAccumulator.hasStylus(); return mMultiTouchMotionAccumulator.hasStylus() || mTouchButtonAccumulator.hasStylus() || shouldSimulateStylusWithTouch(); } bool MultiTouchInputMapper::shouldSimulateStylusWithTouch() const { static const bool SIMULATE_STYLUS_WITH_TOUCH = sysprop::InputProperties::simulate_stylus_with_touch().value_or(false); return SIMULATE_STYLUS_WITH_TOUCH && mParameters.deviceType == Parameters::DeviceType::TOUCH_SCREEN; } } // namespace android services/inputflinger/reader/mapper/MultiTouchInputMapper.h +8 −0 Original line number Diff line number Diff line Loading @@ -104,6 +104,14 @@ protected: bool hasStylus() const override; private: // simulate_stylus_with_touch is a debug mode that converts all finger pointers reported by this // mapper's touchscreen into stylus pointers, and adds SOURCE_STYLUS to the input device. // It is used to simulate stylus events for debugging and testing on a device that does not // support styluses. It can be enabled using // "adb shell setprop persist.debug.input.simulate_stylus_with_touch true", // and requires a reboot to take effect. inline bool shouldSimulateStylusWithTouch() const; // If the slot is in use, return the bit id. Return std::nullopt otherwise. std::optional<int32_t> getActiveBitId(const MultiTouchMotionAccumulator::Slot& inSlot); MultiTouchMotionAccumulator mMultiTouchMotionAccumulator; Loading Loading
services/inputflinger/reader/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -71,6 +71,7 @@ cc_defaults { "libstatslog", "libui", "libutils", "PlatformProperties", ], static_libs: [ "libc++fs", Loading
services/inputflinger/reader/mapper/MultiTouchInputMapper.cpp +15 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,8 @@ #include "MultiTouchInputMapper.h" #include <android/sysprop/InputProperties.sysprop.h> namespace android { // --- Constants --- Loading Loading @@ -309,6 +311,10 @@ void MultiTouchInputMapper::syncTouch(nsecs_t when, RawState* outState) { outPointer.toolType = AMOTION_EVENT_TOOL_TYPE_FINGER; } } if (shouldSimulateStylusWithTouch() && outPointer.toolType == AMOTION_EVENT_TOOL_TYPE_FINGER) { outPointer.toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS; } bool isHovering = mTouchButtonAccumulator.getToolType() != AMOTION_EVENT_TOOL_TYPE_MOUSE && (mTouchButtonAccumulator.isHovering() || Loading Loading @@ -385,7 +391,15 @@ void MultiTouchInputMapper::configureRawPointerAxes() { } bool MultiTouchInputMapper::hasStylus() const { return mMultiTouchMotionAccumulator.hasStylus() || mTouchButtonAccumulator.hasStylus(); return mMultiTouchMotionAccumulator.hasStylus() || mTouchButtonAccumulator.hasStylus() || shouldSimulateStylusWithTouch(); } bool MultiTouchInputMapper::shouldSimulateStylusWithTouch() const { static const bool SIMULATE_STYLUS_WITH_TOUCH = sysprop::InputProperties::simulate_stylus_with_touch().value_or(false); return SIMULATE_STYLUS_WITH_TOUCH && mParameters.deviceType == Parameters::DeviceType::TOUCH_SCREEN; } } // namespace android
services/inputflinger/reader/mapper/MultiTouchInputMapper.h +8 −0 Original line number Diff line number Diff line Loading @@ -104,6 +104,14 @@ protected: bool hasStylus() const override; private: // simulate_stylus_with_touch is a debug mode that converts all finger pointers reported by this // mapper's touchscreen into stylus pointers, and adds SOURCE_STYLUS to the input device. // It is used to simulate stylus events for debugging and testing on a device that does not // support styluses. It can be enabled using // "adb shell setprop persist.debug.input.simulate_stylus_with_touch true", // and requires a reboot to take effect. inline bool shouldSimulateStylusWithTouch() const; // If the slot is in use, return the bit id. Return std::nullopt otherwise. std::optional<int32_t> getActiveBitId(const MultiTouchMotionAccumulator::Slot& inSlot); MultiTouchMotionAccumulator mMultiTouchMotionAccumulator; Loading