From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH] input: don't queue keys while the input console isn't stdin
Date: Sun, 8 Nov 2026 14:40:37 +0100 [thread overview]
Message-ID: <20261108134040.1324667-1-a.fatoum@barebox.org> (raw)
Applications like bareDOOM take the keyboard over by registering their
own input notifier and deactivating the input console. The input console
notifier keeps queueing every key press into its FIFO all the same, so
once the application exits and reactivates the console, the shell
receives the last 32 keys pressed during the game.
Let's only queue keys and start the key repeat while the console is
actually active as stdin.
Tested with DOOM on TinyEMU: the shell prompt stays empty after quitting.
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
drivers/input/input.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 5ee63d94d6f4..b77de20ae975 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -128,7 +128,7 @@ static void input_console_repeat(void *ctx)
{
struct input_console *ic = ctx;
- if (ic->current_key) {
+ if (ic->current_key && (ic->console.f_active & CONSOLE_STDIN)) {
kfifo_putc(ic->fifo, ic->current_key);
poller_call_async(&ic->poller, 40 * MSECOND,
input_console_repeat, ic);
@@ -196,6 +196,9 @@ static void input_console_notify(struct input_notifier *in,
pr_debug("map %02x KEY: 0x%04x code: %d\n", modstate, ascii, ev->code);
if (ev->value) {
+ if (!(ic->console.f_active & CONSOLE_STDIN))
+ return;
+
kfifo_putc(ic->fifo, ascii);
ic->current_key = ascii;
poller_call_async(&ic->poller, 400 * MSECOND,
--
2.47.3
next reply other threads:[~2026-11-08 13:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-08 13:40 Ahmad Fatoum [this message]
2026-11-09 9: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=20261108134040.1324667-1-a.fatoum@barebox.org \
--to=a.fatoum@barebox.org \
--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