src/video/x11/SDL_x11events.c
changeset 2305 fbe8ff44c519
parent 2300 c97ad1abe05b
child 2306 1a8bab15a45d
     1.1 --- a/src/video/x11/SDL_x11events.c	Tue Feb 05 07:30:50 2008 +0000
     1.2 +++ b/src/video/x11/SDL_x11events.c	Thu Feb 07 15:31:09 2008 +0000
     1.3 @@ -140,6 +140,15 @@
     1.4          }
     1.5          break;
     1.6  
     1.7 +        /* Has the keyboard layout changed? */
     1.8 +    case MappingNotify:{
     1.9 +#ifdef DEBUG_XEVENTS
    1.10 +            printf("MappingNotify!\n");
    1.11 +#endif
    1.12 +            X11_UpdateKeymap(this);
    1.13 +        }
    1.14 +        break;
    1.15 +
    1.16          /* Mouse motion? */
    1.17      case MotionNotify:{
    1.18  #ifdef DEBUG_MOTION
    1.19 @@ -174,23 +183,25 @@
    1.20  #ifdef DEBUG_XEVENTS
    1.21              printf("KeyPress (X11 keycode = 0x%X)\n", xevent.xkey.keycode);
    1.22  #endif
    1.23 -            SDLKey physicalKey = videodata->keyCodeToSDLKTable[keycode];
    1.24              SDL_SendKeyboardKey(videodata->keyboard, SDL_PRESSED,
    1.25 -                                (Uint8) keycode, physicalKey);
    1.26 +                                videodata->key_layout[keycode]);
    1.27  #if 1
    1.28 -            if (physicalKey == SDLK_UNKNOWN) {
    1.29 +            if (videodata->key_layout[keycode] == SDLK_UNKNOWN) {
    1.30 +                int min_keycode, max_keycode;
    1.31 +                XDisplayKeycodes(videodata->display, &min_keycode,
    1.32 +                                 &max_keycode);
    1.33 +                keysym = XKeycodeToKeysym(videodata->display, keycode, 0);
    1.34                  fprintf(stderr,
    1.35 -                        "The key you just pressed is not recognized by SDL. To help get this fixed, report this to the SDL mailing list <sdl@libsdl.org> or to Christian Walther <cwalther@gmx.ch>. X11 KeyCode is %d, X11 KeySym 0x%X.\n",
    1.36 -                        (int) keycode,
    1.37 -                        (unsigned int) XKeycodeToKeysym(videodata->display,
    1.38 -                                                        keycode, 0));
    1.39 +                        "The key you just pressed is not recognized by SDL. To help get this fixed, please report this to the SDL mailing list <sdl@libsdl.org> X11 KeyCode %d (%d), X11 KeySym 0x%X (%s).\n",
    1.40 +                        keycode, keycode - min_keycode, keysym,
    1.41 +                        XKeysymToString(keysym));
    1.42              }
    1.43  #endif
    1.44 -            /* works for Latin-1 */
    1.45 -            SDL_memset(&text[0], 0, SDL_TEXTINPUTEVENT_TEXT_SIZE);
    1.46 -            /* Xutf8LookupString() */
    1.47 +            /* Xutf8LookupString(), works for Latin-1 */
    1.48 +            SDL_zero(text);
    1.49              XLookupString(&xevent, text, sizeof(text), &keysym, NULL);
    1.50 -            if (0 != SDL_strlen(text)) {
    1.51 +            if (*text) {
    1.52 +                printf("Sending text event %s\n", text);
    1.53                  SDL_SendKeyboardText(videodata->keyboard, text);
    1.54              }
    1.55          }
    1.56 @@ -204,8 +215,7 @@
    1.57              printf("KeyRelease (X11 keycode = 0x%X)\n", xevent.xkey.keycode);
    1.58  #endif
    1.59              SDL_SendKeyboardKey(videodata->keyboard, SDL_RELEASED,
    1.60 -                                (Uint8) keycode,
    1.61 -                                videodata->keyCodeToSDLKTable[keycode]);
    1.62 +                                videodata->key_layout[keycode]);
    1.63          }
    1.64          break;
    1.65