* [PATCH v2] EmulatorPkg/Unix/Host fixed numeric pad function
@ 2018-11-19 13:03 Liu Yu
0 siblings, 0 replies; only message in thread
From: Liu Yu @ 2018-11-19 13:03 UTC (permalink / raw)
To: jordan.l.justen@intel.com, afish@apple.com, ruiyu.ni@intel.com
Cc: edk2-devel@lists.01.org, Liu Yu
From: Pedroa Liu <pedroa.liu@outlook.com>
origin code in Unix Host numeric pad has no function in shell environment
since we can't get "XK_KP_0 ~ XK_KP_9" from XGetKeyboardMapping just can
get "numlock" key status.
Contributed-under: TianoCore Contribution Agreement 1.1
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] only message in thread
only message in thread, other threads:[~2018-11-19 13:03 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-19 13:03 [PATCH v2] EmulatorPkg/Unix/Host fixed numeric pad function Liu Yu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox