grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/4] Accept Both ESC and F8 as user interrupt keys


From: Hans de Goede
Subject: [PATCH 2/4] Accept Both ESC and F8 as user interrupt keys
Date: Wed, 28 Mar 2018 16:50:26 +0200

On most Bay Trail, Cherry Trail and Apollo Lake devices the ESC key is
the hotkey to enter the BIOS/EFI setup screen.

This makes it hard for the user to show the grub-menu when it is hidden
and a short timeout is used, because pressing ESC too early leads to the
user entering the BIOS/EFI setup screen.

F8 is (almost?) always free (on X86/PC platforms) as Windows uses this for
its boot menu, so also accept F8 as interrupt/show-menu key. As an added
advantage this is also more discoverable / easier for users coming from
Windows.

Signed-off-by: Hans de Goede <address@hidden>
---
 grub-core/commands/sleep.c | 8 ++++++--
 grub-core/normal/menu.c    | 7 ++++---
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/grub-core/commands/sleep.c b/grub-core/commands/sleep.c
index e77e7900f..9f16956e0 100644
--- a/grub-core/commands/sleep.c
+++ b/grub-core/commands/sleep.c
@@ -51,12 +51,16 @@ static int
 grub_interruptible_millisleep (grub_uint32_t ms)
 {
   grub_uint64_t start;
+  int key;
 
   start = grub_get_time_ms ();
 
-  while (grub_get_time_ms () - start < ms)
-    if (grub_getkey_noblock () == GRUB_TERM_ESC)
+  while (grub_get_time_ms () - start < ms) {
+    key = grub_getkey_noblock ();
+    /* ESC sometimes is the BIOS setup hotkey, also allow F8 as intr. */
+    if (key == GRUB_TERM_ESC || key == GRUB_TERM_KEY_F8)
       return 1;
+  }
 
   return 0;
 }
diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c
index e7a83c2d6..d813fade1 100644
--- a/grub-core/normal/menu.c
+++ b/grub-core/normal/menu.c
@@ -610,8 +610,8 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
          print_countdown (pos, timeout);
        }
 
-      /* Enter interruptible sleep until Escape or a menu hotkey is pressed,
-         or the timeout expires.  */
+      /* Sleep until a menu hotkey is pressed, we are interrupted by an ESC/F8
+         keypress, or the timeout expires. */
       saved_time = grub_get_time_ms ();
       while (1)
        {
@@ -624,7 +624,8 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
              if (entry >= 0)
                break;
            }
-         if (key == GRUB_TERM_ESC)
+         /* ESC sometimes is the BIOS setup hotkey, also allow F8 as intr. */
+         if (key == GRUB_TERM_ESC || key == GRUB_TERM_KEY_F8)
            {
              timeout = -1;
              break;
-- 
2.17.0.rc1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]