[Concept,04/18] expo: Correct key-polling timeout

Message ID 20251010034255.1099728-5-sjg@u-boot.org
State New
Headers
Series expo: Extend the boot menu |

Commit Message

Simon Glass Oct. 10, 2025, 3:42 a.m. UTC
  From: Simon Glass <sjg@chromium.org>

When a character is received it should reset the timeout, even if the
character does not result in output from cli_ch_process()

Fix this, so that keypresses which consist of escape codes are correctly
interpreted.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: a5c5b3b2fb6 ("expo: Speed up polling the keyboard")
---

 boot/expo.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
  

Patch

diff --git a/boot/expo.c b/boot/expo.c
index 5704dd9fecc..1fb6d6e9417 100644
--- a/boot/expo.c
+++ b/boot/expo.c
@@ -486,17 +486,17 @@  int expo_iter_scene_objs(struct expo *exp, expo_scene_obj_iterator iter,
 
 static int poll_keys(struct expo *exp)
 {
-	int ichar, key;
+	int ch = 0, ichar, key;
 
 	ichar = cli_ch_process(&exp->cch, 0);
 	if (!ichar) {
 		/* Check once for available input */
 		if (tstc()) {
-			ichar = getchar();
-			ichar = cli_ch_process(&exp->cch, ichar);
+			ch = getchar();
+			ichar = cli_ch_process(&exp->cch, ch);
 		}
 
-		if (!ichar && get_timer(exp->last_key_ms) >= 10)
+		if (!ch && get_timer(exp->last_key_ms) >= 10)
 			ichar = cli_ch_process(&exp->cch, -ETIMEDOUT);
 	}