Add a debug flag to convert all touch pointers to stylus
When the sysprop `persist.debug.input.simulate_stylus_with_touch`
is set, all pointers reported by TouchInputMapper will be converted
into stylus pointers.
Changes to the flag will require a reboot to take effect.
Bug: 217741685
Test: manual
Change-Id: I7723be718354872509a9e85beda10acdbe25dd48
diff --git a/services/inputflinger/reader/mapper/MultiTouchInputMapper.cpp b/services/inputflinger/reader/mapper/MultiTouchInputMapper.cpp
index ff3a592..41a8426 100644
--- a/services/inputflinger/reader/mapper/MultiTouchInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/MultiTouchInputMapper.cpp
@@ -18,6 +18,8 @@
#include "MultiTouchInputMapper.h"
+#include <android/sysprop/InputProperties.sysprop.h>
+
namespace android {
// --- Constants ---
@@ -309,6 +311,10 @@
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() ||
@@ -385,7 +391,15 @@
}
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