Disable new touchpad stack for Sony gamepads
The touchpads on the Sony DualShock 4 and DualSense gamepads do not work
with the gestures library, for a reason that is currently unknown. This
is tracked in b/246587538, but while we wait for that to be fixed just
check for them by vendor and product ID, and fall back to the old stack.
This shouldn't really be a few IDs hard-coded into `InputDevice` — it
should be an input device configuration property, but since those are
currently only loaded in the configuration stage that will require a
larger change.
This is a second attempt after ag/21019000 caused a hwasan failure,
which we believe was due to calling getDeviceInfo() when not all mappers
had been configured. Getting the device ID from contextPtr instead fixes
this issue.
Bug: 251196347, 246587538
Test: `setprop persist.input.touchpad.gestures_library.enabled true`,
connect gamepads, do a pinch gesture, confirm that touch spots
show on screen (which doesn't happen in the new stack)
Test: `setprop persist.input.touchpad.gestures_library.enabled true`,
run android.hardware.input.cts.tests.SonyDualshock4BluetoothTest
Change-Id: Ie843a7552ae31db640a847a9a108a66f6363730e
diff --git a/services/inputflinger/reader/InputDevice.cpp b/services/inputflinger/reader/InputDevice.cpp
index 9bd50f7..bd41fa5 100644
--- a/services/inputflinger/reader/InputDevice.cpp
+++ b/services/inputflinger/reader/InputDevice.cpp
@@ -210,8 +210,14 @@
// Touchscreens and touchpad devices.
static const bool ENABLE_TOUCHPAD_GESTURES_LIBRARY =
sysprop::InputProperties::enable_touchpad_gestures_library().value_or(false);
+ // TODO(b/246587538): Fix the new touchpad stack for Sony DualShock 4 (5c4, 9cc) and DualSense
+ // (ce6) touchpads, or at least load this setting from the IDC file.
+ const InputDeviceIdentifier& identifier = contextPtr->getDeviceIdentifier();
+ const bool isSonyGamepadTouchpad = identifier.vendor == 0x054c &&
+ (identifier.product == 0x05c4 || identifier.product == 0x09cc ||
+ identifier.product == 0x0ce6);
if (ENABLE_TOUCHPAD_GESTURES_LIBRARY && classes.test(InputDeviceClass::TOUCHPAD) &&
- classes.test(InputDeviceClass::TOUCH_MT)) {
+ classes.test(InputDeviceClass::TOUCH_MT) && !isSonyGamepadTouchpad) {
mappers.push_back(std::make_unique<TouchpadInputMapper>(*contextPtr));
} else if (classes.test(InputDeviceClass::TOUCH_MT)) {
mappers.push_back(std::make_unique<MultiTouchInputMapper>(*contextPtr));