[FREELDR] Check for any user keypress in menu even when the timeout is zero.
[reactos.git] / boot / freeldr / freeldr / ui / tuimenu.c
index 69ab50b..86690af 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         FreeLoader
- * FILE:            freeldr/ui/tuimenu.c
+ * FILE:            boot/freeldr/freeldr/ui/tuimenu.c
  * PURPOSE:         UI Menu Functions
  * PROGRAMMERS:     Alex Ionescu (alex@relsoft.net)
  *                  Brian Palmer (brianp@sginet.com)
@@ -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)
     {
         //