[PATCH] input: don't queue keys while the input console isn't stdin
Ahmad Fatoum
a.fatoum at barebox.org
Sun Nov 8 05:40:37 PST 2026
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 at 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
More information about the barebox
mailing list