Supply current group when translating X11 Keycodes to Keysyms.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
diff --git a/src/video/x11/SDL_x11keyboard.c b/src/video/x11/SDL_x11keyboard.c
index 0c4a2a8..8ae80c2 100644
--- a/src/video/x11/SDL_x11keyboard.c
+++ b/src/video/x11/SDL_x11keyboard.c
@@ -29,6 +29,7 @@
#include "../../events/scancodes_xfree86.h"
#include <X11/keysym.h>
+#include <X11/XKBlib.h>
#include "imKStoUCS.h"
@@ -177,12 +178,12 @@ X11_KeyCodeToSDLScancode(Display *display, KeyCode keycode)
}
static Uint32
-X11_KeyCodeToUcs4(Display *display, KeyCode keycode)
+X11_KeyCodeToUcs4(Display *display, KeyCode keycode, unsigned char group)
{
KeySym keysym;
#if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM
- keysym = X11_XkbKeycodeToKeysym(display, keycode, 0, 0);
+ keysym = X11_XkbKeycodeToKeysym(display, keycode, group, 0);
#else
keysym = X11_XKeycodeToKeysym(display, keycode, 0);
#endif
@@ -300,8 +301,17 @@ X11_UpdateKeymap(_THIS)
int i;
SDL_Scancode scancode;
SDL_Keycode keymap[SDL_NUM_SCANCODES];
+ unsigned char group = 0;
SDL_GetDefaultKeymap(keymap);
+
+#if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM
+ XkbStateRec state;
+ if(0 == X11_XkbGetState(data->display, XkbUseCoreKbd, &state))
+ group = state.group;
+#endif
+
+
for (i = 0; i < SDL_arraysize(data->key_layout); i++) {
Uint32 key;
@@ -312,7 +322,7 @@ X11_UpdateKeymap(_THIS)
}
/* See if there is a UCS keycode for this scancode */
- key = X11_KeyCodeToUcs4(data->display, (KeyCode)i);
+ key = X11_KeyCodeToUcs4(data->display, (KeyCode)i, group);
if (key) {
keymap[scancode] = key;
} else {
diff --git a/src/video/x11/SDL_x11sym.h b/src/video/x11/SDL_x11sym.h
index d9843f0..4a926a3 100644
--- a/src/video/x11/SDL_x11sym.h
+++ b/src/video/x11/SDL_x11sym.h
@@ -165,6 +165,7 @@ SDL_X11_SYM(KeySym,XkbKeycodeToKeysym,(Display* a,unsigned int b,int c,int d),(a
#else
SDL_X11_SYM(KeySym,XkbKeycodeToKeysym,(Display* a,KeyCode b,int c,int d),(a,b,c,d),return)
#endif
+SDL_X11_SYM(Status,XkbGetState,(Display* a,unsigned int b,XkbStatePtr c),(a,b,c),return)
#endif
#if NeedWidePrototypes