3 Copyright (c) 2006 - 2011, 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
);
366 // Convert Ctrl+[A-Z] to Ctrl+[1-26]
368 if (Private
->LeftCtrl
|| Private
->RightCtrl
) {
369 if ((KeyData
.Key
.UnicodeChar
>= L
'a') && (KeyData
.Key
.UnicodeChar
<= L
'z')) {
370 KeyData
.Key
.UnicodeChar
= (CHAR16
)(KeyData
.Key
.UnicodeChar
- L
'a' + 1);
371 } else if ((KeyData
.Key
.UnicodeChar
>= L
'A') && (KeyData
.Key
.UnicodeChar
<= L
'Z')) {
372 KeyData
.Key
.UnicodeChar
= (CHAR16
)(KeyData
.Key
.UnicodeChar
- L
'A' + 1);
375 GopPrivateAddQ (Private
, &Private
->QueueForRead
, &KeyData
);
381 GopPrivateUpdateStatusLight (
382 IN GOP_PRIVATE_DATA
*Private
388 This function updates the status light of NumLock, ScrollLock and CapsLock.
392 Private - The private structure of WinNt console In/Out.
396 EFI_SUCCESS - The status light is updated successfully.
401 // BUGBUG:Only SendInput/keybd_event function can toggle
402 // NumLock, CapsLock and ScrollLock keys.
403 // Neither of these functions is included in EFI_WIN_NT_THUNK_PROTOCOL.
404 // Thus, return immediately without operation.
412 GopPrivateResetWorker (
413 IN GOP_PRIVATE_DATA
*Private
419 This function is a worker function for SimpleTextIn/SimpleTextInEx.Reset().
423 Private - WinNT GOP private structure
427 EFI_SUCCESS - Reset successfully
431 EFI_KEY_DATA KeyData
;
435 // Enter critical section
437 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
440 // A reset is draining the Queue
442 while (GopPrivateDeleteQ (Private
, &Private
->QueueForRead
, &KeyData
) == EFI_SUCCESS
)
444 while (GopPrivateDeleteQ (Private
, &Private
->QueueForNotify
, &KeyData
) == EFI_SUCCESS
)
447 Private
->LeftShift
= FALSE
;
448 Private
->RightShift
= FALSE
;
449 Private
->LeftAlt
= FALSE
;
450 Private
->RightAlt
= FALSE
;
451 Private
->LeftCtrl
= FALSE
;
452 Private
->RightCtrl
= FALSE
;
453 Private
->LeftLogo
= FALSE
;
454 Private
->RightLogo
= FALSE
;
455 Private
->Menu
= FALSE
;
456 Private
->SysReq
= FALSE
;
458 Private
->CapsLock
= FALSE
;
459 Private
->NumLock
= FALSE
;
460 Private
->ScrollLock
= FALSE
;
461 Private
->IsPartialKeySupport
= FALSE
;
463 Private
->KeyState
.KeyShiftState
= EFI_SHIFT_STATE_VALID
;
464 Private
->KeyState
.KeyToggleState
= EFI_TOGGLE_STATE_VALID
;
467 // Leave critical section and return
469 gBS
->RestoreTPL (OldTpl
);
475 GopPrivateReadKeyStrokeWorker (
476 IN GOP_PRIVATE_DATA
*Private
,
477 OUT EFI_KEY_DATA
*KeyData
482 Reads the next keystroke from the input device. The WaitForKey Event can
483 be used to test for existance of a keystroke via WaitForEvent () call.
486 Private - The private structure of WinNt Gop device.
487 KeyData - A pointer to a buffer that is filled in with the keystroke
488 state data for the key that was pressed.
491 EFI_SUCCESS - The keystroke information was returned.
492 EFI_NOT_READY - There was no keystroke data availiable.
493 EFI_DEVICE_ERROR - The keystroke information was not returned due to
495 EFI_INVALID_PARAMETER - KeyData is NULL.
502 if (KeyData
== NULL
) {
503 return EFI_INVALID_PARAMETER
;
507 // Enter critical section
509 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
512 // Call hot key callback before telling caller there is a key available
514 WinNtGopSimpleTextInTimerHandler (NULL
, Private
);
516 Status
= GopPrivateCheckQ (&Private
->QueueForRead
);
517 if (!EFI_ERROR (Status
)) {
519 // If a Key press exists try and read it.
521 Status
= GopPrivateDeleteQ (Private
, &Private
->QueueForRead
, KeyData
);
522 if (!EFI_ERROR (Status
)) {
524 // If partial keystroke is not enabled, check whether it is value key. If not return
527 if (!Private
->IsPartialKeySupport
) {
528 if (KeyData
->Key
.ScanCode
== SCAN_NULL
&& KeyData
->Key
.UnicodeChar
== CHAR_NULL
) {
529 Status
= EFI_NOT_READY
;
536 // Leave critical section and return
538 gBS
->RestoreTPL (OldTpl
);
546 // Simple Text In implementation.
551 TODO: Add function description
553 @param This TODO: add argument description
554 @param ExtendedVerification TODO: add argument description
556 @retval EFI_SUCCESS TODO: Add description for return value
561 WinNtGopSimpleTextInReset (
562 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
563 IN BOOLEAN ExtendedVerification
566 GOP_PRIVATE_DATA
*Private
;
568 Private
= GOP_PRIVATE_DATA_FROM_TEXT_IN_THIS (This
);
570 return GopPrivateResetWorker (Private
);
575 TODO: Add function description
577 @param This TODO: add argument description
578 @param Key TODO: add argument description
580 @return TODO: add return values
585 WinNtGopSimpleTextInReadKeyStroke (
586 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
587 OUT EFI_INPUT_KEY
*Key
590 GOP_PRIVATE_DATA
*Private
;
592 EFI_KEY_DATA KeyData
;
594 Private
= GOP_PRIVATE_DATA_FROM_TEXT_IN_THIS (This
);
596 // Considering if the partial keystroke is enabled, there maybe a partial
597 // keystroke in the queue, so here skip the partial keystroke and get the
598 // next key from the queue
601 Status
= GopPrivateReadKeyStrokeWorker (Private
, &KeyData
);
602 if (EFI_ERROR (Status
)) {
605 if (KeyData
.Key
.ScanCode
== SCAN_NULL
&& KeyData
.Key
.UnicodeChar
== CHAR_NULL
) {
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 EFI_HANDLE
*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
->NotifyHandle
;
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 NewNotify
->NotifyHandle
= (EFI_HANDLE
) NewNotify
;
887 CopyMem (&NewNotify
->KeyData
, KeyData
, sizeof (EFI_KEY_DATA
));
888 InsertTailList (&Private
->NotifyList
, &NewNotify
->NotifyEntry
);
890 *NotifyHandle
= NewNotify
->NotifyHandle
;
898 WinNtGopSimpleTextInExUnregisterKeyNotify (
899 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
900 IN EFI_HANDLE NotificationHandle
905 Remove a registered notification function from a particular keystroke.
908 This - Protocol instance pointer.
909 NotificationHandle - The handle of the notification function being unregistered.
912 EFI_SUCCESS - The notification function was unregistered successfully.
913 EFI_INVALID_PARAMETER - The NotificationHandle is invalid.
917 GOP_PRIVATE_DATA
*Private
;
919 WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY
*CurrentNotify
;
921 if (NotificationHandle
== NULL
) {
922 return EFI_INVALID_PARAMETER
;
925 if (((WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY
*) NotificationHandle
)->Signature
!= WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE
) {
926 return EFI_INVALID_PARAMETER
;
929 Private
= GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS (This
);
931 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
934 WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY
,
936 WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE
938 if (CurrentNotify
->NotifyHandle
== NotificationHandle
) {
940 // Remove the notification function from NotifyList and free resources
942 RemoveEntryList (&CurrentNotify
->NotifyEntry
);
944 gBS
->FreePool (CurrentNotify
);
950 // Can not find the specified Notification Handle
952 return EFI_INVALID_PARAMETER
;
957 TODO: Add function description
959 @param Private TODO: add argument description
961 @return TODO: add return values
965 WinNtGopInitializeSimpleTextInForWindow (
966 IN GOP_PRIVATE_DATA
*Private
971 GopPrivateCreateQ (Private
, &Private
->QueueForRead
);
972 GopPrivateCreateQ (Private
, &Private
->QueueForNotify
);
975 // Initialize Simple Text In protoocol
977 Private
->SimpleTextIn
.Reset
= WinNtGopSimpleTextInReset
;
978 Private
->SimpleTextIn
.ReadKeyStroke
= WinNtGopSimpleTextInReadKeyStroke
;
980 Status
= gBS
->CreateEvent (
983 WinNtGopSimpleTextInWaitForKey
,
985 &Private
->SimpleTextIn
.WaitForKey
989 Private
->SimpleTextInEx
.Reset
= WinNtGopSimpleTextInExResetEx
;
990 Private
->SimpleTextInEx
.ReadKeyStrokeEx
= WinNtGopSimpleTextInExReadKeyStrokeEx
;
991 Private
->SimpleTextInEx
.SetState
= WinNtGopSimpleTextInExSetState
;
992 Private
->SimpleTextInEx
.RegisterKeyNotify
= WinNtGopSimpleTextInExRegisterKeyNotify
;
993 Private
->SimpleTextInEx
.UnregisterKeyNotify
= WinNtGopSimpleTextInExUnregisterKeyNotify
;
995 Private
->SimpleTextInEx
.Reset (&Private
->SimpleTextInEx
, FALSE
);
997 InitializeListHead (&Private
->NotifyList
);
999 Status
= gBS
->CreateEvent (
1002 WinNtGopSimpleTextInWaitForKey
,
1004 &Private
->SimpleTextInEx
.WaitForKeyEx
1006 ASSERT_EFI_ERROR (Status
);
1009 // Create the Timer to trigger hot key notifications
1011 Status
= gBS
->CreateEvent (
1012 EVT_TIMER
| EVT_NOTIFY_SIGNAL
,
1014 WinNtGopSimpleTextInTimerHandler
,
1016 &Private
->TimerEvent
1018 ASSERT_EFI_ERROR (Status
);
1020 Status
= gBS
->SetTimer (
1021 Private
->TimerEvent
,
1023 KEYBOARD_TIMER_INTERVAL
1025 ASSERT_EFI_ERROR (Status
);
1033 TODO: Add function description
1035 @param Private TODO: add argument description
1037 @retval EFI_SUCCESS TODO: Add description for return value
1041 WinNtGopDestroySimpleTextInForWindow (
1042 IN GOP_PRIVATE_DATA
*Private
1045 gBS
->CloseEvent (Private
->TimerEvent
);
1047 GopPrivateDestroyQ (Private
, &Private
->QueueForRead
);
1048 GopPrivateDestroyQ (Private
, &Private
->QueueForNotify
);