X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=EmulatorPkg%2FEmuGopDxe%2FGopInput.c;h=cf37a7bd70a2bb2fef88d08c4200ad9e07401a41;hb=6be1193f14a988c280e045e70c90df51e1b0fc26;hp=0bc2eb5a0280349451a26bb6a3964f81db171140;hpb=bb89ec1a7ec2f8d35033df9e47b3604925da3bd3;p=mirror_edk2.git diff --git a/EmulatorPkg/EmuGopDxe/GopInput.c b/EmulatorPkg/EmuGopDxe/GopInput.c index 0bc2eb5a02..cf37a7bd70 100644 --- a/EmulatorPkg/EmuGopDxe/GopInput.c +++ b/EmulatorPkg/EmuGopDxe/GopInput.c @@ -1,6 +1,6 @@ /*++ @file -Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
Portions copyright (c) 2010 0 2011,Apple Inc. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -27,36 +27,36 @@ Routine Description: Arguments: - RegsiteredData - A pointer to a buffer that is filled in with the keystroke + RegsiteredData - A pointer to a buffer that is filled in with the keystroke state data for the key that was registered. - InputData - A pointer to a buffer that is filled in with the keystroke + InputData - A pointer to a buffer that is filled in with the keystroke state data for the key that was pressed. Returns: TRUE - Key be pressed matches a registered key. - FLASE - Match failed. - + FLASE - Match failed. + **/ { ASSERT (RegsiteredData != NULL && InputData != NULL); - + if ((RegsiteredData->Key.ScanCode != InputData->Key.ScanCode) || (RegsiteredData->Key.UnicodeChar != InputData->Key.UnicodeChar)) { - return FALSE; - } - + return FALSE; + } + // // Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored. // if (RegsiteredData->KeyState.KeyShiftState != 0 && RegsiteredData->KeyState.KeyShiftState != InputData->KeyState.KeyShiftState) { - return FALSE; - } + return FALSE; + } if (RegsiteredData->KeyState.KeyToggleState != 0 && RegsiteredData->KeyState.KeyToggleState != InputData->KeyState.KeyToggleState) { - return FALSE; - } - + return FALSE; + } + return TRUE; } @@ -68,26 +68,26 @@ GopPrivateMakeCallbackFunction ( IN VOID *Context, IN EFI_KEY_DATA *KeyData ) -{ +{ LIST_ENTRY *Link; EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY *CurrentNotify; GOP_PRIVATE_DATA *Private = (GOP_PRIVATE_DATA *)Context; - + KeyMapMake (KeyData); for (Link = Private->NotifyList.ForwardLink; Link != &Private->NotifyList; Link = Link->ForwardLink) { CurrentNotify = CR ( - Link, - EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY, - NotifyEntry, + Link, + EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY, + NotifyEntry, EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE ); - if (GopPrivateIsKeyRegistered (&CurrentNotify->KeyData, KeyData)) { - // We could be called at a high TPL so signal an event to call the registered function + if (GopPrivateIsKeyRegistered (&CurrentNotify->KeyData, KeyData)) { + // We could be called at a high TPL so signal an event to call the registered function // at a lower TPL. gBS->SignalEvent (CurrentNotify->Event); } - } + } } @@ -97,7 +97,7 @@ GopPrivateBreakCallbackFunction ( IN VOID *Context, IN EFI_KEY_DATA *KeyData ) -{ +{ KeyMapBreak (KeyData); } @@ -189,7 +189,14 @@ EmuGopSimpleTextInReadKeyStroke ( OldTpl = gBS->RaiseTPL (TPL_NOTIFY); Status = Private->EmuGraphicsWindow->GetKey (Private->EmuGraphicsWindow, &KeyData); - CopyMem (Key, &KeyData.Key, sizeof (EFI_INPUT_KEY)); + if (!EFI_ERROR (Status)) { + if ((KeyData.Key.ScanCode == 0) && (KeyData.Key.UnicodeChar == 0)) { + // Modifier key was pressed + Status = EFI_NOT_READY; + } else { + CopyMem (Key, &KeyData.Key, sizeof (EFI_INPUT_KEY)); + } + } // // Leave critical section and return @@ -202,7 +209,7 @@ EmuGopSimpleTextInReadKeyStroke ( /** - SimpleTextIn and SimpleTextInEx Notify Wait Event + SimpleTextIn and SimpleTextInEx Notify Wait Event @param Event Event whose notification function is being invoked. @param Context Pointer to GOP_PRIVATE_DATA. @@ -268,7 +275,7 @@ EmuGopSimpleTextInWaitForKey ( @retval EFI_SUCCESS The device was reset. - + @retval EFI_DEVICE_ERROR The device is not functioning correctly and could not be reset. @@ -293,10 +300,6 @@ EmuGopSimpleTextInExResetEx ( **/ { - GOP_PRIVATE_DATA *Private; - - Private = GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS (This); - return EFI_SUCCESS; } @@ -333,17 +336,17 @@ EmuGopSimpleTextInExResetEx ( state information, and in those cases the high order bit in the respective Toggle and Shift state fields should not be active. - + @param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance. @param KeyData A pointer to a buffer that is filled in with the keystroke state data for the key that was pressed. - + @retval EFI_SUCCESS The keystroke information was returned. - + @retval EFI_NOT_READY There was no keystroke data available. EFI_DEVICE_ERROR The keystroke information was not returned due to @@ -360,20 +363,20 @@ EmuGopSimpleTextInExReadKeyStrokeEx ( /*++ Routine Description: - Reads the next keystroke from the input device. The WaitForKey Event can + Reads the next keystroke from the input device. The WaitForKey Event can be used to test for existance of a keystroke via WaitForEvent () call. Arguments: This - Protocol instance pointer. - KeyData - A pointer to a buffer that is filled in with the keystroke + KeyData - A pointer to a buffer that is filled in with the keystroke state data for the key that was pressed. Returns: EFI_SUCCESS - The keystroke information was returned. EFI_NOT_READY - There was no keystroke data availiable. - EFI_DEVICE_ERROR - The keystroke information was not returned due to + EFI_DEVICE_ERROR - The keystroke information was not returned due to hardware errors. - EFI_INVALID_PARAMETER - KeyData is NULL. + EFI_INVALID_PARAMETER - KeyData is NULL. **/ { @@ -386,7 +389,7 @@ EmuGopSimpleTextInExReadKeyStrokeEx ( return EFI_INVALID_PARAMETER; } - Private = GOP_PRIVATE_DATA_FROM_TEXT_IN_THIS (This); + Private = GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS (This); if (Private->EmuGraphicsWindow == NULL) { return EFI_NOT_READY; } @@ -411,13 +414,13 @@ EmuGopSimpleTextInExReadKeyStrokeEx ( /** The SetState() function allows the input device hardware to have state settings adjusted. - + @param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance. - + @param KeyToggleState Pointer to the EFI_KEY_TOGGLE_STATE to set the state for the input device. - - + + @retval EFI_SUCCESS The device state was set appropriately. @retval EFI_DEVICE_ERROR The device is not functioning @@ -439,7 +442,7 @@ EmuGopSimpleTextInExSetState ( EFI_STATUS Status; EFI_TPL OldTpl; - Private = GOP_PRIVATE_DATA_FROM_TEXT_IN_THIS (This); + Private = GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS (This); if (Private->EmuGraphicsWindow == NULL) { return EFI_NOT_READY; } @@ -460,7 +463,7 @@ EmuGopSimpleTextInExSetState ( /** - SimpleTextIn and SimpleTextInEx Notify Wait Event + SimpleTextIn and SimpleTextInEx Notify Wait Event @param Event Event whose notification function is being invoked. @param Context Pointer to GOP_PRIVATE_DATA. @@ -474,7 +477,7 @@ EmuGopRegisterKeyCallback ( ) { EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY *ExNotify = (EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY *)Context; - + ExNotify->KeyNotificationFn (&ExNotify->KeyData); } @@ -483,21 +486,21 @@ EmuGopRegisterKeyCallback ( /** The RegisterKeystrokeNotify() function registers a function which will be called when a specified keystroke will occur. - + @param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance. - + @param KeyData A pointer to a buffer that is filled in with the keystroke information for the key that was pressed. - + @param KeyNotificationFunction Points to the function to be called when the key sequence is typed specified by KeyData. - - + + @param NotifyHandle Points to the unique handle assigned to the registered notification. - + @retval EFI_SUCCESS The device state was set appropriately. @@ -531,33 +534,33 @@ EmuGopSimpleTextInExRegisterKeyNotify ( // for (Link = Private->NotifyList.ForwardLink; Link != &Private->NotifyList; Link = Link->ForwardLink) { CurrentNotify = CR ( - Link, - EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY, - NotifyEntry, + Link, + EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY, + NotifyEntry, EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE ); - if (GopPrivateIsKeyRegistered (&CurrentNotify->KeyData, KeyData)) { + if (GopPrivateIsKeyRegistered (&CurrentNotify->KeyData, KeyData)) { if (CurrentNotify->KeyNotificationFn == KeyNotificationFunction) { *NotifyHandle = CurrentNotify->NotifyHandle; return EFI_SUCCESS; } } - } - + } + // // Allocate resource to save the notification function - // + // NewNotify = (EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY *) AllocateZeroPool (sizeof (EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY)); if (NewNotify == NULL) { return EFI_OUT_OF_RESOURCES; } - NewNotify->Signature = EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE; + NewNotify->Signature = EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE; NewNotify->KeyNotificationFn = KeyNotificationFunction; NewNotify->NotifyHandle = (EFI_HANDLE) NewNotify; CopyMem (&NewNotify->KeyData, KeyData, sizeof (KeyData)); InsertTailList (&Private->NotifyList, &NewNotify->NotifyEntry); - + Status = gBS->CreateEvent ( EVT_NOTIFY_SIGNAL, TPL_NOTIFY, @@ -568,24 +571,24 @@ EmuGopSimpleTextInExRegisterKeyNotify ( ASSERT_EFI_ERROR (Status); - *NotifyHandle = NewNotify->NotifyHandle; - + *NotifyHandle = NewNotify->NotifyHandle; + return EFI_SUCCESS; - + } /** The UnregisterKeystrokeNotify() function removes the notification which was previously registered. - + @param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance. - + @param NotificationHandle The handle of the notification function being unregistered. - + @retval EFI_SUCCESS The device state was set appropriately. - + @retval EFI_INVALID_PARAMETER The NotificationHandle is invalid. @@ -602,14 +605,14 @@ EmuGopSimpleTextInExUnregisterKeyNotify ( Remove a registered notification function from a particular keystroke. Arguments: - This - Protocol instance pointer. + This - Protocol instance pointer. NotificationHandle - The handle of the notification function being unregistered. Returns: EFI_SUCCESS - The notification function was unregistered successfully. EFI_INVALID_PARAMETER - The NotificationHandle is invalid. - -**/ + +**/ { GOP_PRIVATE_DATA *Private; LIST_ENTRY *Link; @@ -617,30 +620,30 @@ EmuGopSimpleTextInExUnregisterKeyNotify ( if (NotificationHandle == NULL) { return EFI_INVALID_PARAMETER; - } + } if (((EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY *) NotificationHandle)->Signature != EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE) { return EFI_INVALID_PARAMETER; - } + } Private = GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS (This); for (Link = Private->NotifyList.ForwardLink; Link != &Private->NotifyList; Link = Link->ForwardLink) { CurrentNotify = CR ( - Link, - EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY, - NotifyEntry, + Link, + EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY, + NotifyEntry, EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE - ); + ); if (CurrentNotify->NotifyHandle == NotificationHandle) { // // Remove the notification function from NotifyList and free resources // - RemoveEntryList (&CurrentNotify->NotifyEntry); - + RemoveEntryList (&CurrentNotify->NotifyEntry); + gBS->CloseEvent (CurrentNotify->Event); - gBS->FreePool (CurrentNotify); + gBS->FreePool (CurrentNotify); return EFI_SUCCESS; } } @@ -657,7 +660,7 @@ EmuGopSimpleTextInExUnregisterKeyNotify ( Initialize SimplelTextIn and SimpleTextInEx protocols in the Private context structure. - @param Private Context structure to fill in. + @param Private Context structure to fill in. @return EFI_SUCCESS Initialization was a success @@ -683,12 +686,12 @@ EmuGopInitializeSimpleTextInForWindow ( &Private->SimpleTextIn.WaitForKey ); ASSERT_EFI_ERROR (Status); - - + + // // Initialize Simple Text In Ex // - + Private->SimpleTextInEx.Reset = EmuGopSimpleTextInExResetEx; Private->SimpleTextInEx.ReadKeyStrokeEx = EmuGopSimpleTextInExReadKeyStrokeEx; Private->SimpleTextInEx.SetState = EmuGopSimpleTextInExSetState; @@ -696,7 +699,7 @@ EmuGopInitializeSimpleTextInForWindow ( Private->SimpleTextInEx.UnregisterKeyNotify = EmuGopSimpleTextInExUnregisterKeyNotify; Private->SimpleTextInEx.Reset (&Private->SimpleTextInEx, FALSE); - + InitializeListHead (&Private->NotifyList); Status = gBS->CreateEvent ( @@ -723,17 +726,17 @@ EmuGopInitializeSimpleTextInForWindow ( // -/** +/** Resets the pointer device hardware. - + @param This A pointer to the EFI_SIMPLE_POINTER_PROTOCOL - instance. + instance. @param ExtendedVerification Indicates that the driver may perform a more exhaustive - verification operation of the device during reset. - + verification operation of the device during reset. + @retval EFI_SUCCESS The device was reset. - @retval EFI_DEVICE_ERROR The device is not functioning correctly and could not be reset. - + @retval EFI_DEVICE_ERROR The device is not functioning correctly and could not be reset. + **/ EFI_STATUS EFIAPI @@ -770,19 +773,19 @@ EmuGopSimplePointerReset ( } -/** +/** Retrieves the current state of a pointer device. - + @param This A pointer to the EFI_SIMPLE_POINTER_PROTOCOL - instance. + instance. @param State A pointer to the state information on the pointer device. - + @retval EFI_SUCCESS The state of the pointer device was returned in State. @retval EFI_NOT_READY The state of the pointer device has not changed since the last call to - GetState(). + GetState(). @retval EFI_DEVICE_ERROR A device error occurred while attempting to retrieve the pointer device's - current state. - + current state. + **/ EFI_STATUS EFIAPI @@ -816,7 +819,7 @@ EmuGopSimplePointerGetState ( /** - SimplePointer Notify Wait Event + SimplePointer Notify Wait Event @param Event Event whose notification function is being invoked. @param Context Pointer to GOP_PRIVATE_DATA. @@ -858,11 +861,11 @@ EmuGopSimplePointerWaitForInput ( /** - SimplePointer constructor + SimplePointer constructor - @param Private Context structure to fill in. + @param Private Context structure to fill in. - @retval EFI_SUCCESS Constructor had success + @retval EFI_SUCCESS Constructor had success **/ EFI_STATUS