Input: Add KeySkipFirstDelay

This commit is contained in:
MikeBeaton 2021-03-28 13:54:22 +01:00
parent ea25c33f93
commit 3ced5a4329
11 changed files with 50 additions and 6 deletions

View File

@ -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

View File

@ -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}\\

View File

@ -1154,6 +1154,8 @@
<false/>
<key>KeyForgetThreshold</key>
<integer>5</integer>
<key>KeySkipFirstDelay</key>
<true/>
<key>KeySupport</key>
<true/>
<key>KeySupportMode</key>

View File

@ -1351,6 +1351,8 @@
<false/>
<key>KeyForgetThreshold</key>
<integer>5</integer>
<key>KeySkipFirstDelay</key>
<true/>
<key>KeySupport</key>
<true/>
<key>KeySupportMode</key>

View File

@ -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

View File

@ -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 , ())

View File

@ -154,4 +154,10 @@ EventInputKeyFromAppleKeyCode (
IN BOOLEAN Shifted
);
// InternalSkipFirstKeyDelay
VOID
InternalSkipFirstKeyDelay (
IN BOOLEAN SkipFirstDelay
);
#endif // APPLE_EVENT_INTERNAL_H_

View File

@ -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)
);

View File

@ -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.
//

View File

@ -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),

View File

@ -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"));
}