summaryrefslogtreecommitdiffstats
path: root/services/input
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2011-08-23 17:31:25 -0700
committerJeff Brown <jeffbrown@google.com>2011-08-23 17:49:49 -0700
commitea6892e02e10a57673a42f0922ad28694595dcaa (patch)
tree3f848783f217758c31e3491fef6fd84b7bf8cf52 /services/input
parent2a4c5acc27e546f11e578e9982d8c33deb6b88fb (diff)
downloadframeworks_base-ea6892e02e10a57673a42f0922ad28694595dcaa.zip
frameworks_base-ea6892e02e10a57673a42f0922ad28694595dcaa.tar.gz
frameworks_base-ea6892e02e10a57673a42f0922ad28694595dcaa.tar.bz2
Support BTN_TOOL_*TAP as synonyms for BTN_TOOL_FINGER.
Bug: 5205301 Some drivers report one finger as BTN_TOOL_FINGER, two as BTN_TOOL_DOUBLETAP, three as BTN_TOOL_TRIPLETAP and four as BTN_TOOL_QUADTAP. Since we care about the tool type, we need to handle _DOUBLE/_TRIPLE/_QUAD tap in the same way we handle _FINGER. Change-Id: I8eb83d2a2bada9ac32d07619c7eea84e924316b8
Diffstat (limited to 'services/input')
-rw-r--r--services/input/InputReader.cpp20
-rw-r--r--services/input/InputReader.h3
-rw-r--r--services/input/tests/InputReader_test.cpp52
3 files changed, 71 insertions, 4 deletions
diff --git a/services/input/InputReader.cpp b/services/input/InputReader.cpp
index 40c85fc..643866b 100644
--- a/services/input/InputReader.cpp
+++ b/services/input/InputReader.cpp
@@ -1220,6 +1220,9 @@ void TouchButtonAccumulator::reset(InputDevice* device) {
mBtnToolAirbrush = device->isKeyPressed(BTN_TOOL_AIRBRUSH);
mBtnToolMouse = device->isKeyPressed(BTN_TOOL_MOUSE);
mBtnToolLens = device->isKeyPressed(BTN_TOOL_LENS);
+ mBtnToolDoubleTap = device->isKeyPressed(BTN_TOOL_DOUBLETAP);
+ mBtnToolTripleTap = device->isKeyPressed(BTN_TOOL_TRIPLETAP);
+ mBtnToolQuadTap = device->isKeyPressed(BTN_TOOL_QUADTAP);
}
void TouchButtonAccumulator::clearButtons() {
@@ -1234,6 +1237,9 @@ void TouchButtonAccumulator::clearButtons() {
mBtnToolAirbrush = 0;
mBtnToolMouse = 0;
mBtnToolLens = 0;
+ mBtnToolDoubleTap = 0;
+ mBtnToolTripleTap = 0;
+ mBtnToolQuadTap = 0;
}
void TouchButtonAccumulator::process(const RawEvent* rawEvent) {
@@ -1272,6 +1278,15 @@ void TouchButtonAccumulator::process(const RawEvent* rawEvent) {
case BTN_TOOL_LENS:
mBtnToolLens = rawEvent->value;
break;
+ case BTN_TOOL_DOUBLETAP:
+ mBtnToolDoubleTap = rawEvent->value;
+ break;
+ case BTN_TOOL_TRIPLETAP:
+ mBtnToolTripleTap = rawEvent->value;
+ break;
+ case BTN_TOOL_QUADTAP:
+ mBtnToolQuadTap = rawEvent->value;
+ break;
}
}
}
@@ -1297,7 +1312,7 @@ int32_t TouchButtonAccumulator::getToolType() const {
if (mBtnToolPen || mBtnToolBrush || mBtnToolPencil || mBtnToolAirbrush) {
return AMOTION_EVENT_TOOL_TYPE_STYLUS;
}
- if (mBtnToolFinger) {
+ if (mBtnToolFinger || mBtnToolDoubleTap || mBtnToolTripleTap || mBtnToolQuadTap) {
return AMOTION_EVENT_TOOL_TYPE_FINGER;
}
return AMOTION_EVENT_TOOL_TYPE_UNKNOWN;
@@ -1306,7 +1321,8 @@ int32_t TouchButtonAccumulator::getToolType() const {
bool TouchButtonAccumulator::isToolActive() const {
return mBtnTouch || mBtnToolFinger || mBtnToolPen || mBtnToolRubber
|| mBtnToolBrush || mBtnToolPencil || mBtnToolAirbrush
- || mBtnToolMouse || mBtnToolLens;
+ || mBtnToolMouse || mBtnToolLens
+ || mBtnToolDoubleTap || mBtnToolTripleTap || mBtnToolQuadTap;
}
bool TouchButtonAccumulator::isHovering() const {
diff --git a/services/input/InputReader.h b/services/input/InputReader.h
index 76d77f1..bad96df 100644
--- a/services/input/InputReader.h
+++ b/services/input/InputReader.h
@@ -596,6 +596,9 @@ private:
bool mBtnToolAirbrush;
bool mBtnToolMouse;
bool mBtnToolLens;
+ bool mBtnToolDoubleTap;
+ bool mBtnToolTripleTap;
+ bool mBtnToolQuadTap;
void clearButtons();
};
diff --git a/services/input/tests/InputReader_test.cpp b/services/input/tests/InputReader_test.cpp
index 4796958..32f948b 100644
--- a/services/input/tests/InputReader_test.cpp
+++ b/services/input/tests/InputReader_test.cpp
@@ -3377,8 +3377,32 @@ TEST_F(SingleTouchInputMapperTest, Process_ShouldHandleAllToolTypes) {
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_MOUSE, motionArgs.pointerProperties[0].toolType);
- // finger
+ // double-tap
processKey(mapper, BTN_TOOL_LENS, 0);
+ processKey(mapper, BTN_TOOL_DOUBLETAP, 1);
+ processSync(mapper);
+ ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+ ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+ ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+
+ // triple-tap
+ processKey(mapper, BTN_TOOL_DOUBLETAP, 0);
+ processKey(mapper, BTN_TOOL_TRIPLETAP, 1);
+ processSync(mapper);
+ ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+ ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+ ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+
+ // quad-tap
+ processKey(mapper, BTN_TOOL_TRIPLETAP, 0);
+ processKey(mapper, BTN_TOOL_QUADTAP, 1);
+ processSync(mapper);
+ ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+ ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+ ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+
+ // finger
+ processKey(mapper, BTN_TOOL_QUADTAP, 0);
processKey(mapper, BTN_TOOL_FINGER, 1);
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
@@ -4766,8 +4790,32 @@ TEST_F(MultiTouchInputMapperTest, Process_ShouldHandleAllToolTypes) {
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_MOUSE, motionArgs.pointerProperties[0].toolType);
- // finger
+ // double-tap
processKey(mapper, BTN_TOOL_LENS, 0);
+ processKey(mapper, BTN_TOOL_DOUBLETAP, 1);
+ processSync(mapper);
+ ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+ ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+ ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+
+ // triple-tap
+ processKey(mapper, BTN_TOOL_DOUBLETAP, 0);
+ processKey(mapper, BTN_TOOL_TRIPLETAP, 1);
+ processSync(mapper);
+ ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+ ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+ ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+
+ // quad-tap
+ processKey(mapper, BTN_TOOL_TRIPLETAP, 0);
+ processKey(mapper, BTN_TOOL_QUADTAP, 1);
+ processSync(mapper);
+ ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+ ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+ ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+
+ // finger
+ processKey(mapper, BTN_TOOL_QUADTAP, 0);
processKey(mapper, BTN_TOOL_FINGER, 1);
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));