diff options
author | Ruiyu Ni <ruiyu.ni@intel.com> | 2018-01-12 19:29:32 +0800 |
---|---|---|
committer | Ruiyu Ni <ruiyu.ni@intel.com> | 2018-02-01 14:03:58 +0800 |
commit | c095341cc4c09a59ba285fe3adaa37425721479d (patch) | |
tree | 9f93953cd1b8c1a765f148cb9f25a0239e302d4b | |
parent | 20ddbc133f679b7895dfdaf2fd58ec4c8183a1d8 (diff) | |
download | edk2-c095341cc4c09a59ba285fe3adaa37425721479d.zip edk2-c095341cc4c09a59ba285fe3adaa37425721479d.tar.gz edk2-c095341cc4c09a59ba285fe3adaa37425721479d.tar.bz2 |
MdeModulePkg/UsbKb: ReadKeyStrokeEx always return key state
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 <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
-rw-r--r-- | MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c | 4 | ||||
-rw-r--r-- | MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c | 107 | ||||
-rw-r--r-- | 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 fb2bf3f..722350f 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 Input
Protocol and Simple Text Input Ex Protocol.
-Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
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 ( }
if (IsQueueEmpty (&UsbKeyboardDevice->EfiKeyQueue)) {
+ ZeroMem (&KeyData->Key, sizeof (KeyData->Key));
+ InitializeKeyState (UsbKeyboardDevice, &KeyData->KeyState);
return EFI_NOT_READY;
}
diff --git a/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c b/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c index 91913d4..d140311 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.
-Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
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;
}
+/**
+ Initialize the key state.
+
+ @param UsbKeyboardDevice The USB_KB_DEV instance.
+ @param KeyState A pointer to receive the key state information.
+**/
+VOID
+InitializeKeyState (
+ IN USB_KB_DEV *UsbKeyboardDevice,
+ OUT EFI_KEY_STATE *KeyState
+ )
+{
+ KeyState->KeyShiftState = EFI_SHIFT_STATE_VALID;
+ KeyState->KeyToggleState = EFI_TOGGLE_STATE_VALID;
+
+ if (UsbKeyboardDevice->LeftCtrlOn) {
+ KeyState->KeyShiftState |= EFI_LEFT_CONTROL_PRESSED;
+ }
+ if (UsbKeyboardDevice->RightCtrlOn) {
+ KeyState->KeyShiftState |= EFI_RIGHT_CONTROL_PRESSED;
+ }
+ if (UsbKeyboardDevice->LeftAltOn) {
+ KeyState->KeyShiftState |= EFI_LEFT_ALT_PRESSED;
+ }
+ if (UsbKeyboardDevice->RightAltOn) {
+ KeyState->KeyShiftState |= EFI_RIGHT_ALT_PRESSED;
+ }
+ if (UsbKeyboardDevice->LeftShiftOn) {
+ KeyState->KeyShiftState |= EFI_LEFT_SHIFT_PRESSED;
+ }
+ if (UsbKeyboardDevice->RightShiftOn) {
+ KeyState->KeyShiftState |= EFI_RIGHT_SHIFT_PRESSED;
+ }
+ if (UsbKeyboardDevice->LeftLogoOn) {
+ KeyState->KeyShiftState |= EFI_LEFT_LOGO_PRESSED;
+ }
+ if (UsbKeyboardDevice->RightLogoOn) {
+ KeyState->KeyShiftState |= EFI_RIGHT_LOGO_PRESSED;
+ }
+ if (UsbKeyboardDevice->MenuKeyOn) {
+ KeyState->KeyShiftState |= EFI_MENU_KEY_PRESSED;
+ }
+ if (UsbKeyboardDevice->SysReqOn) {
+ KeyState->KeyShiftState |= EFI_SYS_REQ_PRESSED;
+ }
+
+ if (UsbKeyboardDevice->ScrollOn) {
+ KeyState->KeyToggleState |= EFI_SCROLL_LOCK_ACTIVE;
+ }
+ if (UsbKeyboardDevice->NumLockOn) {
+ KeyState->KeyToggleState |= EFI_NUM_LOCK_ACTIVE;
+ }
+ if (UsbKeyboardDevice->CapsOn) {
+ KeyState->KeyToggleState |= EFI_CAPS_LOCK_ACTIVE;
+ }
+ if (UsbKeyboardDevice->IsSupportPartialKey) {
+ KeyState->KeyToggleState |= EFI_KEY_STATE_EXPOSED;
+ }
+}
/**
Converts USB Keycode ranging from 0x4 to 0x65 to EFI_INPUT_KEY.
@@ -1619,52 +1678,8 @@ UsbKeyCodeToEfiInputKey ( //
// Save Shift/Toggle state
//
- KeyData->KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID;
- KeyData->KeyState.KeyToggleState = EFI_TOGGLE_STATE_VALID;
+ InitializeKeyState (UsbKeyboardDevice, &KeyData->KeyState);
- if (UsbKeyboardDevice->LeftCtrlOn) {
- KeyData->KeyState.KeyShiftState |= EFI_LEFT_CONTROL_PRESSED;
- }
- if (UsbKeyboardDevice->RightCtrlOn) {
- KeyData->KeyState.KeyShiftState |= EFI_RIGHT_CONTROL_PRESSED;
- }
- if (UsbKeyboardDevice->LeftAltOn) {
- KeyData->KeyState.KeyShiftState |= EFI_LEFT_ALT_PRESSED;
- }
- if (UsbKeyboardDevice->RightAltOn) {
- KeyData->KeyState.KeyShiftState |= EFI_RIGHT_ALT_PRESSED;
- }
- if (UsbKeyboardDevice->LeftShiftOn) {
- KeyData->KeyState.KeyShiftState |= EFI_LEFT_SHIFT_PRESSED;
- }
- if (UsbKeyboardDevice->RightShiftOn) {
- KeyData->KeyState.KeyShiftState |= EFI_RIGHT_SHIFT_PRESSED;
- }
- if (UsbKeyboardDevice->LeftLogoOn) {
- KeyData->KeyState.KeyShiftState |= EFI_LEFT_LOGO_PRESSED;
- }
- if (UsbKeyboardDevice->RightLogoOn) {
- KeyData->KeyState.KeyShiftState |= EFI_RIGHT_LOGO_PRESSED;
- }
- if (UsbKeyboardDevice->MenuKeyOn) {
- KeyData->KeyState.KeyShiftState |= EFI_MENU_KEY_PRESSED;
- }
- if (UsbKeyboardDevice->SysReqOn) {
- KeyData->KeyState.KeyShiftState |= EFI_SYS_REQ_PRESSED;
- }
-
- if (UsbKeyboardDevice->ScrollOn) {
- KeyData->KeyState.KeyToggleState |= EFI_SCROLL_LOCK_ACTIVE;
- }
- if (UsbKeyboardDevice->NumLockOn) {
- KeyData->KeyState.KeyToggleState |= EFI_NUM_LOCK_ACTIVE;
- }
- if (UsbKeyboardDevice->CapsOn) {
- KeyData->KeyState.KeyToggleState |= EFI_CAPS_LOCK_ACTIVE;
- }
- if (UsbKeyboardDevice->IsSupportPartialKey) {
- KeyData->KeyState.KeyToggleState |= EFI_KEY_STATE_EXPOSED;
- }
//
// Signal KeyNotify process event if this key pressed matches any key registered.
//
diff --git a/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.h b/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.h index b3eb3e4..87f2132 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.
-Copyright (c) 2004 - 2013, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
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
);
+/**
+ Initialize the key state.
+
+ @param UsbKeyboardDevice The USB_KB_DEV instance.
+ @param KeyState A pointer to receive the key state information.
+**/
+VOID
+InitializeKeyState (
+ IN USB_KB_DEV *UsbKeyboardDevice,
+ OUT EFI_KEY_STATE *KeyState
+ );
+
#endif
|