public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] Nt32Pkg/NtGopInput: ReadKeyStrokeEx always return key state
@ 2018-04-19 10:41 Ruiyu Ni
  2018-04-20  2:31 ` Zeng, Star
  0 siblings, 1 reply; 2+ messages in thread
From: Ruiyu Ni @ 2018-04-19 10:41 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng

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>
Cc: Star Zeng <star.zeng@intel.com>
---
 Nt32Pkg/WinNtGopDxe/WinNtGopInput.c | 79 ++++++++++++++++++++++---------------
 1 file changed, 48 insertions(+), 31 deletions(-)

diff --git a/Nt32Pkg/WinNtGopDxe/WinNtGopInput.c b/Nt32Pkg/WinNtGopDxe/WinNtGopInput.c
index 6a0f4b7892..b19dfdc2ec 100644
--- a/Nt32Pkg/WinNtGopDxe/WinNtGopInput.c
+++ b/Nt32Pkg/WinNtGopDxe/WinNtGopInput.c
@@ -1,6 +1,6 @@
 /** @file
 
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 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
@@ -270,73 +270,87 @@ WinNtGopSimpleTextInTimerHandler (
 }
 
 /**
-  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.
 
+  @param  Private               The GOP_PRIVATE_DATA instance.
+  @param  KeyState              A pointer to receive the key state information.
 **/
-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 = Key;
-
-  KeyData.KeyState.KeyShiftState  = EFI_SHIFT_STATE_VALID;
-  KeyData.KeyState.KeyToggleState = EFI_TOGGLE_STATE_VALID;
+  KeyState->KeyShiftState  = EFI_SHIFT_STATE_VALID;
+  KeyState->KeyToggleState = EFI_TOGGLE_STATE_VALID;
 
   //
   // Record Key shift state and toggle state
   //
   if (Private->LeftCtrl) {
-    KeyData.KeyState.KeyShiftState  |= EFI_LEFT_CONTROL_PRESSED;
+    KeyState->KeyShiftState  |= EFI_LEFT_CONTROL_PRESSED;
   }
   if (Private->RightCtrl) {
-    KeyData.KeyState.KeyShiftState  |= EFI_RIGHT_CONTROL_PRESSED;
+    KeyState->KeyShiftState  |= EFI_RIGHT_CONTROL_PRESSED;
   }
   if (Private->LeftAlt) {
-    KeyData.KeyState.KeyShiftState  |= EFI_LEFT_ALT_PRESSED;
+    KeyState->KeyShiftState  |= EFI_LEFT_ALT_PRESSED;
   }
   if (Private->RightAlt) {
-    KeyData.KeyState.KeyShiftState  |= EFI_RIGHT_ALT_PRESSED;
+    KeyState->KeyShiftState  |= EFI_RIGHT_ALT_PRESSED;
   }
   if (Private->LeftShift) {
-    KeyData.KeyState.KeyShiftState  |= EFI_LEFT_SHIFT_PRESSED;
+    KeyState->KeyShiftState  |= EFI_LEFT_SHIFT_PRESSED;
   }
   if (Private->RightShift) {
-    KeyData.KeyState.KeyShiftState  |= EFI_RIGHT_SHIFT_PRESSED;
+    KeyState->KeyShiftState  |= EFI_RIGHT_SHIFT_PRESSED;
   }
   if (Private->LeftLogo) {
-    KeyData.KeyState.KeyShiftState  |= EFI_LEFT_LOGO_PRESSED;
+    KeyState->KeyShiftState  |= EFI_LEFT_LOGO_PRESSED;
   }
   if (Private->RightLogo) {
-    KeyData.KeyState.KeyShiftState  |= EFI_RIGHT_LOGO_PRESSED;
+    KeyState->KeyShiftState  |= EFI_RIGHT_LOGO_PRESSED;
   }
   if (Private->Menu) {
-    KeyData.KeyState.KeyShiftState  |= EFI_MENU_KEY_PRESSED;
+    KeyState->KeyShiftState  |= EFI_MENU_KEY_PRESSED;
   }
   if (Private->SysReq) {
-    KeyData.KeyState.KeyShiftState  |= EFI_SYS_REQ_PRESSED;
+    KeyState->KeyShiftState  |= EFI_SYS_REQ_PRESSED;
   }
   if (Private->CapsLock) {
-    KeyData.KeyState.KeyToggleState |= EFI_CAPS_LOCK_ACTIVE;
+    KeyState->KeyToggleState |= EFI_CAPS_LOCK_ACTIVE;
   }
   if (Private->NumLock) {
-    KeyData.KeyState.KeyToggleState |= EFI_NUM_LOCK_ACTIVE;
+    KeyState->KeyToggleState |= EFI_NUM_LOCK_ACTIVE;
   }
   if (Private->ScrollLock) {
-    KeyData.KeyState.KeyToggleState |= EFI_SCROLL_LOCK_ACTIVE;
+    KeyState->KeyToggleState |= EFI_SCROLL_LOCK_ACTIVE;
   }
   if (Private->IsPartialKeySupport) {
-    KeyData.KeyState.KeyToggleState |= EFI_KEY_STATE_EXPOSED;
+    KeyState->KeyToggleState |= 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 = Key;
+  InitializeKeyState (Private, &KeyData.KeyState);
 
   //
   // Convert Ctrl+[1-26] to Ctrl+[A-Z]
@@ -503,6 +517,9 @@ GopPrivateReadKeyStrokeWorker (
   //
   WinNtGopSimpleTextInTimerHandler (NULL, Private);
 
+  ZeroMem (&KeyData->Key, sizeof (KeyData->Key));
+  InitializeKeyState (Private, &KeyData->KeyState);
+
   Status  = GopPrivateCheckQ (&Private->QueueForRead);
   if (!EFI_ERROR (Status)) {
     //
-- 
2.16.1.windows.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Nt32Pkg/NtGopInput: ReadKeyStrokeEx always return key state
  2018-04-19 10:41 [PATCH] Nt32Pkg/NtGopInput: ReadKeyStrokeEx always return key state Ruiyu Ni
@ 2018-04-20  2:31 ` Zeng, Star
  0 siblings, 0 replies; 2+ messages in thread
