diff --git a/Changelog.md b/Changelog.md
index 01f8a73671c25484f1743d9c642731d0332c3cd6..8d8083906fecb6e7cec846bc8d207967ea3c9401 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 1dff3104420fc386df3e3002e08ce3e4c2a68212..65dfe3ade7f4e375c125c75bb5bfa20864567b69 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 3d78796879361c71e9395aa836cebdcc2a7e2129..b7890c771aaa1a271f41c7615c3061c005046fbe 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 f427d35274301d511bb1810f4116a9b45edff52d..48417dbd2d8faf02527fe07025efbb4f5652816d 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 dfc06c91bac4c0a06fb25c1e84a5a58a11bc91b0..56d0035db1e37baae5f9324cd3e408dd6362c827 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 20cad9ac62eb4214af4c14dabfc0fc9b90c92d27..a7c117343a7ca01d907935e42faacd9c5027155f 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 b93e863d5266aa125e1404536bdf618c76f26986..0bee8439efcd9ddeb12cab1982f1db632d881da1 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 87aac0eb8cebf1f4b92d79c692d8a106887a3b55..e4c6e435a27f38bea1a481937dc29bdcf59cf4cb 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 (!EFI_ERROR (Status)) {
- ConsoleControl->GetMode (ConsoleControl, &Mode, NULL, NULL);
- }
+ 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 (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 e410727de20c11efc5a9f746fb9a816fecee3356..97deccf114cfa1edd5abad97aa8b147cabf8f4c1 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 a5b11063dd2d1e7a3ba6730bad485c9586473351..a9d9f871fd340c23eac82a889ec9d2002b4cbc93 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 ed8602a7e4a97756a743d975e7d7c56ddbccfd00..b48f9ceadd92a6c0628f4ed4a93684719f5d6d6c 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