]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/SetupBrowserDxe/InputHandler.c
Enable number input for numeric, date and time opcode
[mirror_edk2.git] / MdeModulePkg / Universal / SetupBrowserDxe / InputHandler.c
index 2905006856ac62573e589ecbe49c070a7234ff1c..0d42beae504a89d7188cc91aa8d8395a5ba0f8b6 100644 (file)
@@ -270,6 +270,12 @@ GetNumericInput (
   Minimum       = Question->Minimum;\r
   Maximum       = Question->Maximum;\r
 \r
+  //\r
+  // Only two case, user can enter to this function: Enter and +/- case.\r
+  // In Enter case, gDirection = 0; in +/- case, gDirection = SCAN_LEFT/SCAN_WRIGHT\r
+  //\r
+  ManualInput        = (BOOLEAN)(gDirection == 0 ? TRUE : FALSE);\r
+\r
   if ((Question->Operand == EFI_IFR_DATE_OP) || (Question->Operand == EFI_IFR_TIME_OP)) {\r
     DateOrTime = TRUE;\r
   } else {\r
@@ -344,12 +350,6 @@ GetNumericInput (
     }\r
   }\r
 \r
-  if (Step == 0) {\r
-    ManualInput = TRUE;\r
-  } else {\r
-    ManualInput = FALSE;\r
-  }\r
-\r
   if ((Question->Operand == EFI_IFR_NUMERIC_OP) &&\r
       ((Question->Flags & EFI_IFR_DISPLAY) == EFI_IFR_DISPLAY_UINT_HEX)) {\r
     HexInput = TRUE;\r
@@ -357,41 +357,96 @@ GetNumericInput (
     HexInput = FALSE;\r
   }\r
 \r
+  //\r
+  // Enter from "Enter" input, clear the old word showing.\r
+  //\r
   if (ManualInput) {\r
-    if (HexInput) {\r
-      InputWidth = Question->StorageWidth * 2;\r
-    } else {\r
-      switch (Question->StorageWidth) {\r
-      case 1:\r
-        InputWidth = 3;\r
-        break;\r
+    if (Question->Operand == EFI_IFR_NUMERIC_OP) {\r
+      if (HexInput) {\r
+        InputWidth = Question->StorageWidth * 2;\r
+      } else {\r
+        switch (Question->StorageWidth) {\r
+        case 1:\r
+          InputWidth = 3;\r
+          break;\r
 \r
-      case 2:\r
-        InputWidth = 5;\r
-        break;\r
+        case 2:\r
+          InputWidth = 5;\r
+          break;\r
 \r
-      case 4:\r
-        InputWidth = 10;\r
-        break;\r
+        case 4:\r
+          InputWidth = 10;\r
+          break;\r
 \r
-      case 8:\r
-        InputWidth = 20;\r
-        break;\r
+        case 8:\r
+          InputWidth = 20;\r
+          break;\r
 \r
-      default:\r
-        InputWidth = 0;\r
-        break;\r
+        default:\r
+          InputWidth = 0;\r
+          break;\r
+        }\r
+      }\r
+\r
+      InputText[0] = LEFT_NUMERIC_DELIMITER;\r
+      SetUnicodeMem (InputText + 1, InputWidth, L' ');\r
+      ASSERT (InputWidth + 2 < MAX_NUMERIC_INPUT_WIDTH);\r
+      InputText[InputWidth + 1] = RIGHT_NUMERIC_DELIMITER;\r
+      InputText[InputWidth + 2] = L'\0';\r
+\r
+      PrintAt (Column, Row, InputText);\r
+      Column++;\r
+    }\r
+\r
+    if (Question->Operand == EFI_IFR_DATE_OP) {\r
+      if (MenuOption->Sequence == 2) {\r
+        InputWidth = 4;\r
+      } else {\r
+        InputWidth = 2;\r
+      }\r
+\r
+      if (MenuOption->Sequence == 0) {\r
+        InputText[0] = LEFT_NUMERIC_DELIMITER;\r
+        SetUnicodeMem (InputText + 1, InputWidth, L' ');\r
+      } else {\r
+        SetUnicodeMem (InputText, InputWidth, L' ');\r
+      }\r
+\r
+      if (MenuOption->Sequence == 2) {\r
+        InputText[InputWidth + 1] = RIGHT_NUMERIC_DELIMITER;\r
+      } else {\r
+        InputText[InputWidth + 1] = DATE_SEPARATOR;\r
+      }\r
+      InputText[InputWidth + 2] = L'\0';\r
+\r
+      PrintAt (Column, Row, InputText);\r
+      if (MenuOption->Sequence == 0) {\r
+        Column++;\r
       }\r
     }\r
 \r
-    InputText[0] = LEFT_NUMERIC_DELIMITER;\r
-    SetUnicodeMem (InputText + 1, InputWidth, L' ');\r
-    ASSERT (InputWidth + 2 < MAX_NUMERIC_INPUT_WIDTH);\r
-    InputText[InputWidth + 1] = RIGHT_NUMERIC_DELIMITER;\r
-    InputText[InputWidth + 2] = L'\0';\r
+    if (Question->Operand == EFI_IFR_TIME_OP) {\r
+      InputWidth = 2;\r
+\r
+      if (MenuOption->Sequence == 0) {\r
+        InputText[0] = LEFT_NUMERIC_DELIMITER;\r
+        SetUnicodeMem (InputText + 1, InputWidth, L' ');\r
+      } else {\r
+        SetUnicodeMem (InputText, InputWidth, L' ');\r
+      }\r
+\r
+      if (MenuOption->Sequence == 2) {\r
+        InputText[InputWidth + 1] = RIGHT_NUMERIC_DELIMITER;\r
+      } else {\r
+        InputText[InputWidth + 1] = TIME_SEPARATOR;\r
+      }\r
+      InputText[InputWidth + 2] = L'\0';\r
 \r
-    PrintAt (Column, Row, InputText);\r
-    Column++;\r
+      PrintAt (Column, Row, InputText);\r
+      if (MenuOption->Sequence == 0) {\r
+        Column++;\r
+      }\r
+    }\r
   }\r
 \r
   //\r
@@ -425,7 +480,7 @@ TheKey2:
       switch (Key.ScanCode) {\r
       case SCAN_LEFT:\r
       case SCAN_RIGHT:\r
-        if (DateOrTime) {\r
+        if (DateOrTime && !ManualInput) {\r
           //\r
           // By setting this value, we will return back to the caller.\r
           // We need to do this since an auto-refresh will destroy the adjustment\r
@@ -435,7 +490,7 @@ TheKey2:
           gDirection = SCAN_DOWN;\r
         }\r
 \r
-        if (!ManualInput) {\r
+        if ((Step != 0) && !ManualInput) {\r
           if (Key.ScanCode == SCAN_LEFT) {\r
             if (EditValue > Step) {\r
               EditValue = EditValue - Step;\r