diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-04-10 14:31:00 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-04-10 14:31:00 +0400 |
commit | 5d63f162d596d34998b3cdb4733a7a228fcb3341 (patch) | |
tree | 6d01de36a33bbf9871b9f453e403a06271936f5f | |
parent | 9b60174e75643b59435044c4d3f4572a4172184b (diff) |
Fix numpad emulation in non-US keyboards
Patch D455 from BenoƮt Legat with own minor edits.
-rw-r--r-- | intern/ghost/intern/GHOST_SystemX11.cpp | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp index 9900f7e153f..8f1f9867724 100644 --- a/intern/ghost/intern/GHOST_SystemX11.cpp +++ b/intern/ghost/intern/GHOST_SystemX11.cpp @@ -755,7 +755,7 @@ GHOST_SystemX11::processEvent(XEvent *xe) case KeyRelease: { XKeyEvent *xke = &(xe->xkey); - KeySym key_sym = XLookupKeysym(xke, 0); + KeySym key_sym; char ascii; #if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING) /* utf8_array[] is initial buffer used for Xutf8LookupString(). @@ -771,7 +771,29 @@ GHOST_SystemX11::processEvent(XEvent *xe) char *utf8_buf = NULL; #endif - GHOST_TKey gkey = convertXKey(key_sym); + GHOST_TKey gkey; + + /* In keyboards like latin ones, + * numbers needs a 'Shift' to be accessed but key_sym + * is unmodified (or anyone swapping the keys with xmodmap). + * + * Here we look at the 'Shifted' version of the key. + * If it is a number, then we take it instead of the normal key. + * + * The modified key is sent in the 'ascii's variable anyway. + */ + if ((xke->keycode >= 10 && xke->keycode < 20) && + ((key_sym = XLookupKeysym(xke, ShiftMask)) >= XK_0) && (key_sym <= XK_9)) + { + /* pass (keep shift'ed key_sym) */ + } + else { + /* regular case */ + key_sym = XLookupKeysym(xke, 0); + } + + gkey = convertXKey(key_sym); + GHOST_TEventType type = (xke->type == KeyPress) ? GHOST_kEventKeyDown : GHOST_kEventKeyUp; |