update comments per review comments.
[edk2.git] / MdePkg / Include / Protocol / SimpleTextInEx.h
blob98d0c583dcd8e693a1561bbdcbe587f318378062
1 /** @file
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 - 2009, Intel Corporation
9 All rights reserved. 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
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.
17 **/
19 #ifndef __SIMPLE_TEXT_IN_EX_H__
20 #define __SIMPLE_TEXT_IN_EX_H__
22 #define EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID \
23 {0xdd9e7534, 0x7762, 0x4698, { 0x8c, 0x14, 0xf5, 0x85, 0x17, 0xa6, 0x25, 0xaa } }
26 typedef struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL;
28 /**
29 The Reset() function resets the input device hardware. As part
30 of initialization process, the firmware/device will make a quick
31 but reasonable attempt to verify that the device is functioning.
32 If the ExtendedVerification flag is TRUE the firmware may take
33 an extended amount of time to verify the device is operating on
34 reset. Otherwise the reset operation is to occur as quickly as
35 possible. The hardware verification process is not defined by
36 this specification and is left up to the platform firmware or
37 driver to implement.
39 @param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
41 @param ExtendedVerification Indicates that the driver may
42 perform a more exhaustive
43 verification operation of the
44 device during reset.
47 @retval EFI_SUCCESS The device was reset.
49 @retval EFI_DEVICE_ERROR The device is not functioning
50 correctly and could not be reset.
52 **/
53 typedef
54 EFI_STATUS
55 (EFIAPI *EFI_INPUT_RESET_EX)(
56 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
57 IN BOOLEAN ExtendedVerification
61 ///
62 /// EFI_KEY_TOGGLE_STATE. The toggle states are defined.
63 /// They are: EFI_TOGGLE_STATE_VALID, EFI_SCROLL_LOCK_ACTIVE
64 /// EFI_NUM_LOCK_ACTIVE, EFI_CAPS_LOCK_ACTIVE
65 ///
66 typedef UINT8 EFI_KEY_TOGGLE_STATE;
68 typedef struct _EFI_KEY_STATE {
69 ///
70 /// Reflects the currently pressed shift
71 /// modifiers for the input device. The
72 /// returned value is valid only if the high
73 /// order bit has been set.
74 ///
75 UINT32 KeyShiftState;
76 ///
77 /// Reflects the current internal state of
78 /// various toggled attributes. The returned
79 /// value is valid only if the high order
80 /// bit has been set.
81 ///
82 EFI_KEY_TOGGLE_STATE KeyToggleState;
83 } EFI_KEY_STATE;
85 typedef struct {
86 ///
87 /// The EFI scan code and Unicode value returned from the input device.
88 ///
89 EFI_INPUT_KEY Key;
90 ///
91 /// The current state of various toggled attributes as well as input modifier values.
92 ///
93 EFI_KEY_STATE KeyState;
94 } EFI_KEY_DATA;
97 // Any Shift or Toggle State that is valid should have
98 // high order bit set.
100 // Shift state
102 #define EFI_SHIFT_STATE_VALID 0x80000000
103 #define EFI_RIGHT_SHIFT_PRESSED 0x00000001
104 #define EFI_LEFT_SHIFT_PRESSED 0x00000002
105 #define EFI_RIGHT_CONTROL_PRESSED 0x00000004
106 #define EFI_LEFT_CONTROL_PRESSED 0x00000008
107 #define EFI_RIGHT_ALT_PRESSED 0x00000010
108 #define EFI_LEFT_ALT_PRESSED 0x00000020
109 #define EFI_RIGHT_LOGO_PRESSED 0x00000040
110 #define EFI_LEFT_LOGO_PRESSED 0x00000080
111 #define EFI_MENU_KEY_PRESSED 0x00000100
112 #define EFI_SYS_REQ_PRESSED 0x00000200
115 // Toggle state
117 #define EFI_TOGGLE_STATE_VALID 0x80
118 #define EFI_SCROLL_LOCK_ACTIVE 0x01
119 #define EFI_NUM_LOCK_ACTIVE 0x02
120 #define EFI_CAPS_LOCK_ACTIVE 0x04
123 // EFI Scan codes
125 #define SCAN_F13 0x0068
126 #define SCAN_F14 0x0069
127 #define SCAN_F15 0x006A
128 #define SCAN_F16 0x006B
129 #define SCAN_F17 0x006C
130 #define SCAN_F18 0x006D
131 #define SCAN_F19 0x006E
132 #define SCAN_F20 0x006F
133 #define SCAN_F21 0x0070
134 #define SCAN_F22 0x0071
135 #define SCAN_F23 0x0072
136 #define SCAN_F24 0x0073
137 #define SCAN_MUTE 0x007F
138 #define SCAN_VOLUME_UP 0x0080
139 #define SCAN_VOLUME_DOWN 0x0081
140 #define SCAN_BRIGHTNESS_UP 0x0100
141 #define SCAN_BRIGHTNESS_DOWN 0x0101
142 #define SCAN_SUSPEND 0x0102
143 #define SCAN_HIBERNATE 0x0103
144 #define SCAN_TOGGLE_DISPLAY 0x0104
145 #define SCAN_RECOVERY 0x0105
146 #define SCAN_EJECT 0x0106
149 The function reads the next keystroke from the input device. If
150 there is no pending keystroke the function returns
151 EFI_NOT_READY. If there is a pending keystroke, then
152 KeyData.Key.ScanCode is the EFI scan code defined in Error!
153 Reference source not found. The KeyData.Key.UnicodeChar is the
154 actual printable character, or is zero if the key does not
155 represent a printable character (control key, function key,
156 etc.). The KeyData.KeyState is shift state for the character
157 reflected in KeyData.Key.UnicodeChar or KeyData.Key.ScanCode .
158 When interpreting the data from this function, printable characters that are
159 normally adjusted by shift modifiers (e.g. Shift Key + "f"
160 key) are presented solely as a KeyData.Key.UnicodeChar
161 without the associated shift state. For example,
162 if Shift Key + "f" key are pressed, the only pertinent
163 data returned would be KeyData.Key.UnicodeChar with the value
164 of "F". This would not typically be the case for
165 non-printable characters such as pressing the Right
166 Shift Key + F10 key, since the corresponding returned data
167 would be reflected both in the KeyData.KeyState.KeyShiftState
168 and KeyData.Key.ScanCode values. UEFI drivers which implement
169 the EFI_SIMPLE_TEXT_INPUT_EX protocol are required to return
170 KeyData.Key and KeyData.KeyState values. These drivers must
171 always return the most current state of
172 KeyData.KeyState.KeyShiftState and
173 KeyData.KeyState.KeyToggleState.
174 Certain input devices may not be able to produce shift or toggle
175 state information, and in those cases the high order bit in the
176 respective Toggle and Shift state fields should not be active.
179 @param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
181 @param KeyData A pointer to a buffer that is filled in with
182 the keystroke state data for the key that was
183 pressed.
186 @retval EFI_SUCCESS The keystroke information was
187 returned.
189 @retval EFI_NOT_READY There was no keystroke data available.
190 EFI_DEVICE_ERROR The keystroke
191 information was not returned due to
192 hardware errors.
196 typedef
197 EFI_STATUS
198 (EFIAPI *EFI_INPUT_READ_KEY_EX)(
199 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
200 OUT EFI_KEY_DATA *KeyData
204 The SetState() function allows the input device hardware to
205 have state settings adjusted.
207 @param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
209 @param KeyToggleState Pointer to the EFI_KEY_TOGGLE_STATE to
210 set the state for the input device.
213 @retval EFI_SUCCESS The device state was set appropriately.
215 @retval EFI_DEVICE_ERROR The device is not functioning
216 correctly and could not have the
217 setting adjusted.
219 @retval EFI_UNSUPPORTED The device does not support the
220 ability to have its state set.
223 typedef
224 EFI_STATUS
225 (EFIAPI *EFI_SET_STATE)(
226 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
227 IN EFI_KEY_TOGGLE_STATE *KeyToggleState
231 /// The function will be called when the key sequence is typed specified by KeyData.
233 typedef
234 EFI_STATUS
235 (EFIAPI *EFI_KEY_NOTIFY_FUNCTION)(
236 IN EFI_KEY_DATA *KeyData
240 The RegisterKeystrokeNotify() function registers a function
241 to be called when a specified keystroke will occur.
243 @param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
245 @param KeyData A pointer to a buffer that is filled in with
246 the keystroke information for the key that was
247 pressed.
249 @param KeyNotificationFunction Points to the function to be
250 called when the key sequence
251 is typed specified by KeyData.
254 @param NotifyHandle Points to the unique handle assigned to
255 the registered notification.
257 @retval EFI_SUCCESS The device state was set
258 appropriately.
260 @retval EFI_OUT_OF_RESOURCES Unable to allocate necessary
261 data structures.
264 typedef
265 EFI_STATUS
266 (EFIAPI *EFI_REGISTER_KEYSTROKE_NOTIFY)(
267 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
268 IN EFI_KEY_DATA *KeyData,
269 IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction,
270 OUT EFI_HANDLE *NotifyHandle
274 The UnregisterKeystrokeNotify() function removes a
275 notification that was previously registered.
277 @param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
279 @param NotificationHandle The handle of the notification
280 function being unregistered.
282 @retval EFI_SUCCESS The device state was set appropriately.
284 @retval EFI_INVALID_PARAMETER The NotificationHandle is
285 invalid.
288 typedef
289 EFI_STATUS
290 (EFIAPI *EFI_UNREGISTER_KEYSTROKE_NOTIFY)(
291 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
292 IN EFI_HANDLE NotificationHandle
297 /// The EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL is used on the ConsoleIn
298 /// device. It is an extension to the Simple Text Input protocol
299 /// which allows a variety of extended shift state information to be
300 /// returned.
302 struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL{
303 EFI_INPUT_RESET_EX Reset;
304 EFI_INPUT_READ_KEY_EX ReadKeyStrokeEx;
306 /// Event to use with WaitForEvent() to wait for a key to be available.
308 EFI_EVENT WaitForKeyEx;
309 EFI_SET_STATE SetState;
310 EFI_REGISTER_KEYSTROKE_NOTIFY RegisterKeyNotify;
311 EFI_UNREGISTER_KEYSTROKE_NOTIFY UnregisterKeyNotify;
315 extern EFI_GUID gEfiSimpleTextInputExProtocolGuid;
317 #endif