2 Simple Text Input Ex protocol from the UEFI 2.0 specification.
4 This protocol defines an extension to the EFI_SIMPLE_TEXT_INPUT_PROTOCOL
5 which exposes much more state and modifier information from the input device,
6 also allows one to register a notification for a particular keystroke.
8 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
9 SPDX-License-Identifier: BSD-2-Clause-Patent
13 #ifndef __SIMPLE_TEXT_IN_EX_H__
14 #define __SIMPLE_TEXT_IN_EX_H__
16 #include <Protocol/SimpleTextIn.h>
18 #define EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID \
19 {0xdd9e7534, 0x7762, 0x4698, { 0x8c, 0x14, 0xf5, 0x85, 0x17, 0xa6, 0x25, 0xaa } }
21 typedef struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
;
24 The Reset() function resets the input device hardware. As part
25 of initialization process, the firmware/device will make a quick
26 but reasonable attempt to verify that the device is functioning.
27 If the ExtendedVerification flag is TRUE the firmware may take
28 an extended amount of time to verify the device is operating on
29 reset. Otherwise the reset operation is to occur as quickly as
30 possible. The hardware verification process is not defined by
31 this specification and is left up to the platform firmware or
34 @param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
36 @param ExtendedVerification Indicates that the driver may
37 perform a more exhaustive
38 verification operation of the
42 @retval EFI_SUCCESS The device was reset.
44 @retval EFI_DEVICE_ERROR The device is not functioning
45 correctly and could not be reset.
50 (EFIAPI
*EFI_INPUT_RESET_EX
)(
51 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
52 IN BOOLEAN ExtendedVerification
56 /// EFI_KEY_TOGGLE_STATE. The toggle states are defined.
57 /// They are: EFI_TOGGLE_STATE_VALID, EFI_SCROLL_LOCK_ACTIVE
58 /// EFI_NUM_LOCK_ACTIVE, EFI_CAPS_LOCK_ACTIVE
60 typedef UINT8 EFI_KEY_TOGGLE_STATE
;
62 typedef struct _EFI_KEY_STATE
{
64 /// Reflects the currently pressed shift
65 /// modifiers for the input device. The
66 /// returned value is valid only if the high
67 /// order bit has been set.
71 /// Reflects the current internal state of
72 /// various toggled attributes. The returned
73 /// value is valid only if the high order
76 EFI_KEY_TOGGLE_STATE KeyToggleState
;
81 /// The EFI scan code and Unicode value returned from the input device.
85 /// The current state of various toggled attributes as well as input modifier values.
87 EFI_KEY_STATE KeyState
;
91 // Any Shift or Toggle State that is valid should have
92 // high order bit set.
96 #define EFI_SHIFT_STATE_VALID 0x80000000
97 #define EFI_RIGHT_SHIFT_PRESSED 0x00000001
98 #define EFI_LEFT_SHIFT_PRESSED 0x00000002
99 #define EFI_RIGHT_CONTROL_PRESSED 0x00000004
100 #define EFI_LEFT_CONTROL_PRESSED 0x00000008
101 #define EFI_RIGHT_ALT_PRESSED 0x00000010
102 #define EFI_LEFT_ALT_PRESSED 0x00000020
103 #define EFI_RIGHT_LOGO_PRESSED 0x00000040
104 #define EFI_LEFT_LOGO_PRESSED 0x00000080
105 #define EFI_MENU_KEY_PRESSED 0x00000100
106 #define EFI_SYS_REQ_PRESSED 0x00000200
111 #define EFI_TOGGLE_STATE_VALID 0x80
112 #define EFI_KEY_STATE_EXPOSED 0x40
113 #define EFI_SCROLL_LOCK_ACTIVE 0x01
114 #define EFI_NUM_LOCK_ACTIVE 0x02
115 #define EFI_CAPS_LOCK_ACTIVE 0x04
120 #define SCAN_F11 0x0015
121 #define SCAN_F12 0x0016
122 #define SCAN_PAUSE 0x0048
123 #define SCAN_F13 0x0068
124 #define SCAN_F14 0x0069
125 #define SCAN_F15 0x006A
126 #define SCAN_F16 0x006B
127 #define SCAN_F17 0x006C
128 #define SCAN_F18 0x006D
129 #define SCAN_F19 0x006E
130 #define SCAN_F20 0x006F
131 #define SCAN_F21 0x0070
132 #define SCAN_F22 0x0071
133 #define SCAN_F23 0x0072
134 #define SCAN_F24 0x0073
135 #define SCAN_MUTE 0x007F
136 #define SCAN_VOLUME_UP 0x0080
137 #define SCAN_VOLUME_DOWN 0x0081
138 #define SCAN_BRIGHTNESS_UP 0x0100
139 #define SCAN_BRIGHTNESS_DOWN 0x0101
140 #define SCAN_SUSPEND 0x0102
141 #define SCAN_HIBERNATE 0x0103
142 #define SCAN_TOGGLE_DISPLAY 0x0104
143 #define SCAN_RECOVERY 0x0105
144 #define SCAN_EJECT 0x0106
147 The function reads the next keystroke from the input device. If
148 there is no pending keystroke the function returns
149 EFI_NOT_READY. If there is a pending keystroke, then
150 KeyData.Key.ScanCode is the EFI scan code defined in Error!
151 Reference source not found. The KeyData.Key.UnicodeChar is the
152 actual printable character or is zero if the key does not
153 represent a printable character (control key, function key,
154 etc.). The KeyData.KeyState is shift state for the character
155 reflected in KeyData.Key.UnicodeChar or KeyData.Key.ScanCode .
156 When interpreting the data from this function, it should be
157 noted that if a class of printable characters that are
158 normally adjusted by shift modifiers (e.g. Shift Key + "f"
159 key) would be presented solely as a KeyData.Key.UnicodeChar
160 without the associated shift state. So in the previous example
161 of a Shift Key + "f" key being pressed, the only pertinent
162 data returned would be KeyData.Key.UnicodeChar with the value
163 of "F". This of course would not typically be the case for
164 non-printable characters such as the pressing of the Right
165 Shift Key + F10 key since the corresponding returned data
166 would be reflected both in the KeyData.KeyState.KeyShiftState
167 and KeyData.Key.ScanCode values. UEFI drivers which implement
168 the EFI_SIMPLE_TEXT_INPUT_EX protocol are required to return
169 KeyData.Key and KeyData.KeyState values. These drivers must
170 always return the most current state of
171 KeyData.KeyState.KeyShiftState and
172 KeyData.KeyState.KeyToggleState. It should also be noted that
173 certain input devices may not be able to produce shift or toggle
174 state information, and in those cases the high order bit in the
175 respective Toggle and Shift state fields should not be active.
178 @param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
180 @param KeyData A pointer to a buffer that is filled in with
181 the keystroke state data for the key that was
185 @retval EFI_SUCCESS The keystroke information was returned.
186 @retval EFI_NOT_READY There was no keystroke data available.
187 @retval EFI_DEVICE_ERROR The keystroke information was not returned due to
194 (EFIAPI
*EFI_INPUT_READ_KEY_EX
)(
195 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
196 OUT EFI_KEY_DATA
*KeyData
200 The SetState() function allows the input device hardware to
201 have state settings adjusted.
203 @param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
205 @param KeyToggleState Pointer to the EFI_KEY_TOGGLE_STATE to
206 set the state for the input device.
209 @retval EFI_SUCCESS The device state was set appropriately.
211 @retval EFI_DEVICE_ERROR The device is not functioning
212 correctly and could not have the
215 @retval EFI_UNSUPPORTED The device does not support the
216 ability to have its state set.
221 (EFIAPI
*EFI_SET_STATE
)(
222 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
223 IN EFI_KEY_TOGGLE_STATE
*KeyToggleState
227 /// The function will be called when the key sequence is typed specified by KeyData.
231 (EFIAPI
*EFI_KEY_NOTIFY_FUNCTION
)(
232 IN EFI_KEY_DATA
*KeyData
236 The RegisterKeystrokeNotify() function registers a function
237 which will be called when a specified keystroke will occur.
239 @param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
241 @param KeyData A pointer to a buffer that is filled in with
242 the keystroke information for the key that was
243 pressed. If KeyData.Key, KeyData.KeyState.KeyToggleState
244 and KeyData.KeyState.KeyShiftState are 0, then any incomplete
245 keystroke will trigger a notification of the KeyNotificationFunction.
247 @param KeyNotificationFunction Points to the function to be called when the key sequence
248 is typed specified by KeyData. This notification function
249 should be called at <=TPL_CALLBACK.
252 @param NotifyHandle Points to the unique handle assigned to
253 the registered notification.
255 @retval EFI_SUCCESS Key notify was registered successfully.
257 @retval EFI_OUT_OF_RESOURCES Unable to allocate necessary
263 (EFIAPI
*EFI_REGISTER_KEYSTROKE_NOTIFY
)(
264 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
265 IN EFI_KEY_DATA
*KeyData
,
266 IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction
,
267 OUT VOID
**NotifyHandle
271 The UnregisterKeystrokeNotify() function removes the
272 notification which was previously registered.
274 @param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
276 @param NotificationHandle The handle of the notification
277 function being unregistered.
279 @retval EFI_SUCCESS Key notify was unregistered successfully.
281 @retval EFI_INVALID_PARAMETER The NotificationHandle is
287 (EFIAPI
*EFI_UNREGISTER_KEYSTROKE_NOTIFY
)(
288 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
289 IN VOID
*NotificationHandle
293 /// The EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL is used on the ConsoleIn
294 /// device. It is an extension to the Simple Text Input protocol
295 /// which allows a variety of extended shift state information to be
298 struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
{
299 EFI_INPUT_RESET_EX Reset
;
300 EFI_INPUT_READ_KEY_EX ReadKeyStrokeEx
;
302 /// Event to use with WaitForEvent() to wait for a key to be available.
304 EFI_EVENT WaitForKeyEx
;
305 EFI_SET_STATE SetState
;
306 EFI_REGISTER_KEYSTROKE_NOTIFY RegisterKeyNotify
;
307 EFI_UNREGISTER_KEYSTROKE_NOTIFY UnregisterKeyNotify
;
310 extern EFI_GUID gEfiSimpleTextInputExProtocolGuid
;