diff --git a/bootloader/main.c b/bootloader/main.c index 87e4a8a..8c12ab7 100644 --- a/bootloader/main.c +++ b/bootloader/main.c @@ -998,7 +998,7 @@ skip_list: // Wait before booting. If VOL- is pressed go into bootloader menu. if (!h_cfg.sept_run && !(b_cfg.boot_cfg & BOOT_CFG_FROM_LAUNCH)) { - btn = btn_wait_timeout(h_cfg.bootwait * 1000, BTN_VOL_DOWN); + btn = btn_wait_timeout(h_cfg.bootwait * 1000, BTN_VOL_DOWN | BTN_SINGLE); if (btn & BTN_VOL_DOWN) goto out; diff --git a/bootloader/utils/btn.c b/bootloader/utils/btn.c index 63a983a..678b19f 100644 --- a/bootloader/utils/btn.c +++ b/bootloader/utils/btn.c @@ -61,16 +61,25 @@ u8 btn_wait() u8 btn_wait_timeout(u32 time_ms, u8 mask) { + u8 single_button = mask & BTN_SINGLE; + mask &= ~BTN_SINGLE; + u32 timeout = get_tmr_ms() + time_ms; - u8 res = btn_read() & mask; + u8 res = btn_read(); while (get_tmr_ms() < timeout) { - if (res == mask) - break; + if ((res & mask) == mask) + { + if (single_button && (res & ~mask)) // Undesired button detected. + res = btn_read(); + else + return (res & mask); + } else - res = btn_read() & mask; + res = btn_read(); }; - return res; + // Timed out. + return 0; }