Loading include/input/Input.h +3 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ */ #include <android/input.h> #include <math.h> #include <stdint.h> #include <utils/BitSet.h> #include <utils/KeyedVector.h> Loading Loading @@ -476,6 +477,8 @@ public: float getYCursorPosition() const; static inline bool isValidCursorPosition(float x, float y) { return !isnan(x) && !isnan(y); } inline nsecs_t getDownTime() const { return mDownTime; } inline void setDownTime(nsecs_t downTime) { mDownTime = downTime; } Loading libs/input/Input.cpp +1 −2 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ #define LOG_TAG "Input" //#define LOG_NDEBUG 0 #include <math.h> #include <limits.h> #include <input/Input.h> Loading Loading @@ -434,7 +433,7 @@ void MotionEvent::transform(const float matrix[9]) { transformPoint(matrix, 0, 0, &originX, &originY); // Apply the transformation to cursor position. if (!isnan(mXCursorPosition) && !isnan(mYCursorPosition)) { if (isValidCursorPosition(mXCursorPosition, mYCursorPosition)) { float x = mXCursorPosition + oldXOffset; float y = mYCursorPosition + oldYOffset; transformPoint(matrix, x, y, &x, &y); Loading libs/input/tests/InputEvent_test.cpp +7 −3 Original line number Diff line number Diff line Loading @@ -603,9 +603,13 @@ TEST_F(MotionEventTest, Transform) { ASSERT_NEAR(tanf(angle), tanf(event.getOrientation(i)), 0.1); } // Check cursor positions. ASSERT_NEAR(sinf(PI_180 * (90 + ROTATION)) * RADIUS, event.getXCursorPosition(), 0.001); ASSERT_NEAR(-cosf(PI_180 * (90 + ROTATION)) * RADIUS, event.getYCursorPosition(), 0.001); // Check cursor positions. The original cursor position is at (3 + RADIUS, 2), where the center // of the circle is (3, 2), so the cursor position is to the right of the center of the circle. // The choice of triangular functions in this test defines the angle of rotation clockwise // relative to the y-axis. Therefore the cursor position's angle is 90 degrees. Here we swap the // triangular function so that we don't have to add the 90 degrees. ASSERT_NEAR(cosf(PI_180 * ROTATION) * RADIUS, event.getXCursorPosition(), 0.001); ASSERT_NEAR(sinf(PI_180 * ROTATION) * RADIUS, event.getYCursorPosition(), 0.001); // Applying the transformation should preserve the raw X and Y of the first point. ASSERT_NEAR(originalRawX, event.getRawX(0), 0.001); Loading services/inputflinger/InputDispatcher.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -2766,7 +2766,7 @@ void InputDispatcher::notifyMotion(const NotifyMotionArgs* args) { ", policyFlags=0x%x, " "action=0x%x, actionButton=0x%x, flags=0x%x, metaState=0x%x, buttonState=0x%x, " "edgeFlags=0x%x, xPrecision=%f, yPrecision=%f, xCursorPosition=%f, " "mYCursorPosition=%f, downTime=%" PRId64, "yCursorPosition=%f, downTime=%" PRId64, args->eventTime, args->deviceId, args->source, args->displayId, args->policyFlags, args->action, args->actionButton, args->flags, args->metaState, args->buttonState, args->edgeFlags, args->xPrecision, args->yPrecision, arg->xCursorPosition, Loading Loading
include/input/Input.h +3 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ */ #include <android/input.h> #include <math.h> #include <stdint.h> #include <utils/BitSet.h> #include <utils/KeyedVector.h> Loading Loading @@ -476,6 +477,8 @@ public: float getYCursorPosition() const; static inline bool isValidCursorPosition(float x, float y) { return !isnan(x) && !isnan(y); } inline nsecs_t getDownTime() const { return mDownTime; } inline void setDownTime(nsecs_t downTime) { mDownTime = downTime; } Loading
libs/input/Input.cpp +1 −2 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ #define LOG_TAG "Input" //#define LOG_NDEBUG 0 #include <math.h> #include <limits.h> #include <input/Input.h> Loading Loading @@ -434,7 +433,7 @@ void MotionEvent::transform(const float matrix[9]) { transformPoint(matrix, 0, 0, &originX, &originY); // Apply the transformation to cursor position. if (!isnan(mXCursorPosition) && !isnan(mYCursorPosition)) { if (isValidCursorPosition(mXCursorPosition, mYCursorPosition)) { float x = mXCursorPosition + oldXOffset; float y = mYCursorPosition + oldYOffset; transformPoint(matrix, x, y, &x, &y); Loading
libs/input/tests/InputEvent_test.cpp +7 −3 Original line number Diff line number Diff line Loading @@ -603,9 +603,13 @@ TEST_F(MotionEventTest, Transform) { ASSERT_NEAR(tanf(angle), tanf(event.getOrientation(i)), 0.1); } // Check cursor positions. ASSERT_NEAR(sinf(PI_180 * (90 + ROTATION)) * RADIUS, event.getXCursorPosition(), 0.001); ASSERT_NEAR(-cosf(PI_180 * (90 + ROTATION)) * RADIUS, event.getYCursorPosition(), 0.001); // Check cursor positions. The original cursor position is at (3 + RADIUS, 2), where the center // of the circle is (3, 2), so the cursor position is to the right of the center of the circle. // The choice of triangular functions in this test defines the angle of rotation clockwise // relative to the y-axis. Therefore the cursor position's angle is 90 degrees. Here we swap the // triangular function so that we don't have to add the 90 degrees. ASSERT_NEAR(cosf(PI_180 * ROTATION) * RADIUS, event.getXCursorPosition(), 0.001); ASSERT_NEAR(sinf(PI_180 * ROTATION) * RADIUS, event.getYCursorPosition(), 0.001); // Applying the transformation should preserve the raw X and Y of the first point. ASSERT_NEAR(originalRawX, event.getRawX(0), 0.001); Loading
services/inputflinger/InputDispatcher.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -2766,7 +2766,7 @@ void InputDispatcher::notifyMotion(const NotifyMotionArgs* args) { ", policyFlags=0x%x, " "action=0x%x, actionButton=0x%x, flags=0x%x, metaState=0x%x, buttonState=0x%x, " "edgeFlags=0x%x, xPrecision=%f, yPrecision=%f, xCursorPosition=%f, " "mYCursorPosition=%f, downTime=%" PRId64, "yCursorPosition=%f, downTime=%" PRId64, args->eventTime, args->deviceId, args->source, args->displayId, args->policyFlags, args->action, args->actionButton, args->flags, args->metaState, args->buttonState, args->edgeFlags, args->xPrecision, args->yPrecision, arg->xCursorPosition, Loading