[PATCH libinput] evdev: Be more careful about what we consider a joystick
Peter Hutterer
peter.hutterer at who-t.net
Wed Jan 21 19:45:20 PST 2015
On Wed, Jan 21, 2015 at 12:25:39PM +0100, Michael Schellenberger Costa wrote:
> Hi,
>
> is there an acutal reason, why joysticks and/or gamepads are ignored
> inside libinput. Is it just, that they are not yet implemented, or are
> there some real reasons?
>
> If the answer is that nobody has yet written the code, would someone
> of the more knowledgeable persons on the list be willing to help me a
> little (most likely a lot) to put some code together?
couple of reasons:
right now we only have pointer, keyboard and touch interfaces from libinput,
so devices that don't fall into that category are simply ignored. That
applies to graphics tablets but there's ongoing work in getting those
sorted. we also don't have wayland protocol for anything but P, K, T
interfaces, again tablet is being worked on.
so in short, if libinput could handle joysticks/gamepads we couldn't pass
this data on without having the wayland stack in place too.
X is somewhat the same story here, you usually don't want your joystick
controlling your pointer so having joystick support is of limited use.
joysticks are a lot more varied than the above listed devices and it's hard
to find some unifying factor. even gamepads, though they look the same have
a lot of details that make them different, take the button numbering and
naming for example. David Herrmann has done some work on that in the kernel
code but the differences remain. Joysticks are even worse in that regard.
This makes it hard to have a generic interface for them, especially given
that every app has different requirements (and even what constitutes a
joystick in the first place).
Finally, the main reason though is that there doesn't seem to be a need for
it. SDL for example accesses evdev device nodes directly and parses the
protocol.
We discussed adding support for it at XDC 2014 but the consensus was
essentially: not unless we have real use-cases and someone* asks us to do it.
Cheers,
Peter
* i.e. one of the big toolkits
> Am 21.01.2015 um 12:04 schrieb Hans de Goede:
> > After switching my main workstation over to using
> > xf86-input-libinput, I noticed that the multi-media keys like
> > play/pause on my keyboard no longer worked.
> >
> > It turns out that the second hid interface on my keyboard which has
> > the multimedia-keys, also declares having: BTN_BASE6 and BTN_MODE
> > which both fell into the range we were using to test for something
> > being a joystick.
> >
> > The commit makes our joystick test mode strict, restoring
> > functionality of the multi-media keys on the keyboard in question.
> >
> > Signed-off-by: Hans de Goede <hdegoede at redhat.com> --- src/evdev.c
> > | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9
> > deletions(-)
> >
> > diff --git a/src/evdev.c b/src/evdev.c index 6edacba..b2bb2aa
> > 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -1324,7 +1324,7 @@
> > evdev_configure_device(struct evdev_device *device) struct libevdev
> > *evdev = device->evdev; const struct input_absinfo *absinfo; int
> > has_abs, has_rel, has_mt; - int has_button, has_keyboard,
> > has_touch; + int has_button, has_keyboard, has_touch,
> > has_joy_button; struct mt_slot *slots; int num_slots; int
> > active_slot; @@ -1336,17 +1336,24 @@ evdev_configure_device(struct
> > evdev_device *device) has_abs = 0; has_mt = 0; has_button = 0; +
> > has_joy_button = 0; has_keyboard = 0; has_touch = 0;
> >
> > - for (i = BTN_JOYSTICK; i < BTN_DIGI; i++) { -
> > if (libevdev_has_event_code(evdev, EV_KEY, i)) { -
> > log_info(libinput, - "input device
> > '%s', %s is a joystick, ignoring\n", -
> > device->devname, devnode); - return -1; -
> > } - } + for (i = BTN_JOYSTICK; i <= BTN_PINKIE; i++) + if
> > (libevdev_has_event_code(evdev, EV_KEY, i)) + has_joy_button =
> > 1; + + for (i = BTN_GAMEPAD; i <= BTN_TR2; i++) + if
> > (libevdev_has_event_code(evdev, EV_KEY, i)) + has_joy_button =
> > 1; + + if (has_joy_button) { + log_info(libinput, + "input
> > device '%s', %s is a joystick, ignoring\n", + device->devname,
> > devnode); + return -1; + }
> >
> > if (libevdev_has_event_type(evdev, EV_ABS)) {
> >
> >
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
>
More information about the wayland-devel
mailing list