linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] HID: fix incorrect handling of devices with high button count
@ 2012-10-29 13:29 Ingo Ruhnke
  2012-10-31  6:36 ` Dmitry Torokhov
  0 siblings, 1 reply; 3+ messages in thread
From: Ingo Ruhnke @ 2012-10-29 13:29 UTC (permalink / raw)
  To: linux-input

Button names for USB gamepads are currently assigned incorrectly, as
the evdev code assigned to buttons is "BTN_GAMEPAD + code", which on
devices with more then 16 buttons bleeds over into button names
reserved for graphic tablets (BTN_TOOL_PEN, etc.). This causes
problems further down the line as the device are now no longer
detected as joystick. This patch fixes that by assigning buttons
outside the range to BTN_TRIGGER_HAPPY (as is already the case for USB
joysticks).

Furthermore this patch corrects the assignment to BTN_TRIGGER_HAPPY,
as currently the first button over 16 is assigned to
BTN_TRIGGER_HAPPY17 (i.e. BTN_TRIGGER_HAPPY+0x10) not BTN_TRIGGER_HAPPY.

Signed-off-by: Ingo Ruhnke <grumbel@gmail.com>
---
 drivers/hid/hid-input.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index d917c0d..10248cf 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -502,9 +502,14 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
 				if (code <= 0xf)
 					code += BTN_JOYSTICK;
 				else
-					code += BTN_TRIGGER_HAPPY;
+					code += BTN_TRIGGER_HAPPY - 0x10;
+				break;
+		case HID_GD_GAMEPAD:
+				if (code <= 0xf)
+					code += BTN_GAMEPAD;
+				else
+					code += BTN_TRIGGER_HAPPY - 0x10;
 				break;
-		case HID_GD_GAMEPAD:  code += BTN_GAMEPAD; break;
 		default:
 			switch (field->physical) {
 			case HID_GD_MOUSE:
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] HID: fix incorrect handling of devices with high button count
  2012-10-29 13:29 [PATCH] HID: fix incorrect handling of devices with high button count Ingo Ruhnke
@ 2012-10-31  6:36 ` Dmitry Torokhov
  2012-10-31 15:03   ` Jiri Kosina
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Torokhov @ 2012-10-31  6:36 UTC (permalink / raw)
  To: Ingo Ruhnke, Jiri Kosina; +Cc: linux-input

On Mon, Oct 29, 2012 at 02:29:30PM +0100, Ingo Ruhnke wrote:
> Button names for USB gamepads are currently assigned incorrectly, as
> the evdev code assigned to buttons is "BTN_GAMEPAD + code", which on
> devices with more then 16 buttons bleeds over into button names
> reserved for graphic tablets (BTN_TOOL_PEN, etc.). This causes
> problems further down the line as the device are now no longer
> detected as joystick. This patch fixes that by assigning buttons
> outside the range to BTN_TRIGGER_HAPPY (as is already the case for USB
> joysticks).
> 
> Furthermore this patch corrects the assignment to BTN_TRIGGER_HAPPY,
> as currently the first button over 16 is assigned to
> BTN_TRIGGER_HAPPY17 (i.e. BTN_TRIGGER_HAPPY+0x10) not BTN_TRIGGER_HAPPY.
> 
> Signed-off-by: Ingo Ruhnke <grumbel@gmail.com>

Makes sense.

Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

> ---
>  drivers/hid/hid-input.c |    9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
> index d917c0d..10248cf 100644
> --- a/drivers/hid/hid-input.c
> +++ b/drivers/hid/hid-input.c
> @@ -502,9 +502,14 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
>  				if (code <= 0xf)
>  					code += BTN_JOYSTICK;
>  				else
> -					code += BTN_TRIGGER_HAPPY;
> +					code += BTN_TRIGGER_HAPPY - 0x10;
> +				break;
> +		case HID_GD_GAMEPAD:
> +				if (code <= 0xf)
> +					code += BTN_GAMEPAD;
> +				else
> +					code += BTN_TRIGGER_HAPPY - 0x10;
>  				break;
> -		case HID_GD_GAMEPAD:  code += BTN_GAMEPAD; break;
>  		default:
>  			switch (field->physical) {
>  			case HID_GD_MOUSE:
> -- 
> 1.7.10.4
> 
> --
> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] HID: fix incorrect handling of devices with high button count
  2012-10-31  6:36 ` Dmitry Torokhov
@ 2012-10-31 15:03   ` Jiri Kosina
  0 siblings, 0 replies; 3+ messages in thread
From: Jiri Kosina @ 2012-10-31 15:03 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Ingo Ruhnke, Jiri Kosina, linux-input

yOn Tue, 30 Oct 2012, Dmitry Torokhov wrote:

> On Mon, Oct 29, 2012 at 02:29:30PM +0100, Ingo Ruhnke wrote:
> > Button names for USB gamepads are currently assigned incorrectly, as
> > the evdev code assigned to buttons is "BTN_GAMEPAD + code", which on
> > devices with more then 16 buttons bleeds over into button names
> > reserved for graphic tablets (BTN_TOOL_PEN, etc.). This causes
> > problems further down the line as the device are now no longer
> > detected as joystick. This patch fixes that by assigning buttons
> > outside the range to BTN_TRIGGER_HAPPY (as is already the case for USB
> > joysticks).
> > 
> > Furthermore this patch corrects the assignment to BTN_TRIGGER_HAPPY,
> > as currently the first button over 16 is assigned to
> > BTN_TRIGGER_HAPPY17 (i.e. BTN_TRIGGER_HAPPY+0x10) not BTN_TRIGGER_HAPPY.
> > 
> > Signed-off-by: Ingo Ruhnke <grumbel@gmail.com>
> 
> Makes sense.
> 
> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Good catch indeed. Applied, thanks!

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-10-31 15:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-29 13:29 [PATCH] HID: fix incorrect handling of devices with high button count Ingo Ruhnke
2012-10-31  6:36 ` Dmitry Torokhov
2012-10-31 15:03   ` Jiri Kosina

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).