Only count fingers if they're not hovering

Previously when libevdev was counting how many fingers were on the pad,
it simply counted the number that were reported.  This isn't entirely
accurate anymore because we're beginning to get hover-enabled touchpads.
For these touchpads the events like BTN_TOOL_FINGER don't necessarily
mean that the finger it touching the pad, it could be hovering above it.
You can differentiate the hovering fingers from the touching ones by
looking for the presence of BTN_TOUCH = 1, which indicates if it's
touching or hovering.

This CL modifies Event_Get_Touch_Count to always return 0 unless
BTN_TOUCH is one -- indicating that the reported fingers are actually
touching the surface.  If it's zero, then we know that any fingers are
hovering, which shouldn't count.

The "gestures" library for ChromeOS requires that touchpads have
BTN_TOUCH in addition to the other BTN events referenced in this CL.  A
manual check of an Elan, Atmel, and Cypress touchpad all show the
BTN_TOUCH event appearing as expected, so this should be just fine even
on non-hover devices.

BUG=chrome-os-partner:53064
TEST=manually deployed on a device with a hover-enabled touchpad, and
I'm no longer able to tap-to-click without even touching the pad like I
was before.  Powerd is also not waking up entirely on hover events now
-- it can differentiate between a hover and a touch.

Change-Id: I492af7ae83be542b5fb1fd22fdaa856884d569a3
Signed-off-by: Charlie Mooney <charliemooney@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/360149
Reviewed-by: Dennis Kempin <denniskempin@google.com>
diff --git a/src/libevdev_event.c b/src/libevdev_event.c
index 694ed5a..f284b26 100755
--- a/src/libevdev_event.c
+++ b/src/libevdev_event.c
@@ -159,16 +159,18 @@
 Event_Get_Touch_Count(EvdevPtr device)
 {
 
-    if (TestBit(BTN_TOOL_QUINTTAP, device->key_state_bitmask))
-        return 5;
-    if (TestBit(BTN_TOOL_QUADTAP, device->key_state_bitmask))
-        return 4;
-    if (TestBit(BTN_TOOL_TRIPLETAP, device->key_state_bitmask))
-        return 3;
-    if (TestBit(BTN_TOOL_DOUBLETAP, device->key_state_bitmask))
-        return 2;
-    if (TestBit(BTN_TOOL_FINGER, device->key_state_bitmask))
-        return 1;
+    if (TestBit(BTN_TOUCH, device->key_state_bitmask)) {
+        if (TestBit(BTN_TOOL_QUINTTAP, device->key_state_bitmask))
+            return 5;
+        if (TestBit(BTN_TOOL_QUADTAP, device->key_state_bitmask))
+            return 4;
+        if (TestBit(BTN_TOOL_TRIPLETAP, device->key_state_bitmask))
+            return 3;
+        if (TestBit(BTN_TOOL_DOUBLETAP, device->key_state_bitmask))
+            return 2;
+        if (TestBit(BTN_TOOL_FINGER, device->key_state_bitmask))
+            return 1;
+    }
     return 0;
 }