]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Protocol/SimpleTextInEx.h
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Include / Protocol / SimpleTextInEx.h
CommitLineData
d1f95000 1/** @file\r
c8c44377 2 Simple Text Input Ex protocol from the UEFI 2.0 specification.\r
e791cf44 3\r
c8c44377 4 This protocol defines an extension to the EFI_SIMPLE_TEXT_INPUT_PROTOCOL\r
5 which exposes much more state and modifier information from the input device,\r
6 also allows one to register a notification for a particular keystroke.\r
d1f95000 7\r
2de87e46 8 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
9344f092 9 SPDX-License-Identifier: BSD-2-Clause-Patent\r
d1f95000 10\r
d1f95000 11**/\r
12\r
13#ifndef __SIMPLE_TEXT_IN_EX_H__\r
14#define __SIMPLE_TEXT_IN_EX_H__\r
15\r
2be21afb 16#include <Protocol/SimpleTextIn.h>\r
17\r
d1f95000 18#define EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID \\r
19 {0xdd9e7534, 0x7762, 0x4698, { 0x8c, 0x14, 0xf5, 0x85, 0x17, 0xa6, 0x25, 0xaa } }\r
20\r
21\r
22typedef struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL;\r
23\r
24/**\r
25 The Reset() function resets the input device hardware. As part\r
26 of initialization process, the firmware/device will make a quick\r
27 but reasonable attempt to verify that the device is functioning.\r
28 If the ExtendedVerification flag is TRUE the firmware may take\r
29 an extended amount of time to verify the device is operating on\r
30 reset. Otherwise the reset operation is to occur as quickly as\r
31 possible. The hardware verification process is not defined by\r
32 this specification and is left up to the platform firmware or\r
33 driver to implement.\r
34\r
4ca9b6c4 35 @param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.\r
d1f95000 36\r
37 @param ExtendedVerification Indicates that the driver may\r
38 perform a more exhaustive\r
39 verification operation of the\r
40 device during reset.\r
41\r
42\r
4ca9b6c4 43 @retval EFI_SUCCESS The device was reset.\r
e791cf44 44\r
d1f95000 45 @retval EFI_DEVICE_ERROR The device is not functioning\r
46 correctly and could not be reset.\r
47\r
48**/\r
49typedef\r
50EFI_STATUS\r
8b13229b 51(EFIAPI *EFI_INPUT_RESET_EX)(\r
85f74a01 52 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
53 IN BOOLEAN ExtendedVerification\r
d1f95000 54);\r
55\r
56\r
992f22b9 57///\r
630b4187 58/// EFI_KEY_TOGGLE_STATE. The toggle states are defined.\r
59/// They are: EFI_TOGGLE_STATE_VALID, EFI_SCROLL_LOCK_ACTIVE\r
992f22b9
LG
60/// EFI_NUM_LOCK_ACTIVE, EFI_CAPS_LOCK_ACTIVE\r
61///\r
85f74a01 62typedef UINT8 EFI_KEY_TOGGLE_STATE;\r
d1f95000 63\r
d1f95000 64typedef struct _EFI_KEY_STATE {\r
992f22b9
LG
65 ///\r
66 /// Reflects the currently pressed shift\r
67 /// modifiers for the input device. The\r
68 /// returned value is valid only if the high\r
69 /// order bit has been set.\r
70 ///\r
d1f95000 71 UINT32 KeyShiftState;\r
992f22b9
LG
72 ///\r
73 /// Reflects the current internal state of\r
74 /// various toggled attributes. The returned\r
75 /// value is valid only if the high order\r
76 /// bit has been set.\r
77 ///\r
d1f95000 78 EFI_KEY_TOGGLE_STATE KeyToggleState;\r
79} EFI_KEY_STATE;\r
80\r
d1f95000 81typedef struct {\r
992f22b9
LG
82 ///\r
83 /// The EFI scan code and Unicode value returned from the input device.\r
84 ///\r
d1f95000 85 EFI_INPUT_KEY Key;\r
992f22b9
LG
86 ///\r
87 /// The current state of various toggled attributes as well as input modifier values.\r
88 ///\r
d1f95000 89 EFI_KEY_STATE KeyState;\r
90} EFI_KEY_DATA;\r
91\r
d1f95000 92//\r
93// Any Shift or Toggle State that is valid should have\r
94// high order bit set.\r
95//\r
85f74a01 96// Shift state\r
97//\r
98#define EFI_SHIFT_STATE_VALID 0x80000000\r
99#define EFI_RIGHT_SHIFT_PRESSED 0x00000001\r
100#define EFI_LEFT_SHIFT_PRESSED 0x00000002\r
101#define EFI_RIGHT_CONTROL_PRESSED 0x00000004\r
102#define EFI_LEFT_CONTROL_PRESSED 0x00000008\r
103#define EFI_RIGHT_ALT_PRESSED 0x00000010\r
104#define EFI_LEFT_ALT_PRESSED 0x00000020\r
105#define EFI_RIGHT_LOGO_PRESSED 0x00000040\r
106#define EFI_LEFT_LOGO_PRESSED 0x00000080\r
107#define EFI_MENU_KEY_PRESSED 0x00000100\r
108#define EFI_SYS_REQ_PRESSED 0x00000200\r
109\r
e791cf44 110//\r
111// Toggle state\r
112//\r
85f74a01 113#define EFI_TOGGLE_STATE_VALID 0x80\r
e791cf44 114#define EFI_KEY_STATE_EXPOSED 0x40\r
85f74a01 115#define EFI_SCROLL_LOCK_ACTIVE 0x01\r
116#define EFI_NUM_LOCK_ACTIVE 0x02\r
117#define EFI_CAPS_LOCK_ACTIVE 0x04\r
e791cf44 118\r
119//\r
120// EFI Scan codes\r
2be21afb 121//\r
122#define SCAN_F11 0x0015\r
123#define SCAN_F12 0x0016\r
66b96f92 124#define SCAN_PAUSE 0x0048\r
85f74a01 125#define SCAN_F13 0x0068\r
126#define SCAN_F14 0x0069\r
127#define SCAN_F15 0x006A\r
128#define SCAN_F16 0x006B\r
129#define SCAN_F17 0x006C\r
130#define SCAN_F18 0x006D\r
131#define SCAN_F19 0x006E\r
132#define SCAN_F20 0x006F\r
133#define SCAN_F21 0x0070\r
134#define SCAN_F22 0x0071\r
135#define SCAN_F23 0x0072\r
136#define SCAN_F24 0x0073\r
137#define SCAN_MUTE 0x007F\r
138#define SCAN_VOLUME_UP 0x0080\r
139#define SCAN_VOLUME_DOWN 0x0081\r
140#define SCAN_BRIGHTNESS_UP 0x0100\r
141#define SCAN_BRIGHTNESS_DOWN 0x0101\r
142#define SCAN_SUSPEND 0x0102\r
143#define SCAN_HIBERNATE 0x0103\r
144#define SCAN_TOGGLE_DISPLAY 0x0104\r
145#define SCAN_RECOVERY 0x0105\r
146#define SCAN_EJECT 0x0106\r
d1f95000 147\r
148/**\r
149 The function reads the next keystroke from the input device. If\r
150 there is no pending keystroke the function returns\r
151 EFI_NOT_READY. If there is a pending keystroke, then\r
152 KeyData.Key.ScanCode is the EFI scan code defined in Error!\r
630b4187 153 Reference source not found. The KeyData.Key.UnicodeChar is the\r
f754f721 154 actual printable character or is zero if the key does not\r
d1f95000 155 represent a printable character (control key, function key,\r
156 etc.). The KeyData.KeyState is shift state for the character\r
157 reflected in KeyData.Key.UnicodeChar or KeyData.Key.ScanCode .\r
f754f721 158 When interpreting the data from this function, it should be\r
159 noted that if a class of printable characters that are\r
d1f95000 160 normally adjusted by shift modifiers (e.g. Shift Key + "f"\r
f754f721 161 key) would be presented solely as a KeyData.Key.UnicodeChar\r
162 without the associated shift state. So in the previous example\r
163 of a Shift Key + "f" key being pressed, the only pertinent\r
d1f95000 164 data returned would be KeyData.Key.UnicodeChar with the value\r
f754f721 165 of "F". This of course would not typically be the case for\r
166 non-printable characters such as the pressing of the Right\r
167 Shift Key + F10 key since the corresponding returned data\r
d1f95000 168 would be reflected both in the KeyData.KeyState.KeyShiftState\r
169 and KeyData.Key.ScanCode values. UEFI drivers which implement\r
170 the EFI_SIMPLE_TEXT_INPUT_EX protocol are required to return\r
171 KeyData.Key and KeyData.KeyState values. These drivers must\r
172 always return the most current state of\r
173 KeyData.KeyState.KeyShiftState and\r
f754f721 174 KeyData.KeyState.KeyToggleState. It should also be noted that\r
175 certain input devices may not be able to produce shift or toggle\r
d1f95000 176 state information, and in those cases the high order bit in the\r
177 respective Toggle and Shift state fields should not be active.\r
178\r
e791cf44 179\r
4ca9b6c4 180 @param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.\r
d1f95000 181\r
182 @param KeyData A pointer to a buffer that is filled in with\r
183 the keystroke state data for the key that was\r
184 pressed.\r
185\r
e791cf44 186\r
2de87e46
RN
187 @retval EFI_SUCCESS The keystroke information was returned.\r
188 @retval EFI_NOT_READY There was no keystroke data available.\r
189 @retval EFI_DEVICE_ERROR The keystroke information was not returned due to\r
190 hardware errors.\r
d1f95000 191\r
192\r
193**/\r
194typedef\r
195EFI_STATUS\r
8b13229b 196(EFIAPI *EFI_INPUT_READ_KEY_EX)(\r
85f74a01 197 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
198 OUT EFI_KEY_DATA *KeyData\r
d1f95000 199);\r
200\r
201/**\r
202 The SetState() function allows the input device hardware to\r
203 have state settings adjusted.\r
e791cf44 204\r
4ca9b6c4 205 @param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.\r
e791cf44 206\r
d1f95000 207 @param KeyToggleState Pointer to the EFI_KEY_TOGGLE_STATE to\r
208 set the state for the input device.\r
e791cf44 209\r
210\r
4ca9b6c4 211 @retval EFI_SUCCESS The device state was set appropriately.\r
d1f95000 212\r
213 @retval EFI_DEVICE_ERROR The device is not functioning\r
214 correctly and could not have the\r
215 setting adjusted.\r
216\r
217 @retval EFI_UNSUPPORTED The device does not support the\r
218 ability to have its state set.\r
219\r
220**/\r
221typedef\r
222EFI_STATUS\r
8b13229b 223(EFIAPI *EFI_SET_STATE)(\r
85f74a01 224 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
225 IN EFI_KEY_TOGGLE_STATE *KeyToggleState\r
d1f95000 226);\r
227\r
992f22b9
LG
228///\r
229/// The function will be called when the key sequence is typed specified by KeyData.\r
230///\r
d1f95000 231typedef\r
232EFI_STATUS\r
8b13229b 233(EFIAPI *EFI_KEY_NOTIFY_FUNCTION)(\r
85f74a01 234 IN EFI_KEY_DATA *KeyData\r
d1f95000 235);\r
236\r
237/**\r
238 The RegisterKeystrokeNotify() function registers a function\r
f754f721 239 which will be called when a specified keystroke will occur.\r
e791cf44 240\r
4ca9b6c4 241 @param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.\r
e791cf44 242\r
4ca9b6c4
LG
243 @param KeyData A pointer to a buffer that is filled in with\r
244 the keystroke information for the key that was\r
d4225da1
DB
245 pressed. If KeyData.Key, KeyData.KeyState.KeyToggleState\r
246 and KeyData.KeyState.KeyShiftState are 0, then any incomplete\r
247 keystroke will trigger a notification of the KeyNotificationFunction.\r
e791cf44 248\r
d4225da1
DB
249 @param KeyNotificationFunction Points to the function to be called when the key sequence\r
250 is typed specified by KeyData. This notification function\r
251 should be called at <=TPL_CALLBACK.\r
e791cf44 252\r
253\r
4ca9b6c4
LG
254 @param NotifyHandle Points to the unique handle assigned to\r
255 the registered notification.\r
e791cf44 256\r
d4225da1 257 @retval EFI_SUCCESS Key notify was registered successfully.\r
d1f95000 258\r
259 @retval EFI_OUT_OF_RESOURCES Unable to allocate necessary\r
260 data structures.\r
261\r
262**/\r
263typedef\r
264EFI_STATUS\r
8b13229b 265(EFIAPI *EFI_REGISTER_KEYSTROKE_NOTIFY)(\r
85f74a01 266 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
267 IN EFI_KEY_DATA *KeyData,\r
268 IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction,\r
402e4a9d 269 OUT VOID **NotifyHandle\r
d1f95000 270);\r
271\r
272/**\r
f754f721 273 The UnregisterKeystrokeNotify() function removes the\r
274 notification which was previously registered.\r
e791cf44 275\r
4ca9b6c4 276 @param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.\r
e791cf44 277\r
d1f95000 278 @param NotificationHandle The handle of the notification\r
279 function being unregistered.\r
e791cf44 280\r
d4225da1 281 @retval EFI_SUCCESS Key notify was unregistered successfully.\r
e791cf44 282\r
d1f95000 283 @retval EFI_INVALID_PARAMETER The NotificationHandle is\r
284 invalid.\r
285\r
286**/\r
287typedef\r
288EFI_STATUS\r
8b13229b 289(EFIAPI *EFI_UNREGISTER_KEYSTROKE_NOTIFY)(\r
85f74a01 290 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
402e4a9d 291 IN VOID *NotificationHandle\r
d1f95000 292);\r
293\r
294\r
44717a39 295///\r
296/// The EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL is used on the ConsoleIn\r
297/// device. It is an extension to the Simple Text Input protocol\r
298/// which allows a variety of extended shift state information to be\r
299/// returned.\r
300///\r
d1f95000 301struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL{\r
302 EFI_INPUT_RESET_EX Reset;\r
303 EFI_INPUT_READ_KEY_EX ReadKeyStrokeEx;\r
1f08a159 304 ///\r
305 /// Event to use with WaitForEvent() to wait for a key to be available.\r
306 ///\r
d1f95000 307 EFI_EVENT WaitForKeyEx;\r
308 EFI_SET_STATE SetState;\r
309 EFI_REGISTER_KEYSTROKE_NOTIFY RegisterKeyNotify;\r
310 EFI_UNREGISTER_KEYSTROKE_NOTIFY UnregisterKeyNotify;\r
311};\r
312\r
313\r
314extern EFI_GUID gEfiSimpleTextInputExProtocolGuid;\r
315\r
316#endif\r
317\r