3 Copyright (c) 2006 - 2018, 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 Initialize the key state.
275 @param Private The GOP_PRIVATE_DATA instance.
276 @param KeyState A pointer to receive the key state information.
280 IN GOP_PRIVATE_DATA
*Private
,
281 IN EFI_KEY_STATE
*KeyState
284 KeyState
->KeyShiftState
= EFI_SHIFT_STATE_VALID
;
285 KeyState
->KeyToggleState
= EFI_TOGGLE_STATE_VALID
;
288 // Record Key shift state and toggle state
290 if (Private
->LeftCtrl
) {
291 KeyState
->KeyShiftState
|= EFI_LEFT_CONTROL_PRESSED
;
293 if (Private
->RightCtrl
) {
294 KeyState
->KeyShiftState
|= EFI_RIGHT_CONTROL_PRESSED
;
296 if (Private
->LeftAlt
) {
297 KeyState
->KeyShiftState
|= EFI_LEFT_ALT_PRESSED
;
299 if (Private
->RightAlt
) {
300 KeyState
->KeyShiftState
|= EFI_RIGHT_ALT_PRESSED
;
302 if (Private
->LeftShift
) {
303 KeyState
->KeyShiftState
|= EFI_LEFT_SHIFT_PRESSED
;
305 if (Private
->RightShift
) {
306 KeyState
->KeyShiftState
|= EFI_RIGHT_SHIFT_PRESSED
;
308 if (Private
->LeftLogo
) {
309 KeyState
->KeyShiftState
|= EFI_LEFT_LOGO_PRESSED
;
311 if (Private
->RightLogo
) {
312 KeyState
->KeyShiftState
|= EFI_RIGHT_LOGO_PRESSED
;
315 KeyState
->KeyShiftState
|= EFI_MENU_KEY_PRESSED
;
317 if (Private
->SysReq
) {
318 KeyState
->KeyShiftState
|= EFI_SYS_REQ_PRESSED
;
320 if (Private
->CapsLock
) {
321 KeyState
->KeyToggleState
|= EFI_CAPS_LOCK_ACTIVE
;
323 if (Private
->NumLock
) {
324 KeyState
->KeyToggleState
|= EFI_NUM_LOCK_ACTIVE
;
326 if (Private
->ScrollLock
) {
327 KeyState
->KeyToggleState
|= EFI_SCROLL_LOCK_ACTIVE
;
329 if (Private
->IsPartialKeySupport
) {
330 KeyState
->KeyToggleState
|= EFI_KEY_STATE_EXPOSED
;
335 TODO: Add function description
337 @param Private TODO: add argument description
338 @param Key TODO: add argument description
340 @retval EFI_NOT_READY TODO: Add description for return value
341 @retval EFI_SUCCESS TODO: Add description for return value
346 IN GOP_PRIVATE_DATA
*Private
,
350 EFI_KEY_DATA KeyData
;
353 InitializeKeyState (Private
, &KeyData
.KeyState
);
356 // Convert Ctrl+[1-26] to Ctrl+[A-Z]
358 if ((Private
->LeftCtrl
|| Private
->RightCtrl
) &&
359 (KeyData
.Key
.UnicodeChar
>= 1) && (KeyData
.Key
.UnicodeChar
<= 26)
361 if ((Private
->LeftShift
|| Private
->RightShift
) == Private
->CapsLock
) {
362 KeyData
.Key
.UnicodeChar
= (CHAR16
)(KeyData
.Key
.UnicodeChar
+ L
'a' - 1);
364 KeyData
.Key
.UnicodeChar
= (CHAR16
)(KeyData
.Key
.UnicodeChar
+ L
'A' - 1);
369 // Unmask the Shift bit for printable char
371 if (((KeyData
.Key
.UnicodeChar
>= L
'a') && (KeyData
.Key
.UnicodeChar
<= L
'z')) ||
372 ((KeyData
.Key
.UnicodeChar
>= L
'A') && (KeyData
.Key
.UnicodeChar
<= L
'Z'))
374 KeyData
.KeyState
.KeyShiftState
&= ~(EFI_LEFT_SHIFT_PRESSED
| EFI_RIGHT_SHIFT_PRESSED
);
377 GopPrivateAddQ (Private
, &Private
->QueueForNotify
, &KeyData
);
379 GopPrivateAddQ (Private
, &Private
->QueueForRead
, &KeyData
);
385 GopPrivateUpdateStatusLight (
386 IN GOP_PRIVATE_DATA
*Private
392 This function updates the status light of NumLock, ScrollLock and CapsLock.
396 Private - The private structure of WinNt console In/Out.
400 EFI_SUCCESS - The status light is updated successfully.
405 // BUGBUG:Only SendInput/keybd_event function can toggle
406 // NumLock, CapsLock and ScrollLock keys.
407 // Neither of these functions is included in EFI_WIN_NT_THUNK_PROTOCOL.
408 // Thus, return immediately without operation.
416 GopPrivateResetWorker (
417 IN GOP_PRIVATE_DATA
*Private
423 This function is a worker function for SimpleTextIn/SimpleTextInEx.Reset().
427 Private - WinNT GOP private structure
431 EFI_SUCCESS - Reset successfully
435 EFI_KEY_DATA KeyData
;
439 // Enter critical section
441 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
444 // A reset is draining the Queue
446 while (GopPrivateDeleteQ (Private
, &Private
->QueueForRead
, &KeyData
) == EFI_SUCCESS
)
448 while (GopPrivateDeleteQ (Private
, &Private
->QueueForNotify
, &KeyData
) == EFI_SUCCESS
)
451 Private
->LeftShift
= FALSE
;
452 Private
->RightShift
= FALSE
;
453 Private
->LeftAlt
= FALSE
;
454 Private
->RightAlt
= FALSE
;
455 Private
->LeftCtrl
= FALSE
;
456 Private
->RightCtrl
= FALSE
;
457 Private
->LeftLogo
= FALSE
;
458 Private
->RightLogo
= FALSE
;
459 Private
->Menu
= FALSE
;
460 Private
->SysReq
= FALSE
;
462 Private
->CapsLock
= FALSE
;
463 Private
->NumLock
= FALSE
;
464 Private
->ScrollLock
= FALSE
;
465 Private
->IsPartialKeySupport
= FALSE
;
467 Private
->KeyState
.KeyShiftState
= EFI_SHIFT_STATE_VALID
;
468 Private
->KeyState
.KeyToggleState
= EFI_TOGGLE_STATE_VALID
;
471 // Leave critical section and return
473 gBS
->RestoreTPL (OldTpl
);
479 GopPrivateReadKeyStrokeWorker (
480 IN GOP_PRIVATE_DATA
*Private
,
481 OUT EFI_KEY_DATA
*KeyData
486 Reads the next keystroke from the input device. The WaitForKey Event can
487 be used to test for existance of a keystroke via WaitForEvent () call.
490 Private - The private structure of WinNt Gop device.
491 KeyData - A pointer to a buffer that is filled in with the keystroke
492 state data for the key that was pressed.
495 EFI_SUCCESS - The keystroke information was returned.
496 EFI_NOT_READY - There was no keystroke data availiable.
497 EFI_DEVICE_ERROR - The keystroke information was not returned due to
499 EFI_INVALID_PARAMETER - KeyData is NULL.
506 if (KeyData
== NULL
) {
507 return EFI_INVALID_PARAMETER
;
511 // Enter critical section
513 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
516 // Call hot key callback before telling caller there is a key available
518 WinNtGopSimpleTextInTimerHandler (NULL
, Private
);
520 ZeroMem (&KeyData
->Key
, sizeof (KeyData
->Key
));
521 InitializeKeyState (Private
, &KeyData
->KeyState
);
523 Status
= GopPrivateCheckQ (&Private
->QueueForRead
);
524 if (!EFI_ERROR (Status
)) {
526 // If a Key press exists try and read it.
528 Status
= GopPrivateDeleteQ (Private
, &Private
->QueueForRead
, KeyData
);
529 if (!EFI_ERROR (Status
)) {
531 // If partial keystroke is not enabled, check whether it is value key. If not return
534 if (!Private
->IsPartialKeySupport
) {
535 if (KeyData
->Key
.ScanCode
== SCAN_NULL
&& KeyData
->Key
.UnicodeChar
== CHAR_NULL
) {
536 Status
= EFI_NOT_READY
;
543 // Leave critical section and return
545 gBS
->RestoreTPL (OldTpl
);
553 // Simple Text In implementation.
558 TODO: Add function description
560 @param This TODO: add argument description
561 @param ExtendedVerification TODO: add argument description
563 @retval EFI_SUCCESS TODO: Add description for return value
568 WinNtGopSimpleTextInReset (
569 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
570 IN BOOLEAN ExtendedVerification
573 GOP_PRIVATE_DATA
*Private
;
575 Private
= GOP_PRIVATE_DATA_FROM_TEXT_IN_THIS (This
);
577 return GopPrivateResetWorker (Private
);
582 TODO: Add function description
584 @param This TODO: add argument description
585 @param Key TODO: add argument description
587 @return TODO: add return values
592 WinNtGopSimpleTextInReadKeyStroke (
593 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
594 OUT EFI_INPUT_KEY
*Key
597 GOP_PRIVATE_DATA
*Private
;
599 EFI_KEY_DATA KeyData
;
601 Private
= GOP_PRIVATE_DATA_FROM_TEXT_IN_THIS (This
);
603 // Considering if the partial keystroke is enabled, there maybe a partial
604 // keystroke in the queue, so here skip the partial keystroke and get the
605 // next key from the queue
608 Status
= GopPrivateReadKeyStrokeWorker (Private
, &KeyData
);
609 if (EFI_ERROR (Status
)) {
612 if (KeyData
.Key
.ScanCode
== SCAN_NULL
&& KeyData
.Key
.UnicodeChar
== CHAR_NULL
) {
616 // Convert Ctrl+[A-Z] to Ctrl+[1-26]
618 if ((KeyData
.KeyState
.KeyShiftState
& (EFI_LEFT_CONTROL_PRESSED
| EFI_RIGHT_CONTROL_PRESSED
)) != 0) {
619 if ((KeyData
.Key
.UnicodeChar
>= L
'a') && (KeyData
.Key
.UnicodeChar
<= L
'z')) {
620 KeyData
.Key
.UnicodeChar
= (CHAR16
) (KeyData
.Key
.UnicodeChar
- L
'a' + 1);
621 } else if ((KeyData
.Key
.UnicodeChar
>= L
'A') && (KeyData
.Key
.UnicodeChar
<= L
'Z')) {
622 KeyData
.Key
.UnicodeChar
= (CHAR16
) (KeyData
.Key
.UnicodeChar
- L
'A' + 1);
625 CopyMem (Key
, &KeyData
.Key
, sizeof (EFI_INPUT_KEY
));
632 TODO: Add function description
634 @param Event TODO: add argument description
635 @param Context TODO: add argument description
637 @return TODO: add return values
642 WinNtGopSimpleTextInWaitForKey (
647 GOP_PRIVATE_DATA
*Private
;
650 EFI_KEY_DATA KeyData
;
652 Private
= (GOP_PRIVATE_DATA
*) Context
;
655 // Enter critical section
657 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
660 // Call hot key callback before telling caller there is a key available
662 WinNtGopSimpleTextInTimerHandler (NULL
, Private
);
665 // WaitforKey doesn't suppor the partial key.
666 // Considering if the partial keystroke is enabled, there maybe a partial
667 // keystroke in the queue, so here skip the partial keystroke and get the
668 // next key from the queue
671 Status
= GopPrivateCheckQ (&Private
->QueueForRead
);
672 if (!EFI_ERROR (Status
)) {
674 // If a there is a key in the queue and it is not partial keystroke, signal event.
676 if (Private
->QueueForRead
.Q
[Private
->QueueForRead
.Front
].Key
.ScanCode
== SCAN_NULL
&&
677 Private
->QueueForRead
.Q
[Private
->QueueForRead
.Front
].Key
.UnicodeChar
== CHAR_NULL
) {
678 GopPrivateDeleteQ (Private
,&Private
->QueueForRead
,&KeyData
);
681 gBS
->SignalEvent (Event
);
684 // We need to sleep or NT will schedule this thread with such high
685 // priority that WinProc thread will never run and we will not see
686 // keyboard input. This Sleep makes the syste run 10x faster, so don't
689 Private
->WinNtThunk
->Sleep (1);
695 // Leave critical section and return
697 gBS
->RestoreTPL (OldTpl
);
701 // Simple Text Input Ex protocol functions
706 WinNtGopSimpleTextInExResetEx (
707 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
708 IN BOOLEAN ExtendedVerification
713 Reset the input device and optionaly run diagnostics
716 This - Protocol instance pointer.
717 ExtendedVerification - Driver may perform diagnostics on reset.
720 EFI_SUCCESS - The device was reset.
724 GOP_PRIVATE_DATA
*Private
;
726 Private
= GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS (This
);
728 return GopPrivateResetWorker (Private
);
733 WinNtGopSimpleTextInExReadKeyStrokeEx (
734 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
735 OUT EFI_KEY_DATA
*KeyData
740 Reads the next keystroke from the input device. The WaitForKey Event can
741 be used to test for existance of a keystroke via WaitForEvent () call.
744 This - Protocol instance pointer.
745 KeyData - A pointer to a buffer that is filled in with the keystroke
746 state data for the key that was pressed.
749 EFI_SUCCESS - The keystroke information was returned.
750 EFI_NOT_READY - There was no keystroke data availiable.
751 EFI_DEVICE_ERROR - The keystroke information was not returned due to
753 EFI_INVALID_PARAMETER - KeyData is NULL.
757 GOP_PRIVATE_DATA
*Private
;
759 if (KeyData
== NULL
) {
760 return EFI_INVALID_PARAMETER
;
763 Private
= GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS (This
);
765 return GopPrivateReadKeyStrokeWorker (Private
, KeyData
);
771 WinNtGopSimpleTextInExSetState (
772 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
773 IN EFI_KEY_TOGGLE_STATE
*KeyToggleState
778 Set certain state for the input device.
781 This - Protocol instance pointer.
782 KeyToggleState - A pointer to the EFI_KEY_TOGGLE_STATE to set the
783 state for the input device.
786 EFI_SUCCESS - The device state was set successfully.
787 EFI_DEVICE_ERROR - The device is not functioning correctly and could
788 not have the setting adjusted.
789 EFI_UNSUPPORTED - The device does not have the ability to set its state.
790 EFI_INVALID_PARAMETER - KeyToggleState is NULL.
795 GOP_PRIVATE_DATA
*Private
;
797 if (KeyToggleState
== NULL
) {
798 return EFI_INVALID_PARAMETER
;
801 Private
= GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS (This
);
803 if (((Private
->KeyState
.KeyToggleState
& EFI_TOGGLE_STATE_VALID
) != EFI_TOGGLE_STATE_VALID
) ||
804 ((*KeyToggleState
& EFI_TOGGLE_STATE_VALID
) != EFI_TOGGLE_STATE_VALID
)) {
805 return EFI_UNSUPPORTED
;
808 Private
->ScrollLock
= FALSE
;
809 Private
->NumLock
= FALSE
;
810 Private
->CapsLock
= FALSE
;
811 Private
->IsPartialKeySupport
= FALSE
;
813 if ((*KeyToggleState
& EFI_SCROLL_LOCK_ACTIVE
) == EFI_SCROLL_LOCK_ACTIVE
) {
814 Private
->ScrollLock
= TRUE
;
816 if ((*KeyToggleState
& EFI_NUM_LOCK_ACTIVE
) == EFI_NUM_LOCK_ACTIVE
) {
817 Private
->NumLock
= TRUE
;
819 if ((*KeyToggleState
& EFI_CAPS_LOCK_ACTIVE
) == EFI_CAPS_LOCK_ACTIVE
) {
820 Private
->CapsLock
= TRUE
;
822 if ((*KeyToggleState
& EFI_KEY_STATE_EXPOSED
) == EFI_KEY_STATE_EXPOSED
) {
823 Private
->IsPartialKeySupport
= TRUE
;
826 Status
= GopPrivateUpdateStatusLight (Private
);
827 if (EFI_ERROR (Status
)) {
828 return EFI_DEVICE_ERROR
;
831 Private
->KeyState
.KeyToggleState
= *KeyToggleState
;
838 WinNtGopSimpleTextInExRegisterKeyNotify (
839 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
840 IN EFI_KEY_DATA
*KeyData
,
841 IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction
,
842 OUT VOID
**NotifyHandle
847 Register a notification function for a particular keystroke for the input device.
850 This - Protocol instance pointer.
851 KeyData - A pointer to a buffer that is filled in with the keystroke
852 information data for the key that was pressed.
853 KeyNotificationFunction - Points to the function to be called when the key
854 sequence is typed specified by KeyData.
855 NotifyHandle - Points to the unique handle assigned to the registered notification.
858 EFI_SUCCESS - The notification function was registered successfully.
859 EFI_OUT_OF_RESOURCES - Unable to allocate resources for necesssary data structures.
860 EFI_INVALID_PARAMETER - KeyData or NotifyHandle is NULL.
864 GOP_PRIVATE_DATA
*Private
;
865 WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY
*CurrentNotify
;
867 WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY
*NewNotify
;
869 if (KeyData
== NULL
|| KeyNotificationFunction
== NULL
|| NotifyHandle
== NULL
) {
870 return EFI_INVALID_PARAMETER
;
873 Private
= GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS (This
);
876 // Return EFI_SUCCESS if the (KeyData, NotificationFunction) is already registered.
878 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
881 WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY
,
883 WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE
885 if (GopPrivateIsKeyRegistered (&CurrentNotify
->KeyData
, KeyData
)) {
886 if (CurrentNotify
->KeyNotificationFn
== KeyNotificationFunction
) {
887 *NotifyHandle
= CurrentNotify
;
894 // Allocate resource to save the notification function
896 NewNotify
= (WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY
*) AllocateZeroPool (sizeof (WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY
));
897 if (NewNotify
== NULL
) {
898 return EFI_OUT_OF_RESOURCES
;
901 NewNotify
->Signature
= WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE
;
902 NewNotify
->KeyNotificationFn
= KeyNotificationFunction
;
903 CopyMem (&NewNotify
->KeyData
, KeyData
, sizeof (EFI_KEY_DATA
));
904 InsertTailList (&Private
->NotifyList
, &NewNotify
->NotifyEntry
);
906 *NotifyHandle
= NewNotify
;
914 WinNtGopSimpleTextInExUnregisterKeyNotify (
915 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
916 IN VOID
*NotificationHandle
921 Remove a registered notification function from a particular keystroke.
924 This - Protocol instance pointer.
925 NotificationHandle - The handle of the notification function being unregistered.
928 EFI_SUCCESS - The notification function was unregistered successfully.
929 EFI_INVALID_PARAMETER - The NotificationHandle is invalid.
933 GOP_PRIVATE_DATA
*Private
;
935 WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY
*CurrentNotify
;
937 if (NotificationHandle
== NULL
) {
938 return EFI_INVALID_PARAMETER
;
941 Private
= GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS (This
);
943 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
946 WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY
,
948 WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE
950 if (CurrentNotify
== NotificationHandle
) {
952 // Remove the notification function from NotifyList and free resources
954 RemoveEntryList (&CurrentNotify
->NotifyEntry
);
956 gBS
->FreePool (CurrentNotify
);
962 // Can not find the specified Notification Handle
964 return EFI_INVALID_PARAMETER
;
969 TODO: Add function description
971 @param Private TODO: add argument description
973 @return TODO: add return values
977 WinNtGopInitializeSimpleTextInForWindow (
978 IN GOP_PRIVATE_DATA
*Private
983 GopPrivateCreateQ (Private
, &Private
->QueueForRead
);
984 GopPrivateCreateQ (Private
, &Private
->QueueForNotify
);
987 // Initialize Simple Text In protoocol
989 Private
->SimpleTextIn
.Reset
= WinNtGopSimpleTextInReset
;
990 Private
->SimpleTextIn
.ReadKeyStroke
= WinNtGopSimpleTextInReadKeyStroke
;
992 Status
= gBS
->CreateEvent (
995 WinNtGopSimpleTextInWaitForKey
,
997 &Private
->SimpleTextIn
.WaitForKey
1001 Private
->SimpleTextInEx
.Reset
= WinNtGopSimpleTextInExResetEx
;
1002 Private
->SimpleTextInEx
.ReadKeyStrokeEx
= WinNtGopSimpleTextInExReadKeyStrokeEx
;
1003 Private
->SimpleTextInEx
.SetState
= WinNtGopSimpleTextInExSetState
;
1004 Private
->SimpleTextInEx
.RegisterKeyNotify
= WinNtGopSimpleTextInExRegisterKeyNotify
;
1005 Private
->SimpleTextInEx
.UnregisterKeyNotify
= WinNtGopSimpleTextInExUnregisterKeyNotify
;
1007 Private
->SimpleTextInEx
.Reset (&Private
->SimpleTextInEx
, FALSE
);
1009 InitializeListHead (&Private
->NotifyList
);
1011 Status
= gBS
->CreateEvent (
1014 WinNtGopSimpleTextInWaitForKey
,
1016 &Private
->SimpleTextInEx
.WaitForKeyEx
1018 ASSERT_EFI_ERROR (Status
);
1021 // Create the Timer to trigger hot key notifications
1023 Status
= gBS
->CreateEvent (
1024 EVT_TIMER
| EVT_NOTIFY_SIGNAL
,
1026 WinNtGopSimpleTextInTimerHandler
,
1028 &Private
->TimerEvent
1030 ASSERT_EFI_ERROR (Status
);
1032 Status
= gBS
->SetTimer (
1033 Private
->TimerEvent
,
1035 KEYBOARD_TIMER_INTERVAL
1037 ASSERT_EFI_ERROR (Status
);
1045 TODO: Add function description
1047 @param Private TODO: add argument description
1049 @retval EFI_SUCCESS TODO: Add description for return value
1053 WinNtGopDestroySimpleTextInForWindow (
1054 IN GOP_PRIVATE_DATA
*Private
1057 gBS
->CloseEvent (Private
->TimerEvent
);
1059 GopPrivateDestroyQ (Private
, &Private
->QueueForRead
);
1060 GopPrivateDestroyQ (Private
, &Private
->QueueForNotify
);