diff --git a/Changelog.md b/Changelog.md
index 01f8a736..8d808390 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -2,6 +2,7 @@ OpenCore Changelog
==================
#### v0.7.2
- Fixed OSBundleLibraries/OSBundleLibaries64 handling
+- Added `GraphicsInputMirroring` to fix lost keystrokes in some non-Apple graphical UEFI apps
#### v0.7.1
- Added `SyncTableIds` quirk to sync modified table OEM identifiers
diff --git a/Docs/Configuration.tex b/Docs/Configuration.tex
index 1dff3104..65dfe3ad 100755
--- a/Docs/Configuration.tex
+++ b/Docs/Configuration.tex
@@ -6484,6 +6484,30 @@ functioning. Feature highlights:
then increase \texttt{KeySubsequentDelay} by one or two more until this effect goes away.
\end{itemize}
+ \item
+ \texttt{GraphicsInputMirroring}\\
+ \textbf{Type}: \texttt{plist\ boolean}\\
+ \textbf{Failsafe}: \texttt{false}\\
+ \textbf{Description}:
+ Appleās own implementation of AppleEvent prevents keyboard input during graphics applications from appearing
+ on the basic console input stream.
+
+ With the default setting of \texttt{false}, OC's builtin implementation of AppleEvent replicates this behaviour.
+
+ On non-Apple hardware this can stop keyboard input working in graphics-based applications such as Windows BitLocker
+ which use non-Apple key input methods.
+
+ The recommended setting on all hardware is \texttt{true}.
+
+ \emph{Note}: AppleEvent's default behaviour is intended to prevent unwanted queued keystrokes from appearing
+ after exiting graphics-based UEFI applications; this issue is already handled separately within OpenCore.
+
+ \begin{itemize}
+ \tightlist
+ \item \texttt{true} --- Allow keyboard input to reach graphics mode apps which are not using Apple input protocols.
+ \item \texttt{false} --- Prevent key input mirroring to non-Apple protocols when in graphics mode.
+ \end{itemize}
+
\item
\texttt{PointerSpeedDiv}\\
\textbf{Type}: \texttt{plist\ integer}\\
@@ -7093,7 +7117,7 @@ functioning. Feature highlights:
\emph{Note 2}: On systems without native
support for \texttt{ForceDisplayRotationInEFI}, \texttt{DirectGopRendering=true}
- is also required for this setting to have a visible effect.
+ is also required for this setting to have an effect.
\item
\texttt{AppleFramebufferInfo}\\
diff --git a/Docs/Sample.plist b/Docs/Sample.plist
index 3d787968..b7890c77 100644
--- a/Docs/Sample.plist
+++ b/Docs/Sample.plist
@@ -1281,6 +1281,8 @@
50
KeySubsequentDelay
5
+ GraphicsInputMirroring
+
PointerSpeedDiv
1
PointerSpeedMul
diff --git a/Docs/SampleCustom.plist b/Docs/SampleCustom.plist
index f427d352..48417dbd 100644
--- a/Docs/SampleCustom.plist
+++ b/Docs/SampleCustom.plist
@@ -1619,6 +1619,8 @@
50
KeySubsequentDelay
5
+ GraphicsInputMirroring
+
PointerSpeedDiv
1
PointerSpeedMul
diff --git a/Include/Acidanthera/Library/OcAppleEventLib.h b/Include/Acidanthera/Library/OcAppleEventLib.h
index dfc06c91..56d0035d 100644
--- a/Include/Acidanthera/Library/OcAppleEventLib.h
+++ b/Include/Acidanthera/Library/OcAppleEventLib.h
@@ -21,16 +21,20 @@
/**
Install and initialise Apple Event protocol.
- @param[in] Install If false, do not install even when no suitable OEM version found.
- @param[in] Reinstall If true, force overwrite installed protocol.
- If false, use Apple OEM protocol where possible.
- @param[in] CustomDelays If true, use key delays specified.
- If false, use Apple OEM default key delay values.
- @param[in] KeyInitialDelay Key repeat initial delay in 10ms units.
- @param[in] KeySubsequentDelay Key repeat subsequent delay in 10ms units.
- If zero, warn and use 1.
- @param[in] PointerSpeedDiv Pointer speed divisor. If zero, warn and use 1.
- @param[in] PointerSpeedMul Pointer speed multiplier.
+ @param[in] Install If false, do not install even when no suitable OEM version found.
+ @param[in] Reinstall If true, force overwrite installed protocol.
+ If false, use Apple OEM protocol where possible.
+ @param[in] CustomDelays If true, use key delays specified.
+ If false, use Apple OEM default key delay values.
+ OC builtin AppleEvent only.
+ @param[in] KeyInitialDelay Key repeat initial delay in 10ms units.
+ @param[in] KeySubsequentDelay Key repeat subsequent delay in 10ms units.
+ If zero, warn and use 1.
+ @param[in] GraphicsInputMirroring If true, disable Apple default behaviour which can
+ prevent keyboard input reaching non-Apple GUI UEFI apps.
+ OC builtin AppleEvent only.
+ @param[in] PointerSpeedDiv Pointer speed divisor. If zero, warn and use 1.
+ @param[in] PointerSpeedMul Pointer speed multiplier.
@retval installed or located protocol or NULL.
**/
@@ -41,6 +45,7 @@ OcAppleEventInstallProtocol (
IN BOOLEAN CustomDelays,
IN UINT16 KeyInitialDelay,
IN UINT16 KeySubsequentDelay,
+ IN BOOLEAN GraphicsInputMirroring,
IN UINT16 PointerSpeedDiv,
IN UINT16 PointerSpeedMul
);
diff --git a/Include/Acidanthera/Library/OcConfigurationLib.h b/Include/Acidanthera/Library/OcConfigurationLib.h
index 20cad9ac..a7c11734 100644
--- a/Include/Acidanthera/Library/OcConfigurationLib.h
+++ b/Include/Acidanthera/Library/OcConfigurationLib.h
@@ -591,12 +591,13 @@ typedef enum {
/// AppleInput is a set of options to configure OpenCore's reverse engingeered then customised implementation of the AppleEvent protocol.
///
#define OC_UEFI_APPLEINPUT_FIELDS(_, __) \
- _(OC_STRING , AppleEvent , , OC_STRING_CONSTR ("Auto", _, __) , OC_DESTR (OC_STRING) ) \
- _(BOOLEAN , CustomDelays , , FALSE , ()) \
- _(UINT16 , KeyInitialDelay , , 50 , ()) \
- _(UINT16 , KeySubsequentDelay , , 5 , ()) \
- _(UINT16 , PointerSpeedDiv , , 1 , ()) \
- _(UINT16 , PointerSpeedMul , , 1 , ())
+ _(OC_STRING , AppleEvent , , OC_STRING_CONSTR ("Auto", _, __) , OC_DESTR (OC_STRING) ) \
+ _(BOOLEAN , CustomDelays , , FALSE , ()) \
+ _(UINT16 , KeyInitialDelay , , 50 , ()) \
+ _(UINT16 , KeySubsequentDelay , , 5 , ()) \
+ _(BOOLEAN , GraphicsInputMirroring, , FALSE , ()) \
+ _(UINT16 , PointerSpeedDiv , , 1 , ()) \
+ _(UINT16 , PointerSpeedMul , , 1 , ())
OC_DECLARE (OC_UEFI_APPLEINPUT)
///
diff --git a/Library/OcAppleEventLib/AppleEventInternal.h b/Library/OcAppleEventLib/AppleEventInternal.h
index b93e863d..0bee8439 100644
--- a/Library/OcAppleEventLib/AppleEventInternal.h
+++ b/Library/OcAppleEventLib/AppleEventInternal.h
@@ -154,12 +154,13 @@ EventInputKeyFromAppleKeyCode (
IN BOOLEAN Shifted
);
-// InternalSetKeyDelays
+// InternalSetKeyBehaviour
VOID
-InternalSetKeyDelays (
+InternalSetKeyBehaviour (
IN BOOLEAN CustomDelays,
IN UINT16 KeyInitialDelay,
- IN UINT16 KeySubsequentDelay
+ IN UINT16 KeySubsequentDelay,
+ IN BOOLEAN GraphicsInputMirroring
);
VOID
diff --git a/Library/OcAppleEventLib/KeyHandler.c b/Library/OcAppleEventLib/KeyHandler.c
index 87aac0eb..e4c6e435 100644
--- a/Library/OcAppleEventLib/KeyHandler.c
+++ b/Library/OcAppleEventLib/KeyHandler.c
@@ -72,15 +72,19 @@ STATIC BOOLEAN mCLockChanged = FALSE;
STATIC UINTN mKeyInitialDelay = 50;
STATIC UINTN mKeySubsequentDelay = 5;
+// mGraphicsInputMirroring
+STATIC BOOLEAN mGraphicsInputMirroring = FALSE;
+
// mAppleKeyMapAggregator
STATIC APPLE_KEY_MAP_AGGREGATOR_PROTOCOL *mKeyMapAggregator = NULL;
-// InternalSetKeyDelays
+// InternalSetKeyBehaviour
VOID
-InternalSetKeyDelays (
+InternalSetKeyBehaviour (
IN BOOLEAN CustomDelays,
IN UINT16 KeyInitialDelay,
- IN UINT16 KeySubsequentDelay
+ IN UINT16 KeySubsequentDelay,
+ IN BOOLEAN GraphicsInputMirroring
)
{
if (CustomDelays) {
@@ -100,6 +104,8 @@ InternalSetKeyDelays (
DEBUG ((DEBUG_INFO, "OCAE: Using key delays %d (%d0ms) and %d (%d0ms)\n", mKeyInitialDelay, mKeyInitialDelay, mKeySubsequentDelay, mKeySubsequentDelay));
}
+
+ mGraphicsInputMirroring = GraphicsInputMirroring;
}
// InternalGetAppleKeyStrokes
@@ -596,23 +602,33 @@ InternalAppleEventDataFromCurrentKeyStroke (
&KeyCodes
);
- Mode = EfiConsoleControlScreenGraphics;
- Status = gBS->LocateProtocol (
- &gEfiConsoleControlProtocolGuid,
- NULL,
- (VOID *)&ConsoleControl
- );
+ if (!mGraphicsInputMirroring) {
+ //
+ // Apple OEM AppleEvent unconditionally includes this logic, but
+ // when an AppleEvent handler such as CrScreenshotDxe is active
+ // this code will run and (not entirely consistently across different
+ // firmware) may prevent keystrokes from reaching ConIn-based UEFI GUI
+ // apps such as Windows BitLocker.
+ // REF: https://github.com/acidanthera/bugtracker/issues/1716
+ //
+ Mode = EfiConsoleControlScreenGraphics;
+ Status = gBS->LocateProtocol (
+ &gEfiConsoleControlProtocolGuid,
+ NULL,
+ (VOID *)&ConsoleControl
+ );
- if (!EFI_ERROR (Status)) {
- ConsoleControl->GetMode (ConsoleControl, &Mode, NULL, NULL);
- }
+ if (!EFI_ERROR (Status)) {
+ ConsoleControl->GetMode (ConsoleControl, &Mode, NULL, NULL);
+ }
- if (Mode == EfiConsoleControlScreenGraphics) {
- for (Index = 0; Index < (NumberOfKeyCodes + 1); ++Index) {
- Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &InputKey);
+ if (Mode == EfiConsoleControlScreenGraphics) {
+ for (Index = 0; Index < (NumberOfKeyCodes + 1); ++Index) {
+ Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &InputKey);
- if (EFI_ERROR (Status)) {
- break;
+ if (EFI_ERROR (Status)) {
+ break;
+ }
}
}
}
diff --git a/Library/OcAppleEventLib/OcAppleEventLib.c b/Library/OcAppleEventLib/OcAppleEventLib.c
index e410727d..97deccf1 100644
--- a/Library/OcAppleEventLib/OcAppleEventLib.c
+++ b/Library/OcAppleEventLib/OcAppleEventLib.c
@@ -548,16 +548,20 @@ AppleEventUnload (
/**
Install and initialise Apple Event protocol.
- @param[in] Install If false, do not install even when no suitable OEM version found.
- @param[in] Reinstall If true, force overwrite installed protocol.
- If false, use Apple OEM protocol where possible.
- @param[in] CustomDelays If true, use key delays specified.
- If false, use Apple OEM default key delay values.
- @param[in] KeyInitialDelay Key repeat initial delay in 10ms units.
- @param[in] KeySubsequentDelay Key repeat subsequent delay in 10ms units.
- If zero, warn and use 1.
- @param[in] PointerSpeedDiv Pointer speed divisor. If zero, warn and use 1.
- @param[in] PointerSpeedMul Pointer speed multiplier.
+ @param[in] Install If false, do not install even when no suitable OEM version found.
+ @param[in] Reinstall If true, force overwrite installed protocol.
+ If false, use Apple OEM protocol where possible.
+ @param[in] CustomDelays If true, use key delays specified.
+ If false, use Apple OEM default key delay values.
+ OC builtin AppleEvent only.
+ @param[in] KeyInitialDelay Key repeat initial delay in 10ms units.
+ @param[in] KeySubsequentDelay Key repeat subsequent delay in 10ms units.
+ If zero, warn and use 1.
+ @param[in] GraphicsInputMirroring If true, disable Apple default behaviour which can
+ prevent keyboard input reaching non-Apple GUI UEFI apps.
+ OC builtin AppleEvent only.
+ @param[in] PointerSpeedDiv Pointer speed divisor. If zero, warn and use 1.
+ @param[in] PointerSpeedMul Pointer speed multiplier.
@retval installed or located protocol or NULL.
**/
@@ -568,6 +572,7 @@ OcAppleEventInstallProtocol (
IN BOOLEAN CustomDelays,
IN UINT16 KeyInitialDelay,
IN UINT16 KeySubsequentDelay,
+ IN BOOLEAN GraphicsInputMirroring,
IN UINT16 PointerSpeedDiv,
IN UINT16 PointerSpeedMul
)
@@ -616,7 +621,12 @@ OcAppleEventInstallProtocol (
return NULL;
}
- InternalSetKeyDelays (CustomDelays, KeyInitialDelay, KeySubsequentDelay);
+ InternalSetKeyBehaviour (
+ CustomDelays,
+ KeyInitialDelay,
+ KeySubsequentDelay,
+ GraphicsInputMirroring
+ );
InternalSetPointerSpeed (PointerSpeedDiv, PointerSpeedMul);
diff --git a/Library/OcConfigurationLib/OcConfigurationLib.c b/Library/OcConfigurationLib/OcConfigurationLib.c
index a5b11063..a9d9f871 100644
--- a/Library/OcConfigurationLib/OcConfigurationLib.c
+++ b/Library/OcConfigurationLib/OcConfigurationLib.c
@@ -724,6 +724,7 @@ OC_SCHEMA
mUefiAppleInputSchema[] = {
OC_SCHEMA_STRING_IN ("AppleEvent", OC_GLOBAL_CONFIG, Uefi.AppleInput.AppleEvent),
OC_SCHEMA_BOOLEAN_IN ("CustomDelays", OC_GLOBAL_CONFIG, Uefi.AppleInput.CustomDelays),
+ OC_SCHEMA_BOOLEAN_IN ("GraphicsInputMirroring", OC_GLOBAL_CONFIG, Uefi.AppleInput.GraphicsInputMirroring),
OC_SCHEMA_INTEGER_IN ("KeyInitialDelay", OC_GLOBAL_CONFIG, Uefi.AppleInput.KeyInitialDelay),
OC_SCHEMA_INTEGER_IN ("KeySubsequentDelay", OC_GLOBAL_CONFIG, Uefi.AppleInput.KeySubsequentDelay),
OC_SCHEMA_INTEGER_IN ("PointerSpeedDiv", OC_GLOBAL_CONFIG, Uefi.AppleInput.PointerSpeedDiv),
diff --git a/Library/OcMainLib/OpenCoreUefi.c b/Library/OcMainLib/OpenCoreUefi.c
index ed8602a7..b48f9cea 100644
--- a/Library/OcMainLib/OpenCoreUefi.c
+++ b/Library/OcMainLib/OpenCoreUefi.c
@@ -365,6 +365,7 @@ OcReinstallProtocols (
Config->Uefi.AppleInput.CustomDelays,
Config->Uefi.AppleInput.KeyInitialDelay,
Config->Uefi.AppleInput.KeySubsequentDelay,
+ Config->Uefi.AppleInput.GraphicsInputMirroring,
Config->Uefi.AppleInput.PointerSpeedDiv,
Config->Uefi.AppleInput.PointerSpeedMul
) == NULL