summaryrefslogtreecommitdiffstats
path: root/include/ui
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2010-06-16 01:53:36 -0700
committerJeff Brown <jeffbrown@google.com>2010-06-17 13:27:16 -0700
commitf4a4ec2063dfd28e04bbfe712f67acee4bdc8e37 (patch)
tree9d52c784ebd68acfc44a2cdb06d7cf057bba2c91 /include/ui
parente85dafb4d625cce230695127c39636a40932b313 (diff)
downloadframeworks_native-f4a4ec2063dfd28e04bbfe712f67acee4bdc8e37.zip
frameworks_native-f4a4ec2063dfd28e04bbfe712f67acee4bdc8e37.tar.gz
frameworks_native-f4a4ec2063dfd28e04bbfe712f67acee4bdc8e37.tar.bz2
Even more native input dispatch work in progress.
Added more tests. Fixed a regression in Vector. Fixed bugs in pointer tracking. Fixed a starvation issue in PollLoop when setting or removing callbacks. Fixed a couple of policy nits. Modified the internal representation of MotionEvent to be more efficient and more consistent. Added code to skip/cancel virtual key processing when there are multiple pointers down. This helps to better disambiguate virtual key presses from stray touches (such as cheek presses). Change-Id: I2a7d2cce0195afb9125b23378baa94fd2fc6671c
Diffstat (limited to 'include/ui')
-rw-r--r--include/ui/Input.h49
-rw-r--r--include/ui/InputTransport.h8
2 files changed, 44 insertions, 13 deletions
diff --git a/include/ui/Input.h b/include/ui/Input.h
index d45bfcf..92ff872 100644
--- a/include/ui/Input.h
+++ b/include/ui/Input.h
@@ -148,6 +148,9 @@ private:
int32_t mNature;
};
+/*
+ * Key events.
+ */
class KeyEvent : public InputEvent {
public:
virtual ~KeyEvent() { }
@@ -193,6 +196,9 @@ private:
nsecs_t mEventTime;
};
+/*
+ * Motion events.
+ */
class MotionEvent : public InputEvent {
public:
virtual ~MotionEvent() { }
@@ -205,6 +211,10 @@ public:
inline int32_t getMetaState() const { return mMetaState; }
+ inline float getXOffset() const { return mXOffset; }
+
+ inline float getYOffset() const { return mYOffset; }
+
inline float getXPrecision() const { return mXPrecision; }
inline float getYPrecision() const { return mYPrecision; }
@@ -217,16 +227,20 @@ public:
inline nsecs_t getEventTime() const { return mSampleEventTimes[getHistorySize()]; }
- inline float getRawX() const { return mRawX; }
+ inline float getRawX(size_t pointerIndex) const {
+ return getCurrentPointerCoords(pointerIndex).x;
+ }
- inline float getRawY() const { return mRawY; }
+ inline float getRawY(size_t pointerIndex) const {
+ return getCurrentPointerCoords(pointerIndex).y;
+ }
inline float getX(size_t pointerIndex) const {
- return getCurrentPointerCoords(pointerIndex).x;
+ return getRawX(pointerIndex) + mXOffset;
}
inline float getY(size_t pointerIndex) const {
- return getCurrentPointerCoords(pointerIndex).y;
+ return getRawY(pointerIndex) + mYOffset;
}
inline float getPressure(size_t pointerIndex) const {
@@ -243,14 +257,22 @@ public:
return mSampleEventTimes[historicalIndex];
}
- inline float getHistoricalX(size_t pointerIndex, size_t historicalIndex) const {
+ inline float getHistoricalRawX(size_t pointerIndex, size_t historicalIndex) const {
return getHistoricalPointerCoords(pointerIndex, historicalIndex).x;
}
- inline float getHistoricalY(size_t pointerIndex, size_t historicalIndex) const {
+ inline float getHistoricalRawY(size_t pointerIndex, size_t historicalIndex) const {
return getHistoricalPointerCoords(pointerIndex, historicalIndex).y;
}
+ inline float getHistoricalX(size_t pointerIndex, size_t historicalIndex) const {
+ return getHistoricalRawX(pointerIndex, historicalIndex) + mXOffset;
+ }
+
+ inline float getHistoricalY(size_t pointerIndex, size_t historicalIndex) const {
+ return getHistoricalRawY(pointerIndex, historicalIndex) + mYOffset;
+ }
+
inline float getHistoricalPressure(size_t pointerIndex, size_t historicalIndex) const {
return getHistoricalPointerCoords(pointerIndex, historicalIndex).pressure;
}
@@ -265,8 +287,8 @@ public:
int32_t action,
int32_t edgeFlags,
int32_t metaState,
- float rawX,
- float rawY,
+ float xOffset,
+ float yOffset,
float xPrecision,
float yPrecision,
nsecs_t downTime,
@@ -281,12 +303,19 @@ public:
void offsetLocation(float xOffset, float yOffset);
+ // Low-level accessors.
+ inline const int32_t* getPointerIds() const { return mPointerIds.array(); }
+ inline const nsecs_t* getSampleEventTimes() const { return mSampleEventTimes.array(); }
+ inline const PointerCoords* getSamplePointerCoords() const {
+ return mSamplePointerCoords.array();
+ }
+
private:
int32_t mAction;
int32_t mEdgeFlags;
int32_t mMetaState;
- float mRawX;
- float mRawY;
+ float mXOffset;
+ float mYOffset;
float mXPrecision;
float mYPrecision;
nsecs_t mDownTime;
diff --git a/include/ui/InputTransport.h b/include/ui/InputTransport.h
index 9537523..7b182f3 100644
--- a/include/ui/InputTransport.h
+++ b/include/ui/InputTransport.h
@@ -62,7 +62,7 @@ public:
* Returns OK on success.
*/
static status_t openInputChannelPair(const String8& name,
- InputChannel** outServerChannel, InputChannel** outClientChannel);
+ sp<InputChannel>& outServerChannel, sp<InputChannel>& outClientChannel);
inline String8 getName() const { return mName; }
inline int32_t getAshmemFd() const { return mAshmemFd; }
@@ -72,7 +72,8 @@ public:
/* Sends a signal to the other endpoint.
*
* Returns OK on success.
- * Errors probably indicate that the channel is broken.
+ * Returns DEAD_OBJECT if the channel's peer has been closed.
+ * Other errors probably indicate that the channel is broken.
*/
status_t sendSignal(char signal);
@@ -81,6 +82,7 @@ public:
*
* Returns OK on success.
* Returns WOULD_BLOCK if there is no signal present.
+ * Returns DEAD_OBJECT if the channel's peer has been closed.
* Other errors probably indicate that the channel is broken.
*/
status_t receiveSignal(char* outSignal);
@@ -298,7 +300,7 @@ public:
* Returns INVALID_OPERATION if there is no currently published event.
* Returns NO_MEMORY if the event could not be created.
*/
- status_t consume(InputEventFactoryInterface* factory, InputEvent** event);
+ status_t consume(InputEventFactoryInterface* factory, InputEvent** outEvent);
/* Sends a finished signal to the publisher to inform it that the current message is
* finished processing.