]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg/[hex]edit: Fix CTRL+<Alpha> doesn't work from hyper terminal
authorRuiyu Ni <ruiyu.ni@intel.com>
Tue, 13 Feb 2018 09:29:55 +0000 (17:29 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Thu, 15 Feb 2018 06:12:51 +0000 (14:12 +0800)
After commit 20ddbc133f679b7895dfdaf2fd58ec4c8183a1d8
* MdeModulePkg/ConSplitter: ReadKeyStrokeEx always return key state

When one physical console supports to report the shift key state,
the key data returned from ConSplitter driver at least carries
the shift key valid bit.
The patch fixes the edit/hexedit to accept Unicode (1) when
the no shift key is pressed or reported.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c
ShellPkg/Library/UefiShellDebug1CommandsLib/EditMenuBar.c
ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c

index 4eb998bf5fbad27f9b6b00d9dd46d59287df4b04..6832441e8161c07205f59ab9074450e2aa38a500 100644 (file)
@@ -1387,18 +1387,20 @@ MainCommandDisplayHelp (
       continue;\r
     }\r
 \r
       continue;\r
     }\r
 \r
-    if ((KeyData.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) == 0) {\r
+    if (((KeyData.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) == 0) ||\r
+        (KeyData.KeyState.KeyShiftState == EFI_SHIFT_STATE_VALID)) {\r
       //\r
       //\r
-      // For consoles that don't support shift state reporting,\r
+      // For consoles that don't support/report shift state,\r
       // CTRL+W is translated to L'W' - L'A' + 1.\r
       //\r
       if (KeyData.Key.UnicodeChar == L'W' - L'A' + 1) {\r
         break;\r
       }\r
       // CTRL+W is translated to L'W' - L'A' + 1.\r
       //\r
       if (KeyData.Key.UnicodeChar == L'W' - L'A' + 1) {\r
         break;\r
       }\r
-    } else if (((KeyData.KeyState.KeyShiftState & (EFI_LEFT_CONTROL_PRESSED | EFI_RIGHT_CONTROL_PRESSED)) != 0) &&\r
+    } else if (((KeyData.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) != 0) &&\r
+               ((KeyData.KeyState.KeyShiftState & (EFI_LEFT_CONTROL_PRESSED | EFI_RIGHT_CONTROL_PRESSED)) != 0) &&\r
                ((KeyData.KeyState.KeyShiftState & ~(EFI_SHIFT_STATE_VALID | EFI_LEFT_CONTROL_PRESSED | EFI_RIGHT_CONTROL_PRESSED)) == 0)) {\r
       //\r
                ((KeyData.KeyState.KeyShiftState & ~(EFI_SHIFT_STATE_VALID | EFI_LEFT_CONTROL_PRESSED | EFI_RIGHT_CONTROL_PRESSED)) == 0)) {\r
       //\r
-      // For consoles that supports shift state reporting,\r
+      // For consoles that supports/reports shift state,\r
       // make sure that only CONTROL shift key is pressed.\r
       //\r
       if ((KeyData.Key.UnicodeChar == 'w') || (KeyData.Key.UnicodeChar == 'W')) {\r
       // make sure that only CONTROL shift key is pressed.\r
       //\r
       if ((KeyData.Key.UnicodeChar == 'w') || (KeyData.Key.UnicodeChar == 'W')) {\r
index b86594bb283e146cd1063a6ee632e34321777416..58e90ac5b2eb466e4df321783ab4b9f0864d7cff 100644 (file)
@@ -183,16 +183,18 @@ MenuBarDispatchControlHotKey (
   //\r
   ControlIndex = MAX_UINT16;\r
 \r
   //\r
   ControlIndex = MAX_UINT16;\r
 \r
-  if ((KeyData->KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) == 0) {\r
+  if (((KeyData->KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) == 0) ||\r
+      (KeyData->KeyState.KeyShiftState == EFI_SHIFT_STATE_VALID)) {\r
     //\r
     //\r
-    // For those console devices that cannot report the CONTROL state,\r
+    // For consoles that don't support/report shift state,\r
     // Ctrl+A is translated to 1 (UnicodeChar).\r
     //\r
     ControlIndex = KeyData->Key.UnicodeChar;\r
     // Ctrl+A is translated to 1 (UnicodeChar).\r
     //\r
     ControlIndex = KeyData->Key.UnicodeChar;\r
-  } else if (((KeyData->KeyState.KeyShiftState & (EFI_RIGHT_CONTROL_PRESSED | EFI_LEFT_CONTROL_PRESSED)) != 0) &&\r
+  } else if (((KeyData->KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) != 0) &&\r
+             ((KeyData->KeyState.KeyShiftState & (EFI_RIGHT_CONTROL_PRESSED | EFI_LEFT_CONTROL_PRESSED)) != 0) &&\r
              ((KeyData->KeyState.KeyShiftState & ~(EFI_SHIFT_STATE_VALID | EFI_RIGHT_CONTROL_PRESSED | EFI_LEFT_CONTROL_PRESSED)) == 0)) {\r
     //\r
              ((KeyData->KeyState.KeyShiftState & ~(EFI_SHIFT_STATE_VALID | EFI_RIGHT_CONTROL_PRESSED | EFI_LEFT_CONTROL_PRESSED)) == 0)) {\r
     //\r
-    // For those console devices that can report the CONTROL state,\r
+    // For consoles that supports/reports shift state,\r
     // make sure only CONTROL is pressed.\r
     //\r
     if ((KeyData->Key.UnicodeChar >= L'A') && (KeyData->Key.UnicodeChar <= L'Z')) {\r
     // make sure only CONTROL is pressed.\r
     //\r
     if ((KeyData->Key.UnicodeChar >= L'A') && (KeyData->Key.UnicodeChar <= L'Z')) {\r
index 2b096d71688a39824ca2a38dc7889b4710bfced7..a2e52ea39c10a5ecc9190be1d5ae41c5a896f338 100644 (file)
@@ -134,18 +134,20 @@ HMainCommandDisplayHelp (
       continue;\r
     }\r
 \r
       continue;\r
     }\r
 \r
-    if ((KeyData.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) == 0) {\r
+    if (((KeyData.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) == 0) ||\r
+        (KeyData.KeyState.KeyShiftState == EFI_SHIFT_STATE_VALID)) {\r
       //\r
       //\r
-      // For consoles that don't support shift state reporting,\r
+      // For consoles that don't support/report shift state,\r
       // CTRL+W is translated to L'W' - L'A' + 1.\r
       //\r
       if (KeyData.Key.UnicodeChar == L'W' - L'A' + 1) {\r
         break;\r
       }\r
       // CTRL+W is translated to L'W' - L'A' + 1.\r
       //\r
       if (KeyData.Key.UnicodeChar == L'W' - L'A' + 1) {\r
         break;\r
       }\r
-    } else if (((KeyData.KeyState.KeyShiftState & (EFI_LEFT_CONTROL_PRESSED | EFI_RIGHT_CONTROL_PRESSED)) != 0) &&\r
+    } else if (((KeyData.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) != 0) &&\r
+               ((KeyData.KeyState.KeyShiftState & (EFI_LEFT_CONTROL_PRESSED | EFI_RIGHT_CONTROL_PRESSED)) != 0) &&\r
                ((KeyData.KeyState.KeyShiftState & ~(EFI_SHIFT_STATE_VALID | EFI_LEFT_CONTROL_PRESSED | EFI_RIGHT_CONTROL_PRESSED)) == 0)) {\r
       //\r
                ((KeyData.KeyState.KeyShiftState & ~(EFI_SHIFT_STATE_VALID | EFI_LEFT_CONTROL_PRESSED | EFI_RIGHT_CONTROL_PRESSED)) == 0)) {\r
       //\r
-      // For consoles that supports shift state reporting,\r
+      // For consoles that supports/reports shift state,\r
       // make sure that only CONTROL shift key is pressed.\r
       //\r
       if ((KeyData.Key.UnicodeChar == 'w') || (KeyData.Key.UnicodeChar == 'W')) {\r
       // make sure that only CONTROL shift key is pressed.\r
       //\r
       if ((KeyData.Key.UnicodeChar == 'w') || (KeyData.Key.UnicodeChar == 'W')) {\r