TouchInputMapper: Use ui::Transform to "cook" raw input coordinates
Instead of manually scaling and rotating the input device's raw
coordinates to the un-rotated display's coordinate space, we use a
transfomation matrix as a helper.
This change also exposed some bugs, where the tests were enforcing
incorrect behavior.
Bug: 236798672
Test: atest inputflinger_tests
Test: manual with touchscreen and stylus
Change-Id: I15b5fa6696720736ff1a598f88a4bc7067644cba
diff --git a/services/inputflinger/reader/mapper/TouchInputMapper.h b/services/inputflinger/reader/mapper/TouchInputMapper.h
index 50a7ea3..45a4962 100644
--- a/services/inputflinger/reader/mapper/TouchInputMapper.h
+++ b/services/inputflinger/reader/mapper/TouchInputMapper.h
@@ -419,6 +419,10 @@
// orientation, so it will depend on whether the device is orientation aware.
ui::Rotation mInputDeviceOrientation;
+ // The transform that maps the input device's raw coordinate space to the un-rotated display's
+ // coordinate space. InputReader generates events in the un-rotated display's coordinate space.
+ ui::Transform mRawToDisplay;
+
// Translation and scaling factors, orientation-independent.
float mXScale;
float mXPrecision;
@@ -813,7 +817,7 @@
static void assignPointerIds(const RawState& last, RawState& current);
- void rotateAndScale(float& x, float& y) const;
+ ui::Transform computeInputTransform() const;
void configureDeviceType();
};