mirror of
https://github.com/X11Libre/xf86-input-evdev.git
synced 2026-04-05 07:12:19 +00:00
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>
This commit is contained in:
committed by
Peter Hutterer
parent
6867652c2c
commit
2bd24649ec
19
src/evdev.c
19
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);
|
||||
|
||||
Reference in New Issue
Block a user