From c67078765008aa56e5bd5e3b73604bb98b4d7b5e Mon Sep 17 00:00:00 2001 From: Tibi Nagy Date: Mon, 24 Nov 2008 22:28:44 +0200 Subject: [PATCH] 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). --- src/evdev.c | 19 ++++++++++++++++--- 1 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/evdev.c b/src/evdev.c index 25325a3..56bab1d 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) @@ -1303,7 +1301,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; @@ -1340,6 +1338,7 @@ EvdevProbe(InputInfoPtr pInfo) has_axes = FALSE; has_keys = FALSE; + has_scroll = FALSE; num_buttons = 0; /* count all buttons */ @@ -1363,6 +1362,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; @@ -1415,6 +1419,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); -- 1.6.0.4