Probe: Don't aggressively detect type as keyboard

Some devices like mice have keys. Our probe logic was based on
xf86-input-evdev, and that software will indeed ultimately classify
such devices as keyboard, but it still also sends relative events
through, so the mistake in classification is acceptable.

We lock onto a single device type, so we can't have a device be a
keyboard and mouse.

With this change, we only consider keyboards as a last resort, so that
we detect mice correctly.

BUG=chromium:359754
TEST=Manually tested with problematic mice

Change-Id: I573262b33184f2a267306d0bc520cdedf03e9508
Reviewed-on: https://chromium-review.googlesource.com/193170
Reviewed-by: Andrew de los Reyes <adlr@chromium.org>
Tested-by: Andrew de los Reyes <adlr@chromium.org>
Commit-Queue: Andrew de los Reyes <adlr@chromium.org>
diff --git a/src/libevdev.c b/src/libevdev.c
index 2e0ecc2..a7d3438 100644
--- a/src/libevdev.c
+++ b/src/libevdev.c
@@ -502,9 +502,6 @@
  */
 static EvdevClass EvdevProbeClass(EvdevInfoPtr info) {
   int bit;
-  for (bit = 0; bit < BTN_MISC; bit++)
-    if (TestBit(bit, info->key_bitmask))
-      return EvdevClassKeyboard;
 
   if (TestBit(REL_X, info->rel_bitmask) &&
       TestBit(REL_Y, info->rel_bitmask)) {
@@ -539,6 +536,10 @@
       return EvdevClassTouchscreen;
   }
 
+  for (bit = 0; bit < BTN_MISC; bit++)
+    if (TestBit(bit, info->key_bitmask))
+      return EvdevClassKeyboard;
+
   return EvdevClassUnknown;
 }