linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ivan Gorinov <linux-kernel@altimeter.info>
To: Jiri Kosina <jikos@kernel.org>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] HID: input: Increase maximum number of joystick buttons
Date: Sat, 20 Dec 2025 19:41:00 +0000	[thread overview]
Message-ID: <20251220194100.GA12646@altimeter-info> (raw)

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


                 reply	other threads:[~2025-12-20 19:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251220194100.GA12646@altimeter-info \
    --to=linux-kernel@altimeter.info \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).