From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH master] input: don't report depressed keys that were never pressed
Date: Sat, 24 Aug 2024 22:02:50 +0200 [thread overview]
Message-ID: <20240824200250.2160073-1-a.fatoum@pengutronix.de> (raw)
The USB keyboard driver remove callback sends a depress event for all
keys. This is relayed to all input notifiers and can confuse them by
reporting keys that were never pressed in the first place.
Instead of expecting input notifiers to keep track themselves of whether
keys have been pressed, have the core only report depress event for
previously pressed keys.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
drivers/input/input.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 1a4792935114..e5509bf90d3e 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -44,10 +44,11 @@ void input_report_key_event(struct input_device *idev, unsigned int code, int va
pr_print(MSG_DEBUG, "Event. Dev: %s, Type: %d, Code: %d, Value: %d\n",
dev_name(idev->parent), EV_KEY, code, value);
+ /* Only report depressed keys, if we registered them being pressed */
if (value)
set_bit(code, idev->keys);
- else
- clear_bit(code, idev->keys);
+ else if (!test_and_clear_bit(code, idev->keys))
+ return;
event.code = code;
event.value = value;
--
2.39.2
next reply other threads:[~2024-08-24 20:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-24 20:02 Ahmad Fatoum [this message]
2024-08-26 11:08 ` Sascha Hauer
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=20240824200250.2160073-1-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.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