[RFC PATCH] Only process ABS_MT_SLOT where there are slots available

Subsystems: input (keyboard, mouse, joystick, touchscreen) drivers, the rest

STALE5489d

2 messages, 2 authors, 2011-09-09 · open the first message on its own page

[RFC PATCH] Only process ABS_MT_SLOT where there are slots available

From: Antonio Ospite <hidden>
Date: 2011-08-18 10:29:12

This fixes the case when a non-multitouch device happens to have a HID
code equal to ABS_MT_SLOT, like the Sony Sixaxis has for the left dpad
analog control.

Signed-off-by: Antonio Ospite <redacted>
Cc: Simon Wood <redacted>
Cc: Henrik Rydberg <redacted>
Cc: virtuousfox@gmail.com
---

Hi,

following up from the discussion at 
http://thread.gmane.org/gmane.linux.kernel.input/19632 I've come up with this 
workaround to make the dpad left analog axis of the Sony Sixaxis controller 
working. What happens is that this button has a code of 0x2f (ABS_MT_SLOT) 
which gets some special handling regardless of the device being a multitouch one 
or not.

I do not know anything about multitouch devices, so I am not sure if this 
hack may break something else, I'd like some advice here.

Another possibility could be to remap the code at the HID level for the 
Sixaxis only, Simon you suggested this, are you willing to do that if this 
will be the preferred way? My HID-fu is way worse than yours and It'll take a 
lot more time for me.

Thanks,
   Antonio Ospite
   http://ao2.it

 drivers/input/input.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/input/input.c b/drivers/input/input.c
index da38d97..f878ae9 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -169,7 +169,7 @@ static int input_handle_abs_event(struct input_dev *dev,
 	bool is_mt_event;
 	int *pold;
 
-	if (code == ABS_MT_SLOT) {
+	if (code == ABS_MT_SLOT && dev->mtsize > 0) {
 		/*
 		 * "Stage" the event; we'll flush it later, when we
 		 * get actual touch data.
@@ -205,7 +205,8 @@ static int input_handle_abs_event(struct input_dev *dev,
 	}
 
 	/* Flush pending "slot" event */
-	if (is_mt_event && dev->slot != input_abs_get_val(dev, ABS_MT_SLOT)) {
+	if (is_mt_event && dev->slot != input_abs_get_val(dev, ABS_MT_SLOT) &&
+	    dev->mtsize > 0 ) {
 		input_abs_set_val(dev, ABS_MT_SLOT, dev->slot);
 		input_pass_event(dev, EV_ABS, ABS_MT_SLOT, dev->slot);
 	}
-- 
1.7.5.4

Re: [RFC PATCH] Only process ABS_MT_SLOT where there are slots available

From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date: 2011-09-09 20:54:37

Hi Antonio,

On Thu, Aug 18, 2011 at 12:28:53PM +0200, Antonio Ospite wrote:
This fixes the case when a non-multitouch device happens to have a HID
code equal to ABS_MT_SLOT, like the Sony Sixaxis has for the left dpad
analog control.

Signed-off-by: Antonio Ospite <redacted>
Cc: Simon Wood <redacted>
Cc: Henrik Rydberg <redacted>
Cc: virtuousfox@gmail.com
---

Hi,

following up from the discussion at 
http://thread.gmane.org/gmane.linux.kernel.input/19632 I've come up with this 
workaround to make the dpad left analog axis of the Sony Sixaxis controller 
working. What happens is that this button has a code of 0x2f (ABS_MT_SLOT) 
which gets some special handling regardless of the device being a multitouch one 
or not.

I do not know anything about multitouch devices, so I am not sure if this 
hack may break something else, I'd like some advice here.

Another possibility could be to remap the code at the HID level for the 
Sixaxis only, Simon you suggested this, are you willing to do that if this 
will be the preferred way? My HID-fu is way worse than yours and It'll take a 
lot more time for me.
No, drivers should not be emitting ABS_MT_SLOT if they are not
multitouch devices and not using MT-B protocol. You'll have to remap the
axis into something more suitable.

Thanks,
Dmitry

-- 
Dmitry
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help