mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-27 07:34:06 +02:00
ShellPkg: Add support for input with separately reported modifiers
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2510 Some firmwares: - Report Shift modifier even when they report upper-case unicode letter. - Report Ctrl modifier with "shifted" UniChar (i.e. X - 'A' + 1). This change provides support for these firmwares preserving the compatibility with the previous input handling. Signed-off-by: Michael Belyaev <usrsse2@icloud.com> Reviewed-by: Vitaly Cheptsov <vit9696@protonmail.com>
This commit is contained in:
parent
4928d441c2
commit
28045e5b49
@ -1 +1 @@
|
|||||||
Subproject commit f4153a09f87cbb9c826d8fc12c74642bb2d879ea
|
Subproject commit 666c3280cc11dc433c303d79a83d4ffbdd12cc8d
|
@ -1397,9 +1397,8 @@ MainCommandDisplayHelp (
|
|||||||
continue;
|
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))
|
|| (KeyData.KeyState.KeyShiftState == EFI_SHIFT_STATE_VALID)) {
|
||||||
{
|
|
||||||
//
|
//
|
||||||
// For consoles that don't support/report shift state,
|
// For consoles that don't support/report shift state,
|
||||||
// CTRL+W is translated to L'W' - L'A' + 1.
|
// CTRL+W is translated to L'W' - L'A' + 1.
|
||||||
@ -1407,15 +1406,17 @@ MainCommandDisplayHelp (
|
|||||||
if (KeyData.Key.UnicodeChar == L'W' - L'A' + 1) {
|
if (KeyData.Key.UnicodeChar == L'W' - L'A' + 1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (((KeyData.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) != 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_LEFT_CONTROL_PRESSED | EFI_RIGHT_CONTROL_PRESSED)) != 0)
|
||||||
((KeyData.KeyState.KeyShiftState & ~(EFI_SHIFT_STATE_VALID | 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/reports shift state,
|
// For consoles that supports/reports shift state,
|
||||||
// make sure that only CONTROL shift key is pressed.
|
// make sure that only CONTROL shift key is pressed.
|
||||||
|
// For some consoles that report shift state,
|
||||||
|
// CTRL+W is still translated to L'W' - L'A' + 1.
|
||||||
//
|
//
|
||||||
if ((KeyData.Key.UnicodeChar == 'w') || (KeyData.Key.UnicodeChar == 'W')) {
|
if ((KeyData.Key.UnicodeChar == L'w') || (KeyData.Key.UnicodeChar == L'W')
|
||||||
|
|| (KeyData.Key.UnicodeChar == L'w' - L'a' + 1) || (KeyData.Key.UnicodeChar == L'W' - L'A' + 1)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1854,7 +1855,8 @@ MainEditorKeyInput (
|
|||||||
EFI_KEY_DATA KeyData;
|
EFI_KEY_DATA KeyData;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
EFI_SIMPLE_POINTER_STATE MouseState;
|
EFI_SIMPLE_POINTER_STATE MouseState;
|
||||||
BOOLEAN NoShiftState;
|
BOOLEAN NoModifierState;
|
||||||
|
BOOLEAN ShiftOnlyState;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
Status = EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
@ -1904,17 +1906,28 @@ MainEditorKeyInput (
|
|||||||
//
|
//
|
||||||
StatusBarSetRefresh ();
|
StatusBarSetRefresh ();
|
||||||
//
|
//
|
||||||
// NoShiftState: TRUE when no shift key is pressed.
|
// NoModifierState: TRUE when no modifier key is pressed.
|
||||||
//
|
//
|
||||||
NoShiftState = ((KeyData.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) == 0) || (KeyData.KeyState.KeyShiftState == EFI_SHIFT_STATE_VALID);
|
NoModifierState = ((KeyData.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) == 0)
|
||||||
|
|| (KeyData.KeyState.KeyShiftState == EFI_SHIFT_STATE_VALID);
|
||||||
|
//
|
||||||
|
// ShiftOnlyState: TRUE when no modifier key except Shift is pressed.
|
||||||
|
//
|
||||||
|
ShiftOnlyState = ((KeyData.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) == 0)
|
||||||
|
|| ((KeyData.KeyState.KeyShiftState
|
||||||
|
& ~(EFI_SHIFT_STATE_VALID | EFI_LEFT_SHIFT_PRESSED | EFI_RIGHT_SHIFT_PRESSED)) == 0);
|
||||||
//
|
//
|
||||||
// dispatch to different components' key handling function
|
// dispatch to different components' key handling function
|
||||||
//
|
//
|
||||||
if (EFI_NOT_FOUND != MenuBarDispatchControlHotKey (&KeyData)) {
|
if (EFI_NOT_FOUND != MenuBarDispatchControlHotKey (&KeyData)) {
|
||||||
Status = EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
} else if (NoShiftState && ((KeyData.Key.ScanCode == SCAN_NULL) || ((KeyData.Key.ScanCode >= SCAN_UP) && (KeyData.Key.ScanCode <= SCAN_PAGE_DOWN)))) {
|
} else if ((ShiftOnlyState && (KeyData.Key.ScanCode == SCAN_NULL))
|
||||||
|
|| (NoModifierState && (KeyData.Key.ScanCode >= SCAN_UP) && (KeyData.Key.ScanCode <= SCAN_PAGE_DOWN))) {
|
||||||
|
//
|
||||||
|
// alphanumeric keys with or without shift, or arrow keys without shift
|
||||||
|
//
|
||||||
Status = FileBufferHandleInput (&KeyData.Key);
|
Status = FileBufferHandleInput (&KeyData.Key);
|
||||||
} else if (NoShiftState && (KeyData.Key.ScanCode >= SCAN_F1) && (KeyData.Key.ScanCode <= SCAN_F12)) {
|
} else if (NoModifierState && (KeyData.Key.ScanCode >= SCAN_F1) && (KeyData.Key.ScanCode <= SCAN_F12)) {
|
||||||
Status = MenuBarDispatchFunctionKey (&KeyData.Key);
|
Status = MenuBarDispatchFunctionKey (&KeyData.Key);
|
||||||
} else {
|
} else {
|
||||||
StatusBarSetStatusString (L"Unknown Command");
|
StatusBarSetStatusString (L"Unknown Command");
|
||||||
|
@ -129,6 +129,8 @@ InputBarRefresh (
|
|||||||
UINTN EventIndex;
|
UINTN EventIndex;
|
||||||
UINTN CursorRow;
|
UINTN CursorRow;
|
||||||
UINTN CursorCol;
|
UINTN CursorCol;
|
||||||
|
BOOLEAN ShiftPressed;
|
||||||
|
BOOLEAN ModifiersPressed;
|
||||||
|
|
||||||
//
|
//
|
||||||
// variable initialization
|
// variable initialization
|
||||||
@ -182,19 +184,24 @@ InputBarRefresh (
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((KeyData.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) != 0) &&
|
ModifiersPressed = ((KeyData.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) != 0)
|
||||||
(KeyData.KeyState.KeyShiftState != EFI_SHIFT_STATE_VALID))
|
&& (KeyData.KeyState.KeyShiftState != EFI_SHIFT_STATE_VALID);
|
||||||
{
|
|
||||||
//
|
//
|
||||||
// Shift key pressed.
|
// TRUE if Shift is pressed and no other modifiers are pressed
|
||||||
//
|
//
|
||||||
|
ShiftPressed = ModifiersPressed &&
|
||||||
|
((KeyData.KeyState.KeyShiftState &
|
||||||
|
~(EFI_SHIFT_STATE_VALID | EFI_LEFT_SHIFT_PRESSED | EFI_RIGHT_SHIFT_PRESSED)) == 0);
|
||||||
|
|
||||||
|
if (ModifiersPressed && !ShiftPressed) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// pressed ESC
|
// pressed ESC
|
||||||
//
|
//
|
||||||
if (KeyData.Key.ScanCode == SCAN_ESC) {
|
if (!ModifiersPressed && KeyData.Key.ScanCode == SCAN_ESC) {
|
||||||
Size = 0;
|
Size = 0;
|
||||||
Status = EFI_NOT_READY;
|
Status = EFI_NOT_READY;
|
||||||
break;
|
break;
|
||||||
@ -203,9 +210,10 @@ InputBarRefresh (
|
|||||||
//
|
//
|
||||||
// return pressed
|
// return pressed
|
||||||
//
|
//
|
||||||
if ((KeyData.Key.UnicodeChar == CHAR_LINEFEED) || (KeyData.Key.UnicodeChar == CHAR_CARRIAGE_RETURN)) {
|
if (!ModifiersPressed
|
||||||
|
&& (KeyData.Key.UnicodeChar == CHAR_LINEFEED || KeyData.Key.UnicodeChar == CHAR_CARRIAGE_RETURN)) {
|
||||||
break;
|
break;
|
||||||
} else if (KeyData.Key.UnicodeChar == CHAR_BACKSPACE) {
|
} else if (!ModifiersPressed && KeyData.Key.UnicodeChar == CHAR_BACKSPACE) {
|
||||||
//
|
//
|
||||||
// backspace
|
// backspace
|
||||||
//
|
//
|
||||||
@ -216,7 +224,8 @@ InputBarRefresh (
|
|||||||
InputBarPrintInput (LastColumn, LastRow);
|
InputBarPrintInput (LastColumn, LastRow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if ((KeyData.Key.UnicodeChar <= 127) && (KeyData.Key.UnicodeChar >= 32)) {
|
} else if ((!ModifiersPressed || ShiftPressed)
|
||||||
|
&& KeyData.Key.UnicodeChar <= 127 && KeyData.Key.UnicodeChar >= 32) {
|
||||||
//
|
//
|
||||||
// VALID ASCII char pressed
|
// VALID ASCII char pressed
|
||||||
//
|
//
|
||||||
|
@ -198,11 +198,17 @@ MenuBarDispatchControlHotKey (
|
|||||||
//
|
//
|
||||||
// For consoles that supports/reports shift state,
|
// For consoles that supports/reports shift state,
|
||||||
// make sure only CONTROL is pressed.
|
// make sure only CONTROL is pressed.
|
||||||
|
// For some consoles that report shift state,
|
||||||
|
// Ctrl+A is still translated to 1 (UnicodeChar).
|
||||||
//
|
//
|
||||||
if ((KeyData->Key.UnicodeChar >= L'A') && (KeyData->Key.UnicodeChar <= L'Z')) {
|
if ((KeyData->Key.UnicodeChar >= L'A') && (KeyData->Key.UnicodeChar <= L'Z')) {
|
||||||
ControlIndex = KeyData->Key.UnicodeChar - L'A' + 1;
|
ControlIndex = KeyData->Key.UnicodeChar - L'A' + 1;
|
||||||
} else if ((KeyData->Key.UnicodeChar >= L'a') && (KeyData->Key.UnicodeChar <= L'z')) {
|
} else if ((KeyData->Key.UnicodeChar >= L'a') && (KeyData->Key.UnicodeChar <= L'z')) {
|
||||||
ControlIndex = KeyData->Key.UnicodeChar - L'a' + 1;
|
ControlIndex = KeyData->Key.UnicodeChar - L'a' + 1;
|
||||||
|
} else if ((KeyData->Key.UnicodeChar >= L'A' - L'A' + 1) && (KeyData->Key.UnicodeChar <= L'Z' - L'A' + 1)) {
|
||||||
|
ControlIndex = KeyData->Key.UnicodeChar;
|
||||||
|
} else if ((KeyData->Key.UnicodeChar >= L'a' - L'a' + 1) && (KeyData->Key.UnicodeChar <= L'z' - L'z' + 1)) {
|
||||||
|
ControlIndex = KeyData->Key.UnicodeChar;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,15 +146,17 @@ HMainCommandDisplayHelp (
|
|||||||
if (KeyData.Key.UnicodeChar == L'W' - L'A' + 1) {
|
if (KeyData.Key.UnicodeChar == L'W' - L'A' + 1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (((KeyData.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) != 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_LEFT_CONTROL_PRESSED | EFI_RIGHT_CONTROL_PRESSED)) != 0)
|
||||||
((KeyData.KeyState.KeyShiftState & ~(EFI_SHIFT_STATE_VALID | 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/reports shift state,
|
// For consoles that supports/reports shift state,
|
||||||
// make sure that only CONTROL shift key is pressed.
|
// make sure that only CONTROL shift key is pressed.
|
||||||
|
// For some consoles that report shift state,
|
||||||
|
// CTRL+W is still translated to L'W' - L'A' + 1.
|
||||||
//
|
//
|
||||||
if ((KeyData.Key.UnicodeChar == 'w') || (KeyData.Key.UnicodeChar == 'W')) {
|
if ((KeyData.Key.UnicodeChar == 'w') || (KeyData.Key.UnicodeChar == 'W')
|
||||||
|
|| (KeyData.Key.UnicodeChar == L'w' - L'a' + 1) || (KeyData.Key.UnicodeChar == L'W' - L'A' + 1)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user