summaryrefslogtreecommitdiff
path: root/include/input
diff options
context:
space:
mode:
authorPrabir Pradhan <prabirmsp@google.com>2021-08-26 12:30:32 -0700
committerPrabir Pradhan <prabirmsp@google.com>2021-09-17 04:58:55 -0700
commitb9b18509a6d0f5f074e86802b322a4fb01b43cd5 (patch)
tree879df11308da01c95b782935957cce8dcc718c6c /include/input
parentdf41c269a359e35690f8dfd234f45fd05627db29 (diff)
downloadnative-b9b18509a6d0f5f074e86802b322a4fb01b43cd5.tar.gz
Add display transform to MotionEvent for raw coords
Since input now works in display coordinates, we need to include the display projection with MotionEvent so that the getRaw API can continue to report logical display coordinates. It is also important to highlight the difference in the coordinate systems used by regular input windows and input monitors. MotionEvents coming from input monitors will always report values in unrotated logical display coordinates, because we do not yet have an API to report unrotated values in MotionEvents. Bug: 179274888 Test: presubmit Test: manual, ensure input works Change-Id: Ief3b2b31c6644beaa2f8c4b90302f441f93ab960
Diffstat (limited to 'include/input')
-rw-r--r--include/input/Input.h12
-rw-r--r--include/input/InputTransport.h29
2 files changed, 19 insertions, 22 deletions
diff --git a/include/input/Input.h b/include/input/Input.h
index f170f0fa23..d397313ab6 100644
--- a/include/input/Input.h
+++ b/include/input/Input.h
@@ -579,9 +579,7 @@ public:
void setCursorPosition(float x, float y);
- uint32_t getDisplayOrientation() const { return mDisplayOrientation; }
-
- int2 getDisplaySize() const { return {mDisplayWidth, mDisplayHeight}; }
+ ui::Transform getRawTransform() const { return mRawTransform; }
static inline bool isValidCursorPosition(float x, float y) { return !isnan(x) && !isnan(y); }
@@ -757,8 +755,8 @@ public:
int32_t flags, int32_t edgeFlags, int32_t metaState, int32_t buttonState,
MotionClassification classification, const ui::Transform& transform,
float xPrecision, float yPrecision, float rawXCursorPosition,
- float rawYCursorPosition, uint32_t displayOrientation, int32_t displayWidth,
- int32_t displayHeight, nsecs_t downTime, nsecs_t eventTime, size_t pointerCount,
+ float rawYCursorPosition, const ui::Transform& rawTransform, nsecs_t downTime,
+ nsecs_t eventTime, size_t pointerCount,
const PointerProperties* pointerProperties, const PointerCoords* pointerCoords);
void copyFrom(const MotionEvent* other, bool keepHistory);
@@ -816,9 +814,7 @@ protected:
float mYPrecision;
float mRawXCursorPosition;
float mRawYCursorPosition;
- uint32_t mDisplayOrientation;
- int32_t mDisplayWidth;
- int32_t mDisplayHeight;
+ ui::Transform mRawTransform;
nsecs_t mDownTime;
Vector<PointerProperties> mPointerProperties;
std::vector<nsecs_t> mSampleEventTimes;
diff --git a/include/input/InputTransport.h b/include/input/InputTransport.h
index 7632b30bd2..d655b28278 100644
--- a/include/input/InputTransport.h
+++ b/include/input/InputTransport.h
@@ -114,7 +114,7 @@ struct InputMessage {
struct Motion {
int32_t eventId;
- uint32_t empty1;
+ uint32_t pointerCount;
nsecs_t eventTime __attribute__((aligned(8)));
int32_t deviceId;
int32_t source;
@@ -129,20 +129,22 @@ struct InputMessage {
uint8_t empty2[3]; // 3 bytes to fill gap created by classification
int32_t edgeFlags;
nsecs_t downTime __attribute__((aligned(8)));
- float dsdx;
- float dtdx;
- float dtdy;
- float dsdy;
- float tx;
- float ty;
+ float dsdx; // Begin window transform
+ float dtdx; //
+ float dtdy; //
+ float dsdy; //
+ float tx; //
+ float ty; // End window transform
float xPrecision;
float yPrecision;
float xCursorPosition;
float yCursorPosition;
- uint32_t displayOrientation;
- int32_t displayWidth;
- int32_t displayHeight;
- uint32_t pointerCount;
+ float dsdxRaw; // Begin raw transform
+ float dtdxRaw; //
+ float dtdyRaw; //
+ float dsdyRaw; //
+ float txRaw; //
+ float tyRaw; // End raw transform
/**
* The "pointers" field must be the last field of the struct InputMessage.
* When we send the struct InputMessage across the socket, we are not
@@ -367,9 +369,8 @@ public:
int32_t metaState, int32_t buttonState,
MotionClassification classification, const ui::Transform& transform,
float xPrecision, float yPrecision, float xCursorPosition,
- float yCursorPosition, uint32_t displayOrientation,
- int32_t displayWidth, int32_t displayHeight, nsecs_t downTime,
- nsecs_t eventTime, uint32_t pointerCount,
+ float yCursorPosition, const ui::Transform& rawTransform,
+ nsecs_t downTime, nsecs_t eventTime, uint32_t pointerCount,
const PointerProperties* pointerProperties,
const PointerCoords* pointerCoords);