]> git.proxmox.com Git - mirror_edk2.git/commitdiff
1. Add Partial Keystroke Support in UsbKb drivers. See the Uefi2.3.1a chapter 11.2
authorqianouyang <qianouyang@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 30 Sep 2011 07:28:16 +0000 (07:28 +0000)
committerqianouyang <qianouyang@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 30 Sep 2011 07:28:16 +0000 (07:28 +0000)
Signed-off-by: qianouyang
Reviewed-by: niruiyu vanjeff
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12494 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c
MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.h
MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c

index fa1c7e076b9886d8c092fa5ec26c46ddc0a5df0a..c576b70f46656c1abe614050172ef080a6cc4640 100644 (file)
@@ -259,9 +259,9 @@ USBKeyboardDriverBindingStart (
   UsbKeyboardDevice->SimpleInputEx.SetState            = USBKeyboardSetState;\r
   UsbKeyboardDevice->SimpleInputEx.RegisterKeyNotify   = USBKeyboardRegisterKeyNotify;\r
   UsbKeyboardDevice->SimpleInputEx.UnregisterKeyNotify = USBKeyboardUnregisterKeyNotify;\r
-  \r
+\r
   InitializeListHead (&UsbKeyboardDevice->NotifyList);\r
-  \r
+\r
   Status = gBS->CreateEvent (\r
                   EVT_TIMER | EVT_NOTIFY_SIGNAL,\r
                   TPL_NOTIFY,\r
@@ -546,7 +546,7 @@ USBKeyboardDriverBindingStop (
 \r
   DestroyQueue (&UsbKeyboardDevice->UsbKeyQueue);\r
   DestroyQueue (&UsbKeyboardDevice->EfiKeyQueue);\r
-  \r
+\r
   FreePool (UsbKeyboardDevice);\r
 \r
   return Status;\r
@@ -676,14 +676,25 @@ USBKeyboardReadKeyStroke (
 \r
   UsbKeyboardDevice = USB_KB_DEV_FROM_THIS (This);\r
 \r
-  Status = USBKeyboardReadKeyStrokeWorker (UsbKeyboardDevice, &KeyData);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
+  //\r
+  // Considering if the partial keystroke is enabled, there maybe a partial\r
+  // keystroke in the queue, so here skip the partial keystroke and get the\r
+  // next key from the queue\r
+  //\r
+  while (1) {\r
+    Status = USBKeyboardReadKeyStrokeWorker (UsbKeyboardDevice, &KeyData);\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+    //\r
+    // SimpleTextIn Protocol doesn't support partial keystroke;\r
+    //\r
+    if (KeyData.Key.ScanCode == CHAR_NULL && KeyData.Key.UnicodeChar == SCAN_NULL) {\r
+      continue;\r
+    }\r
+    CopyMem (Key, &KeyData.Key, sizeof (EFI_INPUT_KEY));\r
+    return EFI_SUCCESS;\r
   }\r
-\r
-  CopyMem (Key, &KeyData.Key, sizeof (EFI_INPUT_KEY));\r
-\r
-  return EFI_SUCCESS;\r
 }\r
 \r
 \r
@@ -703,15 +714,42 @@ USBKeyboardWaitForKey (
   )\r
 {\r
   USB_KB_DEV  *UsbKeyboardDevice;\r
+  EFI_KEY_DATA KeyData;\r
+  EFI_TPL      OldTpl;\r
 \r
   UsbKeyboardDevice = (USB_KB_DEV *) Context;\r
 \r
-  if (!IsQueueEmpty (&UsbKeyboardDevice->EfiKeyQueue)) {\r
+  //\r
+  // Enter critical section\r
+  //  \r
+  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
+  \r
+  //\r
+  // WaitforKey doesn't suppor the partial key.\r
+  // Considering if the partial keystroke is enabled, there maybe a partial\r
+  // keystroke in the queue, so here skip the partial keystroke and get the\r
+  // next key from the queue\r
+  //\r
+  while (!IsQueueEmpty (&UsbKeyboardDevice->EfiKeyQueue)) {\r
     //\r
     // If there is pending key, signal the event.\r
     //\r
+    CopyMem (\r
+      &KeyData,\r
+      UsbKeyboardDevice->EfiKeyQueue.Buffer[UsbKeyboardDevice->EfiKeyQueue.Head],\r
+      sizeof (EFI_KEY_DATA)\r
+      );\r
+    if (KeyData.Key.ScanCode == SCAN_NULL && KeyData.Key.UnicodeChar == CHAR_NULL) {\r
+      Dequeue (&UsbKeyboardDevice->EfiKeyQueue, &KeyData, sizeof (EFI_KEY_DATA));\r
+      continue;\r
+    }\r
     gBS->SignalEvent (Event);\r
+    break;\r
   }\r
+  //\r
+  // Leave critical section and return\r
+  //\r
+  gBS->RestoreTPL (OldTpl);\r
 }\r
 \r
 /**\r
@@ -733,7 +771,7 @@ USBKeyboardTimerHandler (
   EFI_KEY_DATA                  KeyData;\r
 \r
   UsbKeyboardDevice = (USB_KB_DEV *) Context;\r
-  \r
+\r
   //\r
   // Fetch raw data from the USB keyboard buffer,\r
   // and translate it into USB keycode.\r
@@ -783,7 +821,7 @@ KbdFreeNotifyList (
     RemoveEntryList (Link);\r
     FreePool (NotifyNode);\r
   }\r
-  \r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -804,29 +842,29 @@ IsKeyRegistered (
   )\r
 {\r
   ASSERT (RegsiteredData != NULL && InputData != NULL);\r
-  \r
+\r
   if ((RegsiteredData->Key.ScanCode    != InputData->Key.ScanCode) ||\r
       (RegsiteredData->Key.UnicodeChar != InputData->Key.UnicodeChar)) {\r
-    return FALSE;  \r
-  }      \r
-  \r
+    return FALSE;\r
+  }\r
+\r
   //\r
   // Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored.\r
   //\r
   if (RegsiteredData->KeyState.KeyShiftState != 0 &&\r
       RegsiteredData->KeyState.KeyShiftState != InputData->KeyState.KeyShiftState) {\r
-    return FALSE;    \r
-  }   \r
+    return FALSE;\r
+  }\r
   if (RegsiteredData->KeyState.KeyToggleState != 0 &&\r
       RegsiteredData->KeyState.KeyToggleState != InputData->KeyState.KeyToggleState) {\r
-    return FALSE;    \r
-  }     \r
-  \r
+    return FALSE;\r
+  }\r
+\r
   return TRUE;\r
 }\r
 \r
 //\r
-// Simple Text Input Ex protocol functions \r
+// Simple Text Input Ex protocol functions\r
 //\r
 /**\r
   Resets the input device hardware.\r
@@ -867,6 +905,9 @@ USBKeyboardResetEx (
     return EFI_DEVICE_ERROR;\r
   }\r
 \r
+  UsbKeyboardDevice->KeyState.KeyShiftState  = EFI_SHIFT_STATE_VALID;\r
+  UsbKeyboardDevice->KeyState.KeyToggleState = EFI_TOGGLE_STATE_VALID;\r
+\r
   return EFI_SUCCESS;\r
 \r
 }\r
@@ -901,7 +942,7 @@ USBKeyboardReadKeyStrokeEx (
   UsbKeyboardDevice = TEXT_INPUT_EX_USB_KB_DEV_FROM_THIS (This);\r
 \r
   return USBKeyboardReadKeyStrokeWorker (UsbKeyboardDevice, KeyData);\r
-  \r
+\r
 }\r
 \r
 /**\r
@@ -933,7 +974,8 @@ USBKeyboardSetState (
 \r
   UsbKeyboardDevice = TEXT_INPUT_EX_USB_KB_DEV_FROM_THIS (This);\r
 \r
-  if ((*KeyToggleState & EFI_TOGGLE_STATE_VALID) != EFI_TOGGLE_STATE_VALID) {\r
+  if (((UsbKeyboardDevice->KeyState.KeyToggleState & EFI_TOGGLE_STATE_VALID) != EFI_TOGGLE_STATE_VALID) ||\r
+      ((*KeyToggleState & EFI_TOGGLE_STATE_VALID) != EFI_TOGGLE_STATE_VALID)) {\r
     return EFI_UNSUPPORTED;\r
   }\r
 \r
@@ -944,7 +986,8 @@ USBKeyboardSetState (
   UsbKeyboardDevice->ScrollOn   = FALSE;\r
   UsbKeyboardDevice->NumLockOn  = FALSE;\r
   UsbKeyboardDevice->CapsOn     = FALSE;\r
\r
+  UsbKeyboardDevice->IsSupportPartialKey = FALSE;\r
+\r
   if ((*KeyToggleState & EFI_SCROLL_LOCK_ACTIVE) == EFI_SCROLL_LOCK_ACTIVE) {\r
     UsbKeyboardDevice->ScrollOn = TRUE;\r
   }\r
@@ -954,11 +997,16 @@ USBKeyboardSetState (
   if ((*KeyToggleState & EFI_CAPS_LOCK_ACTIVE) == EFI_CAPS_LOCK_ACTIVE) {\r
     UsbKeyboardDevice->CapsOn = TRUE;\r
   }\r
+  if ((*KeyToggleState & EFI_KEY_STATE_EXPOSED) == EFI_KEY_STATE_EXPOSED) {\r
+    UsbKeyboardDevice->IsSupportPartialKey = TRUE;\r
+  }\r
 \r
   SetKeyLED (UsbKeyboardDevice);\r
 \r
+  UsbKeyboardDevice->KeyState.KeyToggleState = *KeyToggleState;\r
+\r
   return EFI_SUCCESS;\r
-  \r
+\r
 }\r
 \r
 /**\r
@@ -989,7 +1037,7 @@ USBKeyboardRegisterKeyNotify (
   KEYBOARD_CONSOLE_IN_EX_NOTIFY     *NewNotify;\r
   LIST_ENTRY                        *Link;\r
   LIST_ENTRY                        *NotifyList;\r
-  KEYBOARD_CONSOLE_IN_EX_NOTIFY     *CurrentNotify;  \r
+  KEYBOARD_CONSOLE_IN_EX_NOTIFY     *CurrentNotify;\r
 \r
   if (KeyData == NULL || NotifyHandle == NULL || KeyNotificationFunction == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
@@ -1001,43 +1049,43 @@ USBKeyboardRegisterKeyNotify (
   // Return EFI_SUCCESS if the (KeyData, NotificationFunction) is already registered.\r
   //\r
   NotifyList = &UsbKeyboardDevice->NotifyList;\r
-  \r
+\r
   for (Link = GetFirstNode (NotifyList);\r
        !IsNull (NotifyList, Link);\r
        Link = GetNextNode (NotifyList, Link)) {\r
     CurrentNotify = CR (\r
-                      Link, \r
-                      KEYBOARD_CONSOLE_IN_EX_NOTIFY, \r
-                      NotifyEntry, \r
+                      Link,\r
+                      KEYBOARD_CONSOLE_IN_EX_NOTIFY,\r
+                      NotifyEntry,\r
                       USB_KB_CONSOLE_IN_EX_NOTIFY_SIGNATURE\r
                       );\r
-    if (IsKeyRegistered (&CurrentNotify->KeyData, KeyData)) { \r
+    if (IsKeyRegistered (&CurrentNotify->KeyData, KeyData)) {\r
       if (CurrentNotify->KeyNotificationFn == KeyNotificationFunction) {\r
-        *NotifyHandle = CurrentNotify->NotifyHandle;        \r
+        *NotifyHandle = CurrentNotify->NotifyHandle;\r
         return EFI_SUCCESS;\r
       }\r
     }\r
   }\r
-  \r
+\r
   //\r
   // Allocate resource to save the notification function\r
-  //  \r
+  //\r
   NewNotify = (KEYBOARD_CONSOLE_IN_EX_NOTIFY *) AllocateZeroPool (sizeof (KEYBOARD_CONSOLE_IN_EX_NOTIFY));\r
   if (NewNotify == NULL) {\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
 \r
-  NewNotify->Signature         = USB_KB_CONSOLE_IN_EX_NOTIFY_SIGNATURE;     \r
+  NewNotify->Signature         = USB_KB_CONSOLE_IN_EX_NOTIFY_SIGNATURE;\r
   NewNotify->KeyNotificationFn = KeyNotificationFunction;\r
   NewNotify->NotifyHandle      = (EFI_HANDLE) NewNotify;\r
   CopyMem (&NewNotify->KeyData, KeyData, sizeof (EFI_KEY_DATA));\r
   InsertTailList (&UsbKeyboardDevice->NotifyList, &NewNotify->NotifyEntry);\r
 \r
 \r
-  *NotifyHandle = NewNotify->NotifyHandle;  \r
-  \r
+  *NotifyHandle = NewNotify->NotifyHandle;\r
+\r
   return EFI_SUCCESS;\r
-  \r
+\r
 }\r
 \r
 /**\r
@@ -1064,14 +1112,14 @@ USBKeyboardUnregisterKeyNotify (
 \r
   if (NotificationHandle == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
-  }  \r
+  }\r
 \r
   if (((KEYBOARD_CONSOLE_IN_EX_NOTIFY *) NotificationHandle)->Signature != USB_KB_CONSOLE_IN_EX_NOTIFY_SIGNATURE) {\r
     return EFI_INVALID_PARAMETER;\r
-  } \r
-  \r
+  }\r
+\r
   UsbKeyboardDevice = TEXT_INPUT_EX_USB_KB_DEV_FROM_THIS (This);\r
-  \r
+\r
   //\r
   // Traverse notify list of USB keyboard and remove the entry of NotificationHandle.\r
   //\r
@@ -1080,18 +1128,18 @@ USBKeyboardUnregisterKeyNotify (
        !IsNull (NotifyList, Link);\r
        Link = GetNextNode (NotifyList, Link)) {\r
     CurrentNotify = CR (\r
-                      Link, \r
-                      KEYBOARD_CONSOLE_IN_EX_NOTIFY, \r
-                      NotifyEntry, \r
+                      Link,\r
+                      KEYBOARD_CONSOLE_IN_EX_NOTIFY,\r
+                      NotifyEntry,\r
                       USB_KB_CONSOLE_IN_EX_NOTIFY_SIGNATURE\r
-                      );       \r
+                      );\r
     if (CurrentNotify->NotifyHandle == NotificationHandle) {\r
       //\r
       // Remove the notification function from NotifyList and free resources\r
       //\r
-      RemoveEntryList (&CurrentNotify->NotifyEntry);      \r
+      RemoveEntryList (&CurrentNotify->NotifyEntry);\r
 \r
-      FreePool (CurrentNotify);            \r
+      FreePool (CurrentNotify);\r
       return EFI_SUCCESS;\r
     }\r
   }\r
@@ -1099,6 +1147,6 @@ USBKeyboardUnregisterKeyNotify (
   //\r
   // Cannot find the matching entry in database.\r
   //\r
-  return EFI_INVALID_PARAMETER;  \r
+  return EFI_INVALID_PARAMETER;\r
 }\r
 \r
index 2066c38e7e9a654b8caf0b5ffad66b87efa8e251..3ce383b33ebec2e084beabb7d650a0d73658f08b 100644 (file)
@@ -130,7 +130,7 @@ typedef struct {
   EFI_EVENT                         RepeatTimer;\r
 \r
   EFI_UNICODE_STRING_TABLE          *ControllerNameTable;\r
-  \r
+\r
   BOOLEAN                           LeftCtrlOn;\r
   BOOLEAN                           LeftAltOn;\r
   BOOLEAN                           LeftShiftOn;\r
@@ -138,10 +138,14 @@ typedef struct {
   BOOLEAN                           RightCtrlOn;\r
   BOOLEAN                           RightAltOn;\r
   BOOLEAN                           RightShiftOn;\r
-  BOOLEAN                           RightLogoOn;  \r
+  BOOLEAN                           RightLogoOn;\r
   BOOLEAN                           MenuKeyOn;\r
   BOOLEAN                           SysReqOn;\r
   BOOLEAN                           AltGrOn;\r
+\r
+  BOOLEAN                         IsSupportPartialKey;\r
+\r
+  EFI_KEY_STATE                     KeyState;\r
   //\r
   // Notification function list\r
   //\r
index fe6121985c4e3a5a9bc9a6c979244228518bb617..8c67f67561957e807fdd5d339a1d7304e2369eec 100644 (file)
@@ -296,10 +296,17 @@ UINT8 ModifierValueToEfiScanCodeConvertionTable[] = {
   SCAN_F10,        // EFI_FUNCTION_KEY_TEN_MODIFIER\r
   SCAN_F11,        // EFI_FUNCTION_KEY_ELEVEN_MODIFIER\r
   SCAN_F12,        // EFI_FUNCTION_KEY_TWELVE_MODIFIER\r
+  //\r
+  // For Partial Keystroke support\r
+  //\r
   SCAN_NULL,       // EFI_PRINT_MODIFIER\r
   SCAN_NULL,       // EFI_SYS_REQUEST_MODIFIER\r
   SCAN_NULL,       // EFI_SCROLL_LOCK_MODIFIER\r
-  SCAN_PAUSE       // EFI_PAUSE_MODIFIER\r
+  SCAN_PAUSE,      // EFI_PAUSE_MODIFIER\r
+  SCAN_NULL,       // EFI_BREAK_MODIFIER\r
+  SCAN_NULL,       // EFI_LEFT_LOGO_MODIFIER\r
+  SCAN_NULL,       // EFI_RIGHT_LOGO_MODIFER\r
+  SCAN_NULL,       // EFI_MENU_MODIFER\r
 };\r
 \r
 /**\r
@@ -507,7 +514,7 @@ FindUsbNsKey (
   LIST_ENTRY      *Link;\r
   LIST_ENTRY      *NsKeyList;\r
   USB_NS_KEY      *UsbNsKey;\r
-  \r
+\r
   NsKeyList = &UsbKeyboardDevice->NsKeyList;\r
   Link = GetFirstNode (NsKeyList);\r
   while (!IsNull (NsKeyList, Link)) {\r
@@ -780,7 +787,7 @@ InitKeyboardLayout (
     //\r
     InstallDefaultKeyboardLayout (UsbKeyboardDevice);\r
   }\r
-  \r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -820,14 +827,14 @@ InitUSBKeyboard (
   // Assumed the first config is the correct one and this is not always the case\r
   //\r
   Status = UsbGetConfiguration (\r
-             UsbKeyboardDevice->UsbIo, \r
-             &ConfigValue, \r
+             UsbKeyboardDevice->UsbIo,\r
+             &ConfigValue,\r
              &TransferResult\r
              );\r
   if (EFI_ERROR (Status)) {\r
     ConfigValue = 0x01;\r
   }\r
-  \r
+\r
   //\r
   // Uses default configuration to configure the USB Keyboard device.\r
   //\r
@@ -891,7 +898,7 @@ InitUSBKeyboard (
   UsbKeyboardDevice->NumLockOn  = FALSE;\r
   UsbKeyboardDevice->CapsOn     = FALSE;\r
   UsbKeyboardDevice->ScrollOn   = FALSE;\r
-  \r
+\r
   UsbKeyboardDevice->LeftCtrlOn   = FALSE;\r
   UsbKeyboardDevice->LeftAltOn    = FALSE;\r
   UsbKeyboardDevice->LeftShiftOn  = FALSE;\r
@@ -1033,7 +1040,7 @@ KeyboardHandler (
 \r
     //\r
     // Delete & Submit this interrupt again\r
-    // Handler of DelayedRecoveryEvent triggered by timer will re-submit the interrupt. \r
+    // Handler of DelayedRecoveryEvent triggered by timer will re-submit the interrupt.\r
     //\r
     UsbIo->UsbAsyncInterruptTransfer (\r
              UsbIo,\r
@@ -1382,12 +1389,10 @@ USBParseKey (
     case EFI_LEFT_CONTROL_MODIFIER:\r
       UsbKeyboardDevice->LeftCtrlOn = TRUE;\r
       UsbKeyboardDevice->CtrlOn = TRUE;\r
-      continue;\r
       break;\r
     case EFI_RIGHT_CONTROL_MODIFIER:\r
       UsbKeyboardDevice->RightCtrlOn = TRUE;\r
       UsbKeyboardDevice->CtrlOn = TRUE;\r
-      continue;\r
       break;\r
 \r
     //\r
@@ -1396,12 +1401,10 @@ USBParseKey (
     case EFI_LEFT_SHIFT_MODIFIER:\r
       UsbKeyboardDevice->LeftShiftOn = TRUE;\r
       UsbKeyboardDevice->ShiftOn = TRUE;\r
-      continue;\r
       break;\r
     case EFI_RIGHT_SHIFT_MODIFIER:\r
       UsbKeyboardDevice->RightShiftOn = TRUE;\r
       UsbKeyboardDevice->ShiftOn = TRUE;\r
-      continue;\r
       break;\r
 \r
     //\r
@@ -1410,12 +1413,10 @@ USBParseKey (
     case EFI_LEFT_ALT_MODIFIER:\r
       UsbKeyboardDevice->LeftAltOn = TRUE;\r
       UsbKeyboardDevice->AltOn = TRUE;\r
-      continue;\r
       break;\r
     case EFI_RIGHT_ALT_MODIFIER:\r
       UsbKeyboardDevice->RightAltOn = TRUE;\r
       UsbKeyboardDevice->AltOn = TRUE;\r
-      continue;\r
       break;\r
 \r
     //\r
@@ -1445,7 +1446,6 @@ USBParseKey (
     case EFI_PRINT_MODIFIER:\r
     case EFI_SYS_REQUEST_MODIFIER:\r
       UsbKeyboardDevice->SysReqOn = TRUE;\r
-      continue;\r
       break;\r
 \r
     //\r
@@ -1461,7 +1461,6 @@ USBParseKey (
       //\r
       UsbKeyboardDevice->NumLockOn = (BOOLEAN) (!(UsbKeyboardDevice->NumLockOn));\r
       SetKeyLED (UsbKeyboardDevice);\r
-      continue;\r
       break;\r
 \r
     case EFI_CAPS_LOCK_MODIFIER:\r
@@ -1470,7 +1469,6 @@ USBParseKey (
       //\r
       UsbKeyboardDevice->CapsOn = (BOOLEAN) (!(UsbKeyboardDevice->CapsOn));\r
       SetKeyLED (UsbKeyboardDevice);\r
-      continue;\r
       break;\r
 \r
     case EFI_SCROLL_LOCK_MODIFIER:\r
@@ -1479,7 +1477,6 @@ USBParseKey (
       //\r
       UsbKeyboardDevice->ScrollOn = (BOOLEAN) (!(UsbKeyboardDevice->ScrollOn));\r
       SetKeyLED (UsbKeyboardDevice);\r
-      continue;\r
       break;\r
 \r
     default:\r
@@ -1529,18 +1526,11 @@ UsbKeyCodeToEfiInputKey (
   EFI_KEY_DESCRIPTOR            *KeyDescriptor;\r
   LIST_ENTRY                    *Link;\r
   LIST_ENTRY                    *NotifyList;\r
-  KEYBOARD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;  \r
+  KEYBOARD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;\r
 \r
   //\r
-  // KeyCode must in the range of 0x4 to 0x65\r
+  // KeyCode must in the range of  [0x4, 0x65] or [0xe0, 0xe7].\r
   //\r
-  if (!USBKBD_VALID_KEYCODE (KeyCode)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  if ((KeyCode - 4) >= NUMBER_OF_VALID_NON_MODIFIER_USB_KEYCODE) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
   KeyDescriptor = GetKeyDescriptor (UsbKeyboardDevice, KeyCode);\r
   ASSERT (KeyDescriptor != NULL);\r
 \r
@@ -1618,7 +1608,7 @@ UsbKeyCodeToEfiInputKey (
     if ((UsbKeyboardDevice->NumLockOn) && (!(UsbKeyboardDevice->ShiftOn))) {\r
       KeyData->Key.ScanCode = SCAN_NULL;\r
     } else {\r
-      KeyData->Key.UnicodeChar = 0x00;\r
+      KeyData->Key.UnicodeChar = CHAR_NULL;\r
     }\r
   }\r
 \r
@@ -1627,14 +1617,16 @@ UsbKeyCodeToEfiInputKey (
   //\r
   if (KeyData->Key.UnicodeChar == 0x1B && KeyData->Key.ScanCode == SCAN_NULL) {\r
     KeyData->Key.ScanCode = SCAN_ESC;\r
-    KeyData->Key.UnicodeChar = 0x00;\r
+    KeyData->Key.UnicodeChar = CHAR_NULL;\r
   }\r
 \r
   //\r
   // Not valid for key without both unicode key code and EFI Scan Code.\r
   //\r
   if (KeyData->Key.UnicodeChar == 0 && KeyData->Key.ScanCode == SCAN_NULL) {\r
+    if (!UsbKeyboardDevice->IsSupportPartialKey) {\r
     return EFI_NOT_READY;\r
+    }\r
   }\r
 \r
   //\r
@@ -1683,14 +1675,16 @@ UsbKeyCodeToEfiInputKey (
   if (UsbKeyboardDevice->CapsOn) {\r
     KeyData->KeyState.KeyToggleState |= EFI_CAPS_LOCK_ACTIVE;\r
   }\r
-\r
+  if (UsbKeyboardDevice->IsSupportPartialKey) {\r
+    KeyData->KeyState.KeyToggleState |= EFI_KEY_STATE_EXPOSED;\r
+  }\r
   //\r
   // Invoke notification functions if the key is registered.\r
   //\r
   NotifyList = &UsbKeyboardDevice->NotifyList;\r
   for (Link = GetFirstNode (NotifyList); !IsNull (NotifyList, Link); Link = GetNextNode (NotifyList, Link)) {\r
     CurrentNotify = CR (Link, KEYBOARD_CONSOLE_IN_EX_NOTIFY, NotifyEntry, USB_KB_CONSOLE_IN_EX_NOTIFY_SIGNATURE);\r
-    if (IsKeyRegistered (&CurrentNotify->KeyData, KeyData)) { \r
+    if (IsKeyRegistered (&CurrentNotify->KeyData, KeyData)) {\r
       CurrentNotify->KeyNotificationFn (KeyData);\r
     }\r
   }\r