From 3ced5a43296450f59fb746abf797326cc7db9456 Mon Sep 17 00:00:00 2001 From: MikeBeaton Date: Sun, 28 Mar 2021 13:54:22 +0100 Subject: [PATCH] Input: Add KeySkipFirstDelay --- Changelog.md | 1 + Docs/Configuration.tex | 13 +++++++++++++ Docs/Sample.plist | 2 ++ Docs/SampleCustom.plist | 2 ++ Include/Acidanthera/Library/OcAppleEventLib.h | 6 ++++-- Include/Acidanthera/Library/OcConfigurationLib.h | 1 + Library/OcAppleEventLib/AppleEventInternal.h | 6 ++++++ Library/OcAppleEventLib/KeyHandler.c | 14 +++++++++++++- Library/OcAppleEventLib/OcAppleEventLib.c | 8 ++++++-- Library/OcConfigurationLib/OcConfigurationLib.c | 1 + Library/OcMainLib/OpenCoreUefi.c | 2 +- 11 files changed, 50 insertions(+), 6 deletions(-) diff --git a/Changelog.md b/Changelog.md index 3107db44..d3c29ef2 100644 --- a/Changelog.md +++ b/Changelog.md @@ -43,6 +43,7 @@ OpenCore Changelog - Fixed in-firmware shutdown for some systems running OpenDuet - Added Zero as alias hotkey for Escape, to force show picker if hidden - Added =/+ key as alias for CTRL to set default OS +- Added additional support for configuring correct key repeat behaviour with KeySupport mode #### v0.6.7 - Fixed ocvalidate return code to be non-zero when issues are found diff --git a/Docs/Configuration.tex b/Docs/Configuration.tex index f51da6f8..750009b6 100755 --- a/Docs/Configuration.tex +++ b/Docs/Configuration.tex @@ -6354,6 +6354,19 @@ functioning. Feature highlights: \emph{Note}: Currently \texttt{V1}, \texttt{V2}, and \texttt{AMI} unlike \texttt{Auto} only do filtering of the particular specified protocol. This may change in the future versions. + \item + \texttt{KeySkipFirstDelay}\\ + \textbf{Type}: \texttt{plist\ boolean}\\ + \textbf{Failsafe}: \texttt{false}\\ + \textbf{Description}: Suppress initial delay before key repeat in + OpenCore implementation of Apple Event protocol. + + When combining OpenCore \texttt{KeySupport} with the Apple Event protocol, key repeat behaviour + may show one additional slow key repeat before normal key repeat starts. Enabling this option + works around this problem by suppressing the initial repeat delay in the OpenCore Apple Event + implementation. This option is recommended to be set when using \texttt{KeySupport} mode, in most + cases, and is not recommended to be set on any systems which are not using \texttt{KeySupport} mode. + \item \texttt{KeySwap}\\ \textbf{Type}: \texttt{plist\ boolean}\\ diff --git a/Docs/Sample.plist b/Docs/Sample.plist index 8e17b802..13193fee 100644 --- a/Docs/Sample.plist +++ b/Docs/Sample.plist @@ -1154,6 +1154,8 @@ KeyForgetThreshold 5 + KeySkipFirstDelay + KeySupport KeySupportMode diff --git a/Docs/SampleCustom.plist b/Docs/SampleCustom.plist index 9e90ceb3..38b7bc49 100644 --- a/Docs/SampleCustom.plist +++ b/Docs/SampleCustom.plist @@ -1351,6 +1351,8 @@ KeyForgetThreshold 5 + KeySkipFirstDelay + KeySupport KeySupportMode diff --git a/Include/Acidanthera/Library/OcAppleEventLib.h b/Include/Acidanthera/Library/OcAppleEventLib.h index b867d18a..3c2c910b 100644 --- a/Include/Acidanthera/Library/OcAppleEventLib.h +++ b/Include/Acidanthera/Library/OcAppleEventLib.h @@ -21,13 +21,15 @@ /** Install and initialise Apple Event protocol. - @param[in] Reinstall Overwrite installed protocol. + @param[in] Reinstall Overwrite installed protocol. + @param[in] KeySkipFirstDelay Modify keyboard handling to suppress initial delay. @retval installed or located protocol or NULL. **/ APPLE_EVENT_PROTOCOL * OcAppleEventInstallProtocol ( - IN BOOLEAN Reinstall + IN BOOLEAN Reinstall, + IN BOOLEAN KeySkipFirstDelay ); #endif // OC_APPLE_EVENT_LIB_H diff --git a/Include/Acidanthera/Library/OcConfigurationLib.h b/Include/Acidanthera/Library/OcConfigurationLib.h index eacd2017..f3a9353b 100644 --- a/Include/Acidanthera/Library/OcConfigurationLib.h +++ b/Include/Acidanthera/Library/OcConfigurationLib.h @@ -606,6 +606,7 @@ typedef enum { _(UINT32 , TimerResolution , , 0 , ()) \ _(UINT8 , KeyForgetThreshold , , 0 , ()) \ _(BOOLEAN , KeySupport , , FALSE , ()) \ + _(BOOLEAN , KeySkipFirstDelay , , FALSE , ()) \ _(BOOLEAN , KeyFiltering , , FALSE , ()) \ _(BOOLEAN , KeySwap , , FALSE , ()) \ _(BOOLEAN , PointerSupport , , FALSE , ()) diff --git a/Library/OcAppleEventLib/AppleEventInternal.h b/Library/OcAppleEventLib/AppleEventInternal.h index c9c8bd8a..2acd4390 100644 --- a/Library/OcAppleEventLib/AppleEventInternal.h +++ b/Library/OcAppleEventLib/AppleEventInternal.h @@ -154,4 +154,10 @@ EventInputKeyFromAppleKeyCode ( IN BOOLEAN Shifted ); +// InternalSkipFirstKeyDelay +VOID +InternalSkipFirstKeyDelay ( + IN BOOLEAN SkipFirstDelay + ); + #endif // APPLE_EVENT_INTERNAL_H_ diff --git a/Library/OcAppleEventLib/KeyHandler.c b/Library/OcAppleEventLib/KeyHandler.c index 62a09746..b57ad11f 100644 --- a/Library/OcAppleEventLib/KeyHandler.c +++ b/Library/OcAppleEventLib/KeyHandler.c @@ -66,9 +66,21 @@ STATIC KEY_STROKE_INFORMATION mKeyStrokeInfo[10]; // mCLockChanged STATIC BOOLEAN mCLockChanged = FALSE; +// mSkipFirstDelay +STATIC BOOLEAN mSkipFirstDelay = FALSE; + // mAppleKeyMapAggregator STATIC APPLE_KEY_MAP_AGGREGATOR_PROTOCOL *mKeyMapAggregator = NULL; +// InternalSkipFirstKeyDelay +VOID +InternalSkipFirstKeyDelay ( + IN BOOLEAN SkipFirstDelay + ) +{ + mSkipFirstDelay = SkipFirstDelay; +} + // InternalGetAppleKeyStrokes STATIC EFI_STATUS @@ -492,7 +504,7 @@ InternalGetCurrentKeyStroke ( if (KeyInfo != NULL) { AcceptStroke = (BOOLEAN)( - (KeyInfo->NumberOfStrokes < (KEY_STROKE_DELAY * 10)) + (!mSkipFirstDelay && KeyInfo->NumberOfStrokes < (KEY_STROKE_DELAY * 10)) ? (KeyInfo->NumberOfStrokes == 0) : ((KeyInfo->NumberOfStrokes % KEY_STROKE_DELAY) == 0) ); diff --git a/Library/OcAppleEventLib/OcAppleEventLib.c b/Library/OcAppleEventLib/OcAppleEventLib.c index 1002761d..4c3595e7 100644 --- a/Library/OcAppleEventLib/OcAppleEventLib.c +++ b/Library/OcAppleEventLib/OcAppleEventLib.c @@ -548,13 +548,15 @@ AppleEventUnload ( /** Install and initialise Apple Event protocol. - @param[in] Reinstall Overwrite installed protocol. + @param[in] Reinstall Overwrite installed protocol. + @param[in] KeySkipFirstDelay Modify keyboard handling to suppress initial delay. @retval installed or located protocol or NULL. **/ APPLE_EVENT_PROTOCOL * OcAppleEventInstallProtocol ( - IN BOOLEAN Reinstall + IN BOOLEAN Reinstall, + IN BOOLEAN KeySkipFirstDelay ) { EFI_STATUS Status; @@ -582,6 +584,8 @@ OcAppleEventInstallProtocol ( } } + InternalSkipFirstKeyDelay (KeySkipFirstDelay); + // // Apple code supports unloading, ours does not. // diff --git a/Library/OcConfigurationLib/OcConfigurationLib.c b/Library/OcConfigurationLib/OcConfigurationLib.c index b4dbddf4..9ea502c3 100644 --- a/Library/OcConfigurationLib/OcConfigurationLib.c +++ b/Library/OcConfigurationLib/OcConfigurationLib.c @@ -728,6 +728,7 @@ OC_SCHEMA mUefiInputSchema[] = { OC_SCHEMA_BOOLEAN_IN ("KeyFiltering", OC_GLOBAL_CONFIG, Uefi.Input.KeyFiltering), OC_SCHEMA_INTEGER_IN ("KeyForgetThreshold", OC_GLOBAL_CONFIG, Uefi.Input.KeyForgetThreshold), + OC_SCHEMA_BOOLEAN_IN ("KeySkipFirstDelay", OC_GLOBAL_CONFIG, Uefi.Input.KeySkipFirstDelay), OC_SCHEMA_BOOLEAN_IN ("KeySupport", OC_GLOBAL_CONFIG, Uefi.Input.KeySupport), OC_SCHEMA_STRING_IN ("KeySupportMode", OC_GLOBAL_CONFIG, Uefi.Input.KeySupportMode), OC_SCHEMA_BOOLEAN_IN ("KeySwap", OC_GLOBAL_CONFIG, Uefi.Input.KeySwap), diff --git a/Library/OcMainLib/OpenCoreUefi.c b/Library/OcMainLib/OpenCoreUefi.c index 5a4ad28a..d29c83dd 100644 --- a/Library/OcMainLib/OpenCoreUefi.c +++ b/Library/OcMainLib/OpenCoreUefi.c @@ -341,7 +341,7 @@ OcReinstallProtocols ( DEBUG ((DEBUG_ERROR, "OC: Failed to install key map protocols\n")); } - if (OcAppleEventInstallProtocol (Config->Uefi.ProtocolOverrides.AppleEvent) == NULL) { + if (OcAppleEventInstallProtocol (Config->Uefi.ProtocolOverrides.AppleEvent, Config->Uefi.Input.KeySkipFirstDelay) == NULL) { DEBUG ((DEBUG_ERROR, "OC: Failed to install key event protocol\n")); }