diff mbox

Input: joydev - ignore accelerometer devices

Message ID 20170609203547.17691-2-roderick@gaikai.com (mailing list archive)
State New, archived
Headers show

Commit Message

Roderick Colenbrander June 9, 2017, 8:35 p.m. UTC
From: Roderick Colenbrander <roderick.colenbrander@sony.com>

Gamepads like DualShock 3 / 4 as of 4.12 started reporting motion
sensors on a separate evdev node. Joydev is picking these devices
up as well, but they don't make sense for the joydev interface.

Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com>
---
 drivers/input/joydev.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Benjamin Tissoires June 12, 2017, 7:09 a.m. UTC | #1
On Jun 09 2017 or thereabouts, Roderick Colenbrander wrote:
> From: Roderick Colenbrander <roderick.colenbrander@sony.com>
> 
> Gamepads like DualShock 3 / 4 as of 4.12 started reporting motion
> sensors on a separate evdev node. Joydev is picking these devices
> up as well, but they don't make sense for the joydev interface.
> 
> Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com>
> ---

Acked-By: Benjamin Tissoires <benjamin.tissoires@redhat.com>

Cheers,
Benjamin

>  drivers/input/joydev.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c
> index 29d677c..a5ceaaf 100644
> --- a/drivers/input/joydev.c
> +++ b/drivers/input/joydev.c
> @@ -819,6 +819,10 @@ static bool joydev_match(struct input_handler *handler, struct input_dev *dev)
>  	if (joydev_dev_is_absolute_mouse(dev))
>  		return false;
>  
> +	/* Avoid accelerometers */
> +	if (test_bit(INPUT_PROP_ACCELEROMETER, dev->propbit))
> +		return false;
> +
>  	return true;
>  }
>  
> -- 
> 2.9.3
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Dmitry Torokhov June 20, 2017, 2:57 a.m. UTC | #2
On Mon, Jun 12, 2017 at 09:09:53AM +0200, Benjamin Tissoires wrote:
> On Jun 09 2017 or thereabouts, Roderick Colenbrander wrote:
> > From: Roderick Colenbrander <roderick.colenbrander@sony.com>
> > 
> > Gamepads like DualShock 3 / 4 as of 4.12 started reporting motion
> > sensors on a separate evdev node. Joydev is picking these devices
> > up as well, but they don't make sense for the joydev interface.
> > 
> > Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com>
> > ---
> 
> Acked-By: Benjamin Tissoires <benjamin.tissoires@redhat.com>

Hmm, I think you can quite often use accelerometer as a joystick, it is
only the composite devices that we want to ignore I think.

> 
> Cheers,
> Benjamin
> 
> >  drivers/input/joydev.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c
> > index 29d677c..a5ceaaf 100644
> > --- a/drivers/input/joydev.c
> > +++ b/drivers/input/joydev.c
> > @@ -819,6 +819,10 @@ static bool joydev_match(struct input_handler *handler, struct input_dev *dev)
> >  	if (joydev_dev_is_absolute_mouse(dev))
> >  		return false;
> >  
> > +	/* Avoid accelerometers */
> > +	if (test_bit(INPUT_PROP_ACCELEROMETER, dev->propbit))
> > +		return false;
> > +
> >  	return true;
> >  }
> >  
> > -- 
> > 2.9.3
> >
Roderick Colenbrander June 20, 2017, 4:58 p.m. UTC | #3
On Mon, Jun 19, 2017 at 7:57 PM, Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
> On Mon, Jun 12, 2017 at 09:09:53AM +0200, Benjamin Tissoires wrote:
>> On Jun 09 2017 or thereabouts, Roderick Colenbrander wrote:
>> > From: Roderick Colenbrander <roderick.colenbrander@sony.com>
>> >
>> > Gamepads like DualShock 3 / 4 as of 4.12 started reporting motion
>> > sensors on a separate evdev node. Joydev is picking these devices
>> > up as well, but they don't make sense for the joydev interface.
>> >
>> > Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com>
>> > ---
>>
>> Acked-By: Benjamin Tissoires <benjamin.tissoires@redhat.com>
>
> Hmm, I think you can quite often use accelerometer as a joystick, it is
> only the composite devices that we want to ignore I think.
>

