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