From ef2db45050c4aed6aa2e93d7c00df45706ab4e13 Mon Sep 17 00:00:00 2001 From: MikeBeaton Date: Thu, 25 Mar 2021 06:58:12 +0000 Subject: [PATCH] Pickers: Replace OC_INPUT_EXTRA with better defined change detection --- .../Acidanthera/Library/OcBootManagementLib.h | 9 +++++--- Library/OcBootManagementLib/HotKeySupport.c | 23 ++++++------------- .../OcBootManagementLib/OcBootManagementLib.c | 13 ++++++----- 3 files changed, 20 insertions(+), 25 deletions(-) diff --git a/Include/Acidanthera/Library/OcBootManagementLib.h b/Include/Acidanthera/Library/OcBootManagementLib.h index 330627ab..35c6fc7f 100755 --- a/Include/Acidanthera/Library/OcBootManagementLib.h +++ b/Include/Acidanthera/Library/OcBootManagementLib.h @@ -502,7 +502,9 @@ typedef INTN OC_KEY_CODE; typedef UINT16 OC_MODIFIER_MAP; /** - Full picker key info - OC and non-OC. + Full picker key info. + Note: Typing is 'orthogonal' to actions, and the presence or absence of a next + typing key should be detected by TypingChar != '\0'. **/ typedef struct { OC_KEY_CODE OcKeyCode; @@ -1122,7 +1124,6 @@ OcLoadPickerHotKeys ( #define OC_INPUT_TYPING_RIGHT -17 ///< Move right while typing (UI does not have to support) #define OC_INPUT_TYPING_CONFIRM -18 ///< Confirm input while typing (press enter) #define OC_INPUT_SWITCH_CONTEXT -19 ///< Switch context (tab and shift+tab) -#define OC_INPUT_EXTRA -50 ///< No OC_INPUT value as above, but returned early to allow GUI to respond to modifiers or other keys #define OC_INPUT_FUNCTIONAL(x) (-50 - (x)) ///< Function hotkeys /** @@ -1200,8 +1201,10 @@ OcWaitForPickerKeyInfoGetEndTime( @param[in,out] PickerKeyInfo On input, old modifiers are noticed and used to return immediately on modifier changes. On output, the new picker key info. + + @retval True if modifiers have changed. **/ -VOID +BOOLEAN OcWaitForPickerKeyInfo ( IN OUT OC_PICKER_CONTEXT *Context, IN UINT64 EndTime, diff --git a/Library/OcBootManagementLib/HotKeySupport.c b/Library/OcBootManagementLib/HotKeySupport.c index f54d84ec..ac635c33 100644 --- a/Library/OcBootManagementLib/HotKeySupport.c +++ b/Library/OcBootManagementLib/HotKeySupport.c @@ -575,11 +575,6 @@ OcGetPickerKeyInfo ( } } - if (PickerKeyInfo->TypingChar != '\0') { - PickerKeyInfo->OcKeyCode = OC_INPUT_EXTRA; - return; - } - // // Return NO_ACTION here, since all non-null actions now feedback // immediately to either picker, to allow UI response. @@ -599,7 +594,7 @@ OcWaitForPickerKeyInfoGetEndTime( return GetTimeInNanoSecond (GetPerformanceCounter ()) + Timeout * 1000000u; } -VOID +BOOLEAN OcWaitForPickerKeyInfo ( IN OUT OC_PICKER_CONTEXT *Context, IN UINT64 EndTime, @@ -625,17 +620,11 @@ OcWaitForPickerKeyInfo ( OcGetPickerKeyInfo (Context, FilterForTyping, PickerKeyInfo); // - // All non-null actions (even internal) are now returned to picker for possible UI response + // All non-null actions (even internal) are now returned to picker for possible UI response. // - if (PickerKeyInfo->OcKeyCode != OC_INPUT_NO_ACTION) { - break; - } - - // - // Return modifiers if they change, so we can optionally update UI - // - if (PickerKeyInfo->OcModifiers != OldOcModifiers) { - PickerKeyInfo->OcKeyCode = OC_INPUT_EXTRA; + if (PickerKeyInfo->OcKeyCode != OC_INPUT_NO_ACTION || + PickerKeyInfo->OcModifiers != OldOcModifiers || + PickerKeyInfo->TypingChar != '\0') { break; } @@ -659,4 +648,6 @@ OcWaitForPickerKeyInfo ( } DEBUG_CODE_END (); } + + return PickerKeyInfo->OcModifiers != OldOcModifiers; } diff --git a/Library/OcBootManagementLib/OcBootManagementLib.c b/Library/OcBootManagementLib/OcBootManagementLib.c index 979f6a7b..edfd070e 100644 --- a/Library/OcBootManagementLib/OcBootManagementLib.c +++ b/Library/OcBootManagementLib/OcBootManagementLib.c @@ -297,6 +297,7 @@ OcShowSimpleBootMenu ( BOOLEAN PlayedOnce; BOOLEAN PlayChosen; BOOLEAN IsTyping; + BOOLEAN ModifiersChanged; #if defined(BUILTIN_DEMONSTRATE_TYPING) INT32 TypingColumn; INT32 TypingStartColumn; @@ -509,7 +510,7 @@ OcShowSimpleBootMenu ( KeyEndTime = 0; } - OcWaitForPickerKeyInfo ( + ModifiersChanged = OcWaitForPickerKeyInfo ( BootContext->PickerContext, KeyEndTime, IsTyping, @@ -576,10 +577,6 @@ OcShowSimpleBootMenu ( } #endif - if (PickerKeyInfo.OcKeyCode == OC_INPUT_EXTRA) { - break; - } - if (PlayChosen && PickerKeyInfo.OcKeyCode == OC_INPUT_TIMEOUT) { OcPlayAudioFile (BootContext->PickerContext, OcVoiceOverAudioFileSelected, FALSE); OcPlayAudioEntry (BootContext->PickerContext, BootEntries[ChosenEntry]); @@ -664,11 +661,15 @@ OcShowSimpleBootMenu ( return EFI_SUCCESS; } - if (TimeOutSeconds > 0) { + if (PickerKeyInfo.OcKeyCode != OC_INPUT_NO_ACTION && TimeOutSeconds > 0) { OcPlayAudioFile (BootContext->PickerContext, OcVoiceOverAudioFileAbortTimeout, FALSE); TimeOutSeconds = 0; break; } + + if (ModifiersChanged || PickerKeyInfo.TypingChar != '\0') { + break; + } } }