InputDispatcher: Remove transform only for joysticks and touchpads
This partially reverts commit bd52771be41ae18f9fda43301eeeab89021d4248.
Since window transforms can encode rotations, we need window transforms
for some non-pointer events such as relative mouse events. Joysticks and
touchapds are an exception to this, because neither expect their
reported values to be rotated. For this reason, we only remove window
transformations in InputDispatcher for these two types of devices.
The bug b/182325974 is now solved by selectively applying window
translations for pointer events in MotionEvent.
Bug: 182325974
Bug: 179274888
Test: atest inputflinger_tests
Test: manual with test app
Change-Id: I68a0c87f24a9ddea14e3078ad894410210e42b4a
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index 05efcf6..070ac0a 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -321,11 +321,11 @@
int32_t inputTargetFlags) {
if (eventEntry->type == EventEntry::Type::MOTION) {
const MotionEntry& motionEntry = static_cast<const MotionEntry&>(*eventEntry);
- if ((motionEntry.source & AINPUT_SOURCE_CLASS_POINTER) == 0) {
+ if ((motionEntry.source & AINPUT_SOURCE_CLASS_JOYSTICK) ||
+ (motionEntry.source & AINPUT_SOURCE_CLASS_POSITION)) {
const ui::Transform identityTransform;
- // Use identity transform for events that are not pointer events because their axes
- // values do not represent on-screen coordinates, so they should not have any window
- // transformations applied to them.
+ // Use identity transform for joystick and position-based (touchpad) events because they
+ // don't depend on the window transform.
return std::make_unique<DispatchEntry>(eventEntry, inputTargetFlags, identityTransform,
1.0f /*globalScaleFactor*/,
inputTarget.displaySize);