Loading include/ui/Input.h +46 −13 Original line number Diff line number Diff line Loading @@ -156,14 +156,6 @@ enum { POLICY_FLAG_PASS_TO_USER = 0x40000000, }; /* * Button state. */ enum { // Primary button pressed (left mouse button). BUTTON_STATE_PRIMARY = 1 << 0, }; /* * Describes the basic configuration of input devices that are present. */ Loading Loading @@ -234,6 +226,29 @@ private: void tooManyAxes(int axis); }; /* * Pointer property data. */ struct PointerProperties { // The id of the pointer. int32_t id; // The pointer tool type. int32_t toolType; inline void clear() { id = -1; toolType = 0; } bool operator==(const PointerProperties& other) const; inline bool operator!=(const PointerProperties& other) const { return !(*this == other); } void copyFrom(const PointerProperties& other); }; /* * Input events. */ Loading Loading @@ -346,6 +361,8 @@ public: inline void setMetaState(int32_t metaState) { mMetaState = metaState; } inline int32_t getButtonState() const { return mButtonState; } inline float getXOffset() const { return mXOffset; } inline float getYOffset() const { return mYOffset; } Loading @@ -356,9 +373,21 @@ public: inline nsecs_t getDownTime() const { return mDownTime; } inline size_t getPointerCount() const { return mPointerIds.size(); } inline void setDownTime(nsecs_t downTime) { mDownTime = downTime; } inline size_t getPointerCount() const { return mPointerProperties.size(); } inline int32_t getPointerId(size_t pointerIndex) const { return mPointerIds[pointerIndex]; } inline const PointerProperties* getPointerProperties(size_t pointerIndex) const { return &mPointerProperties[pointerIndex]; } inline int32_t getPointerId(size_t pointerIndex) const { return mPointerProperties[pointerIndex].id; } inline int32_t getToolType(size_t pointerIndex) const { return mPointerProperties[pointerIndex].toolType; } inline nsecs_t getEventTime() const { return mSampleEventTimes[getHistorySize()]; } Loading Loading @@ -490,6 +519,7 @@ public: int32_t flags, int32_t edgeFlags, int32_t metaState, int32_t buttonState, float xOffset, float yOffset, float xPrecision, Loading @@ -497,7 +527,7 @@ public: nsecs_t downTime, nsecs_t eventTime, size_t pointerCount, const int32_t* pointerIds, const PointerProperties* pointerProperties, const PointerCoords* pointerCoords); void copyFrom(const MotionEvent* other, bool keepHistory); Loading @@ -523,7 +553,9 @@ public: } // Low-level accessors. inline const int32_t* getPointerIds() const { return mPointerIds.array(); } inline const PointerProperties* getPointerProperties() const { return mPointerProperties.array(); } inline const nsecs_t* getSampleEventTimes() const { return mSampleEventTimes.array(); } inline const PointerCoords* getSamplePointerCoords() const { return mSamplePointerCoords.array(); Loading @@ -534,12 +566,13 @@ protected: int32_t mFlags; int32_t mEdgeFlags; int32_t mMetaState; int32_t mButtonState; float mXOffset; float mYOffset; float mXPrecision; float mYPrecision; nsecs_t mDownTime; Vector<int32_t> mPointerIds; Vector<PointerProperties> mPointerProperties; Vector<nsecs_t> mSampleEventTimes; Vector<PointerCoords> mSamplePointerCoords; }; Loading include/ui/InputTransport.h +4 −2 Original line number Diff line number Diff line Loading @@ -136,6 +136,7 @@ struct InputMessage { int32_t action; int32_t flags; int32_t metaState; int32_t buttonState; int32_t edgeFlags; nsecs_t downTime; float xOffset; Loading @@ -143,7 +144,7 @@ struct InputMessage { float xPrecision; float yPrecision; size_t pointerCount; int32_t pointerIds[MAX_POINTERS]; PointerProperties pointerProperties[MAX_POINTERS]; size_t sampleCount; SampleData sampleData[0]; // variable length } motion; Loading Loading @@ -221,6 +222,7 @@ public: int32_t flags, int32_t edgeFlags, int32_t metaState, int32_t buttonState, float xOffset, float yOffset, float xPrecision, Loading @@ -228,7 +230,7 @@ public: nsecs_t downTime, nsecs_t eventTime, size_t pointerCount, const int32_t* pointerIds, const PointerProperties* pointerProperties, const PointerCoords* pointerCoords); /* Appends a motion sample to a motion event unless already consumed. Loading libs/ui/Input.cpp +34 −11 Original line number Diff line number Diff line Loading @@ -373,6 +373,19 @@ void PointerCoords::copyFrom(const PointerCoords& other) { } // --- PointerProperties --- bool PointerProperties::operator==(const PointerProperties& other) const { return id == other.id && toolType == other.toolType; } void PointerProperties::copyFrom(const PointerProperties& other) { id = other.id; toolType = other.toolType; } // --- MotionEvent --- void MotionEvent::initialize( Loading @@ -382,6 +395,7 @@ void MotionEvent::initialize( int32_t flags, int32_t edgeFlags, int32_t metaState, int32_t buttonState, float xOffset, float yOffset, float xPrecision, Loading @@ -389,20 +403,21 @@ void MotionEvent::initialize( nsecs_t downTime, nsecs_t eventTime, size_t pointerCount, const int32_t* pointerIds, const PointerProperties* pointerProperties, const PointerCoords* pointerCoords) { InputEvent::initialize(deviceId, source); mAction = action; mFlags = flags; mEdgeFlags = edgeFlags; mMetaState = metaState; mButtonState = buttonState; mXOffset = xOffset; mYOffset = yOffset; mXPrecision = xPrecision; mYPrecision = yPrecision; mDownTime = downTime; mPointerIds.clear(); mPointerIds.appendArray(pointerIds, pointerCount); mPointerProperties.clear(); mPointerProperties.appendArray(pointerProperties, pointerCount); mSampleEventTimes.clear(); mSamplePointerCoords.clear(); addSample(eventTime, pointerCoords); Loading @@ -414,12 +429,13 @@ void MotionEvent::copyFrom(const MotionEvent* other, bool keepHistory) { mFlags = other->mFlags; mEdgeFlags = other->mEdgeFlags; mMetaState = other->mMetaState; mButtonState = other->mButtonState; mXOffset = other->mXOffset; mYOffset = other->mYOffset; mXPrecision = other->mXPrecision; mYPrecision = other->mYPrecision; mDownTime = other->mDownTime; mPointerIds = other->mPointerIds; mPointerProperties = other->mPointerProperties; if (keepHistory) { mSampleEventTimes = other->mSampleEventTimes; Loading Loading @@ -484,9 +500,9 @@ float MotionEvent::getHistoricalAxisValue(int32_t axis, size_t pointerIndex, } ssize_t MotionEvent::findPointerIndex(int32_t pointerId) const { size_t pointerCount = mPointerIds.size(); size_t pointerCount = mPointerProperties.size(); for (size_t i = 0; i < pointerCount; i++) { if (mPointerIds.itemAt(i) == pointerId) { if (mPointerProperties.itemAt(i).id == pointerId) { return i; } } Loading Loading @@ -583,21 +599,25 @@ status_t MotionEvent::readFromParcel(Parcel* parcel) { mFlags = parcel->readInt32(); mEdgeFlags = parcel->readInt32(); mMetaState = parcel->readInt32(); mButtonState = parcel->readInt32(); mXOffset = parcel->readFloat(); mYOffset = parcel->readFloat(); mXPrecision = parcel->readFloat(); mYPrecision = parcel->readFloat(); mDownTime = parcel->readInt64(); mPointerIds.clear(); mPointerIds.setCapacity(pointerCount); mPointerProperties.clear(); mPointerProperties.setCapacity(pointerCount); mSampleEventTimes.clear(); mSampleEventTimes.setCapacity(sampleCount); mSamplePointerCoords.clear(); mSamplePointerCoords.setCapacity(sampleCount * pointerCount); for (size_t i = 0; i < pointerCount; i++) { mPointerIds.push(parcel->readInt32()); mPointerProperties.push(); PointerProperties& properties = mPointerProperties.editTop(); properties.id = parcel->readInt32(); properties.toolType = parcel->readInt32(); } while (sampleCount-- > 0) { Loading @@ -614,7 +634,7 @@ status_t MotionEvent::readFromParcel(Parcel* parcel) { } status_t MotionEvent::writeToParcel(Parcel* parcel) const { size_t pointerCount = mPointerIds.size(); size_t pointerCount = mPointerProperties.size(); size_t sampleCount = mSampleEventTimes.size(); parcel->writeInt32(pointerCount); Loading @@ -626,6 +646,7 @@ status_t MotionEvent::writeToParcel(Parcel* parcel) const { parcel->writeInt32(mFlags); parcel->writeInt32(mEdgeFlags); parcel->writeInt32(mMetaState); parcel->writeInt32(mButtonState); parcel->writeFloat(mXOffset); parcel->writeFloat(mYOffset); parcel->writeFloat(mXPrecision); Loading @@ -633,7 +654,9 @@ status_t MotionEvent::writeToParcel(Parcel* parcel) const { parcel->writeInt64(mDownTime); for (size_t i = 0; i < pointerCount; i++) { parcel->writeInt32(mPointerIds.itemAt(i)); const PointerProperties& properties = mPointerProperties.itemAt(i); parcel->writeInt32(properties.id); parcel->writeInt32(properties.toolType); } const PointerCoords* pc = mSamplePointerCoords.array(); Loading libs/ui/InputTransport.cpp +10 −6 Original line number Diff line number Diff line Loading @@ -366,6 +366,7 @@ status_t InputPublisher::publishMotionEvent( int32_t flags, int32_t edgeFlags, int32_t metaState, int32_t buttonState, float xOffset, float yOffset, float xPrecision, Loading @@ -373,16 +374,17 @@ status_t InputPublisher::publishMotionEvent( nsecs_t downTime, nsecs_t eventTime, size_t pointerCount, const int32_t* pointerIds, const PointerProperties* pointerProperties, const PointerCoords* pointerCoords) { #if DEBUG_TRANSPORT_ACTIONS LOGD("channel '%s' publisher ~ publishMotionEvent: deviceId=%d, source=0x%x, " "action=0x%x, flags=0x%x, edgeFlags=0x%x, metaState=0x%x, xOffset=%f, yOffset=%f, " "action=0x%x, flags=0x%x, edgeFlags=0x%x, metaState=0x%x, buttonState=0x%x, " "xOffset=%f, yOffset=%f, " "xPrecision=%f, yPrecision=%f, downTime=%lld, eventTime=%lld, " "pointerCount=%d", mChannel->getName().string(), deviceId, source, action, flags, edgeFlags, metaState, xOffset, yOffset, xPrecision, yPrecision, downTime, eventTime, pointerCount); deviceId, source, action, flags, edgeFlags, metaState, buttonState, xOffset, yOffset, xPrecision, yPrecision, downTime, eventTime, pointerCount); #endif if (pointerCount > MAX_POINTERS || pointerCount < 1) { Loading @@ -400,6 +402,7 @@ status_t InputPublisher::publishMotionEvent( mSharedMessage->motion.flags = flags; mSharedMessage->motion.edgeFlags = edgeFlags; mSharedMessage->motion.metaState = metaState; mSharedMessage->motion.buttonState = buttonState; mSharedMessage->motion.xOffset = xOffset; mSharedMessage->motion.yOffset = yOffset; mSharedMessage->motion.xPrecision = xPrecision; Loading @@ -411,7 +414,7 @@ status_t InputPublisher::publishMotionEvent( mSharedMessage->motion.sampleData[0].eventTime = eventTime; for (size_t i = 0; i < pointerCount; i++) { mSharedMessage->motion.pointerIds[i] = pointerIds[i]; mSharedMessage->motion.pointerProperties[i].copyFrom(pointerProperties[i]); mSharedMessage->motion.sampleData[0].coords[i].copyFrom(pointerCoords[i]); } Loading Loading @@ -694,6 +697,7 @@ void InputConsumer::populateMotionEvent(MotionEvent* motionEvent) const { mSharedMessage->motion.flags, mSharedMessage->motion.edgeFlags, mSharedMessage->motion.metaState, mSharedMessage->motion.buttonState, mSharedMessage->motion.xOffset, mSharedMessage->motion.yOffset, mSharedMessage->motion.xPrecision, Loading @@ -701,7 +705,7 @@ void InputConsumer::populateMotionEvent(MotionEvent* motionEvent) const { mSharedMessage->motion.downTime, mSharedMessage->motion.sampleData[0].eventTime, mSharedMessage->motion.pointerCount, mSharedMessage->motion.pointerIds, mSharedMessage->motion.pointerProperties, mSharedMessage->motion.sampleData[0].coords); size_t sampleCount = mSharedMessage->motion.sampleCount; Loading libs/ui/tests/InputEvent_test.cpp +18 −7 Original line number Diff line number Diff line Loading @@ -232,7 +232,14 @@ const float MotionEventTest::X_OFFSET = 1.0f; const float MotionEventTest::Y_OFFSET = 1.1f; void MotionEventTest::initializeEventWithHistory(MotionEvent* event) { int32_t pointerIds[] = { 1, 2 }; PointerProperties pointerProperties[2]; pointerProperties[0].clear(); pointerProperties[0].id = 1; pointerProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_FINGER; pointerProperties[1].clear(); pointerProperties[1].id = 2; pointerProperties[1].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS; PointerCoords pointerCoords[2]; pointerCoords[0].clear(); pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_X, 10); Loading @@ -256,10 +263,10 @@ void MotionEventTest::initializeEventWithHistory(MotionEvent* event) { pointerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_ORIENTATION, 28); event->initialize(2, AINPUT_SOURCE_TOUCHSCREEN, AMOTION_EVENT_ACTION_MOVE, AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED, AMOTION_EVENT_EDGE_FLAG_TOP, AMETA_ALT_ON, AMOTION_EVENT_EDGE_FLAG_TOP, AMETA_ALT_ON, AMOTION_EVENT_BUTTON_PRIMARY, X_OFFSET, Y_OFFSET, 2.0f, 2.1f, ARBITRARY_DOWN_TIME, ARBITRARY_EVENT_TIME, 2, pointerIds, pointerCoords); 2, pointerProperties, pointerCoords); pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_X, 110); pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_Y, 111); Loading Loading @@ -311,6 +318,7 @@ void MotionEventTest::assertEqualsEventWithHistory(const MotionEvent* event) { ASSERT_EQ(AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED, event->getFlags()); ASSERT_EQ(AMOTION_EVENT_EDGE_FLAG_TOP, event->getEdgeFlags()); ASSERT_EQ(AMETA_ALT_ON, event->getMetaState()); ASSERT_EQ(AMOTION_EVENT_BUTTON_PRIMARY, event->getButtonState()); ASSERT_EQ(X_OFFSET, event->getXOffset()); ASSERT_EQ(Y_OFFSET, event->getYOffset()); ASSERT_EQ(2.0f, event->getXPrecision()); Loading @@ -319,7 +327,9 @@ void MotionEventTest::assertEqualsEventWithHistory(const MotionEvent* event) { ASSERT_EQ(2U, event->getPointerCount()); ASSERT_EQ(1, event->getPointerId(0)); ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, event->getToolType(0)); ASSERT_EQ(2, event->getPointerId(1)); ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_STYLUS, event->getToolType(1)); ASSERT_EQ(2U, event->getHistorySize()); Loading Loading @@ -534,19 +544,20 @@ TEST_F(MotionEventTest, Transform) { const float ROTATION = ARC * 2; const size_t pointerCount = 11; int pointerIds[pointerCount]; PointerProperties pointerProperties[pointerCount]; PointerCoords pointerCoords[pointerCount]; for (size_t i = 0; i < pointerCount; i++) { float angle = float(i * ARC * PI_180); pointerIds[i] = i; pointerProperties[i].clear(); pointerProperties[i].id = i; pointerCoords[i].clear(); pointerCoords[i].setAxisValue(AMOTION_EVENT_AXIS_X, sinf(angle) * RADIUS + 3); pointerCoords[i].setAxisValue(AMOTION_EVENT_AXIS_Y, -cosf(angle) * RADIUS + 2); pointerCoords[i].setAxisValue(AMOTION_EVENT_AXIS_ORIENTATION, angle); } MotionEvent event; event.initialize(0, 0, AMOTION_EVENT_ACTION_MOVE, 0, 0, 0, 0, 0, 0, 0, 0, 0, pointerCount, pointerIds, pointerCoords); event.initialize(0, 0, AMOTION_EVENT_ACTION_MOVE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, pointerCount, pointerProperties, pointerCoords); float originalRawX = 0 + 3; float originalRawY = -RADIUS + 2; Loading Loading
include/ui/Input.h +46 −13 Original line number Diff line number Diff line Loading @@ -156,14 +156,6 @@ enum { POLICY_FLAG_PASS_TO_USER = 0x40000000, }; /* * Button state. */ enum { // Primary button pressed (left mouse button). BUTTON_STATE_PRIMARY = 1 << 0, }; /* * Describes the basic configuration of input devices that are present. */ Loading Loading @@ -234,6 +226,29 @@ private: void tooManyAxes(int axis); }; /* * Pointer property data. */ struct PointerProperties { // The id of the pointer. int32_t id; // The pointer tool type. int32_t toolType; inline void clear() { id = -1; toolType = 0; } bool operator==(const PointerProperties& other) const; inline bool operator!=(const PointerProperties& other) const { return !(*this == other); } void copyFrom(const PointerProperties& other); }; /* * Input events. */ Loading Loading @@ -346,6 +361,8 @@ public: inline void setMetaState(int32_t metaState) { mMetaState = metaState; } inline int32_t getButtonState() const { return mButtonState; } inline float getXOffset() const { return mXOffset; } inline float getYOffset() const { return mYOffset; } Loading @@ -356,9 +373,21 @@ public: inline nsecs_t getDownTime() const { return mDownTime; } inline size_t getPointerCount() const { return mPointerIds.size(); } inline void setDownTime(nsecs_t downTime) { mDownTime = downTime; } inline size_t getPointerCount() const { return mPointerProperties.size(); } inline int32_t getPointerId(size_t pointerIndex) const { return mPointerIds[pointerIndex]; } inline const PointerProperties* getPointerProperties(size_t pointerIndex) const { return &mPointerProperties[pointerIndex]; } inline int32_t getPointerId(size_t pointerIndex) const { return mPointerProperties[pointerIndex].id; } inline int32_t getToolType(size_t pointerIndex) const { return mPointerProperties[pointerIndex].toolType; } inline nsecs_t getEventTime() const { return mSampleEventTimes[getHistorySize()]; } Loading Loading @@ -490,6 +519,7 @@ public: int32_t flags, int32_t edgeFlags, int32_t metaState, int32_t buttonState, float xOffset, float yOffset, float xPrecision, Loading @@ -497,7 +527,7 @@ public: nsecs_t downTime, nsecs_t eventTime, size_t pointerCount, const int32_t* pointerIds, const PointerProperties* pointerProperties, const PointerCoords* pointerCoords); void copyFrom(const MotionEvent* other, bool keepHistory); Loading @@ -523,7 +553,9 @@ public: } // Low-level accessors. inline const int32_t* getPointerIds() const { return mPointerIds.array(); } inline const PointerProperties* getPointerProperties() const { return mPointerProperties.array(); } inline const nsecs_t* getSampleEventTimes() const { return mSampleEventTimes.array(); } inline const PointerCoords* getSamplePointerCoords() const { return mSamplePointerCoords.array(); Loading @@ -534,12 +566,13 @@ protected: int32_t mFlags; int32_t mEdgeFlags; int32_t mMetaState; int32_t mButtonState; float mXOffset; float mYOffset; float mXPrecision; float mYPrecision; nsecs_t mDownTime; Vector<int32_t> mPointerIds; Vector<PointerProperties> mPointerProperties; Vector<nsecs_t> mSampleEventTimes; Vector<PointerCoords> mSamplePointerCoords; }; Loading
include/ui/InputTransport.h +4 −2 Original line number Diff line number Diff line Loading @@ -136,6 +136,7 @@ struct InputMessage { int32_t action; int32_t flags; int32_t metaState; int32_t buttonState; int32_t edgeFlags; nsecs_t downTime; float xOffset; Loading @@ -143,7 +144,7 @@ struct InputMessage { float xPrecision; float yPrecision; size_t pointerCount; int32_t pointerIds[MAX_POINTERS]; PointerProperties pointerProperties[MAX_POINTERS]; size_t sampleCount; SampleData sampleData[0]; // variable length } motion; Loading Loading @@ -221,6 +222,7 @@ public: int32_t flags, int32_t edgeFlags, int32_t metaState, int32_t buttonState, float xOffset, float yOffset, float xPrecision, Loading @@ -228,7 +230,7 @@ public: nsecs_t downTime, nsecs_t eventTime, size_t pointerCount, const int32_t* pointerIds, const PointerProperties* pointerProperties, const PointerCoords* pointerCoords); /* Appends a motion sample to a motion event unless already consumed. Loading
libs/ui/Input.cpp +34 −11 Original line number Diff line number Diff line Loading @@ -373,6 +373,19 @@ void PointerCoords::copyFrom(const PointerCoords& other) { } // --- PointerProperties --- bool PointerProperties::operator==(const PointerProperties& other) const { return id == other.id && toolType == other.toolType; } void PointerProperties::copyFrom(const PointerProperties& other) { id = other.id; toolType = other.toolType; } // --- MotionEvent --- void MotionEvent::initialize( Loading @@ -382,6 +395,7 @@ void MotionEvent::initialize( int32_t flags, int32_t edgeFlags, int32_t metaState, int32_t buttonState, float xOffset, float yOffset, float xPrecision, Loading @@ -389,20 +403,21 @@ void MotionEvent::initialize( nsecs_t downTime, nsecs_t eventTime, size_t pointerCount, const int32_t* pointerIds, const PointerProperties* pointerProperties, const PointerCoords* pointerCoords) { InputEvent::initialize(deviceId, source); mAction = action; mFlags = flags; mEdgeFlags = edgeFlags; mMetaState = metaState; mButtonState = buttonState; mXOffset = xOffset; mYOffset = yOffset; mXPrecision = xPrecision; mYPrecision = yPrecision; mDownTime = downTime; mPointerIds.clear(); mPointerIds.appendArray(pointerIds, pointerCount); mPointerProperties.clear(); mPointerProperties.appendArray(pointerProperties, pointerCount); mSampleEventTimes.clear(); mSamplePointerCoords.clear(); addSample(eventTime, pointerCoords); Loading @@ -414,12 +429,13 @@ void MotionEvent::copyFrom(const MotionEvent* other, bool keepHistory) { mFlags = other->mFlags; mEdgeFlags = other->mEdgeFlags; mMetaState = other->mMetaState; mButtonState = other->mButtonState; mXOffset = other->mXOffset; mYOffset = other->mYOffset; mXPrecision = other->mXPrecision; mYPrecision = other->mYPrecision; mDownTime = other->mDownTime; mPointerIds = other->mPointerIds; mPointerProperties = other->mPointerProperties; if (keepHistory) { mSampleEventTimes = other->mSampleEventTimes; Loading Loading @@ -484,9 +500,9 @@ float MotionEvent::getHistoricalAxisValue(int32_t axis, size_t pointerIndex, } ssize_t MotionEvent::findPointerIndex(int32_t pointerId) const { size_t pointerCount = mPointerIds.size(); size_t pointerCount = mPointerProperties.size(); for (size_t i = 0; i < pointerCount; i++) { if (mPointerIds.itemAt(i) == pointerId) { if (mPointerProperties.itemAt(i).id == pointerId) { return i; } } Loading Loading @@ -583,21 +599,25 @@ status_t MotionEvent::readFromParcel(Parcel* parcel) { mFlags = parcel->readInt32(); mEdgeFlags = parcel->readInt32(); mMetaState = parcel->readInt32(); mButtonState = parcel->readInt32(); mXOffset = parcel->readFloat(); mYOffset = parcel->readFloat(); mXPrecision = parcel->readFloat(); mYPrecision = parcel->readFloat(); mDownTime = parcel->readInt64(); mPointerIds.clear(); mPointerIds.setCapacity(pointerCount); mPointerProperties.clear(); mPointerProperties.setCapacity(pointerCount); mSampleEventTimes.clear(); mSampleEventTimes.setCapacity(sampleCount); mSamplePointerCoords.clear(); mSamplePointerCoords.setCapacity(sampleCount * pointerCount); for (size_t i = 0; i < pointerCount; i++) { mPointerIds.push(parcel->readInt32()); mPointerProperties.push(); PointerProperties& properties = mPointerProperties.editTop(); properties.id = parcel->readInt32(); properties.toolType = parcel->readInt32(); } while (sampleCount-- > 0) { Loading @@ -614,7 +634,7 @@ status_t MotionEvent::readFromParcel(Parcel* parcel) { } status_t MotionEvent::writeToParcel(Parcel* parcel) const { size_t pointerCount = mPointerIds.size(); size_t pointerCount = mPointerProperties.size(); size_t sampleCount = mSampleEventTimes.size(); parcel->writeInt32(pointerCount); Loading @@ -626,6 +646,7 @@ status_t MotionEvent::writeToParcel(Parcel* parcel) const { parcel->writeInt32(mFlags); parcel->writeInt32(mEdgeFlags); parcel->writeInt32(mMetaState); parcel->writeInt32(mButtonState); parcel->writeFloat(mXOffset); parcel->writeFloat(mYOffset); parcel->writeFloat(mXPrecision); Loading @@ -633,7 +654,9 @@ status_t MotionEvent::writeToParcel(Parcel* parcel) const { parcel->writeInt64(mDownTime); for (size_t i = 0; i < pointerCount; i++) { parcel->writeInt32(mPointerIds.itemAt(i)); const PointerProperties& properties = mPointerProperties.itemAt(i); parcel->writeInt32(properties.id); parcel->writeInt32(properties.toolType); } const PointerCoords* pc = mSamplePointerCoords.array(); Loading
libs/ui/InputTransport.cpp +10 −6 Original line number Diff line number Diff line Loading @@ -366,6 +366,7 @@ status_t InputPublisher::publishMotionEvent( int32_t flags, int32_t edgeFlags, int32_t metaState, int32_t buttonState, float xOffset, float yOffset, float xPrecision, Loading @@ -373,16 +374,17 @@ status_t InputPublisher::publishMotionEvent( nsecs_t downTime, nsecs_t eventTime, size_t pointerCount, const int32_t* pointerIds, const PointerProperties* pointerProperties, const PointerCoords* pointerCoords) { #if DEBUG_TRANSPORT_ACTIONS LOGD("channel '%s' publisher ~ publishMotionEvent: deviceId=%d, source=0x%x, " "action=0x%x, flags=0x%x, edgeFlags=0x%x, metaState=0x%x, xOffset=%f, yOffset=%f, " "action=0x%x, flags=0x%x, edgeFlags=0x%x, metaState=0x%x, buttonState=0x%x, " "xOffset=%f, yOffset=%f, " "xPrecision=%f, yPrecision=%f, downTime=%lld, eventTime=%lld, " "pointerCount=%d", mChannel->getName().string(), deviceId, source, action, flags, edgeFlags, metaState, xOffset, yOffset, xPrecision, yPrecision, downTime, eventTime, pointerCount); deviceId, source, action, flags, edgeFlags, metaState, buttonState, xOffset, yOffset, xPrecision, yPrecision, downTime, eventTime, pointerCount); #endif if (pointerCount > MAX_POINTERS || pointerCount < 1) { Loading @@ -400,6 +402,7 @@ status_t InputPublisher::publishMotionEvent( mSharedMessage->motion.flags = flags; mSharedMessage->motion.edgeFlags = edgeFlags; mSharedMessage->motion.metaState = metaState; mSharedMessage->motion.buttonState = buttonState; mSharedMessage->motion.xOffset = xOffset; mSharedMessage->motion.yOffset = yOffset; mSharedMessage->motion.xPrecision = xPrecision; Loading @@ -411,7 +414,7 @@ status_t InputPublisher::publishMotionEvent( mSharedMessage->motion.sampleData[0].eventTime = eventTime; for (size_t i = 0; i < pointerCount; i++) { mSharedMessage->motion.pointerIds[i] = pointerIds[i]; mSharedMessage->motion.pointerProperties[i].copyFrom(pointerProperties[i]); mSharedMessage->motion.sampleData[0].coords[i].copyFrom(pointerCoords[i]); } Loading Loading @@ -694,6 +697,7 @@ void InputConsumer::populateMotionEvent(MotionEvent* motionEvent) const { mSharedMessage->motion.flags, mSharedMessage->motion.edgeFlags, mSharedMessage->motion.metaState, mSharedMessage->motion.buttonState, mSharedMessage->motion.xOffset, mSharedMessage->motion.yOffset, mSharedMessage->motion.xPrecision, Loading @@ -701,7 +705,7 @@ void InputConsumer::populateMotionEvent(MotionEvent* motionEvent) const { mSharedMessage->motion.downTime, mSharedMessage->motion.sampleData[0].eventTime, mSharedMessage->motion.pointerCount, mSharedMessage->motion.pointerIds, mSharedMessage->motion.pointerProperties, mSharedMessage->motion.sampleData[0].coords); size_t sampleCount = mSharedMessage->motion.sampleCount; Loading
libs/ui/tests/InputEvent_test.cpp +18 −7 Original line number Diff line number Diff line Loading @@ -232,7 +232,14 @@ const float MotionEventTest::X_OFFSET = 1.0f; const float MotionEventTest::Y_OFFSET = 1.1f; void MotionEventTest::initializeEventWithHistory(MotionEvent* event) { int32_t pointerIds[] = { 1, 2 }; PointerProperties pointerProperties[2]; pointerProperties[0].clear(); pointerProperties[0].id = 1; pointerProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_FINGER; pointerProperties[1].clear(); pointerProperties[1].id = 2; pointerProperties[1].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS; PointerCoords pointerCoords[2]; pointerCoords[0].clear(); pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_X, 10); Loading @@ -256,10 +263,10 @@ void MotionEventTest::initializeEventWithHistory(MotionEvent* event) { pointerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_ORIENTATION, 28); event->initialize(2, AINPUT_SOURCE_TOUCHSCREEN, AMOTION_EVENT_ACTION_MOVE, AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED, AMOTION_EVENT_EDGE_FLAG_TOP, AMETA_ALT_ON, AMOTION_EVENT_EDGE_FLAG_TOP, AMETA_ALT_ON, AMOTION_EVENT_BUTTON_PRIMARY, X_OFFSET, Y_OFFSET, 2.0f, 2.1f, ARBITRARY_DOWN_TIME, ARBITRARY_EVENT_TIME, 2, pointerIds, pointerCoords); 2, pointerProperties, pointerCoords); pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_X, 110); pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_Y, 111); Loading Loading @@ -311,6 +318,7 @@ void MotionEventTest::assertEqualsEventWithHistory(const MotionEvent* event) { ASSERT_EQ(AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED, event->getFlags()); ASSERT_EQ(AMOTION_EVENT_EDGE_FLAG_TOP, event->getEdgeFlags()); ASSERT_EQ(AMETA_ALT_ON, event->getMetaState()); ASSERT_EQ(AMOTION_EVENT_BUTTON_PRIMARY, event->getButtonState()); ASSERT_EQ(X_OFFSET, event->getXOffset()); ASSERT_EQ(Y_OFFSET, event->getYOffset()); ASSERT_EQ(2.0f, event->getXPrecision()); Loading @@ -319,7 +327,9 @@ void MotionEventTest::assertEqualsEventWithHistory(const MotionEvent* event) { ASSERT_EQ(2U, event->getPointerCount()); ASSERT_EQ(1, event->getPointerId(0)); ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, event->getToolType(0)); ASSERT_EQ(2, event->getPointerId(1)); ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_STYLUS, event->getToolType(1)); ASSERT_EQ(2U, event->getHistorySize()); Loading Loading @@ -534,19 +544,20 @@ TEST_F(MotionEventTest, Transform) { const float ROTATION = ARC * 2; const size_t pointerCount = 11; int pointerIds[pointerCount]; PointerProperties pointerProperties[pointerCount]; PointerCoords pointerCoords[pointerCount]; for (size_t i = 0; i < pointerCount; i++) { float angle = float(i * ARC * PI_180); pointerIds[i] = i; pointerProperties[i].clear(); pointerProperties[i].id = i; pointerCoords[i].clear(); pointerCoords[i].setAxisValue(AMOTION_EVENT_AXIS_X, sinf(angle) * RADIUS + 3); pointerCoords[i].setAxisValue(AMOTION_EVENT_AXIS_Y, -cosf(angle) * RADIUS + 2); pointerCoords[i].setAxisValue(AMOTION_EVENT_AXIS_ORIENTATION, angle); } MotionEvent event; event.initialize(0, 0, AMOTION_EVENT_ACTION_MOVE, 0, 0, 0, 0, 0, 0, 0, 0, 0, pointerCount, pointerIds, pointerCoords); event.initialize(0, 0, AMOTION_EVENT_ACTION_MOVE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, pointerCount, pointerProperties, pointerCoords); float originalRawX = 0 + 3; float originalRawY = -RADIUS + 2; Loading