]>
Commit | Line | Data |
---|---|---|
804405e7 | 1 | /*++ |
2 | ||
f9b8ab56 | 3 | Copyright (c) 2006, Intel Corporation. All rights reserved.<BR> |
1b7edf0f | 4 | Portions copyright (c) 2010, Apple, Inc. All rights reserved.<BR> |
f9b8ab56 | 5 | This program and the accompanying materials |
804405e7 | 6 | are licensed and made available under the terms and conditions of the BSD License |
7 | which accompanies this distribution. The full text of the license may be found at | |
8 | http://opensource.org/licenses/bsd-license.php | |
9 | ||
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. | |
12 | ||
13 | Module Name: | |
14 | ||
15 | UnixUgaInput.c | |
16 | ||
17 | Abstract: | |
18 | ||
19 | This file produces the Simple Text In for an Uga window. | |
20 | ||
21 | This stuff is linked at the hip to the Window, since the window | |
22 | processing is done in a thread kicked off in UnixUgaImplementation.c | |
23 | ||
24 | Since the window information is processed in an other thread we need | |
25 | a keyboard Queue to pass data about. The Simple Text In code just | |
26 | takes data off the Queue. The WinProc message loop takes keyboard input | |
27 | and places it in the Queue. | |
28 | ||
29 | --*/ | |
30 | ||
31 | #include "UnixUga.h" | |
32 | ||
33 | // | |
34 | // Simple Text In implementation. | |
35 | // | |
36 | ||
37 | EFI_STATUS | |
38 | EFIAPI | |
39 | UnixUgaSimpleTextInReset ( | |
40 | IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This, | |
41 | IN BOOLEAN ExtendedVerification | |
42 | ) | |
43 | /*++ | |
44 | ||
45 | Routine Description: | |
46 | ||
47 | TODO: Add function description | |
48 | ||
49 | Arguments: | |
50 | ||
51 | This - TODO: add argument description | |
52 | ExtendedVerification - TODO: add argument description | |
53 | ||
54 | Returns: | |
55 | ||
56 | EFI_SUCCESS - TODO: Add description for return value | |
57 | ||
58 | --*/ | |
59 | { | |
60 | UGA_PRIVATE_DATA *Private; | |
2ff79f2e | 61 | EFI_KEY_DATA Key; |
804405e7 | 62 | EFI_TPL OldTpl; |
63 | ||
64 | Private = UGA_PRIVATE_DATA_FROM_TEXT_IN_THIS (This); | |
65 | if (Private->UgaIo == NULL) { | |
66 | return EFI_SUCCESS; | |
67 | } | |
68 | ||
69 | // | |
70 | // Enter critical section | |
71 | // | |
72 | OldTpl = gBS->RaiseTPL (TPL_NOTIFY); | |
73 | ||
74 | // | |
75 | // A reset is draining the Queue | |
76 | // | |
2ff79f2e | 77 | while (Private->UgaIo->UgaGetKey (Private->UgaIo, &Key) == EFI_SUCCESS) |
804405e7 | 78 | ; |
79 | ||
80 | // | |
81 | // Leave critical section and return | |
82 | // | |
83 | gBS->RestoreTPL (OldTpl); | |
84 | return EFI_SUCCESS; | |
85 | } | |
86 | ||
804405e7 | 87 | EFI_STATUS |
88 | EFIAPI | |
89 | UnixUgaSimpleTextInReadKeyStroke ( | |
90 | IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This, | |
2ff79f2e | 91 | OUT EFI_INPUT_KEY *Key |
804405e7 | 92 | ) |
93 | /*++ | |
94 | ||
95 | Routine Description: | |
96 | ||
97 | TODO: Add function description | |
98 | ||
99 | Arguments: | |
100 | ||
101 | This - TODO: add argument description | |
102 | Key - TODO: add argument description | |
103 | ||
104 | Returns: | |
105 | ||
106 | TODO: add return values | |
107 | ||
108 | --*/ | |
109 | { | |
110 | UGA_PRIVATE_DATA *Private; | |
111 | EFI_STATUS Status; | |
112 | EFI_TPL OldTpl; | |
2ff79f2e | 113 | EFI_KEY_DATA KeyData; |
114 | ||
804405e7 | 115 | Private = UGA_PRIVATE_DATA_FROM_TEXT_IN_THIS (This); |
116 | if (Private->UgaIo == NULL) { | |
117 | return EFI_NOT_READY; | |
118 | } | |
119 | ||
120 | // | |
121 | // Enter critical section | |
122 | // | |
123 | OldTpl = gBS->RaiseTPL (TPL_NOTIFY); | |
124 | ||
2ff79f2e | 125 | Status = Private->UgaIo->UgaGetKey(Private->UgaIo, &KeyData); |
126 | CopyMem (Key, &KeyData, sizeof (EFI_INPUT_KEY)); | |
127 | ||
804405e7 | 128 | // |
129 | // Leave critical section and return | |
130 | // | |
131 | gBS->RestoreTPL (OldTpl); | |
132 | ||
133 | return Status; | |
134 | } | |
135 | ||
804405e7 | 136 | VOID |
137 | EFIAPI | |
138 | UnixUgaSimpleTextInWaitForKey ( | |
139 | IN EFI_EVENT Event, | |
140 | IN VOID *Context | |
141 | ) | |
142 | /*++ | |
143 | ||
144 | Routine Description: | |
145 | ||
146 | TODO: Add function description | |
147 | ||
148 | Arguments: | |
149 | ||
150 | Event - TODO: add argument description | |
151 | Context - TODO: add argument description | |
152 | ||
153 | Returns: | |
154 | ||
155 | TODO: add return values | |
156 | ||
157 | --*/ | |
158 | { | |
159 | UGA_PRIVATE_DATA *Private; | |
160 | EFI_STATUS Status; | |
161 | EFI_TPL OldTpl; | |
162 | ||
163 | Private = (UGA_PRIVATE_DATA *) Context; | |
164 | if (Private->UgaIo == NULL) { | |
165 | return; | |
166 | } | |
167 | ||
168 | // | |
169 | // Enter critical section | |
170 | // | |
171 | OldTpl = gBS->RaiseTPL (TPL_NOTIFY); | |
172 | ||
173 | Status = Private->UgaIo->UgaCheckKey(Private->UgaIo); | |
174 | if (!EFI_ERROR (Status)) { | |
175 | // | |
176 | // If a there is a key in the queue signal our event. | |
177 | // | |
178 | gBS->SignalEvent (Event); | |
179 | } | |
180 | // | |
181 | // Leave critical section and return | |
182 | // | |
183 | gBS->RestoreTPL (OldTpl); | |
184 | } | |
185 | ||
2ff79f2e | 186 | // |
187 | // Simple Pointer implementation. | |
188 | // | |
189 | ||
190 | EFI_STATUS | |
191 | EFIAPI | |
192 | UnixUgaSimplePointerReset ( | |
193 | IN EFI_SIMPLE_POINTER_PROTOCOL *This, | |
194 | IN BOOLEAN ExtendedVerification | |
195 | ) | |
196 | /*++ | |
197 | ||
198 | Routine Description: | |
199 | ||
200 | TODO: Add function description | |
201 | ||
202 | Arguments: | |
203 | ||
204 | This - TODO: add argument description | |
205 | ExtendedVerification - TODO: add argument description | |
206 | ||
207 | Returns: | |
208 | ||
209 | EFI_SUCCESS - TODO: Add description for return value | |
210 | ||
211 | --*/ | |
212 | { | |
213 | UGA_PRIVATE_DATA *Private; | |
214 | EFI_SIMPLE_POINTER_STATE State; | |
215 | EFI_TPL OldTpl; | |
216 | ||
217 | Private = UGA_PRIVATE_DATA_FROM_POINTER_THIS (This); | |
218 | if (Private->UgaIo == NULL) { | |
219 | return EFI_SUCCESS; | |
220 | } | |
221 | ||
222 | // | |
223 | // Enter critical section | |
224 | // | |
225 | OldTpl = gBS->RaiseTPL (TPL_NOTIFY); | |
226 | ||
227 | // | |
228 | // A reset is draining the Queue | |
229 | // | |
230 | while (Private->UgaIo->UgaGetPointerState(Private->UgaIo, &State) == EFI_SUCCESS) | |
231 | ; | |
232 | ||
233 | // | |
234 | // Leave critical section and return | |
235 | // | |
236 | gBS->RestoreTPL (OldTpl); | |
237 | return EFI_SUCCESS; | |
238 | } | |
239 | ||
240 | EFI_STATUS | |
241 | EFIAPI | |
242 | UnixUgaSimplePointerGetState ( | |
243 | IN EFI_SIMPLE_POINTER_PROTOCOL *This, | |
244 | IN OUT EFI_SIMPLE_POINTER_STATE *State | |
245 | ) | |
246 | /*++ | |
247 | ||
248 | Routine Description: | |
249 | ||
250 | TODO: Add function description | |
251 | ||
252 | Arguments: | |
253 | ||
254 | This - TODO: add argument description | |
255 | Key - TODO: add argument description | |
256 | ||
257 | Returns: | |
258 | ||
259 | TODO: add return values | |
260 | ||
261 | --*/ | |
262 | { | |
263 | UGA_PRIVATE_DATA *Private; | |
264 | EFI_STATUS Status; | |
265 | EFI_TPL OldTpl; | |
266 | ||
267 | Private = UGA_PRIVATE_DATA_FROM_POINTER_THIS (This); | |
268 | if (Private->UgaIo == NULL) { | |
269 | return EFI_NOT_READY; | |
270 | } | |
271 | ||
272 | // | |
273 | // Enter critical section | |
274 | // | |
275 | OldTpl = gBS->RaiseTPL (TPL_NOTIFY); | |
276 | ||
277 | Status = Private->UgaIo->UgaGetPointerState(Private->UgaIo, State); | |
278 | // | |
279 | // Leave critical section and return | |
280 | // | |
281 | gBS->RestoreTPL (OldTpl); | |
282 | ||
283 | return Status; | |
284 | } | |
285 | ||
286 | VOID | |
287 | EFIAPI | |
288 | UnixUgaSimplePointerWaitForInput ( | |
289 | IN EFI_EVENT Event, | |
290 | IN VOID *Context | |
291 | ) | |
292 | /*++ | |
293 | ||
294 | Routine Description: | |
295 | ||
296 | TODO: Add function description | |
297 | ||
298 | Arguments: | |
299 | ||
300 | Event - TODO: add argument description | |
301 | Context - TODO: add argument description | |
302 | ||
303 | Returns: | |
304 | ||
305 | TODO: add return values | |
306 | ||
307 | --*/ | |
308 | { | |
309 | UGA_PRIVATE_DATA *Private; | |
310 | EFI_STATUS Status; | |
311 | EFI_TPL OldTpl; | |
312 | ||
313 | Private = (UGA_PRIVATE_DATA *) Context; | |
314 | if (Private->UgaIo == NULL) { | |
315 | return; | |
316 | } | |
317 | ||
318 | // | |
319 | // Enter critical section | |
320 | // | |
321 | OldTpl = gBS->RaiseTPL (TPL_NOTIFY); | |
322 | ||
323 | Status = Private->UgaIo->UgaCheckPointer(Private->UgaIo); | |
324 | if (!EFI_ERROR (Status)) { | |
325 | // | |
326 | // If the pointer state has changed, signal our event. | |
327 | // | |
328 | gBS->SignalEvent (Event); | |
329 | } | |
330 | // | |
331 | // Leave critical section and return | |
332 | // | |
333 | gBS->RestoreTPL (OldTpl); | |
334 | } | |
335 | ||
804405e7 | 336 | EFI_STATUS |
337 | UnixUgaInitializeSimpleTextInForWindow ( | |
338 | IN UGA_PRIVATE_DATA *Private | |
339 | ) | |
340 | /*++ | |
341 | ||
342 | Routine Description: | |
343 | ||
344 | TODO: Add function description | |
345 | ||
346 | Arguments: | |
347 | ||
348 | Private - TODO: add argument description | |
349 | ||
350 | Returns: | |
351 | ||
352 | TODO: add return values | |
353 | ||
354 | --*/ | |
355 | { | |
356 | EFI_STATUS Status; | |
357 | ||
358 | // | |
359 | // Initialize Simple Text In protoocol | |
360 | // | |
361 | Private->SimpleTextIn.Reset = UnixUgaSimpleTextInReset; | |
362 | Private->SimpleTextIn.ReadKeyStroke = UnixUgaSimpleTextInReadKeyStroke; | |
363 | ||
364 | Status = gBS->CreateEvent ( | |
365 | EVT_NOTIFY_WAIT, | |
366 | TPL_NOTIFY, | |
367 | UnixUgaSimpleTextInWaitForKey, | |
368 | Private, | |
369 | &Private->SimpleTextIn.WaitForKey | |
370 | ); | |
371 | ||
372 | return Status; | |
373 | } | |
2ff79f2e | 374 | |
375 | EFI_STATUS | |
376 | UnixUgaInitializeSimplePointerForWindow ( | |
377 | IN UGA_PRIVATE_DATA *Private | |
378 | ) | |
379 | /*++ | |
380 | ||
381 | Routine Description: | |
382 | ||
383 | TODO: Add function description | |
384 | ||
385 | Arguments: | |
386 | ||
387 | Private - TODO: add argument description | |
388 | ||
389 | Returns: | |
390 | ||
391 | TODO: add return values | |
392 | ||
393 | --*/ | |
394 | { | |
395 | EFI_STATUS Status; | |
396 | ||
397 | // | |
398 | // Initialize Simple Pointer protoocol | |
399 | // | |
400 | Private->PointerMode.ResolutionX = 1; | |
401 | Private->PointerMode.ResolutionY = 1; | |
402 | Private->PointerMode.LeftButton = TRUE; | |
403 | Private->PointerMode.RightButton = TRUE; | |
404 | ||
405 | Private->SimplePointer.Reset = UnixUgaSimplePointerReset; | |
406 | Private->SimplePointer.GetState = UnixUgaSimplePointerGetState; | |
407 | Private->SimplePointer.Mode = &Private->PointerMode; | |
408 | ||
409 | Status = gBS->CreateEvent ( | |
410 | EVT_NOTIFY_WAIT, | |
411 | TPL_NOTIFY, | |
412 | UnixUgaSimplePointerWaitForInput, | |
413 | Private, | |
414 | &Private->SimplePointer.WaitForInput | |
415 | ); | |
416 | ||
417 | return Status; | |
418 | } |