From: "Tomasz Pakuła" <tomasz.pakula.oficjalny@gmail.com>
To: dmitry.torokhov@gmail.com, corbet@lwn.net, jikos@kernel.org,
bentiss@kernel.org
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org, vi@endrift.com,
linux-kernel@altimeter.info, peter.hutterer@who-t.net
Subject: [RFC PATCH 3/6] Input: Fire EV_BTN if found in ev_bit
Date: Sun, 4 Jan 2026 22:31:29 +0100 [thread overview]
Message-ID: <20260104213132.163904-4-tomasz.pakula.oficjalny@gmail.com> (raw)
In-Reply-To: <20260104213132.163904-1-tomasz.pakula.oficjalny@gmail.com>
Passes EV_BTN through to handlers and allows reacting to this event by
clients.
Signed-off-by: Tomasz Pakuła <tomasz.pakula.oficjalny@gmail.com>
---
drivers/hid/hid-input.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index 2bbb645c2ff4..900a6fc9813e 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -1673,7 +1673,8 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct
switch (usage->type) {
case EV_KEY:
- if (usage->code == 0) /* Key 0 is "unassigned", not KEY_UNKNOWN */
+ /* Key 0 is "unassigned", not KEY_UNKNOWN */
+ if (usage->code == 0 && !test_bit(EV_BTN, input->evbit))
return;
break;
@@ -1723,10 +1724,19 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct
value == field->value[usage->usage_index])
return;
- /* report the usage code as scancode if the key status has changed */
- if (usage->type == EV_KEY &&
- (!test_bit(usage->code, input->key)) == value)
- input_event(input, EV_MSC, MSC_SCAN, usage->hid);
+
+ if (usage->type == EV_KEY) {
+ /* Send out EV_BTN with button number (starts at 1) */
+ if (test_bit(EV_BTN, input->evbit))
+ input_event(input, EV_BTN, usage->hid & HID_USAGE, value);
+
+ if (usage->code == 0)
+ return;
+
+ /* report usage code as scancode if the status has changed */
+ if ((!test_bit(usage->code, input->key)) == value)
+ input_event(input, EV_MSC, MSC_SCAN, usage->hid);
+ }
input_event(input, usage->type, usage->code, value);
--
2.52.0
next prev parent reply other threads:[~2026-01-04 21:31 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-04 21:31 [RFC PATCH 0/6] Input: New EV_BTN event for generic buttons Tomasz Pakuła
2026-01-04 21:31 ` [RFC PATCH 1/6] Input: Introduce " Tomasz Pakuła
2026-01-04 22:30 ` Randy Dunlap
2026-01-04 21:31 ` [RFC PATCH 2/6] Input: Add info about EV_BTN Tomasz Pakuła
2026-01-04 21:31 ` Tomasz Pakuła [this message]
2026-01-08 10:48 ` [RFC PATCH 3/6] Input: Fire EV_BTN if found in ev_bit Benjamin Tissoires
2026-01-04 21:31 ` [RFC PATCH 4/6] Input: Assign EV_BTN event to HID Joysticks Tomasz Pakuła
2026-01-08 10:50 ` Benjamin Tissoires
2026-01-04 21:31 ` [RFC PATCH 5/6] Input: Realign rest of the HID_UP_BUTTON cases Tomasz Pakuła
2026-01-04 21:31 ` [RFC PATCH 6/6] Input: Add EVIOCGBTNCNT Tomasz Pakuła
2026-01-07 5:44 ` [RFC PATCH 0/6] Input: New EV_BTN event for generic buttons Ivan Gorinov
2026-01-08 3:24 ` Peter Hutterer
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=20260104213132.163904-4-tomasz.pakula.oficjalny@gmail.com \
--to=tomasz.pakula.oficjalny@gmail.com \
--cc=bentiss@kernel.org \
--cc=corbet@lwn.net \
--cc=dmitry.torokhov@gmail.com \
--cc=jikos@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@altimeter.info \
--cc=linux-kernel@vger.kernel.org \
--cc=peter.hutterer@who-t.net \
--cc=vi@endrift.com \
/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