Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a91efe00 authored by Prabir Pradhan's avatar Prabir Pradhan Committed by Android (Google) Code Review
Browse files

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
parents 030a3fb0 64fd520f
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -203,6 +203,13 @@ class Parcel;
 */
vec2 transformWithoutTranslation(const ui::Transform& transform, const vec2& xy);

/*
 * Transform an angle on the x-y plane. An angle of 0 radians corresponds to "north" or
 * pointing upwards in the negative Y direction, a positive angle points towards the right, and a
 * negative angle points towards the left.
 */
float transformAngle(const ui::Transform& transform, float angleRadians);

const char* inputEventTypeToString(int32_t type);

std::string inputEventSourceToString(int32_t source);
+19 −19
Original line number Diff line number Diff line
@@ -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: {
+78 −212

File changed.

Preview size limit exceeded, changes collapsed.

+13 −16

File changed.

Preview size limit exceeded, changes collapsed.

+59 −5

File changed.

Preview size limit exceeded, changes collapsed.