Per-window input rotation: Let InputReader use un-rotated coordinates
InputReader works in the rotated coordinate system that is oriented with
the display's orientation obtained through DisplayViewport.
When per-window input rotation is enabled, we let InputReader work in
the un-rotated coordinate space as if the display's orientation is
always ROTATION_0. Since the input rotation is included in the
per-window transform, the output from InputReader should not be rotated.
This requires two changes in InputReader:
1. When setting an orientation to use for an InputDevice, we do the
opposite of the default behavior: If a device was being rotated before,
we don't rotate it anymore, and vice-versa. We invert the direction of
the rotation so that when the coordinates are rotated by the per-window
transform, they appear as expected.
2. Since PointerController should still use the rotated coordinates, we
need to convert all display coordinates going in/out of
PointerController.
Bug: 179274888
Test: test touch, mouse, and touchpad input in all four orientations
using a test app and the PointerLocationView.
Change-Id: I1eec8ba1d72355564a79cdf1c14c88828124e8a4
diff --git a/services/inputflinger/reader/mapper/TouchInputMapper.h b/services/inputflinger/reader/mapper/TouchInputMapper.h
index 9b84ed5..5146299 100644
--- a/services/inputflinger/reader/mapper/TouchInputMapper.h
+++ b/services/inputflinger/reader/mapper/TouchInputMapper.h
@@ -776,6 +776,14 @@
const char* modeToString(DeviceMode deviceMode);
void rotateAndScale(float& x, float& y);
+
+ // Wrapper methods for interfacing with PointerController. These are used to convert points
+ // between the coordinate spaces used by InputReader and PointerController, if they differ.
+ void moveMouseCursor(float dx, float dy) const;
+ std::pair<float, float> getMouseCursorPosition() const;
+ void setMouseCursorPosition(float x, float y) const;
+ void setTouchSpots(const PointerCoords* spotCoords, const uint32_t* spotIdToIndex,
+ BitSet32 spotIdBits, int32_t displayId);
};
} // namespace android