From nobody Mon Dec 23 16:56:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1516608637969795.0693874134204; Mon, 22 Jan 2018 00:10:37 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 0E3832238B5A9; Mon, 22 Jan 2018 00:05:07 -0800 (PST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 B85DE2232BE18 for ; Mon, 22 Jan 2018 00:05:03 -0800 (PST) Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Jan 2018 00:10:29 -0800 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.19]) by fmsmga008.fm.intel.com with ESMTP; 22 Jan 2018 00:10:28 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.65; helo=mga03.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,395,1511856000"; d="scan'208";a="12170506" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Mon, 22 Jan 2018 16:10:21 +0800 Message-Id: <20180122081024.283496-4-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.15.1.windows.2 In-Reply-To: <20180122081024.283496-1-ruiyu.ni@intel.com> References: <20180122081024.283496-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH 3/6] MdeModulePkg/UsbKb: ReadKeyStrokeEx always return key state X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael D Kinney , Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 Cc: Michael D Kinney --- MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c | 4 +- MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c | 107 ++++++++++++++++++---------= ---- MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.h | 14 +++- 3 files changed, 77 insertions(+), 48 deletions(-) diff --git a/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c b/MdeModulePkg/Bus/Usb/= UsbKbDxe/EfiKey.c index fb2bf3fd81..722350f609 100644 --- a/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c +++ b/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c @@ -2,7 +2,7 @@ USB Keyboard Driver that manages USB keyboard and produces Simple Text I= nput Protocol and Simple Text Input Ex Protocol. =20 -Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 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 @@ -607,6 +607,8 @@ USBKeyboardReadKeyStrokeWorker ( } =20 if (IsQueueEmpty (&UsbKeyboardDevice->EfiKeyQueue)) { + ZeroMem (&KeyData->Key, sizeof (KeyData->Key)); + InitializeKeyState (UsbKeyboardDevice, &KeyData->KeyState); return EFI_NOT_READY; } =20 diff --git a/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c b/MdeModulePkg/Bus/Us= b/UsbKbDxe/KeyBoard.c index 91913d4e54..d140311c52 100644 --- a/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c +++ b/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c @@ -1,7 +1,7 @@ /** @file Helper functions for USB Keyboard Driver. =20 -Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 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 @@ -1484,6 +1484,65 @@ USBParseKey ( return EFI_NOT_READY; } =20 +/** + Initialize the key state. + + @param UsbKeyboardDevice The USB_KB_DEV instance. + @param KeyState A pointer to receive the key state informa= tion. +**/ +VOID +InitializeKeyState ( + IN USB_KB_DEV *UsbKeyboardDevice, + OUT EFI_KEY_STATE *KeyState + ) +{ + KeyState->KeyShiftState =3D EFI_SHIFT_STATE_VALID; + KeyState->KeyToggleState =3D EFI_TOGGLE_STATE_VALID; + + if (UsbKeyboardDevice->LeftCtrlOn) { + KeyState->KeyShiftState |=3D EFI_LEFT_CONTROL_PRESSED; + } + if (UsbKeyboardDevice->RightCtrlOn) { + KeyState->KeyShiftState |=3D EFI_RIGHT_CONTROL_PRESSED; + } + if (UsbKeyboardDevice->LeftAltOn) { + KeyState->KeyShiftState |=3D EFI_LEFT_ALT_PRESSED; + } + if (UsbKeyboardDevice->RightAltOn) { + KeyState->KeyShiftState |=3D EFI_RIGHT_ALT_PRESSED; + } + if (UsbKeyboardDevice->LeftShiftOn) { + KeyState->KeyShiftState |=3D EFI_LEFT_SHIFT_PRESSED; + } + if (UsbKeyboardDevice->RightShiftOn) { + KeyState->KeyShiftState |=3D EFI_RIGHT_SHIFT_PRESSED; + } + if (UsbKeyboardDevice->LeftLogoOn) { + KeyState->KeyShiftState |=3D EFI_LEFT_LOGO_PRESSED; + } + if (UsbKeyboardDevice->RightLogoOn) { + KeyState->KeyShiftState |=3D EFI_RIGHT_LOGO_PRESSED; + } + if (UsbKeyboardDevice->MenuKeyOn) { + KeyState->KeyShiftState |=3D EFI_MENU_KEY_PRESSED; + } + if (UsbKeyboardDevice->SysReqOn) { + KeyState->KeyShiftState |=3D EFI_SYS_REQ_PRESSED; + } + + if (UsbKeyboardDevice->ScrollOn) { + KeyState->KeyToggleState |=3D EFI_SCROLL_LOCK_ACTIVE; + } + if (UsbKeyboardDevice->NumLockOn) { + KeyState->KeyToggleState |=3D EFI_NUM_LOCK_ACTIVE; + } + if (UsbKeyboardDevice->CapsOn) { + KeyState->KeyToggleState |=3D EFI_CAPS_LOCK_ACTIVE; + } + if (UsbKeyboardDevice->IsSupportPartialKey) { + KeyState->KeyToggleState |=3D EFI_KEY_STATE_EXPOSED; + } +} =20 /** Converts USB Keycode ranging from 0x4 to 0x65 to EFI_INPUT_KEY. @@ -1619,52 +1678,8 @@ UsbKeyCodeToEfiInputKey ( // // Save Shift/Toggle state // - KeyData->KeyState.KeyShiftState =3D EFI_SHIFT_STATE_VALID; - KeyData->KeyState.KeyToggleState =3D EFI_TOGGLE_STATE_VALID; + InitializeKeyState (UsbKeyboardDevice, &KeyData->KeyState); =20 - if (UsbKeyboardDevice->LeftCtrlOn) { - KeyData->KeyState.KeyShiftState |=3D EFI_LEFT_CONTROL_PRESSED; - } - if (UsbKeyboardDevice->RightCtrlOn) { - KeyData->KeyState.KeyShiftState |=3D EFI_RIGHT_CONTROL_PRESSED; - } - if (UsbKeyboardDevice->LeftAltOn) { - KeyData->KeyState.KeyShiftState |=3D EFI_LEFT_ALT_PRESSED; - } - if (UsbKeyboardDevice->RightAltOn) { - KeyData->KeyState.KeyShiftState |=3D EFI_RIGHT_ALT_PRESSED; - } - if (UsbKeyboardDevice->LeftShiftOn) { - KeyData->KeyState.KeyShiftState |=3D EFI_LEFT_SHIFT_PRESSED; - } - if (UsbKeyboardDevice->RightShiftOn) { - KeyData->KeyState.KeyShiftState |=3D EFI_RIGHT_SHIFT_PRESSED; - } - if (UsbKeyboardDevice->LeftLogoOn) { - KeyData->KeyState.KeyShiftState |=3D EFI_LEFT_LOGO_PRESSED; - } - if (UsbKeyboardDevice->RightLogoOn) { - KeyData->KeyState.KeyShiftState |=3D EFI_RIGHT_LOGO_PRESSED; - } - if (UsbKeyboardDevice->MenuKeyOn) { - KeyData->KeyState.KeyShiftState |=3D EFI_MENU_KEY_PRESSED; - } - if (UsbKeyboardDevice->SysReqOn) { - KeyData->KeyState.KeyShiftState |=3D EFI_SYS_REQ_PRESSED; - } - - if (UsbKeyboardDevice->ScrollOn) { - KeyData->KeyState.KeyToggleState |=3D EFI_SCROLL_LOCK_ACTIVE; - } - if (UsbKeyboardDevice->NumLockOn) { - KeyData->KeyState.KeyToggleState |=3D EFI_NUM_LOCK_ACTIVE; - } - if (UsbKeyboardDevice->CapsOn) { - KeyData->KeyState.KeyToggleState |=3D EFI_CAPS_LOCK_ACTIVE; - } - if (UsbKeyboardDevice->IsSupportPartialKey) { - KeyData->KeyState.KeyToggleState |=3D EFI_KEY_STATE_EXPOSED; - } // // Signal KeyNotify process event if this key pressed matches any key re= gistered. // diff --git a/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.h b/MdeModulePkg/Bus/Us= b/UsbKbDxe/KeyBoard.h index b3eb3e462f..87f2132eac 100644 --- a/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.h +++ b/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.h @@ -1,7 +1,7 @@ /** @file Function prototype for USB Keyboard Driver. =20 -Copyright (c) 2004 - 2013, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 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 @@ -317,4 +317,16 @@ SetKeyLED ( IN USB_KB_DEV *UsbKeyboardDevice ); =20 +/** + Initialize the key state. + + @param UsbKeyboardDevice The USB_KB_DEV instance. + @param KeyState A pointer to receive the key state informa= tion. +**/ +VOID +InitializeKeyState ( + IN USB_KB_DEV *UsbKeyboardDevice, + OUT EFI_KEY_STATE *KeyState + ); + #endif --=20 2.15.1.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel