mirror of
https://github.com/edera-dev/sprout.git
synced 2026-11-04 21:42:23 +00:00
fix(menu): keep the countdown going after a spurious key event
Some firmware signals the key event without a key being available. The simple menu then skipped the countdown for that tick, and the basic menu started waiting for the full timeout again, so firmware that kept signaling the key event would never boot the default entry. Read the key inside the wait, and when no key is available keep waiting on the same timer.
This commit is contained in:
1 parent
11736ccabb
commit
78bcaa79ff
3 files changed
+38
-41
No files matched your search
@@ -1,5 +1,5 @@
|
||||
use crate::entries::BootableEntry;
|
||||
use crate::menu::{BootMenu, wait_for_key};
|
||||
use crate::menu::{BootMenu, read_key};
|
||||
use anyhow::{Context, Result};
|
||||
use core::time::Duration;
|
||||
use log::info;
|
||||
@@ -30,15 +30,8 @@ enum MenuOperation {
|
||||
/// performed.
|
||||
fn read(input: &mut Input, timeout: &Duration) -> Result<MenuOperation> {
|
||||
// If the timer triggered, the user did not select a numbered entry.
|
||||
if !wait_for_key(input, *timeout)? {
|
||||
let Some(key) = read_key(input, *timeout)? else {
|
||||
return Ok(MenuOperation::Timeout);
|
||||
}
|
||||
|
||||
// If we reach here, there is a key event.
|
||||
// Some firmware signals the key event without a key being available,
|
||||
// in which case there is nothing to do.
|
||||
let Some(key) = input.read_key().context("unable to read key")? else {
|
||||
return Ok(MenuOperation::Nop);
|
||||
};
|
||||
|
||||
match key {
|
||||
|
||||
Reference in new issue
Block a user