IntelFrameworkModule/ThunkKb: ReadKeyStrokeEx always return key state
authorRuiyu Ni <ruiyu.ni@intel.com>
Fri, 19 Jan 2018 07:59:38 +0000 (15:59 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Thu, 1 Feb 2018 06:04:12 +0000 (14:04 +0800)
Today's implementation only return key state when there is a 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>
IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/BiosKeyboard.c
IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/BiosKeyboard.h

index ec52589..ac8e236 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   ConsoleOut Routines that speak VGA.\r
 \r
-Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
 \r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions\r
@@ -269,7 +269,9 @@ BiosKeyboardDriverBindingStart (
   BiosKeyboardPrivate->StatusRegisterAddress      = KEYBOARD_8042_STATUS_REGISTER;\r
   BiosKeyboardPrivate->CommandRegisterAddress     = KEYBOARD_8042_COMMAND_REGISTER;\r
   BiosKeyboardPrivate->ExtendedKeyboard           = TRUE;\r
-  \r
+\r
+  BiosKeyboardPrivate->KeyState.KeyShiftState     = 0;\r
+  BiosKeyboardPrivate->KeyState.KeyToggleState    = 0;\r
   BiosKeyboardPrivate->Queue.Front                = 0;\r
   BiosKeyboardPrivate->Queue.Rear                 = 0;\r
   BiosKeyboardPrivate->QueueForNotify.Front       = 0;\r
@@ -978,6 +980,8 @@ KeyboardReadKeyStrokeWorker (
   //\r
   Status = CheckQueue (&BiosKeyboardPrivate->Queue);\r
   if (EFI_ERROR (Status)) {\r
+    ZeroMem (&KeyData->Key, sizeof (KeyData->Key));\r
+    CopyMem (&KeyData->KeyState, &BiosKeyboardPrivate->KeyState, sizeof (EFI_KEY_STATE));\r
     gBS->RestoreTPL (OldTpl);\r
     return EFI_NOT_READY;\r
   }\r
@@ -1986,6 +1990,12 @@ BiosKeyboardTimerHandler (
   }\r
 \r
   Enqueue (&BiosKeyboardPrivate->Queue, &KeyData);\r
+\r
+  //\r
+  // Save the current key state\r
+  //\r
+  CopyMem (&BiosKeyboardPrivate->KeyState, &KeyData.KeyState, sizeof (EFI_KEY_STATE));\r
+\r
   //\r
   // Leave critical section and return\r
   //\r
index c64ec00..5300eaa 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 \r
-Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
 \r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions\r
@@ -220,7 +220,8 @@ typedef struct {
   UINT16                                      StatusRegisterAddress;\r
   UINT16                                      CommandRegisterAddress;\r
   BOOLEAN                                     ExtendedKeyboard;\r
-  \r
+\r
+  EFI_KEY_STATE                               KeyState;\r
   //\r
   // Buffer storing EFI_KEY_DATA\r
   //\r