3 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
4 SPDX-License-Identifier: BSD-2-Clause-Patent
12 This file produces the Simple Text In for an Gop window.
14 This stuff is linked at the hip to the Window, since the window
15 processing is done in a thread kicked off in WinNtGopImplementation.c
17 Since the window information is processed in an other thread we need
18 a keyboard Queue to pass data about. The Simple Text In code just
19 takes data off the Queue. The WinProc message loop takes keyboard input
20 and places it in the Queue.
30 TODO: Add function description
32 @param Private TODO: add argument description
34 @retval EFI_SUCCESS TODO: Add description for return value
39 IN GOP_PRIVATE_DATA
*Private
,
40 IN GOP_QUEUE_FIXED
*Queue
43 Private
->WinNtThunk
->InitializeCriticalSection (&Queue
->Cs
);
51 TODO: Add function description
53 @param Private TODO: add argument description
55 @retval EFI_SUCCESS TODO: Add description for return value
60 IN GOP_PRIVATE_DATA
*Private
,
61 IN GOP_QUEUE_FIXED
*Queue
66 Private
->WinNtThunk
->DeleteCriticalSection (&Queue
->Cs
);
72 TODO: Add function description
74 @param Private TODO: add argument description
75 @param Key TODO: add argument description
77 @retval EFI_NOT_READY TODO: Add description for return value
78 @retval EFI_SUCCESS TODO: Add description for return value
83 IN GOP_PRIVATE_DATA
*Private
,
84 IN GOP_QUEUE_FIXED
*Queue
,
85 IN EFI_KEY_DATA
*KeyData
88 Private
->WinNtThunk
->EnterCriticalSection (&Queue
->Cs
);
90 if ((Queue
->Rear
+ 1) % MAX_Q
== Queue
->Front
) {
91 Private
->WinNtThunk
->LeaveCriticalSection (&Queue
->Cs
);
95 CopyMem (&Queue
->Q
[Queue
->Rear
], KeyData
, sizeof (EFI_KEY_DATA
));
96 Queue
->Rear
= (Queue
->Rear
+ 1) % MAX_Q
;
98 Private
->WinNtThunk
->LeaveCriticalSection (&Queue
->Cs
);
104 TODO: Add function description
106 @param Private TODO: add argument description
107 @param Key TODO: add argument description
109 @retval EFI_NOT_READY TODO: Add description for return value
110 @retval EFI_SUCCESS TODO: Add description for return value
115 IN GOP_PRIVATE_DATA
*Private
,
116 IN GOP_QUEUE_FIXED
*Queue
,
117 OUT EFI_KEY_DATA
*Key
120 Private
->WinNtThunk
->EnterCriticalSection (&Queue
->Cs
);
122 if (Queue
->Front
== Queue
->Rear
) {
123 Private
->WinNtThunk
->LeaveCriticalSection (&Queue
->Cs
);
124 return EFI_NOT_READY
;
127 CopyMem (Key
, &Queue
->Q
[Queue
->Front
], sizeof (EFI_KEY_DATA
));
128 Queue
->Front
= (Queue
->Front
+ 1) % MAX_Q
;
130 if (Key
->Key
.ScanCode
== SCAN_NULL
&& Key
->Key
.UnicodeChar
== CHAR_NULL
) {
131 if (!Private
->IsPartialKeySupport
) {
133 // If partial keystrok is not enabled, don't return the partial keystroke.
135 Private
->WinNtThunk
->LeaveCriticalSection (&Queue
->Cs
);
136 ZeroMem (Key
, sizeof (EFI_KEY_DATA
));
137 return EFI_NOT_READY
;
140 Private
->WinNtThunk
->LeaveCriticalSection (&Queue
->Cs
);
146 TODO: Add function description
148 @param Private TODO: add argument description
150 @retval EFI_NOT_READY TODO: Add description for return value
151 @retval EFI_SUCCESS TODO: Add description for return value
156 IN GOP_QUEUE_FIXED
*Queue
159 if (Queue
->Front
== Queue
->Rear
) {
160 return EFI_NOT_READY
;
167 GopPrivateIsKeyRegistered (
168 IN EFI_KEY_DATA
*RegsiteredData
,
169 IN EFI_KEY_DATA
*InputData
177 RegsiteredData - A pointer to a buffer that is filled in with the keystroke
178 state data for the key that was registered.
179 InputData - A pointer to a buffer that is filled in with the keystroke
180 state data for the key that was pressed.
183 TRUE - Key be pressed matches a registered key.
184 FLASE - Match failed.
188 ASSERT (RegsiteredData
!= NULL
&& InputData
!= NULL
);
190 if ((RegsiteredData
->Key
.ScanCode
!= InputData
->Key
.ScanCode
) ||
191 (RegsiteredData
->Key
.UnicodeChar
!= InputData
->Key
.UnicodeChar
)) {
196 // Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored.
198 if (RegsiteredData
->KeyState
.KeyShiftState
!= 0 &&
199 RegsiteredData
->KeyState
.KeyShiftState
!= InputData
->KeyState
.KeyShiftState
) {
202 if (RegsiteredData
->KeyState
.KeyToggleState
!= 0 &&
203 RegsiteredData
->KeyState
.KeyToggleState
!= InputData
->KeyState
.KeyToggleState
) {
213 GopPrivateInvokeRegisteredFunction (
214 IN GOP_PRIVATE_DATA
*Private
,
215 IN EFI_KEY_DATA
*KeyData
221 This function updates the status light of NumLock, ScrollLock and CapsLock.
225 Private - The private structure of WinNt Gop device.
226 KeyData - A pointer to a buffer that is filled in with the keystroke
227 state data for the key that was pressed.
231 EFI_SUCCESS - The status light is updated successfully.
236 WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY
*CurrentNotify
;
238 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
241 WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY
,
243 WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE
245 if (GopPrivateIsKeyRegistered (&CurrentNotify
->KeyData
, KeyData
)) {
246 CurrentNotify
->KeyNotificationFn (KeyData
);
252 WinNtGopSimpleTextInTimerHandler (
257 GOP_PRIVATE_DATA
*Private
;
258 EFI_KEY_DATA KeyData
;
260 Private
= (GOP_PRIVATE_DATA
*)Context
;
261 while (GopPrivateDeleteQ (Private
, &Private
->QueueForNotify
, &KeyData
) == EFI_SUCCESS
) {
262 GopPrivateInvokeRegisteredFunction (Private
, &KeyData
);
267 Initialize the key state.
269 @param Private The GOP_PRIVATE_DATA instance.
270 @param KeyState A pointer to receive the key state information.
274 IN GOP_PRIVATE_DATA
*Private
,
275 IN EFI_KEY_STATE
*KeyState
278 KeyState
->KeyShiftState
= EFI_SHIFT_STATE_VALID
;
279 KeyState
->KeyToggleState
= EFI_TOGGLE_STATE_VALID
;
282 // Record Key shift state and toggle state
284 if (Private
->LeftCtrl
) {
285 KeyState
->KeyShiftState
|= EFI_LEFT_CONTROL_PRESSED
;
287 if (Private
->RightCtrl
) {
288 KeyState
->KeyShiftState
|= EFI_RIGHT_CONTROL_PRESSED
;
290 if (Private
->LeftAlt
) {
291 KeyState
->KeyShiftState
|= EFI_LEFT_ALT_PRESSED
;
293 if (Private
->RightAlt
) {
294 KeyState
->KeyShiftState
|= EFI_RIGHT_ALT_PRESSED
;
296 if (Private
->LeftShift
) {
297 KeyState
->KeyShiftState
|= EFI_LEFT_SHIFT_PRESSED
;
299 if (Private
->RightShift
) {
300 KeyState
->KeyShiftState
|= EFI_RIGHT_SHIFT_PRESSED
;
302 if (Private
->LeftLogo
) {
303 KeyState
->KeyShiftState
|= EFI_LEFT_LOGO_PRESSED
;
305 if (Private
->RightLogo
) {
306 KeyState
->KeyShiftState
|= EFI_RIGHT_LOGO_PRESSED
;
309 KeyState
->KeyShiftState
|= EFI_MENU_KEY_PRESSED
;
311 if (Private
->SysReq
) {
312 KeyState
->KeyShiftState
|= EFI_SYS_REQ_PRESSED
;
314 if (Private
->CapsLock
) {
315 KeyState
->KeyToggleState
|= EFI_CAPS_LOCK_ACTIVE
;
317 if (Private
->NumLock
) {
318 KeyState
->KeyToggleState
|= EFI_NUM_LOCK_ACTIVE
;
320 if (Private
->ScrollLock
) {
321 KeyState
->KeyToggleState
|= EFI_SCROLL_LOCK_ACTIVE
;
323 if (Private
->IsPartialKeySupport
) {
324 KeyState
->KeyToggleState
|= EFI_KEY_STATE_EXPOSED
;
329 TODO: Add function description
331 @param Private TODO: add argument description
332 @param Key TODO: add argument description
334 @retval EFI_NOT_READY TODO: Add description for return value
335 @retval EFI_SUCCESS TODO: Add description for return value
340 IN GOP_PRIVATE_DATA
*Private
,
344 EFI_KEY_DATA KeyData
;
347 InitializeKeyState (Private
, &KeyData
.KeyState
);
350 // Convert Ctrl+[1-26] to Ctrl+[A-Z]
352 if ((Private
->LeftCtrl
|| Private
->RightCtrl
) &&
353 (KeyData
.Key
.UnicodeChar
>= 1) && (KeyData
.Key
.UnicodeChar
<= 26)
355 if ((Private
->LeftShift
|| Private
->RightShift
) == Private
->CapsLock
) {
356 KeyData
.Key
.UnicodeChar
= (CHAR16
)(KeyData
.Key
.UnicodeChar
+ L
'a' - 1);
358 KeyData
.Key
.UnicodeChar
= (CHAR16
)(KeyData
.Key
.UnicodeChar
+ L
'A' - 1);
363 // Unmask the Shift bit for printable char
365 if (((KeyData
.Key
.UnicodeChar
>= L
'a') && (KeyData
.Key
.UnicodeChar
<= L
'z')) ||
366 ((KeyData
.Key
.UnicodeChar
>= L
'A') && (KeyData
.Key
.UnicodeChar
<= L
'Z'))
368 KeyData
.KeyState
.KeyShiftState
&= ~(EFI_LEFT_SHIFT_PRESSED
| EFI_RIGHT_SHIFT_PRESSED
);
371 GopPrivateAddQ (Private
, &Private
->QueueForNotify
, &KeyData
);
373 GopPrivateAddQ (Private
, &Private
->QueueForRead
, &KeyData
);
379 GopPrivateUpdateStatusLight (
380 IN GOP_PRIVATE_DATA
*Private
386 This function updates the status light of NumLock, ScrollLock and CapsLock.
390 Private - The private structure of WinNt console In/Out.
394 EFI_SUCCESS - The status light is updated successfully.
399 // BUGBUG:Only SendInput/keybd_event function can toggle
400 // NumLock, CapsLock and ScrollLock keys.
401 // Neither of these functions is included in EFI_WIN_NT_THUNK_PROTOCOL.
402 // Thus, return immediately without operation.
410 GopPrivateResetWorker (
411 IN GOP_PRIVATE_DATA
*Private
417 This function is a worker function for SimpleTextIn/SimpleTextInEx.Reset().
421 Private - WinNT GOP private structure
425 EFI_SUCCESS - Reset successfully
429 EFI_KEY_DATA KeyData
;
433 // Enter critical section
435 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
438 // A reset is draining the Queue
440 while (GopPrivateDeleteQ (Private
, &Private
->QueueForRead
, &KeyData
) == EFI_SUCCESS
)
442 while (GopPrivateDeleteQ (Private
, &Private
->QueueForNotify
, &KeyData
) == EFI_SUCCESS
)
445 Private
->LeftShift
= FALSE
;
446 Private
->RightShift
= FALSE
;
447 Private
->LeftAlt
= FALSE
;
448 Private
->RightAlt
= FALSE
;
449 Private
->LeftCtrl
= FALSE
;
450 Private
->RightCtrl
= FALSE
;
451 Private
->LeftLogo
= FALSE
;
452 Private
->RightLogo
= FALSE
;
453 Private
->Menu
= FALSE
;
454 Private
->SysReq
= FALSE
;
456 Private
->CapsLock
= FALSE
;
457 Private
->NumLock
= FALSE
;
458 Private
->ScrollLock
= FALSE
;
459 Private
->IsPartialKeySupport
= FALSE
;
461 Private
->KeyState
.KeyShiftState
= EFI_SHIFT_STATE_VALID
;
462 Private
->KeyState
.KeyToggleState
= EFI_TOGGLE_STATE_VALID
;
465 // Leave critical section and return
467 gBS
->RestoreTPL (OldTpl
);
473 GopPrivateReadKeyStrokeWorker (
474 IN GOP_PRIVATE_DATA
*Private
,
475 OUT EFI_KEY_DATA
*KeyData
480 Reads the next keystroke from the input device. The WaitForKey Event can
481 be used to test for existance of a keystroke via WaitForEvent () call.
484 Private - The private structure of WinNt Gop device.
485 KeyData - A pointer to a buffer that is filled in with the keystroke
486 state data for the key that was pressed.
489 EFI_SUCCESS - The keystroke information was returned.
490 EFI_NOT_READY - There was no keystroke data availiable.
491 EFI_DEVICE_ERROR - The keystroke information was not returned due to
493 EFI_INVALID_PARAMETER - KeyData is NULL.
500 if (KeyData
== NULL
) {
501 return EFI_INVALID_PARAMETER
;
505 // Enter critical section
507 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
510 // Call hot key callback before telling caller there is a key available
512 WinNtGopSimpleTextInTimerHandler (NULL
, Private
);
514 ZeroMem (&KeyData
->Key
, sizeof (KeyData
->Key
));
515 InitializeKeyState (Private
, &KeyData
->KeyState
);
517 Status
= GopPrivateCheckQ (&Private
->QueueForRead
);
518 if (!EFI_ERROR (Status
)) {
520 // If a Key press exists try and read it.
522 Status
= GopPrivateDeleteQ (Private
, &Private
->QueueForRead
, KeyData
);
523 if (!EFI_ERROR (Status
)) {
525 // If partial keystroke is not enabled, check whether it is value key. If not return
528 if (!Private
->IsPartialKeySupport
) {
529 if (KeyData
->Key
.ScanCode
== SCAN_NULL
&& KeyData
->Key
.UnicodeChar
== CHAR_NULL
) {
530 Status
= EFI_NOT_READY
;
537 // Leave critical section and return
539 gBS
->RestoreTPL (OldTpl
);
547 // Simple Text In implementation.
552 TODO: Add function description
554 @param This TODO: add argument description
555 @param ExtendedVerification TODO: add argument description
557 @retval EFI_SUCCESS TODO: Add description for return value
562 WinNtGopSimpleTextInReset (
563 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
564 IN BOOLEAN ExtendedVerification
567 GOP_PRIVATE_DATA
*Private
;
569 Private
= GOP_PRIVATE_DATA_FROM_TEXT_IN_THIS (This
);
571 return GopPrivateResetWorker (Private
);
576 TODO: Add function description
578 @param This TODO: add argument description
579 @param Key TODO: add argument description
581 @return TODO: add return values
586 WinNtGopSimpleTextInReadKeyStroke (
587 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
588 OUT EFI_INPUT_KEY
*Key
591 GOP_PRIVATE_DATA
*Private
;
593 EFI_KEY_DATA KeyData
;
595 Private
= GOP_PRIVATE_DATA_FROM_TEXT_IN_THIS (This
);
597 // Considering if the partial keystroke is enabled, there maybe a partial
598 // keystroke in the queue, so here skip the partial keystroke and get the
599 // next key from the queue
602 Status
= GopPrivateReadKeyStrokeWorker (Private
, &KeyData
);
603 if (EFI_ERROR (Status
)) {
606 if (KeyData
.Key
.ScanCode
== SCAN_NULL
&& KeyData
.Key
.UnicodeChar
== CHAR_NULL
) {
610 // Convert Ctrl+[A-Z] to Ctrl+[1-26]
612 if ((KeyData
.KeyState
.KeyShiftState
& (EFI_LEFT_CONTROL_PRESSED
| EFI_RIGHT_CONTROL_PRESSED
)) != 0) {
613 if ((KeyData
.Key
.UnicodeChar
>= L
'a') && (KeyData
.Key
.UnicodeChar
<= L
'z')) {
614 KeyData
.Key
.UnicodeChar
= (CHAR16
) (KeyData
.Key
.UnicodeChar
- L
'a' + 1);
615 } else if ((KeyData
.Key
.UnicodeChar
>= L
'A') && (KeyData
.Key
.UnicodeChar
<= L
'Z')) {
616 KeyData
.Key
.UnicodeChar
= (CHAR16
) (KeyData
.Key
.UnicodeChar
- L
'A' + 1);
619 CopyMem (Key
, &KeyData
.Key
, sizeof (EFI_INPUT_KEY
));
626 TODO: Add function description
628 @param Event TODO: add argument description
629 @param Context TODO: add argument description
631 @return TODO: add return values
636 WinNtGopSimpleTextInWaitForKey (
641 GOP_PRIVATE_DATA
*Private
;
644 EFI_KEY_DATA KeyData
;
646 Private
= (GOP_PRIVATE_DATA
*) Context
;
649 // Enter critical section
651 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
654 // Call hot key callback before telling caller there is a key available
656 WinNtGopSimpleTextInTimerHandler (NULL
, Private
);
659 // WaitforKey doesn't suppor the partial key.
660 // Considering if the partial keystroke is enabled, there maybe a partial
661 // keystroke in the queue, so here skip the partial keystroke and get the
662 // next key from the queue
665 Status
= GopPrivateCheckQ (&Private
->QueueForRead
);
666 if (!EFI_ERROR (Status
)) {
668 // If a there is a key in the queue and it is not partial keystroke, signal event.
670 if (Private
->QueueForRead
.Q
[Private
->QueueForRead
.Front
].Key
.ScanCode
== SCAN_NULL
&&
671 Private
->QueueForRead
.Q
[Private
->QueueForRead
.Front
].Key
.UnicodeChar
== CHAR_NULL
) {
672 GopPrivateDeleteQ (Private
,&Private
->QueueForRead
,&KeyData
);
675 gBS
->SignalEvent (Event
);
678 // We need to sleep or NT will schedule this thread with such high
679 // priority that WinProc thread will never run and we will not see
680 // keyboard input. This Sleep makes the syste run 10x faster, so don't
683 Private
->WinNtThunk
->Sleep (1);
689 // Leave critical section and return
691 gBS
->RestoreTPL (OldTpl
);
695 // Simple Text Input Ex protocol functions
700 WinNtGopSimpleTextInExResetEx (
701 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
702 IN BOOLEAN ExtendedVerification
707 Reset the input device and optionaly run diagnostics
710 This - Protocol instance pointer.
711 ExtendedVerification - Driver may perform diagnostics on reset.
714 EFI_SUCCESS - The device was reset.
718 GOP_PRIVATE_DATA
*Private
;
720 Private
= GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS (This
);
722 return GopPrivateResetWorker (Private
);
727 WinNtGopSimpleTextInExReadKeyStrokeEx (
728 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
729 OUT EFI_KEY_DATA
*KeyData
734 Reads the next keystroke from the input device. The WaitForKey Event can
735 be used to test for existance of a keystroke via WaitForEvent () call.
738 This - Protocol instance pointer.
739 KeyData - A pointer to a buffer that is filled in with the keystroke
740 state data for the key that was pressed.
743 EFI_SUCCESS - The keystroke information was returned.
744 EFI_NOT_READY - There was no keystroke data availiable.
745 EFI_DEVICE_ERROR - The keystroke information was not returned due to
747 EFI_INVALID_PARAMETER - KeyData is NULL.
751 GOP_PRIVATE_DATA
*Private
;
753 if (KeyData
== NULL
) {
754 return EFI_INVALID_PARAMETER
;
757 Private
= GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS (This
);
759 return GopPrivateReadKeyStrokeWorker (Private
, KeyData
);
765 WinNtGopSimpleTextInExSetState (
766 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
767 IN EFI_KEY_TOGGLE_STATE
*KeyToggleState
772 Set certain state for the input device.
775 This - Protocol instance pointer.
776 KeyToggleState - A pointer to the EFI_KEY_TOGGLE_STATE to set the
777 state for the input device.
780 EFI_SUCCESS - The device state was set successfully.
781 EFI_DEVICE_ERROR - The device is not functioning correctly and could
782 not have the setting adjusted.
783 EFI_UNSUPPORTED - The device does not have the ability to set its state.
784 EFI_INVALID_PARAMETER - KeyToggleState is NULL.
789 GOP_PRIVATE_DATA
*Private
;
791 if (KeyToggleState
== NULL
) {
792 return EFI_INVALID_PARAMETER
;
795 Private
= GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS (This
);
797 if (((Private
->KeyState
.KeyToggleState
& EFI_TOGGLE_STATE_VALID
) != EFI_TOGGLE_STATE_VALID
) ||
798 ((*KeyToggleState
& EFI_TOGGLE_STATE_VALID
) != EFI_TOGGLE_STATE_VALID
)) {
799 return EFI_UNSUPPORTED
;
802 Private
->ScrollLock
= FALSE
;
803 Private
->NumLock
= FALSE
;
804 Private
->CapsLock
= FALSE
;
805 Private
->IsPartialKeySupport
= FALSE
;
807 if ((*KeyToggleState
& EFI_SCROLL_LOCK_ACTIVE
) == EFI_SCROLL_LOCK_ACTIVE
) {
808 Private
->ScrollLock
= TRUE
;
810 if ((*KeyToggleState
& EFI_NUM_LOCK_ACTIVE
) == EFI_NUM_LOCK_ACTIVE
) {
811 Private
->NumLock
= TRUE
;
813 if ((*KeyToggleState
& EFI_CAPS_LOCK_ACTIVE
) == EFI_CAPS_LOCK_ACTIVE
) {
814 Private
->CapsLock
= TRUE
;
816 if ((*KeyToggleState
& EFI_KEY_STATE_EXPOSED
) == EFI_KEY_STATE_EXPOSED
) {
817 Private
->IsPartialKeySupport
= TRUE
;
820 Status
= GopPrivateUpdateStatusLight (Private
);
821 if (EFI_ERROR (Status
)) {
822 return EFI_DEVICE_ERROR
;
825 Private
->KeyState
.KeyToggleState
= *KeyToggleState
;
832 WinNtGopSimpleTextInExRegisterKeyNotify (
833 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
834 IN EFI_KEY_DATA
*KeyData
,
835 IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction
,
836 OUT VOID
**NotifyHandle
841 Register a notification function for a particular keystroke for the input device.
844 This - Protocol instance pointer.
845 KeyData - A pointer to a buffer that is filled in with the keystroke
846 information data for the key that was pressed.
847 KeyNotificationFunction - Points to the function to be called when the key
848 sequence is typed specified by KeyData.
849 NotifyHandle - Points to the unique handle assigned to the registered notification.
852 EFI_SUCCESS - The notification function was registered successfully.
853 EFI_OUT_OF_RESOURCES - Unable to allocate resources for necesssary data structures.
854 EFI_INVALID_PARAMETER - KeyData or NotifyHandle is NULL.
858 GOP_PRIVATE_DATA
*Private
;
859 WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY
*CurrentNotify
;
861 WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY
*NewNotify
;
863 if (KeyData
== NULL
|| KeyNotificationFunction
== NULL
|| NotifyHandle
== NULL
) {
864 return EFI_INVALID_PARAMETER
;
867 Private
= GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS (This
);
870 // Return EFI_SUCCESS if the (KeyData, NotificationFunction) is already registered.
872 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
875 WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY
,
877 WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE
879 if (GopPrivateIsKeyRegistered (&CurrentNotify
->KeyData
, KeyData
)) {
880 if (CurrentNotify
->KeyNotificationFn
== KeyNotificationFunction
) {
881 *NotifyHandle
= CurrentNotify
;
888 // Allocate resource to save the notification function
890 NewNotify
= (WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY
*) AllocateZeroPool (sizeof (WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY
));
891 if (NewNotify
== NULL
) {
892 return EFI_OUT_OF_RESOURCES
;
895 NewNotify
->Signature
= WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE
;
896 NewNotify
->KeyNotificationFn
= KeyNotificationFunction
;
897 CopyMem (&NewNotify
->KeyData
, KeyData
, sizeof (EFI_KEY_DATA
));
898 InsertTailList (&Private
->NotifyList
, &NewNotify
->NotifyEntry
);
900 *NotifyHandle
= NewNotify
;
908 WinNtGopSimpleTextInExUnregisterKeyNotify (
909 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
910 IN VOID
*NotificationHandle
915 Remove a registered notification function from a particular keystroke.
918 This - Protocol instance pointer.
919 NotificationHandle - The handle of the notification function being unregistered.
922 EFI_SUCCESS - The notification function was unregistered successfully.
923 EFI_INVALID_PARAMETER - The NotificationHandle is invalid.
927 GOP_PRIVATE_DATA
*Private
;
929 WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY
*CurrentNotify
;
931 if (NotificationHandle
== NULL
) {
932 return EFI_INVALID_PARAMETER
;
935 Private
= GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS (This
);
937 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
940 WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY
,
942 WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE
944 if (CurrentNotify
== NotificationHandle
) {
946 // Remove the notification function from NotifyList and free resources
948 RemoveEntryList (&CurrentNotify
->NotifyEntry
);
950 gBS
->FreePool (CurrentNotify
);
956 // Can not find the specified Notification Handle
958 return EFI_INVALID_PARAMETER
;
963 TODO: Add function description
965 @param Private TODO: add argument description
967 @return TODO: add return values
971 WinNtGopInitializeSimpleTextInForWindow (
972 IN GOP_PRIVATE_DATA
*Private
977 GopPrivateCreateQ (Private
, &Private
->QueueForRead
);
978 GopPrivateCreateQ (Private
, &Private
->QueueForNotify
);
981 // Initialize Simple Text In protoocol
983 Private
->SimpleTextIn
.Reset
= WinNtGopSimpleTextInReset
;
984 Private
->SimpleTextIn
.ReadKeyStroke
= WinNtGopSimpleTextInReadKeyStroke
;
986 Status
= gBS
->CreateEvent (
989 WinNtGopSimpleTextInWaitForKey
,
991 &Private
->SimpleTextIn
.WaitForKey
995 Private
->SimpleTextInEx
.Reset
= WinNtGopSimpleTextInExResetEx
;
996 Private
->SimpleTextInEx
.ReadKeyStrokeEx
= WinNtGopSimpleTextInExReadKeyStrokeEx
;
997 Private
->SimpleTextInEx
.SetState
= WinNtGopSimpleTextInExSetState
;
998 Private
->SimpleTextInEx
.RegisterKeyNotify
= WinNtGopSimpleTextInExRegisterKeyNotify
;
999 Private
->SimpleTextInEx
.UnregisterKeyNotify
= WinNtGopSimpleTextInExUnregisterKeyNotify
;
1001 Private
->SimpleTextInEx
.Reset (&Private
->SimpleTextInEx
, FALSE
);
1003 InitializeListHead (&Private
->NotifyList
);
1005 Status
= gBS
->CreateEvent (
1008 WinNtGopSimpleTextInWaitForKey
,
1010 &Private
->SimpleTextInEx
.WaitForKeyEx
1012 ASSERT_EFI_ERROR (Status
);
1015 // Create the Timer to trigger hot key notifications
1017 Status
= gBS
->CreateEvent (
1018 EVT_TIMER
| EVT_NOTIFY_SIGNAL
,
1020 WinNtGopSimpleTextInTimerHandler
,
1022 &Private
->TimerEvent
1024 ASSERT_EFI_ERROR (Status
);
1026 Status
= gBS
->SetTimer (
1027 Private
->TimerEvent
,
1029 KEYBOARD_TIMER_INTERVAL
1031 ASSERT_EFI_ERROR (Status
);
1039 TODO: Add function description
1041 @param Private TODO: add argument description
1043 @retval EFI_SUCCESS TODO: Add description for return value
1047 WinNtGopDestroySimpleTextInForWindow (
1048 IN GOP_PRIVATE_DATA
*Private
1051 gBS
->CloseEvent (Private
->TimerEvent
);
1053 GopPrivateDestroyQ (Private
, &Private
->QueueForRead
);
1054 GopPrivateDestroyQ (Private
, &Private
->QueueForNotify
);