]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/SetupBrowserDxe/InputHandler.c
Fix AutoUpdateLangVariable() logic to handle the case PlatformLang/Lang is set before...
[mirror_edk2.git] / MdeModulePkg / Universal / SetupBrowserDxe / InputHandler.c
index 48f5815e4360de4660e5784389e7a1478c2e9e09..2905006856ac62573e589ecbe49c070a7234ff1c 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
 Implementation for handling user input from the User Interfaces.\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 http://opensource.org/licenses/bsd-license.php\r
@@ -12,7 +12,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 **/\r
 \r
-#include "Ui.h"\r
 #include "Setup.h"\r
 \r
 \r
@@ -92,7 +91,7 @@ ReadString (
   //\r
   // Display prompt for string\r
   //\r
-  CreatePopUp (ScreenSize, 4, &NullCharacter, Prompt, Space, &NullCharacter);\r
+  CreateMultiStringPopUp (ScreenSize, 4, &NullCharacter, Prompt, Space, &NullCharacter);\r
 \r
   gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_BLACK, EFI_LIGHTGRAY));\r
 \r
@@ -387,7 +386,7 @@ GetNumericInput (
 \r
     InputText[0] = LEFT_NUMERIC_DELIMITER;\r
     SetUnicodeMem (InputText + 1, InputWidth, L' ');\r
-    ASSERT (InputWidth + 2 < MAX_NUMERIC_INPUT_WIDTH); \r
+    ASSERT (InputWidth + 2 < MAX_NUMERIC_INPUT_WIDTH);\r
     InputText[InputWidth + 1] = RIGHT_NUMERIC_DELIMITER;\r
     InputText[InputWidth + 2] = L'\0';\r
 \r
@@ -456,25 +455,29 @@ TheKey2:
               //\r
               // Year\r
               //\r
-              UnicodeSPrint (FormattedNumber, 21 * sizeof (CHAR16), L"%04d", EditValue);\r
+              UnicodeSPrint (FormattedNumber, 21 * sizeof (CHAR16), L"%04d", (UINT16) EditValue);\r
             } else {\r
               //\r
               // Month/Day\r
               //\r
-              UnicodeSPrint (FormattedNumber, 21 * sizeof (CHAR16), L"%02d", EditValue);\r
+              UnicodeSPrint (FormattedNumber, 21 * sizeof (CHAR16), L"%02d", (UINT8) EditValue);\r
             }\r
 \r
             if (MenuOption->Sequence == 0) {\r
+              ASSERT (EraseLen >= 2);\r
               FormattedNumber[EraseLen - 2] = DATE_SEPARATOR;\r
             } else if (MenuOption->Sequence == 1) {\r
+              ASSERT (EraseLen >= 1);\r
               FormattedNumber[EraseLen - 1] = DATE_SEPARATOR;\r
             }\r
           } else if (Question->Operand == EFI_IFR_TIME_OP) {\r
-            UnicodeSPrint (FormattedNumber, 21 * sizeof (CHAR16), L"%02d", EditValue);\r
+            UnicodeSPrint (FormattedNumber, 21 * sizeof (CHAR16), L"%02d", (UINT8) EditValue);\r
 \r
             if (MenuOption->Sequence == 0) {\r
+              ASSERT (EraseLen >= 2);\r
               FormattedNumber[EraseLen - 2] = TIME_SEPARATOR;\r
             } else if (MenuOption->Sequence == 1) {\r
+              ASSERT (EraseLen >= 1);\r
               FormattedNumber[EraseLen - 1] = TIME_SEPARATOR;\r
             }\r
           } else {\r
@@ -605,7 +608,13 @@ EnterCarriageReturn:
     default:\r
       if (ManualInput) {\r
         if (HexInput) {\r
-          if (!IsHexDigit (&Digital, Key.UnicodeChar)) {\r
+          if ((Key.UnicodeChar >= L'0') && (Key.UnicodeChar <= L'9')) {\r
+            Digital = (UINT8) (Key.UnicodeChar - L'0');\r
+          } else if ((Key.UnicodeChar >= L'A') && (Key.UnicodeChar <= L'F')) {\r
+            Digital = (UINT8) (Key.UnicodeChar - L'A' + 0x0A);\r
+          } else if ((Key.UnicodeChar >= L'a') && (Key.UnicodeChar <= L'f')) {\r
+            Digital = (UINT8) (Key.UnicodeChar - L'a' + 0x0A);\r
+          } else {\r
             UpdateStatusBar (INPUT_ERROR, Question->QuestionFlags, TRUE);\r
             break;\r
           }\r
@@ -701,6 +710,7 @@ GetSelectionInputPopUp (
   LIST_ENTRY              *Link;\r
   BOOLEAN                 OrderedList;\r
   UINT8                   *ValueArray;\r
+  UINT8                   ValueType;\r
   EFI_HII_VALUE           HiiValue;\r
   EFI_HII_VALUE           *HiiValueArray;\r
   UINTN                   OptionCount;\r
@@ -711,6 +721,7 @@ GetSelectionInputPopUp (
   DimensionsWidth   = gScreenDimensions.RightColumn - gScreenDimensions.LeftColumn;\r
 \r
   ValueArray        = NULL;\r
+  ValueType         = 0;\r
   CurrentOption     = NULL;\r
   ShowDownArrow     = FALSE;\r
   ShowUpArrow       = FALSE;\r
@@ -721,6 +732,7 @@ GetSelectionInputPopUp (
   Question = MenuOption->ThisTag;\r
   if (Question->Operand == EFI_IFR_ORDERED_LIST_OP) {\r
     ValueArray = Question->BufferValue;\r
+    ValueType = Question->ValueType;\r
     OrderedList = TRUE;\r
   } else {\r
     OrderedList = FALSE;\r
@@ -731,7 +743,7 @@ GetSelectionInputPopUp (
   //\r
   if (OrderedList) {\r
     for (Index = 0; Index < Question->MaxContainers; Index++) {\r
-      if (ValueArray[Index] == 0) {\r
+      if (GetArrayData (ValueArray, ValueType, Index) == 0) {\r
         break;\r
       }\r
     }\r
@@ -757,8 +769,8 @@ GetSelectionInputPopUp (
   Link = GetFirstNode (&Question->OptionListHead);\r
   for (Index = 0; Index < OptionCount; Index++) {\r
     if (OrderedList) {\r
-      HiiValueArray[Index].Type = EFI_IFR_TYPE_NUM_SIZE_8;\r
-      HiiValueArray[Index].Value.u8 = ValueArray[Index];\r
+      HiiValueArray[Index].Type = ValueType;\r
+      HiiValueArray[Index].Value.u64 = GetArrayData (ValueArray, ValueType, Index);\r
     } else {\r
       OneOfOption = QUESTION_OPTION_FROM_LINK (Link);\r
       CopyMem (&HiiValueArray[Index], &OneOfOption->Value, sizeof (EFI_HII_VALUE));\r
@@ -1054,11 +1066,11 @@ TheKey:
         // Restore link list order for orderedlist\r
         //\r
         if (OrderedList) {\r
-          HiiValue.Type = EFI_IFR_TYPE_NUM_SIZE_8;\r
+          HiiValue.Type = ValueType;\r
           HiiValue.Value.u64 = 0;\r
           for (Index = 0; Index < Question->MaxContainers; Index++) {\r
-            HiiValue.Value.u8 = ValueArray[Index];\r
-            if (HiiValue.Value.u8 != 0) {\r
+            HiiValue.Value.u64 = GetArrayData (ValueArray, ValueType, Index);\r
+            if (HiiValue.Value.u64 == 0) {\r
               break;\r
             }\r
 \r
@@ -1091,7 +1103,7 @@ TheKey:
         while (!IsNull (&Question->OptionListHead, Link)) {\r
           OneOfOption = QUESTION_OPTION_FROM_LINK (Link);\r
 \r
-          Question->BufferValue[Index] = OneOfOption->Value.Value.u8;\r
+          SetArrayData (ValueArray, ValueType, Index, OneOfOption->Value.Value.u64);\r
 \r
           Index++;\r
           if (Index > Question->MaxContainers) {\r