https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f8d3f9de29982a27a125a2338aaf5ea722211a66

commit f8d3f9de29982a27a125a2338aaf5ea722211a66
Author:     Hermès Bélusca-Maïto <hermes.belusca-ma...@reactos.org>
AuthorDate: Sun Nov 25 17:01:54 2018 +0100
Commit:     Hermès Bélusca-Maïto <hermes.belusca-ma...@reactos.org>
CommitDate: Sun Nov 25 17:09:19 2018 +0100

    [FREELDR] Check for any user keypress in menu even when the timeout is zero.
    
    Before taking any default action if there is no timeout, check whether
    the supplied key filter callback function may handle a specific user
    keypress. If it does, the menu timeout is cancelled.
    
    This allows e.g. handling F8 press for displaying boot options even when
    the timeout is zero.
    
    CORE-14046
---
 boot/freeldr/freeldr/ui/directui.c | 25 +++++++++++++++++++++++++
 boot/freeldr/freeldr/ui/tuimenu.c  | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 57 insertions(+)

diff --git a/boot/freeldr/freeldr/ui/directui.c 
b/boot/freeldr/freeldr/ui/directui.c
index 352f8309fc..a602700988 100644
--- a/boot/freeldr/freeldr/ui/directui.c
+++ b/boot/freeldr/freeldr/ui/directui.c
@@ -556,6 +556,31 @@ UiDisplayMenu(IN PCSTR MenuHeader,
     ULONG CurrentClockSecond;
     ULONG KeyPress;
 
+    /*
+     * Before taking any default action if there is no timeout,
+     * check whether the supplied key filter callback function
+     * may handle a specific user keypress. If it does, the
+     * timeout is cancelled.
+     */
+    if (!MenuTimeOut && KeyPressFilter && MachConsKbHit())
+    {
+        /* Get the key */
+        KeyPress = MachConsGetCh();
+
+        /* Is it extended? Then get the extended key */
+        if (!KeyPress) KeyPress = MachConsGetCh();
+
+        /*
+         * Call the supplied key filter callback function to see
+         * if it is going to handle this keypress.
+         */
+        if (KeyPressFilter(KeyPress))
+        {
+            /* It processed the key character, cancel the timeout */
+            MenuTimeOut = -1;
+        }
+    }
+
     /* Check if there's no timeout */
     if (!MenuTimeOut)
     {
diff --git a/boot/freeldr/freeldr/ui/tuimenu.c 
b/boot/freeldr/freeldr/ui/tuimenu.c
index fa950b3ccf..86690af784 100644
--- a/boot/freeldr/freeldr/ui/tuimenu.c
+++ b/boot/freeldr/freeldr/ui/tuimenu.c
@@ -30,8 +30,40 @@ TuiDisplayMenu(PCSTR MenuHeader,
     ULONG CurrentClockSecond;
     ULONG KeyPress;
 
+    //
+    // Before taking any default action if there is no timeout,
+    // check whether the supplied key filter callback function
+    // may handle a specific user keypress. If it does, the
+    // timeout is cancelled.
+    //
+    if (!MenuTimeOut && KeyPressFilter && MachConsKbHit())
+    {
+        //
+        // Get the key
+        //
+        KeyPress = MachConsGetCh();
+
+        //
+        // Is it extended? Then get the extended key
+        //
+        if (!KeyPress) KeyPress = MachConsGetCh();
+
+        //
+        // Call the supplied key filter callback function to see
+        // if it is going to handle this keypress.
+        //
+        if (KeyPressFilter(KeyPress))
+        {
+            //
+            // It processed the key character, cancel the timeout
+            //
+            MenuTimeOut = -1;
+        }
+    }
+
     //
     // Check if there's no timeout
+    //
     if (!MenuTimeOut)
     {
         //

Reply via email to