From: Liu Yu <pedroa.liu@outlook.com>
To: "jordan.l.justen@intel.com" <jordan.l.justen@intel.com>,
"afish@apple.com" <afish@apple.com>,
"ruiyu.ni@intel.com" <ruiyu.ni@intel.com>
Cc: "edk2-devel@lists.01.org" <edk2-devel@lists.01.org>,
Liu Yu <pedroa.liu@outlook.com>
Subject: [PATCH v2] EmulatorPkg/Unix/Host fixed numeric pad function
Date: Mon, 19 Nov 2018 13:03:31 +0000 [thread overview]
Message-ID: <TY2PR02MB283122B65959485A3377A5858FD80@TY2PR02MB2831.apcprd02.prod.outlook.com> (raw)
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
reply other threads:[~2018-11-19 13:03 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=TY2PR02MB283122B65959485A3377A5858FD80@TY2PR02MB2831.apcprd02.prod.outlook.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox