summaryrefslogtreecommitdiff
path: root/include/input
diff options
context:
space:
mode:
author Xin Li <delphij@google.com> 2017-12-06 11:52:02 -0800
committer Xin Li <delphij@google.com> 2017-12-06 14:24:50 -0800
commitd1a6d1eb81b14966a30a68b67996916ee27afb6f (patch)
treef5100ca72ea06d172b17fd11f8403549315740d8 /include/input
parent68686bd15198f64db633a757718b918895a1ca71 (diff)
parent60175af9c8938d2362ec8a8b06543ce8c41b2338 (diff)
DO NOT MERGE: Merge Oreo MR1 into master
Exempt-From-Owner-Approval: Changes already landed internally Change-Id: I37c19d77fbf144fb30cc2a2877247a855684d4ad
Diffstat (limited to 'include/input')
-rw-r--r--include/input/InputEventLabels.h1
-rw-r--r--include/input/InputTransport.h38
2 files changed, 31 insertions, 8 deletions
diff --git a/include/input/InputEventLabels.h b/include/input/InputEventLabels.h
index 20154eb10e..c282cf0b22 100644
--- a/include/input/InputEventLabels.h
+++ b/include/input/InputEventLabels.h
@@ -323,6 +323,7 @@ static const InputEventLabel KEYCODES[] = {
DEFINE_KEYCODE(SYSTEM_NAVIGATION_DOWN),
DEFINE_KEYCODE(SYSTEM_NAVIGATION_LEFT),
DEFINE_KEYCODE(SYSTEM_NAVIGATION_RIGHT),
+ DEFINE_KEYCODE(ALL_APPS),
{ NULL, 0 }
};
diff --git a/include/input/InputTransport.h b/include/input/InputTransport.h
index efa1ffbfee..944947420e 100644
--- a/include/input/InputTransport.h
+++ b/include/input/InputTransport.h
@@ -370,20 +370,24 @@ private:
int32_t idToIndex[MAX_POINTER_ID + 1];
PointerCoords pointers[MAX_POINTERS];
- void initializeFrom(const InputMessage* msg) {
- eventTime = msg->body.motion.eventTime;
+ void initializeFrom(const InputMessage& msg) {
+ eventTime = msg.body.motion.eventTime;
idBits.clear();
- for (uint32_t i = 0; i < msg->body.motion.pointerCount; i++) {
- uint32_t id = msg->body.motion.pointers[i].properties.id;
+ for (uint32_t i = 0; i < msg.body.motion.pointerCount; i++) {
+ uint32_t id = msg.body.motion.pointers[i].properties.id;
idBits.markBit(id);
idToIndex[id] = i;
- pointers[i].copyFrom(msg->body.motion.pointers[i].coords);
+ pointers[i].copyFrom(msg.body.motion.pointers[i].coords);
}
}
const PointerCoords& getPointerById(uint32_t id) const {
return pointers[idToIndex[id]];
}
+
+ bool hasPointerId(uint32_t id) const {
+ return idBits.hasBit(id);
+ }
};
struct TouchState {
int32_t deviceId;
@@ -402,7 +406,7 @@ private:
lastResample.idBits.clear();
}
- void addHistory(const InputMessage* msg) {
+ void addHistory(const InputMessage& msg) {
historyCurrent ^= 1;
if (historySize < 2) {
historySize += 1;
@@ -413,6 +417,24 @@ private:
const History* getHistory(size_t index) const {
return &history[(historyCurrent + index) & 1];
}
+
+ bool recentCoordinatesAreIdentical(uint32_t id) const {
+ // Return true if the two most recently received "raw" coordinates are identical
+ if (historySize < 2) {
+ return false;
+ }
+ if (!getHistory(0)->hasPointerId(id) || !getHistory(1)->hasPointerId(id)) {
+ return false;
+ }
+ float currentX = getHistory(0)->getPointerById(id).getX();
+ float currentY = getHistory(0)->getPointerById(id).getY();
+ float previousX = getHistory(1)->getPointerById(id).getX();
+ float previousY = getHistory(1)->getPointerById(id).getY();
+ if (currentX == previousX && currentY == previousY) {
+ return true;
+ }
+ return false;
+ }
};
Vector<TouchState> mTouchStates;
@@ -432,8 +454,8 @@ private:
Batch& batch, size_t count, uint32_t* outSeq, InputEvent** outEvent,
int32_t* displayId);
- void updateTouchState(InputMessage* msg);
- void rewriteMessage(const TouchState& state, InputMessage* msg);
+ void updateTouchState(InputMessage& msg);
+ bool rewriteMessage(const TouchState& state, InputMessage& msg);
void resampleTouchState(nsecs_t frameTime, MotionEvent* event,
const InputMessage *next);