Skip to content

Commit

Permalink
HID: fix incorrect handling of devices with high button count
Browse files Browse the repository at this point in the history
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>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
  • Loading branch information
Ingo Ruhnke authored and Jiri Kosina committed Oct 31, 2012
1 parent c10354d commit f8e86d0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions drivers/hid/hid-input.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit f8e86d0

Please sign in to comment.