diff options
author | Jeff Brown <jeffbrown@google.com> | 2011-05-13 12:14:27 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-05-13 12:14:27 -0700 |
commit | 65f47d88107b2e34e4bab1f5208bff3f73ce4e8a (patch) | |
tree | f78d55c1374dc07e571eed2c1ad638c5fd4ba325 /include | |
parent | 5684d6bc7e768e905d163cd94b92c977f15c6d89 (diff) | |
parent | fe9f8ab03a63b1037f07dd85799fbea80ec6adaa (diff) | |
download | frameworks_base-65f47d88107b2e34e4bab1f5208bff3f73ce4e8a.zip frameworks_base-65f47d88107b2e34e4bab1f5208bff3f73ce4e8a.tar.gz frameworks_base-65f47d88107b2e34e4bab1f5208bff3f73ce4e8a.tar.bz2 |
Merge "Add initial API for stylus and mouse buttons."
Diffstat (limited to 'include')
-rw-r--r-- | include/ui/Input.h | 59 | ||||
-rw-r--r-- | include/ui/InputTransport.h | 6 |
2 files changed, 50 insertions, 15 deletions
diff --git a/include/ui/Input.h b/include/ui/Input.h index c7ebf56..ba1c6b4 100644 --- a/include/ui/Input.h +++ b/include/ui/Input.h @@ -157,14 +157,6 @@ enum { }; /* - * Button state. - */ -enum { - // Primary button pressed (left mouse button). - BUTTON_STATE_PRIMARY = 1 << 0, -}; - -/* * Describes the basic configuration of input devices that are present. */ struct InputConfiguration { @@ -235,6 +227,29 @@ private: }; /* + * 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. */ class InputEvent : public AInputEvent { @@ -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; } @@ -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()]; } @@ -490,6 +519,7 @@ public: int32_t flags, int32_t edgeFlags, int32_t metaState, + int32_t buttonState, float xOffset, float yOffset, float xPrecision, @@ -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); @@ -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(); @@ -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; }; diff --git a/include/ui/InputTransport.h b/include/ui/InputTransport.h index 119db81..95e4447 100644 --- a/include/ui/InputTransport.h +++ b/include/ui/InputTransport.h @@ -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; @@ -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; @@ -221,6 +222,7 @@ public: int32_t flags, int32_t edgeFlags, int32_t metaState, + int32_t buttonState, float xOffset, float yOffset, float xPrecision, @@ -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. |