Ignore devices that have joystick buttons

Submitted by Krzysztof A. Sobiecki on Nov. 25, 2014, 1:33 a.m.

Details

Message ID 871tosf4hq.fsf@gmail.com
State Not Applicable
Headers show

Not browsing as part of any series.

Commit Message

Krzysztof A. Sobiecki Nov. 25, 2014, 1:33 a.m.

Patch hide | download patch | download mbox

This patch allows libinput to ignore devices that have joystick buttons.

Signed-off-by: Krzysztof Sobiecki <sobkas@gmail.com>
---
 src/evdev.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/evdev.c b/src/evdev.c
index 36c6859..5f6cc32 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1274,6 +1274,15 @@  evdev_configure_device(struct evdev_device *device)
 	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, device->devnode);
+                        return -1;
+                }
+        }
+
 	if (libevdev_has_event_type(evdev, EV_ABS)) {
 
 		if ((absinfo = libevdev_get_abs_info(evdev, ABS_X))) {
-- 
2.2.0.rc0.207.ga3a616c


Comments

On Tue, 25 Nov 2014 02:33:53 +0100
sobkas@gmail.com (Krzysztof A. Sobiecki) wrote:

> This patch allows libinput to ignore devices that have joystick buttons.
> 
> Signed-off-by: Krzysztof Sobiecki <sobkas@gmail.com>
> ---
>  src/evdev.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/src/evdev.c b/src/evdev.c
> index 36c6859..5f6cc32 100644
> --- a/src/evdev.c
> +++ b/src/evdev.c
> @@ -1274,6 +1274,15 @@ evdev_configure_device(struct evdev_device *device)
>  	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, device->devnode);
> +                        return -1;
> +                }
> +        }
> +
>  	if (libevdev_has_event_type(evdev, EV_ABS)) {
>  
>  		if ((absinfo = libevdev_get_abs_info(evdev, ABS_X))) {

This is a patch for libinput, not Weston, right?
Weston also has a src/evdev.c, but the patch doesn't apply.


Thanks,
pq
On Tue, Nov 25, 2014 at 12:16:18PM +0200, Pekka Paalanen wrote:
> On Tue, 25 Nov 2014 02:33:53 +0100
> sobkas@gmail.com (Krzysztof A. Sobiecki) wrote:
> 
> > This patch allows libinput to ignore devices that have joystick buttons.
> > 
> > Signed-off-by: Krzysztof Sobiecki <sobkas@gmail.com>
> > ---
> >  src/evdev.c | 9 +++++++++
> >  1 file changed, 9 insertions(+)
> > 
> > diff --git a/src/evdev.c b/src/evdev.c
> > index 36c6859..5f6cc32 100644
> > --- a/src/evdev.c
> > +++ b/src/evdev.c
> > @@ -1274,6 +1274,15 @@ evdev_configure_device(struct evdev_device *device)
> >  	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, device->devnode);
> > +                        return -1;
> > +                }
> > +        }
> > +
> >  	if (libevdev_has_event_type(evdev, EV_ABS)) {
> >  
> >  		if ((absinfo = libevdev_get_abs_info(evdev, ABS_X))) {
> 
> This is a patch for libinput, not Weston, right?
> Weston also has a src/evdev.c, but the patch doesn't apply.

yeah, it's for libinput. Krzysztof and I discussed it on irc today.

Krzysztof - for next time pls add the repo as [PATCH <repo>]. I usually run
    git config --add format.subjectprefix "PATCH `basename $PWD`"
when I clone a new repo then you dont' have to think about it.

Cheers,
   Peter
On Tue, Nov 25, 2014 at 02:33:53AM +0100, Krzysztof A. Sobiecki wrote:
> This patch allows libinput to ignore devices that have joystick buttons.
> 
> Signed-off-by: Krzysztof Sobiecki <sobkas@gmail.com>
> ---
>  src/evdev.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/src/evdev.c b/src/evdev.c
> index 36c6859..5f6cc32 100644
> --- a/src/evdev.c
> +++ b/src/evdev.c
> @@ -1274,6 +1274,15 @@ evdev_configure_device(struct evdev_device *device)
>  	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, device->devnode);
> +                        return -1;
> +                }
> +        }
> +
>  	if (libevdev_has_event_type(evdev, EV_ABS)) {
>  
>  		if ((absinfo = libevdev_get_abs_info(evdev, ABS_X))) {
> -- 
> 2.2.0.rc0.207.ga3a616c
 
merged with a minor change, device->devnode is just devnode in my local
tree. thanks.

Cheers,
   Peter
On 25/11/14 04:32 AM, Peter Hutterer wrote:
> On Tue, Nov 25, 2014 at 02:33:53AM +0100, Krzysztof A. Sobiecki wrote:
>> This patch allows libinput to ignore devices that have joystick buttons.
>>
>> Signed-off-by: Krzysztof Sobiecki <sobkas@gmail.com>
>> ---
>>  src/evdev.c | 9 +++++++++
>>  1 file changed, 9 insertions(+)
>>
>> diff --git a/src/evdev.c b/src/evdev.c
>> index 36c6859..5f6cc32 100644
>> --- a/src/evdev.c
>> +++ b/src/evdev.c
>> @@ -1274,6 +1274,15 @@ evdev_configure_device(struct evdev_device *device)
>>  	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, device->devnode);
>> +                        return -1;
>> +                }
>> +        }
>> +
>>  	if (libevdev_has_event_type(evdev, EV_ABS)) {
>>  
>>  		if ((absinfo = libevdev_get_abs_info(evdev, ABS_X))) {
>> -- 
>> 2.2.0.rc0.207.ga3a616c
>  
> merged with a minor change, device->devnode is just devnode in my local
> tree. thanks.


Err, is there some long term plan for gamepad support in libinput?  I'm
kind of hoping this isn't it... :)

I kind of wonder if gamepads should be implicitly assigned seats
(player1, player2, etc) and the compositor can choose whether to ignore
them?
Well, SDL already opens your gamepad evdev device manually. libinput is
designed for compositors and Wayland, and I don't see any reason to
introduce a gamepad protocol into Wayland if SDL already just uses evdev.

On Tue, Nov 25, 2014 at 8:41 AM, Derek Foreman <derekf@osg.samsung.com>
wrote:

> On 25/11/14 04:32 AM, Peter Hutterer wrote:
> > On Tue, Nov 25, 2014 at 02:33:53AM +0100, Krzysztof A. Sobiecki wrote:
> >> This patch allows libinput to ignore devices that have joystick buttons.
> >>
> >> Signed-off-by: Krzysztof Sobiecki <sobkas@gmail.com>
> >> ---
> >>  src/evdev.c | 9 +++++++++
> >>  1 file changed, 9 insertions(+)
> >>
> >> diff --git a/src/evdev.c b/src/evdev.c
> >> index 36c6859..5f6cc32 100644
> >> --- a/src/evdev.c
> >> +++ b/src/evdev.c
> >> @@ -1274,6 +1274,15 @@ evdev_configure_device(struct evdev_device
> *device)
> >>      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, device->devnode);
> >> +                        return -1;
> >> +                }
> >> +        }
> >> +
> >>      if (libevdev_has_event_type(evdev, EV_ABS)) {
> >>
> >>              if ((absinfo = libevdev_get_abs_info(evdev, ABS_X))) {
> >> --
> >> 2.2.0.rc0.207.ga3a616c
> >
> > merged with a minor change, device->devnode is just devnode in my local
> > tree. thanks.
>
>
> Err, is there some long term plan for gamepad support in libinput?  I'm
> kind of hoping this isn't it... :)
>
> I kind of wonder if gamepads should be implicitly assigned seats
> (player1, player2, etc) and the compositor can choose whether to ignore
> them?
> _______________________________________________
> wayland-devel mailing list
> wayland-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
>
On Tue, Nov 25, 2014 at 10:41:50AM -0600, Derek Foreman wrote:
> On 25/11/14 04:32 AM, Peter Hutterer wrote:
> > On Tue, Nov 25, 2014 at 02:33:53AM +0100, Krzysztof A. Sobiecki wrote:
> >> This patch allows libinput to ignore devices that have joystick buttons.
> >>
> >> Signed-off-by: Krzysztof Sobiecki <sobkas@gmail.com>
> >> ---
> >>  src/evdev.c | 9 +++++++++
> >>  1 file changed, 9 insertions(+)
> >>
> >> diff --git a/src/evdev.c b/src/evdev.c
> >> index 36c6859..5f6cc32 100644
> >> --- a/src/evdev.c
> >> +++ b/src/evdev.c
> >> @@ -1274,6 +1274,15 @@ evdev_configure_device(struct evdev_device *device)
> >>  	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, device->devnode);
> >> +                        return -1;
> >> +                }
> >> +        }
> >> +
> >>  	if (libevdev_has_event_type(evdev, EV_ABS)) {
> >>  
> >>  		if ((absinfo = libevdev_get_abs_info(evdev, ABS_X))) {
> >> -- 
> >> 2.2.0.rc0.207.ga3a616c
> >  
> > merged with a minor change, device->devnode is just devnode in my local
> > tree. thanks.
> 
> 
> Err, is there some long term plan for gamepad support in libinput?  I'm
> kind of hoping this isn't it... :)
> 
> I kind of wonder if gamepads should be implicitly assigned seats
> (player1, player2, etc) and the compositor can choose whether to ignore
> them?

we had a chat about this at XDC and it came down to: we don't exactly know
what is required, SDL already does its own thing (as Jasper also said) and
while we could try to add support for joysticks, it's unclear what anyone
would really gain from it atm.

So we're pretty much waiting for a use-case of ppl saying "hey, this is what
we need". then we can start thinking about it in more detail.

meanwhile, ignoring devices that we don't correctly support is the prudent
option.

Cheers,
   Peter