[PATCH libinput] evdev: actually ignore joysticks

Peter Hutterer peter.hutterer at who-t.net
Wed Nov 2 03:17:16 UTC 2016


On Tue, Nov 01, 2016 at 08:06:09PM -0700, Dima Ryazanov wrote:
> On Tue, Nov 1, 2016 at 6:19 PM, Peter Hutterer <peter.hutterer at who-t.net>
> wrote:
> 
> > A joystick has ID_INPUT_JOYSTICK *and* ID_INPUT set, so we need to check
> > for
> > both.
> >
> > https://bugs.freedesktop.org/show_bug.cgi?id=98009
> >
> > Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> > ---
> >  src/evdev.c   |  2 +-
> >  test/device.c | 34 ++++++++++++++++++++++++++++++++++
> >  2 files changed, 35 insertions(+), 1 deletion(-)
> >
> > diff --git a/src/evdev.c b/src/evdev.c
> > index d49b391..b7396f3 100644
> > --- a/src/evdev.c
> > +++ b/src/evdev.c
> > @@ -2468,7 +2468,7 @@ evdev_configure_device(struct evdev_device *device)
> >
> >         /* libwacom *adds* TABLET, TOUCHPAD but leaves JOYSTICK in place,
> > so
> >            make sure we only ignore real joystick devices */
> > -       if ((udev_tags & EVDEV_UDEV_TAG_JOYSTICK) == udev_tags) {
> > +       if ((udev_tags & (EVDEV_UDEV_TAG_INPUT|EVDEV_UDEV_TAG_JOYSTICK))
> > == udev_tags) {
> >
> 
> Shouldn't this just be "udev_tags == EVDEV_UDEV_TAG_INPUT|EVDEV_
> UDEV_TAG_JOYSTICK"?
> 
> Otherwise, the check will succeed even if udev_tags is just
> EVDEV_UDEV_TAG_INPUT. (Assuming such devices exist, that is.)

whoops, you're right. I'll send a fixed version in a sec.

and yes, those devices can exist, but I'd have to look up udev's input-id
builtin to check which devices this would apply to.  basically if a device
is lacking any well-known buttons or axes, it won't get any of the other
tags applied. for example, an led-only device.

Cheers,
   Peter

> 
> 
> >                 log_info(libinput,
> >                          "input device '%s', %s is a joystick, ignoring\n",
> >                          device->devname, devnode);
> > diff --git a/test/device.c b/test/device.c
> > index 4ed12d9..f44a988 100644
> > --- a/test/device.c
> > +++ b/test/device.c
> > @@ -1058,6 +1058,39 @@ START_TEST(abs_mt_device_missing_res)
> >  }
> >  END_TEST
> >
> > +START_TEST(ignore_joystick)
> > +{
> > +       struct libinput *li;
> > +       struct libevdev_uinput *uinput;
> > +       struct libinput_device *device;
> > +       struct input_absinfo absinfo[] = {
> > +               { ABS_X, 0, 10, 0, 0, 10 },
> > +               { ABS_Y, 0, 10, 0, 0, 10 },
> > +               { ABS_RX, 0, 10, 0, 0, 10 },
> > +               { ABS_RY, 0, 10, 0, 0, 10 },
> > +               { ABS_THROTTLE, 0, 2, 0, 0, 0 },
> > +               { ABS_RUDDER, 0, 255, 0, 0, 0 },
> > +               { -1, -1, -1, -1, -1, -1 }
> > +       };
> > +
> > +       li = litest_create_context();
> > +       litest_disable_log_handler(li);
> > +       litest_drain_events(li);
> > +
> > +       uinput = litest_create_uinput_abs_device("joystick test device",
> > NULL,
> > +                                                absinfo,
> > +                                                EV_KEY, BTN_TRIGGER,
> > +                                                EV_KEY, BTN_A,
> > +                                                -1);
> > +       device = libinput_path_add_device(li,
> > +                                         libevdev_uinput_get_devnode(
> > uinput));
> > +       litest_assert_ptr_null(device);
> > +       libevdev_uinput_destroy(uinput);
> > +       litest_restore_log_handler(li);
> > +       libinput_unref(li);
> > +}
> > +END_TEST
> > +
> >  START_TEST(device_wheel_only)
> >  {
> >         struct litest_device *dev = litest_current_device();
> > @@ -1464,6 +1497,7 @@ litest_setup_tests_device(void)
> >         litest_add_ranged_no_device("device:invalid devices",
> > abs_mt_device_no_range, &abs_mt_range);
> >         litest_add_no_device("device:invalid devices",
> > abs_device_missing_res);
> >         litest_add_no_device("device:invalid devices",
> > abs_mt_device_missing_res);
> > +       litest_add_no_device("device:invalid devices", ignore_joystick);
> >
> >         litest_add("device:wheel", device_wheel_only, LITEST_WHEEL,
> > LITEST_RELATIVE|LITEST_ABSOLUTE|LITEST_TABLET);
> >         litest_add_no_device("device:accelerometer",
> > device_accelerometer);
> > --
> > 2.9.3
> >
> > _______________________________________________
> > wayland-devel mailing list
> > wayland-devel at lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/wayland-devel
> >


More information about the wayland-devel mailing list