public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] ShellPkg/[hex]edit: Fix CTRL+<Alpha> doesn't work from hyper terminal
@ 2018-02-13  9:44 Ruiyu Ni
  2018-02-14 15:02 ` Carsey, Jaben
  0 siblings, 1 reply; 2+ messages in thread
From: Ruiyu Ni @ 2018-02-13  9:44 UTC (permalink / raw)
  To: edk2-devel; +Cc: Jaben Carsey

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>
Cc: Jaben Carsey <jaben.carsey@intel.com>
---
 .../Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c   | 10 ++++++----
 ShellPkg/Library/UefiShellDebug1CommandsLib/EditMenuBar.c      | 10 ++++++----
 .../Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c | 10 ++++++----
 3 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c
index 4eb998bf5f..6832441e81 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c
@@ -1387,18 +1387,20 @@ MainCommandDisplayHelp (
       continue;
     }
 
-    if ((KeyData.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) == 0) {
+    if (((KeyData.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) == 0) ||
+        (KeyData.KeyState.KeyShiftState == EFI_SHIFT_STATE_VALID)) {
       //
-      // For consoles that don't support shift state reporting,
+      // For consoles that don't support/report shift state,
       // CTRL+W is translated to L'W' - L'A' + 1.
       //
       if (KeyData.Key.UnicodeChar == L'W' - L'A' + 1) {
         break;
       }
-    } else if (((KeyData.KeyState.KeyShiftState & (EFI_LEFT_CONTROL_PRESSED | EFI_RIGHT_CONTROL_PRESSED)) != 0) &&
+    } else if (((KeyData.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) != 0) &&
+               ((KeyData.KeyState.KeyShiftState & (EFI_LEFT_CONTROL_PRESSED | EFI_RIGHT_CONTROL_PRESSED)) != 0) &&
                ((KeyData.KeyState.KeyShiftState & ~(EFI_SHIFT_STATE_VALID | EFI_LEFT_CONTROL_PRESSED | EFI_RIGHT_CONTROL_PRESSED)) == 0)) {
       //
-      // For consoles that supports shift state reporting,
+      // For consoles that supports/reports shift state,
       // make sure that only CONTROL shift key is pressed.
       //
       if ((KeyData.Key.UnicodeChar == 'w') || (KeyData.Key.UnicodeChar == 'W')) {
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/EditMenuBar.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/EditMenuBar.c
index b86594bb28..58e90ac5b2 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/EditMenuBar.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/EditMenuBar.c
@@ -183,16 +183,18 @@ MenuBarDispatchControlHotKey (
   //
   ControlIndex = MAX_UINT16;
 
-  if ((KeyData->KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) == 0) {
+  if (((KeyData->KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) == 0) ||
+      (KeyData->KeyState.KeyShiftState == EFI_SHIFT_STATE_VALID)) {
     //
-    // For those console devices that cannot report the CONTROL state,
+    // For consoles that don't support/report shift state,
     // Ctrl+A is translated to 1 (UnicodeChar).
     //
     ControlIndex = KeyData->Key.UnicodeChar;
-  } else if (((KeyData->KeyState.KeyShiftState & (EFI_RIGHT_CONTROL_PRESSED | EFI_LEFT_CONTROL_PRESSED)) != 0) &&
+  } else if (((KeyData->KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) != 0) &&
+             ((KeyData->KeyState.KeyShiftState & (EFI_RIGHT_CONTROL_PRESSED | EFI_LEFT_CONTROL_PRESSED)) != 0) &&
              ((KeyData->KeyState.KeyShiftState & ~(EFI_SHIFT_STATE_VALID | EFI_RIGHT_CONTROL_PRESSED | EFI_LEFT_CONTROL_PRESSED)) == 0)) {
     //
-    // For those console devices that can report the CONTROL state,
+    // For consoles that supports/reports shift state,
     // make sure only CONTROL is pressed.
     //
     if ((KeyData->Key.UnicodeChar >= L'A') && (KeyData->Key.UnicodeChar <= L'Z')) {
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c
index 2b096d7168..a2e52ea39c 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c
@@ -134,18 +134,20 @@ HMainCommandDisplayHelp (
       continue;
     }
 
-    if ((KeyData.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) == 0) {
+    if (((KeyData.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) == 0) ||
+        (KeyData.KeyState.KeyShiftState == EFI_SHIFT_STATE_VALID)) {
       //
-      // For consoles that don't support shift state reporting,
+      // For consoles that don't support/report shift state,
       // CTRL+W is translated to L'W' - L'A' + 1.
       //
       if (KeyData.Key.UnicodeChar == L'W' - L'A' + 1) {
         break;
       }
-    } else if (((KeyData.KeyState.KeyShiftState & (EFI_LEFT_CONTROL_PRESSED | EFI_RIGHT_CONTROL_PRESSED)) != 0) &&
+    } else if (((KeyData.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) != 0) &&
+               ((KeyData.KeyState.KeyShiftState & (EFI_LEFT_CONTROL_PRESSED | EFI_RIGHT_CONTROL_PRESSED)) != 0) &&
                ((KeyData.KeyState.KeyShiftState & ~(EFI_SHIFT_STATE_VALID | EFI_LEFT_CONTROL_PRESSED | EFI_RIGHT_CONTROL_PRESSED)) == 0)) {
       //
-      // For consoles that supports shift state reporting,
+      // For consoles that supports/reports shift state,
       // make sure that only CONTROL shift key is pressed.
       //
       if ((KeyData.Key.UnicodeChar == 'w') || (KeyData.Key.UnicodeChar == 'W')) {
-- 
2.16.1.windows.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ShellPkg/[hex]edit: Fix CTRL+<Alpha> doesn't work from hyper terminal
  2018-02-13  9:44 [PATCH] ShellPkg/[hex]edit: Fix CTRL+<Alpha> doesn't work from hyper terminal Ruiyu Ni
@ 2018-02-14 15:02 ` Carsey, Jaben
  0 siblings, 0 replies; 2+ messages in thread
From: Carsey, Jaben @ 2018-02-14 15:02 UTC (permalink / raw)
  To: Ni, Ruiyu, edk2-devel@lists.01.org

Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>

> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Ruiyu Ni
> Sent: Tuesday, February 13, 2018 1:45 AM
> To: edk2-devel@lists.01.org
> Cc: Carsey, Jaben <jaben.carsey@intel.com>
> Subject: [edk2] [PATCH] ShellPkg/[hex]edit: Fix CTRL+<Alpha> doesn't work
> from hyper terminal
> Importance: High
> 
> 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>
> Cc: Jaben Carsey <jaben.carsey@intel.com>
> ---
>  .../Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c   | 10
> ++++++----
>  ShellPkg/Library/UefiShellDebug1CommandsLib/EditMenuBar.c      | 10
> ++++++----
>  .../Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c | 10
> ++++++----
>  3 files changed, 18 insertions(+), 12 deletions(-)
> 
> diff --git
> a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c
> b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c
> index 4eb998bf5f..6832441e81 100644
> --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c
> +++
> b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c
> @@ -1387,18 +1387,20 @@ MainCommandDisplayHelp (
>        continue;
>      }
> 
> -    if ((KeyData.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) == 0) {
> +    if (((KeyData.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) == 0) ||
> +        (KeyData.KeyState.KeyShiftState == EFI_SHIFT_STATE_VALID)) {
>        //
> -      // For consoles that don't support shift state reporting,
> +      // For consoles that don't support/report shift state,
>        // CTRL+W is translated to L'W' - L'A' + 1.
>        //
>        if (KeyData.Key.UnicodeChar == L'W' - L'A' + 1) {
>          break;
>        }
> -    } else if (((KeyData.KeyState.KeyShiftState &
> (EFI_LEFT_CONTROL_PRESSED | EFI_RIGHT_CONTROL_PRESSED)) != 0) &&
> +    } else if (((KeyData.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) !=
> 0) &&
> +               ((KeyData.KeyState.KeyShiftState & (EFI_LEFT_CONTROL_PRESSED
> | EFI_RIGHT_CONTROL_PRESSED)) != 0) &&
>                 ((KeyData.KeyState.KeyShiftState & ~(EFI_SHIFT_STATE_VALID |
> EFI_LEFT_CONTROL_PRESSED | EFI_RIGHT_CONTROL_PRESSED)) == 0)) {
>        //
> -      // For consoles that supports shift state reporting,
> +      // For consoles that supports/reports shift state,
>        // make sure that only CONTROL shift key is pressed.
>        //
>        if ((KeyData.Key.UnicodeChar == 'w') || (KeyData.Key.UnicodeChar ==
> 'W')) {
> diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/EditMenuBar.c
> b/ShellPkg/Library/UefiShellDebug1CommandsLib/EditMenuBar.c
> index b86594bb28..58e90ac5b2 100644
> --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/EditMenuBar.c
> +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/EditMenuBar.c
> @@ -183,16 +183,18 @@ MenuBarDispatchControlHotKey (
>    //
>    ControlIndex = MAX_UINT16;
> 
> -  if ((KeyData->KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) == 0) {
> +  if (((KeyData->KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) == 0) ||
> +      (KeyData->KeyState.KeyShiftState == EFI_SHIFT_STATE_VALID)) {
>      //
> -    // For those console devices that cannot report the CONTROL state,
> +    // For consoles that don't support/report shift state,
>      // Ctrl+A is translated to 1 (UnicodeChar).
>      //
>      ControlIndex = KeyData->Key.UnicodeChar;
> -  } else if (((KeyData->KeyState.KeyShiftState &
> (EFI_RIGHT_CONTROL_PRESSED | EFI_LEFT_CONTROL_PRESSED)) != 0) &&
> +  } else if (((KeyData->KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) !=
> 0) &&
> +             ((KeyData->KeyState.KeyShiftState &
> (EFI_RIGHT_CONTROL_PRESSED | EFI_LEFT_CONTROL_PRESSED)) != 0) &&
>               ((KeyData->KeyState.KeyShiftState & ~(EFI_SHIFT_STATE_VALID |
> EFI_RIGHT_CONTROL_PRESSED | EFI_LEFT_CONTROL_PRESSED)) == 0)) {
>      //
> -    // For those console devices that can report the CONTROL state,
> +    // For consoles that supports/reports shift state,
>      // make sure only CONTROL is pressed.
>      //
>      if ((KeyData->Key.UnicodeChar >= L'A') && (KeyData->Key.UnicodeChar
> <= L'Z')) {
> diff --git
> a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c
> b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c
> index 2b096d7168..a2e52ea39c 100644
> ---
> a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c
> +++
> b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c
> @@ -134,18 +134,20 @@ HMainCommandDisplayHelp (
>        continue;
>      }
> 
> -    if ((KeyData.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) == 0) {
> +    if (((KeyData.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) == 0) ||
> +        (KeyData.KeyState.KeyShiftState == EFI_SHIFT_STATE_VALID)) {
>        //
> -      // For consoles that don't support shift state reporting,
> +      // For consoles that don't support/report shift state,
>        // CTRL+W is translated to L'W' - L'A' + 1.
>        //
>        if (KeyData.Key.UnicodeChar == L'W' - L'A' + 1) {
>          break;
>        }
> -    } else if (((KeyData.KeyState.KeyShiftState &
> (EFI_LEFT_CONTROL_PRESSED | EFI_RIGHT_CONTROL_PRESSED)) != 0) &&
> +    } else if (((KeyData.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) !=
> 0) &&
> +               ((KeyData.KeyState.KeyShiftState & (EFI_LEFT_CONTROL_PRESSED
> | EFI_RIGHT_CONTROL_PRESSED)) != 0) &&
>                 ((KeyData.KeyState.KeyShiftState & ~(EFI_SHIFT_STATE_VALID |
> EFI_LEFT_CONTROL_PRESSED | EFI_RIGHT_CONTROL_PRESSED)) == 0)) {
>        //
> -      // For consoles that supports shift state reporting,
> +      // For consoles that supports/reports shift state,
>        // make sure that only CONTROL shift key is pressed.
>        //
>        if ((KeyData.Key.UnicodeChar == 'w') || (KeyData.Key.UnicodeChar ==
> 'W')) {
> --
> 2.16.1.windows.1
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-02-14 14:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-13  9:44 [PATCH] ShellPkg/[hex]edit: Fix CTRL+<Alpha> doesn't work from hyper terminal Ruiyu Ni
2018-02-14 15:02 ` Carsey, Jaben

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox