mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH master] input: don't report depressed keys that were never pressed
@ 2024-08-24 20:02 Ahmad Fatoum
  2024-08-26 11:08 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2024-08-24 20:02 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

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




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

* Re: [PATCH master] input: don't report depressed keys that were never pressed
  2024-08-24 20:02 [PATCH master] input: don't report depressed keys that were never pressed Ahmad Fatoum
@ 2024-08-26 11:08 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2024-08-26 11:08 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum


On Sat, 24 Aug 2024 22:02:50 +0200, Ahmad Fatoum wrote:
> 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.
> 
> [...]

Applied, thanks!

[1/1] input: don't report depressed keys that were never pressed
      https://git.pengutronix.de/cgit/barebox/commit/?id=bad0d48fa6ab (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




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

end of thread, other threads:[~2024-08-26 11:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-24 20:02 [PATCH master] input: don't report depressed keys that were never pressed Ahmad Fatoum
2024-08-26 11:08 ` Sascha Hauer

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