22.2 Simple Text Input Protocol Implementation
The implementation of the Simple Text Input Protocols is typically found in the file
SimpleTextInput.c
. Appendix A contains a template for a SimpleTextInput.c
file for a UEFI Driver. The list of tasks to implement the Simple Text Input Protocols is as follows:- Add global variable for the
EFI_SIMPLE_TEXT_INPUT_PROTOCOL
instance toSimpleTextInput.c
. - Add global variable for theEFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
instance toSimpleTextInput.c
. - Implement the
Reset()
andReadKeyStroke()
services inSimpleTextInput.c
that is shared between the Simple Text Input Protocol and the Simple TextInput Ex Protocol. - Implement the
SetState()
,RegisterKeyNotify()
andUnregisterKeyNotify()
services inSimpleTextInput.c
for the Simple Text Input Ex Protocol. - Implement notification function for the WaitForKey and WaitForKeyExevents in
SimpleTextInput.c
that is shared between the Simple Text InputProtocol and the Simple Text Input Ex Protocol. - Create WaitForKey and WaitForKeyEx events before the Simple InputProtocols are installed into the Handle Database.
- If a device does not buffer keystrokes, or the buffer is very small, a timerevent may be required to periodically read contents from a keyboard buffer.
Example 223, following, shows the protocol interface structure for the Simple Text Input Protocol and Example 224, below that, shows the protocol interface structure for the Simple Text Input Ex Protocol for reference. These two protocols are composed of services and each has an
EFI_EVENT
that may be used by the UEFI Boot Manager or UEFI Applications to determine if a keystroke has been pressed. The UEFI Boot Services WaitForEvent()
and CheckEvent()
can be used to perform these checks on the events specified by WaitForKey and WaitForKeyEx.typedef struct _EFI_SIMPLE_TEXT_INPUT_PROTOCOL EFI_SIMPLE_TEXT_INPUT_PROTOCOL;
///
/// The EFI_SIMPLE_TEXT_INPUT_PROTOCOL is used on the ConsoleIn device.
/// It is the minimum required protocol for ConsoleIn.
///
struct _EFI_SIMPLE_TEXT_INPUT_PROTOCOL {
EFI_INPUT_RESET Reset;
EFI_INPUT_READ_KEY ReadKeyStroke;
///
/// Event to use with WaitForEvent() to wait for a key to be available
///
EFI_EVENT WaitForKey;
};
typedef struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL;
///
/// The EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL is used on the ConsoleIn
/// device. It is an extension to the Simple Text Input protocol
/// which allows a variety of extended shift state information to be
/// returned.
///
struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL {
EFI_INPUT_RESET_EX Reset;
EFI_INPUT_READ_KEY_EX ReadKeyStrokeEx;
///
/// Event to use with WaitForEvent() to wait for a key to be available.
///
EFI_EVENT WaitForKeyEx;
EFI_SET_STATE SetState;
EFI_REGISTER_KEYSTROKE_NOTIFY RegisterKeyNotify;
EFI_UNREGISTER_KEYSTROKE_NOTIFY UnregisterKeyNotify;
};
Last modified 2yr ago