Loading services/inputflinger/reader/mapper/MultiTouchInputMapper.cpp +14 −9 Original line number Diff line number Diff line Loading @@ -131,7 +131,7 @@ void MultiTouchInputMapper::syncTouch(nsecs_t when, RawState* outState) { bumpGeneration(); } } if (shouldSimulateStylusWithTouch() && outPointer.toolType == ToolType::FINGER) { if (mShouldSimulateStylusWithTouch && outPointer.toolType == ToolType::FINGER) { outPointer.toolType = ToolType::STYLUS; } Loading Loading @@ -177,6 +177,18 @@ void MultiTouchInputMapper::syncTouch(nsecs_t when, RawState* outState) { mMultiTouchMotionAccumulator.finishSync(); } std::list<NotifyArgs> MultiTouchInputMapper::reconfigure(nsecs_t when, const InputReaderConfiguration& config, ConfigurationChanges changes) { const bool simulateStylusWithTouch = sysprop::InputProperties::simulate_stylus_with_touch().value_or(false); if (simulateStylusWithTouch != mShouldSimulateStylusWithTouch) { mShouldSimulateStylusWithTouch = simulateStylusWithTouch; bumpGeneration(); } return TouchInputMapper::reconfigure(when, config, changes); } void MultiTouchInputMapper::configureRawPointerAxes() { TouchInputMapper::configureRawPointerAxes(); Loading Loading @@ -211,14 +223,7 @@ void MultiTouchInputMapper::configureRawPointerAxes() { bool MultiTouchInputMapper::hasStylus() const { return mStylusMtToolSeen || 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; mShouldSimulateStylusWithTouch; } } // namespace android services/inputflinger/reader/mapper/MultiTouchInputMapper.h +12 −7 Original line number Diff line number Diff line Loading @@ -32,6 +32,9 @@ public: [[nodiscard]] std::list<NotifyArgs> reset(nsecs_t when) override; [[nodiscard]] std::list<NotifyArgs> process(const RawEvent* rawEvent) override; [[nodiscard]] std::list<NotifyArgs> reconfigure(nsecs_t when, const InputReaderConfiguration& config, ConfigurationChanges changes) override; protected: void syncTouch(nsecs_t when, RawState* outState) override; Loading @@ -41,13 +44,6 @@ protected: private: explicit MultiTouchInputMapper(InputDeviceContext& deviceContext, const InputReaderConfiguration& readerConfig); // 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); Loading @@ -58,6 +54,15 @@ private: int32_t mPointerTrackingIdMap[MAX_POINTER_ID + 1]; bool mStylusMtToolSeen{false}; // 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 debug.input.simulate_stylus_with_touch true". // After enabling, the touchscreen will need to be reconfigured. A reconfiguration usually // happens when turning the screen on/off or by rotating the device orientation. bool mShouldSimulateStylusWithTouch{false}; }; } // namespace android Loading
services/inputflinger/reader/mapper/MultiTouchInputMapper.cpp +14 −9 Original line number Diff line number Diff line Loading @@ -131,7 +131,7 @@ void MultiTouchInputMapper::syncTouch(nsecs_t when, RawState* outState) { bumpGeneration(); } } if (shouldSimulateStylusWithTouch() && outPointer.toolType == ToolType::FINGER) { if (mShouldSimulateStylusWithTouch && outPointer.toolType == ToolType::FINGER) { outPointer.toolType = ToolType::STYLUS; } Loading Loading @@ -177,6 +177,18 @@ void MultiTouchInputMapper::syncTouch(nsecs_t when, RawState* outState) { mMultiTouchMotionAccumulator.finishSync(); } std::list<NotifyArgs> MultiTouchInputMapper::reconfigure(nsecs_t when, const InputReaderConfiguration& config, ConfigurationChanges changes) { const bool simulateStylusWithTouch = sysprop::InputProperties::simulate_stylus_with_touch().value_or(false); if (simulateStylusWithTouch != mShouldSimulateStylusWithTouch) { mShouldSimulateStylusWithTouch = simulateStylusWithTouch; bumpGeneration(); } return TouchInputMapper::reconfigure(when, config, changes); } void MultiTouchInputMapper::configureRawPointerAxes() { TouchInputMapper::configureRawPointerAxes(); Loading Loading @@ -211,14 +223,7 @@ void MultiTouchInputMapper::configureRawPointerAxes() { bool MultiTouchInputMapper::hasStylus() const { return mStylusMtToolSeen || 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; mShouldSimulateStylusWithTouch; } } // namespace android
services/inputflinger/reader/mapper/MultiTouchInputMapper.h +12 −7 Original line number Diff line number Diff line Loading @@ -32,6 +32,9 @@ public: [[nodiscard]] std::list<NotifyArgs> reset(nsecs_t when) override; [[nodiscard]] std::list<NotifyArgs> process(const RawEvent* rawEvent) override; [[nodiscard]] std::list<NotifyArgs> reconfigure(nsecs_t when, const InputReaderConfiguration& config, ConfigurationChanges changes) override; protected: void syncTouch(nsecs_t when, RawState* outState) override; Loading @@ -41,13 +44,6 @@ protected: private: explicit MultiTouchInputMapper(InputDeviceContext& deviceContext, const InputReaderConfiguration& readerConfig); // 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); Loading @@ -58,6 +54,15 @@ private: int32_t mPointerTrackingIdMap[MAX_POINTER_ID + 1]; bool mStylusMtToolSeen{false}; // 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 debug.input.simulate_stylus_with_touch true". // After enabling, the touchscreen will need to be reconfigured. A reconfiguration usually // happens when turning the screen on/off or by rotating the device orientation. bool mShouldSimulateStylusWithTouch{false}; }; } // namespace android