-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Add OcTextInputLib for EFI 1.1/cMP5,1 compatibility #581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 53 commits
af2012f
6658f61
5584cb6
9e2eef2
215ef5f
a1b6392
7929923
38b1c7f
ab47c0d
2008664
78c71f0
e88a73d
5ffe22d
ff01d13
29c85fb
f6aaaca
305db3a
83b679f
3527b71
fbd6461
7b8bc18
101f745
c7fa1fb
d44a5f3
fd37d80
ccccdb8
4973b29
0eaee55
5184d9c
411fc73
a83da00
aff942b
d679a15
a7b0418
b200cd0
b684ae2
0f05ca0
169ebb7
717b78a
d7a8027
d255a9b
e2d1c53
c9ab7fe
998654e
9da8a04
26cbff3
bbd6508
6ed0fb0
fea9089
7bc1d52
355a9bc
2d6ba43
7573e73
b7894c1
63d8617
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/** @file | ||
OcTextInputLib - SimpleTextInputEx Protocol Compatibility Library | ||
|
||
This library provides SimpleTextInputEx protocol compatibility for systems | ||
that only have SimpleTextInput protocol available (EFI 1.1 systems). | ||
|
||
Copyright (c) 2025, OpenCore Team. All rights reserved. | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
|
||
#ifndef OC_TEXT_INPUT_LIB_H | ||
#define OC_TEXT_INPUT_LIB_H | ||
|
||
#include <Uefi.h> | ||
#include <Protocol/SimpleTextInEx.h> | ||
|
||
/** | ||
Install SimpleTextInputEx compatibility protocol on the console input handle. | ||
|
||
This function checks if SimpleTextInputEx is already available, and if not, | ||
installs a compatibility version that wraps SimpleTextInput protocol. | ||
|
||
For the "normal" variant, this uses standard gBS->InstallProtocolInterface. | ||
For the "local" variant, this uses OcRegisterBootServicesProtocol for | ||
use within OpenShell. | ||
|
||
@retval EFI_SUCCESS Protocol installed successfully or already present | ||
@retval EFI_ALREADY_STARTED Protocol already exists, no action taken | ||
@retval Others Installation failed | ||
**/ | ||
EFI_STATUS | ||
OcInstallSimpleTextInputEx ( | ||
VOID | ||
); | ||
|
||
/** | ||
Uninstall SimpleTextInputEx compatibility protocol. | ||
|
||
This should be called during cleanup if the compatibility protocol | ||
was installed by this library. | ||
|
||
@retval EFI_SUCCESS Protocol uninstalled successfully | ||
@retval EFI_NOT_FOUND Protocol was not installed by this library | ||
@retval Others Uninstallation failed | ||
**/ | ||
EFI_STATUS | ||
OcUninstallSimpleTextInputEx ( | ||
VOID | ||
); | ||
|
||
/** | ||
Test CTRL key detection on the current system. | ||
|
||
This function can be used to verify that CTRL key combinations | ||
are properly detected on EFI 1.1 systems. Useful for debugging | ||
compatibility issues like those seen on cMP5,1. | ||
|
||
@retval EFI_SUCCESS Test completed, check debug output | ||
@retval Others Test failed | ||
**/ | ||
EFI_STATUS | ||
OcTestCtrlKeyDetection ( | ||
VOID | ||
); | ||
|
||
/** | ||
Process key data and handle control characters. | ||
|
||
This function is provided by OcTextInputLib for use by standalone drivers. | ||
It handles control character mapping and key processing logic. | ||
|
||
@param[in,out] KeyData Key data to process | ||
|
||
@retval EFI_SUCCESS Key data processed successfully | ||
@retval EFI_NOT_FOUND Key data does not need processing | ||
@retval EFI_INVALID_PARAMETER KeyData is NULL | ||
**/ | ||
EFI_STATUS | ||
OctiProcessKeyData ( | ||
IN OUT EFI_KEY_DATA *KeyData | ||
); | ||
|
||
#endif // OC_TEXT_INPUT_LIB_H | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is an empty file in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was an empty file at Include/Library/OcTextInputLib.h Verified with successful local Xcode5 build. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/** @file | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This whole file is a duplicate of Acidanthera/Library/OcTextInputLib.h and should be removed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplicate OcTextInputLib.h has been removed in 63d8617 |
||
OcTextInputLib - SimpleTextInputEx Protocol Compatibility Library | ||
|
||
This library provides SimpleTextInputEx protocol compatibility for systems | ||
that only have SimpleTextInput protocol available (EFI 1.1 systems). | ||
|
||
Copyright (c) 2025, OpenCore Team. All rights reserved. | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
|
||
#ifndef OC_TEXT_INPUT_LIB_H | ||
#define OC_TEXT_INPUT_LIB_H | ||
|
||
#include <Uefi.h> | ||
#include <Protocol/SimpleTextInEx.h> | ||
|
||
// | ||
// Control character mapping structure for hotkey descriptions. | ||
// | ||
typedef struct { | ||
UINT8 ControlChar; ///< Control character code (0x01-0x1F) | ||
CHAR8 *Description; ///< Human-readable description (e.g., "CTRL+A") | ||
CHAR8 *ShellFunction; ///< Shell function name (e.g., "StartOfLine") | ||
} CONTROL_CHAR_MAPPING; | ||
|
||
/** | ||
Get control character mapping for a given character. | ||
|
||
@param[in] ControlChar The control character to get mapping for. | ||
|
||
@retval Pointer to CONTROL_CHAR_MAPPING structure, or NULL if not found. | ||
**/ | ||
CONTROL_CHAR_MAPPING * | ||
EFIAPI | ||
GetControlCharMapping ( | ||
IN CHAR16 ControlChar | ||
); | ||
|
||
/** | ||
Compatibility implementation of SimpleTextInputEx ReadKeyStrokeEx. | ||
|
||
@param[in] This Protocol instance pointer. | ||
@param[out] KeyData A pointer to a buffer that is filled in with | ||
the keystroke state data for the key that was | ||
pressed. | ||
|
||
@retval EFI_SUCCESS The keystroke information was returned. | ||
@retval EFI_NOT_READY There was no keystroke data available. | ||
@retval EFI_DEVICE_ERROR The keystroke information was not returned due | ||
to an error. | ||
@retval EFI_INVALID_PARAMETER KeyData is NULL. | ||
**/ | ||
EFI_STATUS | ||
EFIAPI | ||
CompatReadKeyStrokeEx ( | ||
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, | ||
OUT EFI_KEY_DATA *KeyData | ||
); | ||
|
||
/** | ||
Install SimpleTextInputEx Protocol compatibility. | ||
|
||
This function installs a SimpleTextInputEx protocol instance that provides | ||
compatibility for systems that only have SimpleTextInput protocol available. | ||
|
||
@param[in] UseLocalRegistration If TRUE, register protocol with OpenCore's | ||
internal table. If FALSE, register with | ||
system's boot services table. | ||
|
||
@retval EFI_SUCCESS Protocol installed successfully. | ||
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory. | ||
@retval Other Installation failed. | ||
**/ | ||
EFI_STATUS | ||
OcInstallSimpleTextInputExInternal ( | ||
IN BOOLEAN UseLocalRegistration | ||
); | ||
|
||
#endif // OC_TEXT_INPUT_LIB_H |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** @file | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This whole file does not appear to be used? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unused OcTextInputCommon.h has been removed in 63d8617 |
||
Copyright (C) 2021, vit9696. All rights reserved. | ||
|
||
All rights reserved. | ||
|
||
This program and the accompanying materials | ||
are licensed and made available under the terms and conditions of the BSD License | ||
which accompanies this distribution. The full text of the license may be found at | ||
http://opensource.org/licenses/bsd-license.php | ||
|
||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. | ||
**/ | ||
|
||
#ifndef OC_TEXT_INPUT_COMMON_H | ||
#define OC_TEXT_INPUT_COMMON_H | ||
|
||
#include <Uefi.h> | ||
#include <Protocol/SimpleTextInEx.h> | ||
|
||
/** | ||
Process key data and handle control characters. | ||
|
||
This function is provided by OcTextInputLib for use by standalone drivers. | ||
It handles control character mapping and key processing logic. | ||
|
||
@param[in,out] KeyData Key data to process | ||
|
||
@retval EFI_SUCCESS Key data processed successfully | ||
@retval EFI_NOT_FOUND Key data does not need processing | ||
**/ | ||
EFI_STATUS | ||
OctiProcessKeyData ( | ||
IN OUT EFI_KEY_DATA *KeyData | ||
); | ||
|
||
#endif // OC_TEXT_INPUT_COMMON_H |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi - Sorry if I'm coming a bit late with this suggestion, but I would suggest changing to using
SimpleTextInput
,SIMPLE_TEXT_INPUT
, etc., everwhere. E.g.Library/OcSimpleTextInputLib
, etc. - just so it's very clear at first sight what this is. (As we already have lots of helper libraries, for lots of somewhat related things.)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we've already implemented the functionality and it's working, and this would require extensive renaming across files, folders, and function names, this could be addressed in a separate refactoring if desired. Isn't the current naming clear and functional?