Correct the issue came up for composite devices. So far the
input_prop_accelerometer flag is only used in a handful of drivers
(udraw, wacom and sony). They don't have any buttons on the motion
devices.

The wii driver doesn't set any the acceleration flag yet, but may mix
acceleration sensors, buttons and sticks. At least currently it does
for nunchuck and questionably uses ABS_HAT0X/0Y instead of 'ABS_X/_Y'
for an analog stick, maybe not to get picked up by joydev, the same
device reports acceleration through ABS_RX/_RY_RZ.

Personally I had the feeling that motion sensors may not be in the
spirit of the classic joydev interface in part, because it is
difficult to figure out what axes of which type. If you think it is
okay to support them through here, I don't mind finding another way at
least for composite devices to not get these registered. I'm not fully
sure how we can figure out something is a composite device from joydev
in an easy way. Any suggestions?
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Roderick Colenbrander July 11, 2017, 12:42 a.m. UTC | #4
On Tue, Jun 20, 2017 at 9:58 AM, Roderick Colenbrander
<roderick@gaikai.com> wrote:
> On Mon, Jun 19, 2017 at 7:57 PM, Dmitry Torokhov
> <dmitry.torokhov@gmail.com> wrote:
>> On Mon, Jun 12, 2017 at 09:09:53AM +0200, Benjamin Tissoires wrote:
>>> On Jun 09 2017 or thereabouts, Roderick Colenbrander wrote:
>>> > From: Roderick Colenbrander <roderick.colenbrander@sony.com>
>>> >
>>> > Gamepads like DualShock 3 / 4 as of 4.12 started reporting motion
>>> > sensors on a separate evdev node. Joydev is picking these devices
>>> > up as well, but they don't make sense for the joydev interface.
>>> >
>>> > Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com>
>>> > ---
>>>
>>> Acked-By: Benjamin Tissoires <benjamin.tissoires@redhat.com>
>>
>> Hmm, I think you can quite often use accelerometer as a joystick, it is
>> only the composite devices that we want to ignore I think.
>>
>
> Correct the issue came up for composite devices. So far the
> input_prop_accelerometer flag is only used in a handful of drivers
> (udraw, wacom and sony). They don't have any buttons on the motion
> devices.
>
> The wii driver doesn't set any the acceleration flag yet, but may mix
> acceleration sensors, buttons and sticks. At least currently it does
> for nunchuck and questionably uses ABS_HAT0X/0Y instead of 'ABS_X/_Y'
> for an analog stick, maybe not to get picked up by joydev, the same
> device reports acceleration through ABS_RX/_RY_RZ.
>
> Personally I had the feeling that motion sensors may not be in the
> spirit of the classic joydev interface in part, because it is
> difficult to figure out what axes of which type. If you think it is
> okay to support them through here, I don't mind finding another way at
> least for composite devices to not get these registered. I'm not fully
> sure how we can figure out something is a composite device from joydev
> in an easy way. Any suggestions?

I have been trying to see how this could be handed. Considering we
can't easily look up other devices (and we are still in the process of
device initialization), the best I could think of is maybe adding more
flags to devices. Maybe introduce a new flag to mark something as a
composite device e.g. 'INPUT_PROP_COMPOSITE'. The logic could then be
to filter out composite devices with accelerometers. In addition such
a flag could also be a nice hint to user space that a device is a
composite device.

Another option if no new flags are desired, could be a check which
checks if the device has accelerometers, but no other axes or keys.
Something along these lines is a bit messier.
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c
index 29d677c..a5ceaaf 100644
--- a/drivers/input/joydev.c
+++ b/drivers/input/joydev.c
@@ -819,6 +819,10 @@  static bool joydev_match(struct input_handler *handler, struct input_dev *dev)
 	if (joydev_dev_is_absolute_mouse(dev))
 		return false;
 
+	/* Avoid accelerometers */
+	if (test_bit(INPUT_PROP_ACCELEROMETER, dev->propbit))
+		return false;
+
 	return true;
 }