From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.43; helo=mga05.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 0F740226847A5 for ; Thu, 19 Apr 2018 19:31:25 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Apr 2018 19:31:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,299,1520924400"; d="scan'208";a="33939636" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga008.fm.intel.com with ESMTP; 19 Apr 2018 19:31:24 -0700 Received: from fmsmsx115.amr.corp.intel.com (10.18.116.19) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 19 Apr 2018 19:31:24 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx115.amr.corp.intel.com (10.18.116.19) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 19 Apr 2018 19:31:24 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.79]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.40]) with mapi id 14.03.0319.002; Fri, 20 Apr 2018 10:31:18 +0800 From: "Zeng, Star" To: "Ni, Ruiyu" , "edk2-devel@lists.01.org" CC: "Zeng, Star" Thread-Topic: [PATCH] Nt32Pkg/NtGopInput: ReadKeyStrokeEx always return key state Thread-Index: AQHT18sJNuysBxGvzEeG5AKx+XsUCKQI76Qg Date: Fri, 20 Apr 2018 02:31:19 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103BAD6313@shsmsx102.ccr.corp.intel.com> References: <20180419104147.196512-1-ruiyu.ni@intel.com> In-Reply-To: <20180419104147.196512-1-ruiyu.ni@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] Nt32Pkg/NtGopInput: ReadKeyStrokeEx always return key state X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Apr 2018 02:31:25 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Star Zeng Thanks, Star -----Original Message----- From: Ni, Ruiyu=20 Sent: Thursday, April 19, 2018 6:42 PM To: edk2-devel@lists.01.org Cc: Zeng, Star Subject: [PATCH] Nt32Pkg/NtGopInput: ReadKeyStrokeEx always return key stat= e Today's implementation only return key state when there is key. But when user doesn't press any key, the key state cannot be returned. The patch changes the ReadKeyStrokeEx() to always return the key state even there is no key pressed. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Star Zeng --- Nt32Pkg/WinNtGopDxe/WinNtGopInput.c | 79 ++++++++++++++++++++++-----------= ---- 1 file changed, 48 insertions(+), 31 deletions(-) diff --git a/Nt32Pkg/WinNtGopDxe/WinNtGopInput.c b/Nt32Pkg/WinNtGopDxe/WinN= tGopInput.c index 6a0f4b7892..b19dfdc2ec 100644 --- a/Nt32Pkg/WinNtGopDxe/WinNtGopInput.c +++ b/Nt32Pkg/WinNtGopDxe/WinNtGopInput.c @@ -1,6 +1,6 @@ /** @file =20 -Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD = License which accompanies this distribution. The full text of the license may be = found at @@ -270,73 +270,87 @@ WinNtGopSimpleTextInTimerHandler ( } =20 /** - TODO: Add function description - - @param Private TODO: add argument description - @param Key TODO: add argument description - - @retval EFI_NOT_READY TODO: Add description for return value - @retval EFI_SUCCESS TODO: Add description for return value + Initialize the key state. =20 + @param Private The GOP_PRIVATE_DATA instance. + @param KeyState A pointer to receive the key state informa= tion. **/ -EFI_STATUS -GopPrivateAddKey ( +VOID +InitializeKeyState ( IN GOP_PRIVATE_DATA *Private, - IN EFI_INPUT_KEY Key + IN EFI_KEY_STATE *KeyState ) { - EFI_KEY_DATA KeyData; - - KeyData.Key =3D Key; - - KeyData.KeyState.KeyShiftState =3D EFI_SHIFT_STATE_VALID; - KeyData.KeyState.KeyToggleState =3D EFI_TOGGLE_STATE_VALID; + KeyState->KeyShiftState =3D EFI_SHIFT_STATE_VALID; + KeyState->KeyToggleState =3D EFI_TOGGLE_STATE_VALID; =20 // // Record Key shift state and toggle state // if (Private->LeftCtrl) { - KeyData.KeyState.KeyShiftState |=3D EFI_LEFT_CONTROL_PRESSED; + KeyState->KeyShiftState |=3D EFI_LEFT_CONTROL_PRESSED; } if (Private->RightCtrl) { - KeyData.KeyState.KeyShiftState |=3D EFI_RIGHT_CONTROL_PRESSED; + KeyState->KeyShiftState |=3D EFI_RIGHT_CONTROL_PRESSED; } if (Private->LeftAlt) { - KeyData.KeyState.KeyShiftState |=3D EFI_LEFT_ALT_PRESSED; + KeyState->KeyShiftState |=3D EFI_LEFT_ALT_PRESSED; } if (Private->RightAlt) { - KeyData.KeyState.KeyShiftState |=3D EFI_RIGHT_ALT_PRESSED; + KeyState->KeyShiftState |=3D EFI_RIGHT_ALT_PRESSED; } if (Private->LeftShift) { - KeyData.KeyState.KeyShiftState |=3D EFI_LEFT_SHIFT_PRESSED; + KeyState->KeyShiftState |=3D EFI_LEFT_SHIFT_PRESSED; } if (Private->RightShift) { - KeyData.KeyState.KeyShiftState |=3D EFI_RIGHT_SHIFT_PRESSED; + KeyState->KeyShiftState |=3D EFI_RIGHT_SHIFT_PRESSED; } if (Private->LeftLogo) { - KeyData.KeyState.KeyShiftState |=3D EFI_LEFT_LOGO_PRESSED; + KeyState->KeyShiftState |=3D EFI_LEFT_LOGO_PRESSED; } if (Private->RightLogo) { - KeyData.KeyState.KeyShiftState |=3D EFI_RIGHT_LOGO_PRESSED; + KeyState->KeyShiftState |=3D EFI_RIGHT_LOGO_PRESSED; } if (Private->Menu) { - KeyData.KeyState.KeyShiftState |=3D EFI_MENU_KEY_PRESSED; + KeyState->KeyShiftState |=3D EFI_MENU_KEY_PRESSED; } if (Private->SysReq) { - KeyData.KeyState.KeyShiftState |=3D EFI_SYS_REQ_PRESSED; + KeyState->KeyShiftState |=3D EFI_SYS_REQ_PRESSED; } if (Private->CapsLock) { - KeyData.KeyState.KeyToggleState |=3D EFI_CAPS_LOCK_ACTIVE; + KeyState->KeyToggleState |=3D EFI_CAPS_LOCK_ACTIVE; } if (Private->NumLock) { - KeyData.KeyState.KeyToggleState |=3D EFI_NUM_LOCK_ACTIVE; + KeyState->KeyToggleState |=3D EFI_NUM_LOCK_ACTIVE; } if (Private->ScrollLock) { - KeyData.KeyState.KeyToggleState |=3D EFI_SCROLL_LOCK_ACTIVE; + KeyState->KeyToggleState |=3D EFI_SCROLL_LOCK_ACTIVE; } if (Private->IsPartialKeySupport) { - KeyData.KeyState.KeyToggleState |=3D EFI_KEY_STATE_EXPOSED; + KeyState->KeyToggleState |=3D EFI_KEY_STATE_EXPOSED; } +} + +/** + TODO: Add function description + + @param Private TODO: add argument description + @param Key TODO: add argument description + + @retval EFI_NOT_READY TODO: Add description for return value + @retval EFI_SUCCESS TODO: Add description for return value + +**/ +EFI_STATUS +GopPrivateAddKey ( + IN GOP_PRIVATE_DATA *Private, + IN EFI_INPUT_KEY Key + ) +{ + EFI_KEY_DATA KeyData; + + KeyData.Key =3D Key; + InitializeKeyState (Private, &KeyData.KeyState); =20 // // Convert Ctrl+[1-26] to Ctrl+[A-Z] @@ -503,6 +517,9 @@ GopPrivateReadKeyStrokeWorker ( // WinNtGopSimpleTextInTimerHandler (NULL, Private); =20 + ZeroMem (&KeyData->Key, sizeof (KeyData->Key)); + InitializeKeyState (Private, &KeyData->KeyState); + Status =3D GopPrivateCheckQ (&Private->QueueForRead); if (!EFI_ERROR (Status)) { // --=20 2.16.1.windows.1