]> xenbits.xensource.com Git - seabios.git/commitdiff
boot.c: delay exiting boot if menu key is ESC
authorPaolo Bonzini <pbonzini@redhat.com>
Thu, 12 Mar 2015 17:12:23 +0000 (18:12 +0100)
committerKevin O'Connor <kevin@koconnor.net>
Mon, 16 Mar 2015 14:34:55 +0000 (10:34 -0400)
If the menu key is ESC, do not restart boot unless
1.5 seconds have passed.  Otherwise users (trained by years of
repeatedly hitting keys to enter the BIOS) will end up hitting ESC
multiple times and immediately booting the primary boot device.

Suggested-by: Matt DeVillier <matt.devillier@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
src/boot.c

index f23e9e154ea21e9170c164646526436c9dd7787d..3aab8d42c839467a42ba657b58bfadcbc3f378e3 100644 (file)
@@ -486,9 +486,15 @@ interactive_bootmenu(void)
                , strtcpy(desc, pos->description, ARRAY_SIZE(desc)));
     }
 
-    // Get key press
+    // Get key press.  If the menu key is ESC, do not restart boot unless
+    // 1.5 seconds have passed.  Otherwise users (trained by years of
+    // repeatedly hitting keys to enter the BIOS) will end up hitting ESC
+    // multiple times and immediately booting the primary boot device.
+    int esc_accepted_time = irqtimer_calc(menukey == 1 ? 1500 : 0);
     for (;;) {
         scan_code = get_keystroke(1000);
+        if (scan_code == 1 && !irqtimer_check(esc_accepted_time))
+            continue;
         if (scan_code >= 1 && scan_code <= maxmenu+1)
             break;
     }