Supply current group when translating X11 Keycodes to Keysyms.
authorJason Wyatt <jwyatt@feralinteractive.com>
Fri, 14 Aug 2015 16:23:31 +0100
changeset 98428a89b58895c1
parent 9841 aa1321ce8425
child 9843 13bbc6d4ab12
Supply current group when translating X11 Keycodes to Keysyms.
src/video/x11/SDL_x11keyboard.c
src/video/x11/SDL_x11sym.h
     1.1 --- a/src/video/x11/SDL_x11keyboard.c	Fri Aug 14 01:20:41 2015 -0400
     1.2 +++ b/src/video/x11/SDL_x11keyboard.c	Fri Aug 14 16:23:31 2015 +0100
     1.3 @@ -29,6 +29,7 @@
     1.4  #include "../../events/scancodes_xfree86.h"
     1.5  
     1.6  #include <X11/keysym.h>
     1.7 +#include <X11/XKBlib.h>
     1.8  
     1.9  #include "imKStoUCS.h"
    1.10  
    1.11 @@ -177,12 +178,12 @@
    1.12  }
    1.13  
    1.14  static Uint32
    1.15 -X11_KeyCodeToUcs4(Display *display, KeyCode keycode)
    1.16 +X11_KeyCodeToUcs4(Display *display, KeyCode keycode, unsigned char group)
    1.17  {
    1.18      KeySym keysym;
    1.19  
    1.20  #if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM
    1.21 -    keysym = X11_XkbKeycodeToKeysym(display, keycode, 0, 0);
    1.22 +    keysym = X11_XkbKeycodeToKeysym(display, keycode, group, 0);
    1.23  #else
    1.24      keysym = X11_XKeycodeToKeysym(display, keycode, 0);
    1.25  #endif
    1.26 @@ -300,8 +301,17 @@
    1.27      int i;
    1.28      SDL_Scancode scancode;
    1.29      SDL_Keycode keymap[SDL_NUM_SCANCODES];
    1.30 +    unsigned char group = 0;
    1.31  
    1.32      SDL_GetDefaultKeymap(keymap);
    1.33 +    
    1.34 +#if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM
    1.35 +    XkbStateRec state;
    1.36 +    if(0 == X11_XkbGetState(data->display, XkbUseCoreKbd, &state))
    1.37 +        group = state.group;
    1.38 +#endif
    1.39 +
    1.40 +
    1.41      for (i = 0; i < SDL_arraysize(data->key_layout); i++) {
    1.42          Uint32 key;
    1.43  
    1.44 @@ -312,7 +322,7 @@
    1.45          }
    1.46  
    1.47          /* See if there is a UCS keycode for this scancode */
    1.48 -        key = X11_KeyCodeToUcs4(data->display, (KeyCode)i);
    1.49 +        key = X11_KeyCodeToUcs4(data->display, (KeyCode)i, group);
    1.50          if (key) {
    1.51              keymap[scancode] = key;
    1.52          } else {
     2.1 --- a/src/video/x11/SDL_x11sym.h	Fri Aug 14 01:20:41 2015 -0400
     2.2 +++ b/src/video/x11/SDL_x11sym.h	Fri Aug 14 16:23:31 2015 +0100
     2.3 @@ -165,6 +165,7 @@
     2.4  #else
     2.5  SDL_X11_SYM(KeySym,XkbKeycodeToKeysym,(Display* a,KeyCode b,int c,int d),(a,b,c,d),return)
     2.6  #endif
     2.7 +SDL_X11_SYM(Status,XkbGetState,(Display* a,unsigned int b,XkbStatePtr c),(a,b,c),return)
     2.8  #endif
     2.9  
    2.10  #if NeedWidePrototypes