[Bf-blender-cvs] [5d63f16] master: Fix numpad emulation in non-US keyboards
Campbell Barton
noreply at git.blender.org
Thu Apr 10 12:34:37 CEST 2014
Commit: 5d63f162d596d34998b3cdb4733a7a228fcb3341
Author: Campbell Barton
Date: Thu Apr 10 20:31:00 2014 +1000
https://developer.blender.org/rB5d63f162d596d34998b3cdb4733a7a228fcb3341
Fix numpad emulation in non-US keyboards
Patch D455 from Benoît Legat with own minor edits.
===================================================================
M intern/ghost/intern/GHOST_SystemX11.cpp
===================================================================
diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp
index 9900f7e..8f1f986 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;
More information about the Bf-blender-cvs
mailing list