src/video/x11/SDL_x11events.c
changeset 2305 fbe8ff44c519
parent 2300 c97ad1abe05b
child 2306 1a8bab15a45d
equal deleted inserted replaced
2304:50f58ce12497 2305:fbe8ff44c519
   138                X11_SetKeyboardState(SDL_Display, xevent.xkeymap.key_vector);
   138                X11_SetKeyboardState(SDL_Display, xevent.xkeymap.key_vector);
   139              */
   139              */
   140         }
   140         }
   141         break;
   141         break;
   142 
   142 
       
   143         /* Has the keyboard layout changed? */
       
   144     case MappingNotify:{
       
   145 #ifdef DEBUG_XEVENTS
       
   146             printf("MappingNotify!\n");
       
   147 #endif
       
   148             X11_UpdateKeymap(this);
       
   149         }
       
   150         break;
       
   151 
   143         /* Mouse motion? */
   152         /* Mouse motion? */
   144     case MotionNotify:{
   153     case MotionNotify:{
   145 #ifdef DEBUG_MOTION
   154 #ifdef DEBUG_MOTION
   146             printf("X11 motion: %d,%d\n", xevent.xmotion.x, xevent.xmotion.y);
   155             printf("X11 motion: %d,%d\n", xevent.xmotion.x, xevent.xmotion.y);
   147 #endif
   156 #endif
   172             Uint32 ucs4 = 0;
   181             Uint32 ucs4 = 0;
   173 
   182 
   174 #ifdef DEBUG_XEVENTS
   183 #ifdef DEBUG_XEVENTS
   175             printf("KeyPress (X11 keycode = 0x%X)\n", xevent.xkey.keycode);
   184             printf("KeyPress (X11 keycode = 0x%X)\n", xevent.xkey.keycode);
   176 #endif
   185 #endif
   177             SDLKey physicalKey = videodata->keyCodeToSDLKTable[keycode];
       
   178             SDL_SendKeyboardKey(videodata->keyboard, SDL_PRESSED,
   186             SDL_SendKeyboardKey(videodata->keyboard, SDL_PRESSED,
   179                                 (Uint8) keycode, physicalKey);
   187                                 videodata->key_layout[keycode]);
   180 #if 1
   188 #if 1
   181             if (physicalKey == SDLK_UNKNOWN) {
   189             if (videodata->key_layout[keycode] == SDLK_UNKNOWN) {
       
   190                 int min_keycode, max_keycode;
       
   191                 XDisplayKeycodes(videodata->display, &min_keycode,
       
   192                                  &max_keycode);
       
   193                 keysym = XKeycodeToKeysym(videodata->display, keycode, 0);
   182                 fprintf(stderr,
   194                 fprintf(stderr,
   183                         "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",
   195                         "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",
   184                         (int) keycode,
   196                         keycode, keycode - min_keycode, keysym,
   185                         (unsigned int) XKeycodeToKeysym(videodata->display,
   197                         XKeysymToString(keysym));
   186                                                         keycode, 0));
   198             }
   187             }
   199 #endif
   188 #endif
   200             /* Xutf8LookupString(), works for Latin-1 */
   189             /* works for Latin-1 */
   201             SDL_zero(text);
   190             SDL_memset(&text[0], 0, SDL_TEXTINPUTEVENT_TEXT_SIZE);
       
   191             /* Xutf8LookupString() */
       
   192             XLookupString(&xevent, text, sizeof(text), &keysym, NULL);
   202             XLookupString(&xevent, text, sizeof(text), &keysym, NULL);
   193             if (0 != SDL_strlen(text)) {
   203             if (*text) {
       
   204                 printf("Sending text event %s\n", text);
   194                 SDL_SendKeyboardText(videodata->keyboard, text);
   205                 SDL_SendKeyboardText(videodata->keyboard, text);
   195             }
   206             }
   196         }
   207         }
   197         break;
   208         break;
   198 
   209 
   202 
   213 
   203 #ifdef DEBUG_XEVENTS
   214 #ifdef DEBUG_XEVENTS
   204             printf("KeyRelease (X11 keycode = 0x%X)\n", xevent.xkey.keycode);
   215             printf("KeyRelease (X11 keycode = 0x%X)\n", xevent.xkey.keycode);
   205 #endif
   216 #endif
   206             SDL_SendKeyboardKey(videodata->keyboard, SDL_RELEASED,
   217             SDL_SendKeyboardKey(videodata->keyboard, SDL_RELEASED,
   207                                 (Uint8) keycode,
   218                                 videodata->key_layout[keycode]);
   208                                 videodata->keyCodeToSDLKTable[keycode]);
       
   209         }
   219         }
   210         break;
   220         break;
   211 
   221 
   212         /* Have we been iconified? */
   222         /* Have we been iconified? */
   213     case UnmapNotify:{
   223     case UnmapNotify:{