1 /**
2 	Based on Protocol/SimpleTextInEx.h, original notice:
3 
4 	Simple Text Input Ex protocol from the UEFI 2.0 specification.
5 	
6 	This protocol defines an extension to the EFI_SIMPLE_TEXT_INPUT_PROTOCOL
7 	which exposes much more state and modifier information from the input device,
8 	also allows one to register a notification for a particular keystroke.
9 	
10 	Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
11 	This program and the accompanying materials
12 	are licensed and made available under the terms and conditions of the BSD License
13 	which accompanies this distribution.  The full text of the license may be found at
14 	http://opensource.org/licenses/bsd-license.php
15 	
16 	THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
17 	WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 	
19 **/
20 module uefi.protocols.simpletextinex;
21 import uefi.base;
22 import uefi.base_type;
23 import uefi.protocols.simpletextin;
24 
25 public:
26 extern (C):
27 
28 enum EFI_GUID EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID = EFI_GUID(0xdd9e7534,
29         0x7762, 0x4698, [0x8c, 0x14, 0xf5, 0x85, 0x17, 0xa6, 0x25, 0xaa]);
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 alias EFI_INPUT_RESET_EX = EFI_STATUS function(
56     EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL* This, BOOLEAN ExtendedVerification) @nogc nothrow;
57 /// EFI_KEY_TOGGLE_STATE. The toggle states are defined.
58 /// They are: EFI_TOGGLE_STATE_VALID, EFI_SCROLL_LOCK_ACTIVE
59 /// EFI_NUM_LOCK_ACTIVE, EFI_CAPS_LOCK_ACTIVE
60 alias EFI_KEY_TOGGLE_STATE = UINT8;
61 struct EFI_KEY_STATE
62 {
63     ///
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.
68     ///
69     UINT32 KeyShiftState;
70     ///
71     /// Reflects the current internal state of
72     /// various toggled attributes. The returned
73     /// value is valid only if the high order
74     /// bit has been set.
75     ///
76     EFI_KEY_TOGGLE_STATE KeyToggleState;
77 }
78 
79 struct EFI_KEY_DATA
80 {
81     ///
82     /// The EFI scan code and Unicode value returned from the input device.
83     ///
84     EFI_INPUT_KEY Key;
85     ///
86     /// The current state of various toggled attributes as well as input modifier values.
87     ///
88     EFI_KEY_STATE KeyState;
89 }
90 
91 enum EFI_SHIFT_STATE_VALID = 0x80000000;
92 enum EFI_RIGHT_SHIFT_PRESSED = 0x00000001;
93 enum EFI_LEFT_SHIFT_PRESSED = 0x00000002;
94 enum EFI_RIGHT_CONTROL_PRESSED = 0x00000004;
95 enum EFI_LEFT_CONTROL_PRESSED = 0x00000008;
96 enum EFI_RIGHT_ALT_PRESSED = 0x00000010;
97 enum EFI_LEFT_ALT_PRESSED = 0x00000020;
98 enum EFI_RIGHT_LOGO_PRESSED = 0x00000040;
99 enum EFI_LEFT_LOGO_PRESSED = 0x00000080;
100 enum EFI_MENU_KEY_PRESSED = 0x00000100;
101 enum EFI_SYS_REQ_PRESSED = 0x00000200;
102 enum EFI_TOGGLE_STATE_VALID = 0x80;
103 enum EFI_KEY_STATE_EXPOSED = 0x40;
104 enum EFI_SCROLL_LOCK_ACTIVE = 0x01;
105 enum EFI_NUM_LOCK_ACTIVE = 0x02;
106 enum EFI_CAPS_LOCK_ACTIVE = 0x04;
107 enum SCAN_F11 = 0x0015;
108 enum SCAN_F12 = 0x0016;
109 enum SCAN_PAUSE = 0x0048;
110 enum SCAN_F13 = 0x0068;
111 enum SCAN_F14 = 0x0069;
112 enum SCAN_F15 = 0x006A;
113 enum SCAN_F16 = 0x006B;
114 enum SCAN_F17 = 0x006C;
115 enum SCAN_F18 = 0x006D;
116 enum SCAN_F19 = 0x006E;
117 enum SCAN_F20 = 0x006F;
118 enum SCAN_F21 = 0x0070;
119 enum SCAN_F22 = 0x0071;
120 enum SCAN_F23 = 0x0072;
121 enum SCAN_F24 = 0x0073;
122 enum SCAN_MUTE = 0x007F;
123 enum SCAN_VOLUME_UP = 0x0080;
124 enum SCAN_VOLUME_DOWN = 0x0081;
125 enum SCAN_BRIGHTNESS_UP = 0x0100;
126 enum SCAN_BRIGHTNESS_DOWN = 0x0101;
127 enum SCAN_SUSPEND = 0x0102;
128 enum SCAN_HIBERNATE = 0x0103;
129 enum SCAN_TOGGLE_DISPLAY = 0x0104;
130 enum SCAN_RECOVERY = 0x0105;
131 enum SCAN_EJECT = 0x0106;
132 /**
133 	The function reads the next keystroke from the input device. If
134 	there is no pending keystroke the function returns
135 	EFI_NOT_READY. If there is a pending keystroke, then
136 	KeyData.Key.ScanCode is the EFI scan code defined in Error!
137 	Reference source not found. The KeyData.Key.UnicodeChar is the
138 	actual printable character or is zero if the key does not
139 	represent a printable character (control key, function key,
140 	etc.). The KeyData.KeyState is shift state for the character
141 	reflected in KeyData.Key.UnicodeChar or KeyData.Key.ScanCode .
142 	When interpreting the data from this function, it should be
143 	noted that if a class of printable characters that are
144 	normally adjusted by shift modifiers (e.g. Shift Key + "f"
145 	key) would be presented solely as a KeyData.Key.UnicodeChar
146 	without the associated shift state. So in the previous example
147 	of a Shift Key + "f" key being pressed, the only pertinent
148 	data returned would be KeyData.Key.UnicodeChar with the value
149 	of "F". This of course would not typically be the case for
150 	non-printable characters such as the pressing of the Right
151 	Shift Key + F10 key since the corresponding returned data
152 	would be reflected both in the KeyData.KeyState.KeyShiftState
153 	and KeyData.Key.ScanCode values. UEFI drivers which implement
154 	the EFI_SIMPLE_TEXT_INPUT_EX protocol are required to return
155 	KeyData.Key and KeyData.KeyState values. These drivers must
156 	always return the most current state of
157 	KeyData.KeyState.KeyShiftState and
158 	KeyData.KeyState.KeyToggleState. It should also be noted that
159 	certain input devices may not be able to produce shift or toggle
160 	state information, and in those cases the high order bit in the
161 	respective Toggle and Shift state fields should not be active.
162 	
163 	
164 	@param This     A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
165 	
166 	@param KeyData  A pointer to a buffer that is filled in with
167 	the keystroke state data for the key that was
168 	pressed.
169 	
170 	
171 	@retval EFI_SUCCESS     The keystroke information was
172 	returned.
173 	
174 	@retval EFI_NOT_READY   There was no keystroke data available.
175 	EFI_DEVICE_ERROR The keystroke
176 	information was not returned due to
177 	hardware errors.
178 	
179 	
180 **/
181 alias EFI_INPUT_READ_KEY_EX = EFI_STATUS function(
182     EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL* This, EFI_KEY_DATA* KeyData) @nogc nothrow;
183 /**
184 	The SetState() function allows the input device hardware to
185 	have state settings adjusted.
186 	
187 	@param This           A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
188 	
189 	@param KeyToggleState Pointer to the EFI_KEY_TOGGLE_STATE to
190 	set the state for the input device.
191 	
192 	
193 	@retval EFI_SUCCESS       The device state was set appropriately.
194 	
195 	@retval EFI_DEVICE_ERROR  The device is not functioning
196 	correctly and could not have the
197 	setting adjusted.
198 	
199 	@retval EFI_UNSUPPORTED   The device does not support the
200 	ability to have its state set.
201 	
202 **/
203 alias EFI_SET_STATE = EFI_STATUS function(EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL* This,
204     EFI_KEY_TOGGLE_STATE* KeyToggleState) @nogc nothrow;
205 /// The function will be called when the key sequence is typed specified by KeyData.
206 alias EFI_KEY_NOTIFY_FUNCTION = EFI_STATUS function(EFI_KEY_DATA* KeyData) @nogc nothrow;
207 /**
208 	The RegisterKeystrokeNotify() function registers a function
209 	which will be called when a specified keystroke will occur.
210 	
211 	@param This                     A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
212 	
213 	@param KeyData                  A pointer to a buffer that is filled in with
214 	the keystroke information for the key that was
215 	pressed.
216 	
217 	@param KeyNotificationFunction  Points to the function to be
218 	called when the key sequence
219 	is typed specified by KeyData.
220 	
221 	
222 	@param NotifyHandle             Points to the unique handle assigned to
223 	the registered notification.
224 	
225 	@retval EFI_SUCCESS           The device state was set
226 	appropriately.
227 	
228 	@retval EFI_OUT_OF_RESOURCES  Unable to allocate necessary
229 	data structures.
230 	
231 **/
232 alias EFI_REGISTER_KEYSTROKE_NOTIFY = EFI_STATUS function(
233     EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL* This, EFI_KEY_DATA* KeyData,
234     EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction, void** NotifyHandle) @nogc nothrow;
235 /**
236 	The UnregisterKeystrokeNotify() function removes the
237 	notification which was previously registered.
238 	
239 	@param This               A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
240 	
241 	@param NotificationHandle The handle of the notification
242 	function being unregistered.
243 	
244 	@retval EFI_SUCCESS The device state was set appropriately.
245 	
246 	@retval EFI_INVALID_PARAMETER The NotificationHandle is
247 	invalid.
248 	
249 **/
250 alias EFI_UNREGISTER_KEYSTROKE_NOTIFY = EFI_STATUS function(
251     EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL* This, void* NotificationHandle) @nogc nothrow;
252 /// The EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL is used on the ConsoleIn
253 /// device. It is an extension to the Simple Text Input protocol
254 /// which allows a variety of extended shift state information to be
255 /// returned.
256 struct EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
257 {
258     EFI_INPUT_RESET_EX Reset;
259     EFI_INPUT_READ_KEY_EX ReadKeyStrokeEx;
260     ///
261     /// Event to use with WaitForEvent() to wait for a key to be available.
262     ///
263     EFI_EVENT WaitForKeyEx;
264     EFI_SET_STATE SetState;
265     EFI_REGISTER_KEYSTROKE_NOTIFY RegisterKeyNotify;
266     EFI_UNREGISTER_KEYSTROKE_NOTIFY UnregisterKeyNotify;
267 
268 }