3 Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
4 This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 This file produces the Simple Text In for an Gop window.
20 This stuff is linked at the hip to the Window, since the window
21 processing is done in a thread kicked off in WinNtGopImplementation.c
23 Since the window information is processed in an other thread we need
24 a keyboard Queue to pass data about. The Simple Text In code just
25 takes data off the Queue. The WinProc message loop takes keyboard input
26 and places it in the Queue.
36 TODO: Add function description
38 @param Private TODO: add argument description
40 @retval EFI_SUCCESS TODO: Add description for return value
45 IN GOP_PRIVATE_DATA
*Private
,
46 IN GOP_QUEUE_FIXED
*Queue
49 Private
->WinNtThunk
->InitializeCriticalSection (&Queue
->Cs
);
57 TODO: Add function description
59 @param Private TODO: add argument description
61 @retval EFI_SUCCESS TODO: Add description for return value
66 IN GOP_PRIVATE_DATA
*Private
,
67 IN GOP_QUEUE_FIXED
*Queue
72 Private
->WinNtThunk
->DeleteCriticalSection (&Queue
->Cs
);
78 TODO: Add function description
80 @param Private TODO: add argument description
81 @param Key TODO: add argument description
83 @retval EFI_NOT_READY TODO: Add description for return value
84 @retval EFI_SUCCESS TODO: Add description for return value
89 IN GOP_PRIVATE_DATA
*Private
,
90 IN GOP_QUEUE_FIXED
*Queue
,
91 IN EFI_KEY_DATA
*KeyData
94 Private
->WinNtThunk
->EnterCriticalSection (&Queue
->Cs
);
96 if ((Queue
->Rear
+ 1) % MAX_Q
== Queue
->Front
) {
97 Private
->WinNtThunk
->LeaveCriticalSection (&Queue
->Cs
);
101 CopyMem (&Queue
->Q
[Queue
->Rear
], KeyData
, sizeof (EFI_KEY_DATA
));
102 Queue
->Rear
= (Queue
->Rear
+ 1) % MAX_Q
;
104 Private
->WinNtThunk
->LeaveCriticalSection (&Queue
->Cs
);
110 TODO: Add function description
112 @param Private TODO: add argument description
113 @param Key TODO: add argument description
115 @retval EFI_NOT_READY TODO: Add description for return value
116 @retval EFI_SUCCESS TODO: Add description for return value
121 IN GOP_PRIVATE_DATA
*Private
,
122 IN GOP_QUEUE_FIXED
*Queue
,
123 OUT EFI_KEY_DATA
*Key
126 Private
->WinNtThunk
->EnterCriticalSection (&Queue
->Cs
);
128 if (Queue
->Front
== Queue
->Rear
) {
129 Private
->WinNtThunk
->LeaveCriticalSection (&Queue
->Cs
);
130 return EFI_NOT_READY
;
133 CopyMem (Key
, &Queue
->Q
[Queue
->Front
], sizeof (EFI_KEY_DATA
));
134 Queue
->Front
= (Queue
->Front
+ 1) % MAX_Q
;
136 if (Key
->Key
.ScanCode
== SCAN_NULL
&& Key
->Key
.UnicodeChar
== CHAR_NULL
) {
137 if (!Private
->IsPartialKeySupport
) {
139 // If partial keystrok is not enabled, don't return the partial keystroke.
141 Private
->WinNtThunk
->LeaveCriticalSection (&Queue
->Cs
);
142 ZeroMem (Key
, sizeof (EFI_KEY_DATA
));
143 return EFI_NOT_READY
;
146 Private
->WinNtThunk
->LeaveCriticalSection (&Queue
->Cs
);
152 TODO: Add function description
154 @param Private TODO: add argument description
156 @retval EFI_NOT_READY TODO: Add description for return value
157 @retval EFI_SUCCESS TODO: Add description for return value
162 IN GOP_QUEUE_FIXED
*Queue
165 if (Queue
->Front
== Queue
->Rear
) {
166 return EFI_NOT_READY
;
173 GopPrivateIsKeyRegistered (
174 IN EFI_KEY_DATA
*RegsiteredData
,
175 IN EFI_KEY_DATA
*InputData
183 RegsiteredData - A pointer to a buffer that is filled in with the keystroke
184 state data for the key that was registered.
185 InputData - A pointer to a buffer that is filled in with the keystroke
186 state data for the key that was pressed.
189 TRUE - Key be pressed matches a registered key.
190 FLASE - Match failed.
194 ASSERT (RegsiteredData
!= NULL
&& InputData
!= NULL
);
196 if ((RegsiteredData
->Key
.ScanCode
!= InputData
->Key
.ScanCode
) ||
197 (RegsiteredData
->Key
.UnicodeChar
!= InputData
->Key
.UnicodeChar
)) {
202 // Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored.
204 if (RegsiteredData
->KeyState
.KeyShiftState
!= 0 &&
205 RegsiteredData
->KeyState
.KeyShiftState
!= InputData
->KeyState
.KeyShiftState
) {
208 if (RegsiteredData
->KeyState
.KeyToggleState
!= 0 &&
209 RegsiteredData
->KeyState
.KeyToggleState
!= InputData
->KeyState
.KeyToggleState
) {
219 GopPrivateInvokeRegisteredFunction (
220 IN GOP_PRIVATE_DATA
*Private
,
221 IN EFI_KEY_DATA
*KeyData
227 This function updates the status light of NumLock, ScrollLock and CapsLock.
231 Private - The private structure of WinNt Gop device.
232 KeyData - A pointer to a buffer that is filled in with the keystroke
233 state data for the key that was pressed.
237 EFI_SUCCESS - The status light is updated successfully.
242 WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY
*CurrentNotify
;
244 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
247 WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY
,
249 WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE
251 if (GopPrivateIsKeyRegistered (&CurrentNotify
->KeyData
, KeyData
)) {
252 CurrentNotify
->KeyNotificationFn (KeyData
);
258 WinNtGopSimpleTextInTimerHandler (
263 GOP_PRIVATE_DATA
*Private
;
264 EFI_KEY_DATA KeyData
;
266 Private
= (GOP_PRIVATE_DATA
*)Context
;
267 while (GopPrivateDeleteQ (Private
, &Private
->QueueForNotify
, &KeyData
) == EFI_SUCCESS
) {
268 GopPrivateInvokeRegisteredFunction (Private
, &KeyData
);
273 TODO: Add function description
275 @param Private TODO: add argument description
276 @param Key TODO: add argument description
278 @retval EFI_NOT_READY TODO: Add description for return value
279 @retval EFI_SUCCESS TODO: Add description for return value
284 IN GOP_PRIVATE_DATA
*Private
,
288 EFI_KEY_DATA KeyData
;
292 KeyData
.KeyState
.KeyShiftState
= EFI_SHIFT_STATE_VALID
;
293 KeyData
.KeyState
.KeyToggleState
= EFI_TOGGLE_STATE_VALID
;
296 // Record Key shift state and toggle state
298 if (Private
->LeftCtrl
) {
299 KeyData
.KeyState
.KeyShiftState
|= EFI_LEFT_CONTROL_PRESSED
;
301 if (Private
->RightCtrl
) {
302 KeyData
.KeyState
.KeyShiftState
|= EFI_RIGHT_CONTROL_PRESSED
;
304 if (Private
->LeftAlt
) {
305 KeyData
.KeyState
.KeyShiftState
|= EFI_LEFT_ALT_PRESSED
;
307 if (Private
->RightAlt
) {
308 KeyData
.KeyState
.KeyShiftState
|= EFI_RIGHT_ALT_PRESSED
;
310 if (Private
->LeftShift
) {
311 KeyData
.KeyState
.KeyShiftState
|= EFI_LEFT_SHIFT_PRESSED
;
313 if (Private
->RightShift
) {
314 KeyData
.KeyState
.KeyShiftState
|= EFI_RIGHT_SHIFT_PRESSED
;
316 if (Private
->LeftLogo
) {
317 KeyData
.KeyState
.KeyShiftState
|= EFI_LEFT_LOGO_PRESSED
;
319 if (Private
->RightLogo
) {
320 KeyData
.KeyState
.KeyShiftState
|= EFI_RIGHT_LOGO_PRESSED
;
323 KeyData
.KeyState
.KeyShiftState
|= EFI_MENU_KEY_PRESSED
;
325 if (Private
->SysReq
) {
326 KeyData
.KeyState
.KeyShiftState
|= EFI_SYS_REQ_PRESSED
;
328 if (Private
->CapsLock
) {
329 KeyData
.KeyState
.KeyToggleState
|= EFI_CAPS_LOCK_ACTIVE
;
331 if (Private
->NumLock
) {
332 KeyData
.KeyState
.KeyToggleState
|= EFI_NUM_LOCK_ACTIVE
;
334 if (Private
->ScrollLock
) {
335 KeyData
.KeyState
.KeyToggleState
|= EFI_SCROLL_LOCK_ACTIVE
;
337 if (Private
->IsPartialKeySupport
) {
338 KeyData
.KeyState
.KeyToggleState
|= EFI_KEY_STATE_EXPOSED
;
342 // Convert Ctrl+[1-26] to Ctrl+[A-Z]
344 if ((Private
->LeftCtrl
|| Private
->RightCtrl
) &&
345 (KeyData
.Key
.UnicodeChar
>= 1) && (KeyData
.Key
.UnicodeChar
<= 26)
347 if ((Private
->LeftShift
|| Private
->RightShift
) == Private
->CapsLock
) {
348 KeyData
.Key
.UnicodeChar
= (CHAR16
)(KeyData
.Key
.UnicodeChar
+ L
'a' - 1);
350 KeyData
.Key
.UnicodeChar
= (CHAR16
)(KeyData
.Key
.UnicodeChar
+ L
'A' - 1);
355 // Unmask the Shift bit for printable char
357 if (((KeyData
.Key
.UnicodeChar
>= L
'a') && (KeyData
.Key
.UnicodeChar
<= L
'z')) ||
358 ((KeyData
.Key
.UnicodeChar
>= L
'A') && (KeyData
.Key
.UnicodeChar
<= L
'Z'))
360 KeyData
.KeyState
.KeyShiftState
&= ~(EFI_LEFT_SHIFT_PRESSED
| EFI_RIGHT_SHIFT_PRESSED
);
363 GopPrivateAddQ (Private
, &Private
->QueueForNotify
, &KeyData
);
365 GopPrivateAddQ (Private
, &Private
->QueueForRead
, &KeyData
);
371 GopPrivateUpdateStatusLight (
372 IN GOP_PRIVATE_DATA
*Private
378 This function updates the status light of NumLock, ScrollLock and CapsLock.
382 Private - The private structure of WinNt console In/Out.
386 EFI_SUCCESS - The status light is updated successfully.
391 // BUGBUG:Only SendInput/keybd_event function can toggle
392 // NumLock, CapsLock and ScrollLock keys.
393 // Neither of these functions is included in EFI_WIN_NT_THUNK_PROTOCOL.
394 // Thus, return immediately without operation.
402 GopPrivateResetWorker (
403 IN GOP_PRIVATE_DATA
*Private
409 This function is a worker function for SimpleTextIn/SimpleTextInEx.Reset().
413 Private - WinNT GOP private structure
417 EFI_SUCCESS - Reset successfully
421 EFI_KEY_DATA KeyData
;
425 // Enter critical section
427 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
430 // A reset is draining the Queue
432 while (GopPrivateDeleteQ (Private
, &Private
->QueueForRead
, &KeyData
) == EFI_SUCCESS
)
434 while (GopPrivateDeleteQ (Private
, &Private
->QueueForNotify
, &KeyData
) == EFI_SUCCESS
)
437 Private
->LeftShift
= FALSE
;
438 Private
->RightShift
= FALSE
;
439 Private
->LeftAlt
= FALSE
;
440 Private
->RightAlt
= FALSE
;
441 Private
->LeftCtrl
= FALSE
;
442 Private
->RightCtrl
= FALSE
;
443 Private
->LeftLogo
= FALSE
;
444 Private
->RightLogo
= FALSE
;
445 Private
->Menu
= FALSE
;
446 Private
->SysReq
= FALSE
;
448 Private
->CapsLock
= FALSE
;
449 Private
->NumLock
= FALSE
;
450 Private
->ScrollLock
= FALSE
;
451 Private
->IsPartialKeySupport
= FALSE
;
453 Private
->KeyState
.KeyShiftState
= EFI_SHIFT_STATE_VALID
;
454 Private
->KeyState
.KeyToggleState
= EFI_TOGGLE_STATE_VALID
;
457 // Leave critical section and return
459 gBS
->RestoreTPL (OldTpl
);
465 GopPrivateReadKeyStrokeWorker (
466 IN GOP_PRIVATE_DATA
*Private
,
467 OUT EFI_KEY_DATA
*KeyData
472 Reads the next keystroke from the input device. The WaitForKey Event can
473 be used to test for existance of a keystroke via WaitForEvent () call.
476 Private - The private structure of WinNt Gop device.
477 KeyData - A pointer to a buffer that is filled in with the keystroke
478 state data for the key that was pressed.
481 EFI_SUCCESS - The keystroke information was returned.
482 EFI_NOT_READY - There was no keystroke data availiable.
483 EFI_DEVICE_ERROR - The keystroke information was not returned due to
485 EFI_INVALID_PARAMETER - KeyData is NULL.
492 if (KeyData
== NULL
) {
493 return EFI_INVALID_PARAMETER
;
497 // Enter critical section
499 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
502 // Call hot key callback before telling caller there is a key available
504 WinNtGopSimpleTextInTimerHandler (NULL
, Private
);
506 Status
= GopPrivateCheckQ (&Private
->QueueForRead
);
507 if (!EFI_ERROR (Status
)) {
509 // If a Key press exists try and read it.
511 Status
= GopPrivateDeleteQ (Private
, &Private
->QueueForRead
, KeyData
);
512 if (!EFI_ERROR (Status
)) {
514 // If partial keystroke is not enabled, check whether it is value key. If not return
517 if (!Private
->IsPartialKeySupport
) {
518 if (KeyData
->Key
.ScanCode
== SCAN_NULL
&& KeyData
->Key
.UnicodeChar
== CHAR_NULL
) {
519 Status
= EFI_NOT_READY
;
526 // Leave critical section and return
528 gBS
->RestoreTPL (OldTpl
);
536 // Simple Text In implementation.
541 TODO: Add function description
543 @param This TODO: add argument description
544 @param ExtendedVerification TODO: add argument description
546 @retval EFI_SUCCESS TODO: Add description for return value
551 WinNtGopSimpleTextInReset (
552 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
553 IN BOOLEAN ExtendedVerification
556 GOP_PRIVATE_DATA
*Private
;
558 Private
= GOP_PRIVATE_DATA_FROM_TEXT_IN_THIS (This
);
560 return GopPrivateResetWorker (Private
);
565 TODO: Add function description
567 @param This TODO: add argument description
568 @param Key TODO: add argument description
570 @return TODO: add return values
575 WinNtGopSimpleTextInReadKeyStroke (
576 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
577 OUT EFI_INPUT_KEY
*Key
580 GOP_PRIVATE_DATA
*Private
;
582 EFI_KEY_DATA KeyData
;
584 Private
= GOP_PRIVATE_DATA_FROM_TEXT_IN_THIS (This
);
586 // Considering if the partial keystroke is enabled, there maybe a partial
587 // keystroke in the queue, so here skip the partial keystroke and get the
588 // next key from the queue
591 Status
= GopPrivateReadKeyStrokeWorker (Private
, &KeyData
);
592 if (EFI_ERROR (Status
)) {
595 if (KeyData
.Key
.ScanCode
== SCAN_NULL
&& KeyData
.Key
.UnicodeChar
== CHAR_NULL
) {
599 // Convert Ctrl+[A-Z] to Ctrl+[1-26]
601 if ((KeyData
.KeyState
.KeyShiftState
& (EFI_LEFT_CONTROL_PRESSED
| EFI_RIGHT_CONTROL_PRESSED
)) != 0) {
602 if ((KeyData
.Key
.UnicodeChar
>= L
'a') && (KeyData
.Key
.UnicodeChar
<= L
'z')) {
603 KeyData
.Key
.UnicodeChar
= (CHAR16
) (KeyData
.Key
.UnicodeChar
- L
'a' + 1);
604 } else if ((KeyData
.Key
.UnicodeChar
>= L
'A') && (KeyData
.Key
.UnicodeChar
<= L
'Z')) {
605 KeyData
.Key
.UnicodeChar
= (CHAR16
) (KeyData
.Key
.UnicodeChar
- L
'A' + 1);
608 CopyMem (Key
, &KeyData
.Key
, sizeof (EFI_INPUT_KEY
));
615 TODO: Add function description
617 @param Event TODO: add argument description
618 @param Context TODO: add argument description
620 @return TODO: add return values
625 WinNtGopSimpleTextInWaitForKey (
630 GOP_PRIVATE_DATA
*Private
;
633 EFI_KEY_DATA KeyData
;
635 Private
= (GOP_PRIVATE_DATA
*) Context
;
638 // Enter critical section
640 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
643 // Call hot key callback before telling caller there is a key available
645 WinNtGopSimpleTextInTimerHandler (NULL
, Private
);
648 // WaitforKey doesn't suppor the partial key.
649 // Considering if the partial keystroke is enabled, there maybe a partial
650 // keystroke in the queue, so here skip the partial keystroke and get the
651 // next key from the queue
654 Status
= GopPrivateCheckQ (&Private
->QueueForRead
);
655 if (!EFI_ERROR (Status
)) {
657 // If a there is a key in the queue and it is not partial keystroke, signal event.
659 if (Private
->QueueForRead
.Q
[Private
->QueueForRead
.Front
].Key
.ScanCode
== SCAN_NULL
&&
660 Private
->QueueForRead
.Q
[Private
->QueueForRead
.Front
].Key
.UnicodeChar
== CHAR_NULL
) {
661 GopPrivateDeleteQ (Private
,&Private
->QueueForRead
,&KeyData
);
664 gBS
->SignalEvent (Event
);
667 // We need to sleep or NT will schedule this thread with such high
668 // priority that WinProc thread will never run and we will not see
669 // keyboard input. This Sleep makes the syste run 10x faster, so don't
672 Private
->WinNtThunk
->Sleep (1);
678 // Leave critical section and return
680 gBS
->RestoreTPL (OldTpl
);
684 // Simple Text Input Ex protocol functions
689 WinNtGopSimpleTextInExResetEx (
690 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
691 IN BOOLEAN ExtendedVerification
696 Reset the input device and optionaly run diagnostics
699 This - Protocol instance pointer.
700 ExtendedVerification - Driver may perform diagnostics on reset.
703 EFI_SUCCESS - The device was reset.
707 GOP_PRIVATE_DATA
*Private
;
709 Private
= GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS (This
);
711 return GopPrivateResetWorker (Private
);
716 WinNtGopSimpleTextInExReadKeyStrokeEx (
717 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
718 OUT EFI_KEY_DATA
*KeyData
723 Reads the next keystroke from the input device. The WaitForKey Event can
724 be used to test for existance of a keystroke via WaitForEvent () call.
727 This - Protocol instance pointer.
728 KeyData - A pointer to a buffer that is filled in with the keystroke
729 state data for the key that was pressed.
732 EFI_SUCCESS - The keystroke information was returned.
733 EFI_NOT_READY - There was no keystroke data availiable.
734 EFI_DEVICE_ERROR - The keystroke information was not returned due to
736 EFI_INVALID_PARAMETER - KeyData is NULL.
740 GOP_PRIVATE_DATA
*Private
;
742 if (KeyData
== NULL
) {
743 return EFI_INVALID_PARAMETER
;
746 Private
= GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS (This
);
748 return GopPrivateReadKeyStrokeWorker (Private
, KeyData
);
754 WinNtGopSimpleTextInExSetState (
755 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
756 IN EFI_KEY_TOGGLE_STATE
*KeyToggleState
761 Set certain state for the input device.
764 This - Protocol instance pointer.
765 KeyToggleState - A pointer to the EFI_KEY_TOGGLE_STATE to set the
766 state for the input device.
769 EFI_SUCCESS - The device state was set successfully.
770 EFI_DEVICE_ERROR - The device is not functioning correctly and could
771 not have the setting adjusted.
772 EFI_UNSUPPORTED - The device does not have the ability to set its state.
773 EFI_INVALID_PARAMETER - KeyToggleState is NULL.
778 GOP_PRIVATE_DATA
*Private
;
780 if (KeyToggleState
== NULL
) {
781 return EFI_INVALID_PARAMETER
;
784 Private
= GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS (This
);
786 if (((Private
->KeyState
.KeyToggleState
& EFI_TOGGLE_STATE_VALID
) != EFI_TOGGLE_STATE_VALID
) ||
787 ((*KeyToggleState
& EFI_TOGGLE_STATE_VALID
) != EFI_TOGGLE_STATE_VALID
)) {
788 return EFI_UNSUPPORTED
;
791 Private
->ScrollLock
= FALSE
;
792 Private
->NumLock
= FALSE
;
793 Private
->CapsLock
= FALSE
;
794 Private
->IsPartialKeySupport
= FALSE
;
796 if ((*KeyToggleState
& EFI_SCROLL_LOCK_ACTIVE
) == EFI_SCROLL_LOCK_ACTIVE
) {
797 Private
->ScrollLock
= TRUE
;
799 if ((*KeyToggleState
& EFI_NUM_LOCK_ACTIVE
) == EFI_NUM_LOCK_ACTIVE
) {
800 Private
->NumLock
= TRUE
;
802 if ((*KeyToggleState
& EFI_CAPS_LOCK_ACTIVE
) == EFI_CAPS_LOCK_ACTIVE
) {
803 Private
->CapsLock
= TRUE
;
805 if ((*KeyToggleState
& EFI_KEY_STATE_EXPOSED
) == EFI_KEY_STATE_EXPOSED
) {
806 Private
->IsPartialKeySupport
= TRUE
;
809 Status
= GopPrivateUpdateStatusLight (Private
);
810 if (EFI_ERROR (Status
)) {
811 return EFI_DEVICE_ERROR
;
814 Private
->KeyState
.KeyToggleState
= *KeyToggleState
;
821 WinNtGopSimpleTextInExRegisterKeyNotify (
822 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
823 IN EFI_KEY_DATA
*KeyData
,
824 IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction
,
825 OUT VOID
**NotifyHandle
830 Register a notification function for a particular keystroke for the input device.
833 This - Protocol instance pointer.
834 KeyData - A pointer to a buffer that is filled in with the keystroke
835 information data for the key that was pressed.
836 KeyNotificationFunction - Points to the function to be called when the key
837 sequence is typed specified by KeyData.
838 NotifyHandle - Points to the unique handle assigned to the registered notification.
841 EFI_SUCCESS - The notification function was registered successfully.
842 EFI_OUT_OF_RESOURCES - Unable to allocate resources for necesssary data structures.
843 EFI_INVALID_PARAMETER - KeyData or NotifyHandle is NULL.
847 GOP_PRIVATE_DATA
*Private
;
848 WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY
*CurrentNotify
;
850 WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY
*NewNotify
;
852 if (KeyData
== NULL
|| KeyNotificationFunction
== NULL
|| NotifyHandle
== NULL
) {
853 return EFI_INVALID_PARAMETER
;
856 Private
= GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS (This
);
859 // Return EFI_SUCCESS if the (KeyData, NotificationFunction) is already registered.
861 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
864 WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY
,
866 WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE
868 if (GopPrivateIsKeyRegistered (&CurrentNotify
->KeyData
, KeyData
)) {
869 if (CurrentNotify
->KeyNotificationFn
== KeyNotificationFunction
) {
870 *NotifyHandle
= CurrentNotify
;
877 // Allocate resource to save the notification function
879 NewNotify
= (WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY
*) AllocateZeroPool (sizeof (WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY
));
880 if (NewNotify
== NULL
) {
881 return EFI_OUT_OF_RESOURCES
;
884 NewNotify
->Signature
= WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE
;
885 NewNotify
->KeyNotificationFn
= KeyNotificationFunction
;
886 CopyMem (&NewNotify
->KeyData
, KeyData
, sizeof (EFI_KEY_DATA
));
887 InsertTailList (&Private
->NotifyList
, &NewNotify
->NotifyEntry
);
889 *NotifyHandle
= NewNotify
;
897 WinNtGopSimpleTextInExUnregisterKeyNotify (
898 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
899 IN VOID
*NotificationHandle
904 Remove a registered notification function from a particular keystroke.
907 This - Protocol instance pointer.
908 NotificationHandle - The handle of the notification function being unregistered.
911 EFI_SUCCESS - The notification function was unregistered successfully.
912 EFI_INVALID_PARAMETER - The NotificationHandle is invalid.
916 GOP_PRIVATE_DATA
*Private
;
918 WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY
*CurrentNotify
;
920 if (NotificationHandle
== NULL
) {
921 return EFI_INVALID_PARAMETER
;
924 Private
= GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS (This
);
926 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
929 WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY
,
931 WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE
933 if (CurrentNotify
== NotificationHandle
) {
935 // Remove the notification function from NotifyList and free resources
937 RemoveEntryList (&CurrentNotify
->NotifyEntry
);
939 gBS
->FreePool (CurrentNotify
);
945 // Can not find the specified Notification Handle
947 return EFI_INVALID_PARAMETER
;
952 TODO: Add function description
954 @param Private TODO: add argument description
956 @return TODO: add return values
960 WinNtGopInitializeSimpleTextInForWindow (
961 IN GOP_PRIVATE_DATA
*Private
966 GopPrivateCreateQ (Private
, &Private
->QueueForRead
);
967 GopPrivateCreateQ (Private
, &Private
->QueueForNotify
);
970 // Initialize Simple Text In protoocol
972 Private
->SimpleTextIn
.Reset
= WinNtGopSimpleTextInReset
;
973 Private
->SimpleTextIn
.ReadKeyStroke
= WinNtGopSimpleTextInReadKeyStroke
;
975 Status
= gBS
->CreateEvent (
978 WinNtGopSimpleTextInWaitForKey
,
980 &Private
->SimpleTextIn
.WaitForKey
984 Private
->SimpleTextInEx
.Reset
= WinNtGopSimpleTextInExResetEx
;
985 Private
->SimpleTextInEx
.ReadKeyStrokeEx
= WinNtGopSimpleTextInExReadKeyStrokeEx
;
986 Private
->SimpleTextInEx
.SetState
= WinNtGopSimpleTextInExSetState
;
987 Private
->SimpleTextInEx
.RegisterKeyNotify
= WinNtGopSimpleTextInExRegisterKeyNotify
;
988 Private
->SimpleTextInEx
.UnregisterKeyNotify
= WinNtGopSimpleTextInExUnregisterKeyNotify
;
990 Private
->SimpleTextInEx
.Reset (&Private
->SimpleTextInEx
, FALSE
);
992 InitializeListHead (&Private
->NotifyList
);
994 Status
= gBS
->CreateEvent (
997 WinNtGopSimpleTextInWaitForKey
,
999 &Private
->SimpleTextInEx
.WaitForKeyEx
1001 ASSERT_EFI_ERROR (Status
);
1004 // Create the Timer to trigger hot key notifications
1006 Status
= gBS
->CreateEvent (
1007 EVT_TIMER
| EVT_NOTIFY_SIGNAL
,
1009 WinNtGopSimpleTextInTimerHandler
,
1011 &Private
->TimerEvent
1013 ASSERT_EFI_ERROR (Status
);
1015 Status
= gBS
->SetTimer (
1016 Private
->TimerEvent
,
1018 KEYBOARD_TIMER_INTERVAL
1020 ASSERT_EFI_ERROR (Status
);
1028 TODO: Add function description
1030 @param Private TODO: add argument description
1032 @retval EFI_SUCCESS TODO: Add description for return value
1036 WinNtGopDestroySimpleTextInForWindow (
1037 IN GOP_PRIVATE_DATA
*Private
1040 gBS
->CloseEvent (Private
->TimerEvent
);
1042 GopPrivateDestroyQ (Private
, &Private
->QueueForRead
);
1043 GopPrivateDestroyQ (Private
, &Private
->QueueForNotify
);