From 1cf7b8f7ee224d823d94ea65458f5269a1a77d2e Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Sat, 28 Jun 2008 17:50:26 +0930 Subject: Count buttons at probe and print to log. We don't really do anything with the number other than print it since I'm sure that half the mice don't report the correct number anyway (especially with the wheel button mapping). But having a bit more debug info is good. --- src/evdev.c | 25 +++++++++++++++++-------- src/evdev.h | 1 + 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/evdev.c b/src/evdev.c index 0078881..2f7da51 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -887,7 +887,7 @@ EvdevProbe(InputInfoPtr pInfo) char key_bitmask[(KEY_MAX + 7) / 8]; char rel_bitmask[(REL_MAX + 7) / 8]; char abs_bitmask[(ABS_MAX + 7) / 8]; - int i, has_axes, has_buttons, has_keys; + int i, has_axes, has_keys, num_buttons; EvdevPtr pEvdev = pInfo->private; if (ioctl(pInfo->fd, EVIOCGRAB, (void *)1)) { @@ -921,15 +921,15 @@ EvdevProbe(InputInfoPtr pInfo) } has_axes = FALSE; - has_buttons = FALSE; has_keys = FALSE; + num_buttons = 0; if (TestBit(REL_X, rel_bitmask) && TestBit(REL_Y, rel_bitmask)) { xf86Msg(X_INFO, "%s: Found x and y relative axes\n", pInfo->name); pEvdev->flags |= EVDEV_RELATIVE_EVENTS; has_axes = TRUE; } - + if (TestBit(ABS_X, abs_bitmask) && TestBit(ABS_Y, abs_bitmask)) { xf86Msg(X_INFO, "%s: Found x and y absolute axes\n", pInfo->name); pEvdev->flags |= EVDEV_ABSOLUTE_EVENTS; @@ -941,10 +941,19 @@ EvdevProbe(InputInfoPtr pInfo) has_axes = TRUE; } - if (TestBit(BTN_LEFT, key_bitmask)) { - xf86Msg(X_INFO, "%s: Found mouse buttons\n", pInfo->name); - pEvdev->flags |= EVDEV_BUTTON_EVENTS; - has_buttons = TRUE; + /* count all buttons */ + for (i = BTN_MISC; i < BTN_JOYSTICK; i++) + { + if (TestBit(i, key_bitmask)) + num_buttons++; + } + + if (num_buttons) + { + pEvdev->flags |= EVDEV_BUTTON_EVENTS; + pEvdev->buttons = num_buttons; + xf86Msg(X_INFO, "%s: Found %d mouse buttons\n", pInfo->name, + num_buttons); } for (i = 0; i < BTN_MISC; i++) @@ -957,7 +966,7 @@ EvdevProbe(InputInfoPtr pInfo) has_keys = TRUE; } - if (has_axes && has_buttons) { + if (has_axes && num_buttons) { xf86Msg(X_INFO, "%s: Configuring as mouse\n", pInfo->name); pInfo->flags |= XI86_POINTER_CAPABLE | XI86_SEND_DRAG_EVENTS | XI86_CONFIGURED; diff --git a/src/evdev.h b/src/evdev.h index cad1eed..c6a6e99 100644 --- a/src/evdev.h +++ b/src/evdev.h @@ -47,6 +47,7 @@ typedef struct { int abs_x, abs_y, old_x, old_y; int flags; int tool; + int buttons; /* number of buttons */ /* XKB stuff has to be per-device rather than per-driver */ int noXkb; -- cgit v1.2.3