summaryrefslogtreecommitdiff
path: root/libs/input/Input.cpp
diff options
context:
space:
mode:
author Prabir Pradhan <prabirmsp@google.com> 2022-12-21 19:51:18 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2022-12-21 19:51:18 +0000
commita91efe00996bb025da011f0eb4dedca2516745f9 (patch)
tree35e3829b4148932f9abf18753b4e5cd723a94101 /libs/input/Input.cpp
parent030a3fb0cc943e18b28b8b88d10ae122581c6f85 (diff)
parent64fd520f4ad9c34639389bfd8f0d50d78581f0d4 (diff)
Merge changes If7b0026a,Ibfb6d2ab,I403a686c,I15b5fa66
* changes: TouchInputMapper: Remove the concept of coverage calibration TouchInputMapper: Use ui::Transform to calculate orientation angles TouchInputMapper: Perform physical frame hit test in rotated display space TouchInputMapper: Use ui::Transform to "cook" raw input coordinates
Diffstat (limited to 'libs/input/Input.cpp')
-rw-r--r--libs/input/Input.cpp38
1 files changed, 19 insertions, 19 deletions
diff --git a/libs/input/Input.cpp b/libs/input/Input.cpp
index 9e8ebf30c5..d893cb99ba 100644
--- a/libs/input/Input.cpp
+++ b/libs/input/Input.cpp
@@ -46,25 +46,6 @@ namespace android {
namespace {
-float transformAngle(const ui::Transform& transform, float angleRadians) {
- // Construct and transform a vector oriented at the specified clockwise angle from vertical.
- // Coordinate system: down is increasing Y, right is increasing X.
- float x = sinf(angleRadians);
- float y = -cosf(angleRadians);
- vec2 transformedPoint = transform.transform(x, y);
-
- // Determine how the origin is transformed by the matrix so that we
- // can transform orientation vectors.
- const vec2 origin = transform.transform(0, 0);
-
- transformedPoint.x -= origin.x;
- transformedPoint.y -= origin.y;
-
- // Derive the transformed vector's clockwise angle from vertical.
- // The return value of atan2f is in range [-pi, pi] which conforms to the orientation API.
- return atan2f(transformedPoint.x, -transformedPoint.y);
-}
-
bool shouldDisregardTransformation(uint32_t source) {
// Do not apply any transformations to axes from joysticks, touchpads, or relative mice.
return isFromSource(source, AINPUT_SOURCE_CLASS_JOYSTICK) ||
@@ -172,6 +153,25 @@ vec2 transformWithoutTranslation(const ui::Transform& transform, const vec2& xy)
return transformedXy - transformedOrigin;
}
+float transformAngle(const ui::Transform& transform, float angleRadians) {
+ // Construct and transform a vector oriented at the specified clockwise angle from vertical.
+ // Coordinate system: down is increasing Y, right is increasing X.
+ float x = sinf(angleRadians);
+ float y = -cosf(angleRadians);
+ vec2 transformedPoint = transform.transform(x, y);
+
+ // Determine how the origin is transformed by the matrix so that we
+ // can transform orientation vectors.
+ const vec2 origin = transform.transform(0, 0);
+
+ transformedPoint.x -= origin.x;
+ transformedPoint.y -= origin.y;
+
+ // Derive the transformed vector's clockwise angle from vertical.
+ // The return value of atan2f is in range [-pi, pi] which conforms to the orientation API.
+ return atan2f(transformedPoint.x, -transformedPoint.y);
+}
+
const char* inputEventTypeToString(int32_t type) {
switch (type) {
case AINPUT_EVENT_TYPE_KEY: {