]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
kern/term: Make grub_getkeystatus() helper function available everywhere
authorHans de Goede <hdegoede@redhat.com>
Wed, 15 Apr 2020 10:26:18 +0000 (12:26 +0200)
committerDaniel Kiper <daniel.kiper@oracle.com>
Tue, 21 Apr 2020 20:08:52 +0000 (22:08 +0200)
Move grub_getkeystatushelper() function from grub-core/commands/keystatus.c
to grub-core/kern/term.c and export it so that it can be used outside of
the keystatus command code too.

There's no logic change in this patch. The function definition is moved so
it can be called from grub-core/kern/term.c in a subsequent patch. It will
be used to determine if a SHIFT key has was held down and use that also to
interrupt the countdown, without the need to press a key at the right time.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/commands/keystatus.c
grub-core/kern/term.c
include/grub/term.h

index 460cf4e7e50c0ee95b4c938853dda4a99b1b51e0..ff3f587816356cf899d76bb93125098b8515d3c4 100644 (file)
@@ -35,24 +35,6 @@ static const struct grub_arg_option options[] =
     {0, 0, 0, 0, 0, 0}
   };
 
-static int
-grub_getkeystatus (void)
-{
-  int status = 0;
-  grub_term_input_t term;
-
-  if (grub_term_poll_usb)
-    grub_term_poll_usb (0);
-
-  FOR_ACTIVE_TERM_INPUTS(term)
-  {
-    if (term->getkeystatus)
-      status |= term->getkeystatus (term);
-  }
-
-  return status;
-}
-
 static grub_err_t
 grub_cmd_keystatus (grub_extcmd_context_t ctxt,
                    int argc __attribute__ ((unused)),
index 07720ee67463547c2a5b33cf0334277965c9a0fd..93bd3378d186f708c8d9c42dff01837dd5b4e31d 100644 (file)
@@ -120,6 +120,24 @@ grub_getkey (void)
     }
 }
 
+int
+grub_getkeystatus (void)
+{
+  int status = 0;
+  grub_term_input_t term;
+
+  if (grub_term_poll_usb)
+    grub_term_poll_usb (0);
+
+  FOR_ACTIVE_TERM_INPUTS(term)
+  {
+    if (term->getkeystatus)
+      status |= term->getkeystatus (term);
+  }
+
+  return status;
+}
+
 void
 grub_refresh (void)
 {
index 8117e2a24dac3f270d05408f1897fae9f0fa1593..c215133383fb302480cf0edfd84a089d0674f879 100644 (file)
@@ -327,6 +327,7 @@ grub_term_unregister_output (grub_term_output_t term)
 void grub_putcode (grub_uint32_t code, struct grub_term_output *term);
 int EXPORT_FUNC(grub_getkey) (void);
 int EXPORT_FUNC(grub_getkey_noblock) (void);
+int EXPORT_FUNC(grub_getkeystatus) (void);
 void grub_cls (void);
 void EXPORT_FUNC(grub_refresh) (void);
 void grub_puts_terminal (const char *str, struct grub_term_output *term);