Linux Input/HID development
 help / color / mirror / Atom feed
* [PATCH] HID: input: Increase maximum number of joystick buttons
@ 2025-12-20 19:41 Ivan Gorinov
  2026-01-03 19:26 ` tomasz.pakula.oficjalny
  0 siblings, 1 reply; 3+ messages in thread
From: Ivan Gorinov @ 2025-12-20 19:41 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: linux-input, linux-kernel

This patch increases the limit from 80 to 112 key codes.

If a joystick has 80 or fewer buttons, mapping stays the same.

If a joystick has more than 80 buttons:

  Map buttons [  0 ..  15 ] to key codes starting with BTN_JOYSTICK;
  Map buttons [ 16 ..  47 ] to key codes starting with KEY_MACRO1;
  Map buttons [ 48 .. 111 ] to key codes starting with BTN_TRIGGER_HAPPY.

Signed-off-by: Ivan Gorinov <linux-kernel@altimeter.info>
---
 drivers/hid/hid-input.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index 2633fcd8f910..c6159f96de04 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -763,7 +763,13 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
 				if (code <= 0xf)
 					code += BTN_JOYSTICK;
 				else
-					code += BTN_TRIGGER_HAPPY - 0x10;
+					if (field->maxusage <= 80)
+						code += BTN_TRIGGER_HAPPY - 0x10;
+					else
+						if (code <= 0x2f)
+							code += KEY_MACRO1 - 0x10;
+						else
+							code += BTN_TRIGGER_HAPPY - 0x30;
 				break;
 		case HID_GD_GAMEPAD:
 				if (code <= 0xf)
-- 
2.43.0


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

end of thread, other threads:[~2026-01-04  0:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-20 19:41 [PATCH] HID: input: Increase maximum number of joystick buttons Ivan Gorinov
2026-01-03 19:26 ` tomasz.pakula.oficjalny
2026-01-04  0:48   ` Ivan Gorinov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox