MdeModulePkg/UsbKb: fix shell edit cannot read '!@#$%^&*' characters

Commit 5563281fa2b31093a1cbd415553b9264c5136e89
* ShellPkg/[hex]edit: use SimpleTextInEx to read console
changes shell edit and hexedit to read input through SimpleTextInEx.

It exposes a issue in UsbKeyboard driver:
Per UEFI Spec,
When interpreting the data from this function (ReadKeyStrokeEx), it
should be noted that if a class of printable characters that are
normally adjusted by shift modifiers (e.g. Shift Key + "f" key) would
be presented solely as a KeyData.Key.UnicodeChar without the
associated shift state. So in the previous example of a Shift Key +
"f" key being pressed, the only pertinent data returned would be
KeyData.Key.UnicodeChar with the value of "F".

UsbKeyboard driver does convert Shift Key + "f" to "F" without the
shift state. But it doesn't do the conversion for all printable
characters, e.g.: Shift Key + "1" --> "!".

The root cause is today's logic to check whether a character is
printable or not is as below:
  if ((KeyDescriptor->AffectedAttribute & EFI_AFFECTED_BY_CAPS_LOCK)
      != 0) {

So it only converts Shift + "a"-"z", but doesn't for Shift + "0"-"9",
and Shift + "["...

The patch updates the check logic as below to fix the issue:
  if ((KeyDescriptor->Unicode != CHAR_NULL) &&
      (KeyDescriptor->ShiftedUnicode != CHAR_NULL) &&
      (KeyDescriptor->Unicode != KeyDescriptor->ShiftedUnicode)) {

The above check is TRUE when the character is printable and
it's *really* affected by Shift key.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit dd190645eb43424706eb1709d0032c69a1935d9f)
1 file changed
tree: 2108a547b9c7d08dd30ca6dfc0ea4a31cb206819
  1. AppPkg/
  2. ArmPkg/
  3. ArmPlatformPkg/
  4. ArmVirtPkg/
  5. BaseTools/
  6. BeagleBoardPkg/
  7. Conf/
  8. CorebootModulePkg/
  9. CorebootPayloadPkg/
  10. CryptoPkg/
  11. DuetPkg/
  12. EdkCompatibilityPkg/
  13. EdkShellBinPkg/
  14. EdkShellPkg/
  15. EmbeddedPkg/
  16. EmulatorPkg/
  17. FatBinPkg/
  18. FatPkg/
  19. IntelFrameworkModulePkg/
  20. IntelFrameworkPkg/
  21. IntelFsp2Pkg/
  22. IntelFsp2WrapperPkg/
  23. IntelFspPkg/
  24. IntelFspWrapperPkg/
  25. IntelSiliconPkg/
  26. MdeModulePkg/
  27. MdePkg/
  28. NetworkPkg/
  29. Nt32Pkg/
  30. Omap35xxPkg/
  31. OptionRomPkg/
  32. OvmfPkg/
  33. PcAtChipsetPkg/
  34. QuarkPlatformPkg/
  35. QuarkSocPkg/
  36. SecurityPkg/
  37. ShellBinPkg/
  38. ShellPkg/
  39. SignedCapsulePkg/
  40. SourceLevelDebugPkg/
  41. StdLib/
  42. StdLibPrivateInternalFiles/
  43. UefiCpuPkg/
  44. UnixPkg/
  45. Vlv2DeviceRefCodePkg/
  46. Vlv2TbltDevicePkg/
  47. .gitignore
  48. .gitmodules
  49. BuildNotes2.txt
  50. Contributions.txt
  51. edksetup.bat
  52. edksetup.sh
  53. License.txt
  54. Maintainers.txt
  55. Readme.md
Readme.md

EDK II Project

A modern, feature-rich, cross-platform firmware development environment for the UEFI and PI specifications from www.uefi.org.

Contributions to the EDK II open source project are covered by the TianoCore Contribution Agreement 1.1

The majority of the content in the EDK II open source project uses a BSD 2-Clause License. The EDK II open source project contains the following components that are covered by additional licenses:

The EDK II Project is composed of packages. The maintainers for each package are listed in Maintainers.txt.

Resources