public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* EmulatorPkg/Unix/Host fixed numeric pad function
@ 2018-11-18 14:53 Liu Yu
  2018-11-19  0:52 ` Gao, Liming
  0 siblings, 1 reply; 3+ messages in thread
From: Liu Yu @ 2018-11-18 14:53 UTC (permalink / raw)
  To: "afish@apple.com;  jordan.l.justen@intel.com ; ruiyu.ni"@intel.com
  Cc: edk2-devel@lists.01.org

add numeric pad key map

Signed-off-by: Pedroa Liu <pedroa.liu@outlook.com>
---
  EmulatorPkg/Unix/Host/X11GraphicsWindow.c | 54 ++++++++++++++++++-----
  1 file changed, 43 insertions(+), 11 deletions(-)

diff --git a/EmulatorPkg/Unix/Host/X11GraphicsWindow.c 
b/EmulatorPkg/Unix/Host/X11GraphicsWindow.c
index a3cc28c223..573f0f1bfd 100644
--- a/EmulatorPkg/Unix/Host/X11GraphicsWindow.c
+++ b/EmulatorPkg/Unix/Host/X11GraphicsWindow.c
@@ -271,7 +271,14 @@ handleKeyEvent (
      }
    }

-  // Skipping EFI_MENU_KEY_PRESSED and EFI_SYS_REQ_PRESSED
+  if ((ev->xkey.state & Mod2Mask) == 0) {
+    Drv->KeyState.KeyToggleState &= ~EFI_NUM_LOCK_ACTIVE;
+  } else {
+    if (Make) {
+      Drv->KeyState.KeyToggleState |= EFI_NUM_LOCK_ACTIVE;
+    }
+  }
+ // Skipping EFI_MENU_KEY_PRESSED and EFI_SYS_REQ_PRESSED

    switch (*KeySym) {
    case XK_Control_R:
@@ -328,35 +335,70 @@ handleKeyEvent (
      break;

    case XK_KP_Home:
+    if ((Drv->KeyState.KeyShiftState & (EFI_LEFT_SHIFT_PRESSED | 
EFI_RIGHT_SHIFT_PRESSED)) ^ (Drv->KeyState.KeyToggleState & 
(EFI_NUM_LOCK_ACTIVE))) {
+      KeyData.Key.UnicodeChar = L'7'; break;
+    }
    case XK_Home:       KeyData.Key.ScanCode = SCAN_HOME; break;

    case XK_KP_End:
+    if ((Drv->KeyState.KeyShiftState & (EFI_LEFT_SHIFT_PRESSED | 
EFI_RIGHT_SHIFT_PRESSED)) ^ (Drv->KeyState.KeyToggleState & 
(EFI_NUM_LOCK_ACTIVE))) {
+      KeyData.Key.UnicodeChar = L'1'; break;
+    }
    case XK_End:        KeyData.Key.ScanCode = SCAN_END; break;

    case XK_KP_Left:
+    if ((Drv->KeyState.KeyShiftState & (EFI_LEFT_SHIFT_PRESSED | 
EFI_RIGHT_SHIFT_PRESSED)) ^ (Drv->KeyState.KeyToggleState & 
(EFI_NUM_LOCK_ACTIVE))) {
+      KeyData.Key.UnicodeChar = L'4'; break;
+    }
    case XK_Left:       KeyData.Key.ScanCode = SCAN_LEFT; break;

    case XK_KP_Right:
+    if((Drv->KeyState.KeyShiftState & (EFI_LEFT_SHIFT_PRESSED | 
EFI_RIGHT_SHIFT_PRESSED)) ^ (Drv->KeyState.KeyToggleState & 
(EFI_NUM_LOCK_ACTIVE)) ){
+      KeyData.Key.UnicodeChar = L'6'; break;
+    }
    case XK_Right:      KeyData.Key.ScanCode = SCAN_RIGHT; break;

    case XK_KP_Up:
+    if((Drv->KeyState.KeyShiftState & (EFI_LEFT_SHIFT_PRESSED | 
EFI_RIGHT_SHIFT_PRESSED)) ^ (Drv->KeyState.KeyToggleState & 
(EFI_NUM_LOCK_ACTIVE)) ){
+      KeyData.Key.UnicodeChar = L'8'; break;
+    }
    case XK_Up:         KeyData.Key.ScanCode = SCAN_UP; break;

    case XK_KP_Down:
+    if((Drv->KeyState.KeyShiftState & (EFI_LEFT_SHIFT_PRESSED | 
EFI_RIGHT_SHIFT_PRESSED)) ^ (Drv->KeyState.KeyToggleState & 
(EFI_NUM_LOCK_ACTIVE)) ){
+      KeyData.Key.UnicodeChar = L'2'; break;
+    }
    case XK_Down:       KeyData.Key.ScanCode = SCAN_DOWN; break;

    case XK_KP_Delete:
+    if((Drv->KeyState.KeyShiftState & (EFI_LEFT_SHIFT_PRESSED | 
EFI_RIGHT_SHIFT_PRESSED)) ^ (Drv->KeyState.KeyToggleState & 
(EFI_NUM_LOCK_ACTIVE)) ){
+      KeyData.Key.UnicodeChar = L'.'; break;
+    }
    case XK_Delete:       KeyData.Key.ScanCode = SCAN_DELETE; break;

    case XK_KP_Insert:
+    if((Drv->KeyState.KeyShiftState & (EFI_LEFT_SHIFT_PRESSED | 
EFI_RIGHT_SHIFT_PRESSED)) ^ (Drv->KeyState.KeyToggleState & 
(EFI_NUM_LOCK_ACTIVE)) ){
+      KeyData.Key.UnicodeChar = L'0';break;
+    }
    case XK_Insert:     KeyData.Key.ScanCode = SCAN_INSERT; break;

    case XK_KP_Page_Up:
+    if((Drv->KeyState.KeyShiftState & (EFI_LEFT_SHIFT_PRESSED | 
EFI_RIGHT_SHIFT_PRESSED)) ^ (Drv->KeyState.KeyToggleState & 
(EFI_NUM_LOCK_ACTIVE)) ){
+      KeyData.Key.UnicodeChar = L'9'; break;
+    }
    case XK_Page_Up:    KeyData.Key.ScanCode = SCAN_PAGE_UP; break;

    case XK_KP_Page_Down:
+    if((Drv->KeyState.KeyShiftState & (EFI_LEFT_SHIFT_PRESSED | 
EFI_RIGHT_SHIFT_PRESSED)) ^ (Drv->KeyState.KeyToggleState & 
(EFI_NUM_LOCK_ACTIVE)) ){
+      KeyData.Key.UnicodeChar = L'3'; break;
+    }
    case XK_Page_Down:  KeyData.Key.ScanCode = SCAN_PAGE_DOWN; break;

+  case XK_KP_Begin:
+    if((Drv->KeyState.KeyShiftState & (EFI_LEFT_SHIFT_PRESSED | 
EFI_RIGHT_SHIFT_PRESSED)) ^ (Drv->KeyState.KeyToggleState & 
(EFI_NUM_LOCK_ACTIVE)) ){
+      KeyData.Key.UnicodeChar = L'5'; break;
+    }
+    /* no map efi scan code */ break;
    case XK_Escape:     KeyData.Key.ScanCode = SCAN_ESC; break;

    case XK_Pause:      KeyData.Key.ScanCode = SCAN_PAUSE; break;
@@ -431,16 +473,6 @@ handleKeyEvent (
    case XK_KP_Decimal    : KeyData.Key.UnicodeChar = L'.'; break;
    case XK_KP_Divide     : KeyData.Key.UnicodeChar = L'/'; break;

-  case XK_KP_0    : KeyData.Key.UnicodeChar = L'0'; break;
-  case XK_KP_1    : KeyData.Key.UnicodeChar = L'1'; break;
-  case XK_KP_2    : KeyData.Key.UnicodeChar = L'2'; break;
-  case XK_KP_3    : KeyData.Key.UnicodeChar = L'3'; break;
-  case XK_KP_4    : KeyData.Key.UnicodeChar = L'4'; break;
-  case XK_KP_5    : KeyData.Key.UnicodeChar = L'5'; break;
-  case XK_KP_6    : KeyData.Key.UnicodeChar = L'6'; break;
-  case XK_KP_7    : KeyData.Key.UnicodeChar = L'7'; break;
-  case XK_KP_8    : KeyData.Key.UnicodeChar = L'8'; break;
-  case XK_KP_9    : KeyData.Key.UnicodeChar = L'9'; break;

    default:
      ;
-- 
2.17.1


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

end of thread, other threads:[~2018-11-19  6:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-18 14:53 EmulatorPkg/Unix/Host fixed numeric pad function Liu Yu
2018-11-19  0:52 ` Gao, Liming
2018-11-19  6:11   ` 答复: " Liu Yu

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