From: Zeng, Star @ 2018-04-20  2:31 UTC (permalink / raw)
  To: Ni, Ruiyu, edk2-devel@lists.01.org; +Cc: Zeng, Star

Reviewed-by: Star Zeng <star.zeng@intel.com>

Thanks,
Star
-----Original Message-----
From: Ni, Ruiyu 
Sent: Thursday, April 19, 2018 6:42 PM
To: edk2-devel@lists.01.org
Cc: Zeng, Star <star.zeng@intel.com>
Subject: [PATCH] Nt32Pkg/NtGopInput: 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>
Cc: Star Zeng <star.zeng@intel.com>
---
 Nt32Pkg/WinNtGopDxe/WinNtGopInput.c | 79 ++++++++++++++++++++++---------------
 1 file changed, 48 insertions(+), 31 deletions(-)

diff --git a/Nt32Pkg/WinNtGopDxe/WinNtGopInput.c b/Nt32Pkg/WinNtGopDxe/WinNtGopInput.c
index 6a0f4b7892..b19dfdc2ec 100644
--- a/Nt32Pkg/WinNtGopDxe/WinNtGopInput.c
+++ b/Nt32Pkg/WinNtGopDxe/WinNtGopInput.c
@@ -1,6 +1,6 @@
 /** @file
 
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 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
@@ -270,73 +270,87 @@ WinNtGopSimpleTextInTimerHandler (
 }
 
 /**
-  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.
 
+  @param  Private               The GOP_PRIVATE_DATA instance.
+  @param  KeyState              A pointer to receive the key state information.
 **/
-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 = Key;
-
-  KeyData.KeyState.KeyShiftState  = EFI_SHIFT_STATE_VALID;
-  KeyData.KeyState.KeyToggleState = EFI_TOGGLE_STATE_VALID;
+  KeyState->KeyShiftState  = EFI_SHIFT_STATE_VALID;
+  KeyState->KeyToggleState = EFI_TOGGLE_STATE_VALID;
 
   //
   // Record Key shift state and toggle state
   //
   if (Private->LeftCtrl) {
-    KeyData.KeyState.KeyShiftState  |= EFI_LEFT_CONTROL_PRESSED;
+    KeyState->KeyShiftState  |= EFI_LEFT_CONTROL_PRESSED;
   }
   if (Private->RightCtrl) {
-    KeyData.KeyState.KeyShiftState  |= EFI_RIGHT_CONTROL_PRESSED;
+    KeyState->KeyShiftState  |= EFI_RIGHT_CONTROL_PRESSED;
   }
   if (Private->LeftAlt) {
-    KeyData.KeyState.KeyShiftState  |= EFI_LEFT_ALT_PRESSED;
+    KeyState->KeyShiftState  |= EFI_LEFT_ALT_PRESSED;
   }
   if (Private->RightAlt) {
-    KeyData.KeyState.KeyShiftState  |= EFI_RIGHT_ALT_PRESSED;
+    KeyState->KeyShiftState  |= EFI_RIGHT_ALT_PRESSED;
   }
   if (Private->LeftShift) {
-    KeyData.KeyState.KeyShiftState  |= EFI_LEFT_SHIFT_PRESSED;
+    KeyState->KeyShiftState  |= EFI_LEFT_SHIFT_PRESSED;
   }
   if (Private->RightShift) {
-    KeyData.KeyState.KeyShiftState  |= EFI_RIGHT_SHIFT_PRESSED;
+    KeyState->KeyShiftState  |= EFI_RIGHT_SHIFT_PRESSED;
   }
   if (Private->LeftLogo) {
-    KeyData.KeyState.KeyShiftState  |= EFI_LEFT_LOGO_PRESSED;
+    KeyState->KeyShiftState  |= EFI_LEFT_LOGO_PRESSED;
   }
   if (Private->RightLogo) {
-    KeyData.KeyState.KeyShiftState  |= EFI_RIGHT_LOGO_PRESSED;
+    KeyState->KeyShiftState  |= EFI_RIGHT_LOGO_PRESSED;
   }
   if (Private->Menu) {
-    KeyData.KeyState.KeyShiftState  |= EFI_MENU_KEY_PRESSED;
+    KeyState->KeyShiftState  |= EFI_MENU_KEY_PRESSED;
   }
   if (Private->SysReq) {
-    KeyData.KeyState.KeyShiftState  |= EFI_SYS_REQ_PRESSED;
+    KeyState->KeyShiftState  |= EFI_SYS_REQ_PRESSED;
   }
   if (Private->CapsLock) {
-    KeyData.KeyState.KeyToggleState |= EFI_CAPS_LOCK_ACTIVE;
+    KeyState->KeyToggleState |= EFI_CAPS_LOCK_ACTIVE;
   }
   if (Private->NumLock) {
-    KeyData.KeyState.KeyToggleState |= EFI_NUM_LOCK_ACTIVE;
+    KeyState->KeyToggleState |= EFI_NUM_LOCK_ACTIVE;
   }
   if (Private->ScrollLock) {
-    KeyData.KeyState.KeyToggleState |= EFI_SCROLL_LOCK_ACTIVE;
+    KeyState->KeyToggleState |= EFI_SCROLL_LOCK_ACTIVE;
   }
   if (Private->IsPartialKeySupport) {
-    KeyData.KeyState.KeyToggleState |= EFI_KEY_STATE_EXPOSED;
+    KeyState->KeyToggleState |= 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 = Key;
+  InitializeKeyState (Private, &KeyData.KeyState);
 
   //
   // Convert Ctrl+[1-26] to Ctrl+[A-Z]
@@ -503,6 +517,9 @@ GopPrivateReadKeyStrokeWorker (
   //
   WinNtGopSimpleTextInTimerHandler (NULL, Private);
 
+  ZeroMem (&KeyData->Key, sizeof (KeyData->Key));
+  InitializeKeyState (Private, &KeyData->KeyState);
+
   Status  = GopPrivateCheckQ (&Private->QueueForRead);
   if (!EFI_ERROR (Status)) {
     //
-- 
2.16.1.windows.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-04-20  2:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-19 10:41 [PATCH] Nt32Pkg/NtGopInput: ReadKeyStrokeEx always return key state Ruiyu Ni
2018-04-20  2:31 ` Zeng, Star

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox