diff options
author | Tibi Nagy <nltibi@gmail.com> | 2008-11-24 22:28:44 +0200 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@redhat.com> | 2008-12-03 16:36:29 +1000 |
commit | 2bd24649ecbae08b7bd4dacd67d141ae665f8db7 (patch) | |
tree | a50cad80a693a6b064321f106bea3572f431b1c5 | |
parent | 6867652c2c8ad563d5655302d94134592b10265b (diff) |
Support keyboards with scroll wheels.
For keyboards, scroll events are reported by the kernel as EV_REL class events
of REL_WHEEL type. If, during probing, the device is found to support wheel
events, make sure it is set up as a pointing device, even if it doesn't have
buttons or doesn't report motion along the X and Y axis so that the scroll
events can be mapped to mouse wheel buttons (usually buttons 4 and 5).
Signed-off-by: Peter Hutterer <peter.hutterer@redhat.com>
-rw-r--r-- | src/evdev.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/evdev.c b/src/evdev.c index c11bd3e..275d6bc 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -1043,8 +1043,6 @@ EvdevInit(DeviceIntPtr device) pInfo = device->public.devicePrivate; pEvdev = pInfo->private; - /* FIXME: This doesn't add buttons for keyboards with scrollwheels. */ - if (pEvdev->flags & EVDEV_KEYBOARD_EVENTS) EvdevAddKeyClass(device); if (pEvdev->flags & EVDEV_BUTTON_EVENTS) @@ -1332,7 +1330,7 @@ EvdevProbe(InputInfoPtr pInfo) long key_bitmask[NBITS(KEY_MAX)] = {0}; long rel_bitmask[NBITS(REL_MAX)] = {0}; long abs_bitmask[NBITS(ABS_MAX)] = {0}; - int i, has_axes, has_keys, num_buttons; + int i, has_axes, has_keys, num_buttons, has_scroll; int kernel24 = 0; EvdevPtr pEvdev = pInfo->private; @@ -1369,6 +1367,7 @@ EvdevProbe(InputInfoPtr pInfo) has_axes = FALSE; has_keys = FALSE; + has_scroll = FALSE; num_buttons = 0; /* count all buttons */ @@ -1392,6 +1391,11 @@ EvdevProbe(InputInfoPtr pInfo) has_axes = TRUE; } + if (TestBit(REL_WHEEL, rel_bitmask) || TestBit(REL_HWHEEL, rel_bitmask)) { + xf86Msg(X_INFO, "%s: Found scroll wheel(s)\n", pInfo->name); + has_scroll = 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; @@ -1444,6 +1448,15 @@ EvdevProbe(InputInfoPtr pInfo) } } + if (has_scroll && (pInfo->flags & XI86_CONFIGURED) && + (pInfo->flags & XI86_POINTER_CAPABLE) == 0) + { + xf86Msg(X_INFO, "%s: Adding scrollwheel support\n", pInfo->name); + pInfo->flags |= XI86_POINTER_CAPABLE; + pEvdev->flags |= EVDEV_BUTTON_EVENTS; + pEvdev->flags |= EVDEV_RELATIVE_EVENTS; + } + if ((pInfo->flags & XI86_CONFIGURED) == 0) { xf86Msg(X_WARNING, "%s: Don't know how to use device\n", pInfo->name); |