Enabled key board auto repeat in X11_InitKeyboard.c. Had to add a couple of new Xlib symbols.
authorBob Pendleton <bob@pendleton.com>
Sat, 12 Jan 2008 18:07:06 +0000
changeset 2299a7cbc25071b6
parent 2298 41d2599b7117
child 2300 c97ad1abe05b
Enabled key board auto repeat in X11_InitKeyboard.c. Had to add a couple of new Xlib symbols.
src/video/x11/SDL_x11events.c
src/video/x11/SDL_x11keyboard.c
src/video/x11/SDL_x11sym.h
     1.1 --- a/src/video/x11/SDL_x11events.c	Sat Jan 12 16:56:42 2008 +0000
     1.2 +++ b/src/video/x11/SDL_x11events.c	Sat Jan 12 18:07:06 2008 +0000
     1.3 @@ -29,29 +29,6 @@
     1.4  #include "SDL_x11video.h"
     1.5  #include "../../events/SDL_events_c.h"
     1.6  
     1.7 -
     1.8 -/* Check to see if this is a repeated key.
     1.9 -   (idea shamelessly lifted from GII -- thanks guys! :)
    1.10 - */
    1.11 -static int
    1.12 -X11_KeyRepeat(Display * display, XEvent * event)
    1.13 -{
    1.14 -    XEvent peekevent;
    1.15 -    int repeated;
    1.16 -
    1.17 -    repeated = 0;
    1.18 -    if (XPending(display)) {
    1.19 -        XPeekEvent(display, &peekevent);
    1.20 -        if ((peekevent.type == KeyPress) &&
    1.21 -            (peekevent.xkey.keycode == event->xkey.keycode) &&
    1.22 -            ((peekevent.xkey.time - event->xkey.time) < 2)) {
    1.23 -            repeated = 1;
    1.24 -            XNextEvent(display, &peekevent);
    1.25 -        }
    1.26 -    }
    1.27 -    return (repeated);
    1.28 -}
    1.29 -
    1.30  static void
    1.31  X11_DispatchEvent(_THIS)
    1.32  {
    1.33 @@ -194,21 +171,18 @@
    1.34  #ifdef DEBUG_XEVENTS
    1.35              printf("KeyPress (X11 keycode = 0x%X)\n", xevent.xkey.keycode);
    1.36  #endif
    1.37 -            if (!X11_KeyRepeat(videodata->display, &xevent)) {
    1.38 -                SDLKey physicalKey = videodata->keyCodeToSDLKTable[keycode];
    1.39 -                SDL_SendKeyboardKey(videodata->keyboard, SDL_PRESSED,
    1.40 -                                    (Uint8) keycode, physicalKey);
    1.41 +            SDLKey physicalKey = videodata->keyCodeToSDLKTable[keycode];
    1.42 +            SDL_SendKeyboardKey(videodata->keyboard, SDL_PRESSED,
    1.43 +                                (Uint8) keycode, physicalKey);
    1.44  #if 1
    1.45 -                if (physicalKey == SDLK_UNKNOWN) {
    1.46 -                    fprintf(stderr,
    1.47 -                            "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.48 -                            (int) keycode,
    1.49 -                            (unsigned int) XKeycodeToKeysym(videodata->
    1.50 -                                                            display, keycode,
    1.51 -                                                            0));
    1.52 -                }
    1.53 +            if (physicalKey == SDLK_UNKNOWN) {
    1.54 +                fprintf(stderr,
    1.55 +                        "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.56 +                        (int) keycode,
    1.57 +                        (unsigned int) XKeycodeToKeysym(videodata->display,
    1.58 +                                                        keycode, 0));
    1.59 +            }
    1.60  #endif
    1.61 -            }
    1.62          }
    1.63          break;
    1.64  
    1.65 @@ -219,11 +193,6 @@
    1.66  #ifdef DEBUG_XEVENTS
    1.67              printf("KeyRelease (X11 keycode = 0x%X)\n", xevent.xkey.keycode);
    1.68  #endif
    1.69 -            /* Check to see if this is a repeated key */
    1.70 -            if (X11_KeyRepeat(videodata->display, &xevent)) {
    1.71 -                break;
    1.72 -            }
    1.73 -
    1.74              SDL_SendKeyboardKey(videodata->keyboard, SDL_RELEASED,
    1.75                                  (Uint8) keycode,
    1.76                                  videodata->keyCodeToSDLKTable[keycode]);
     2.1 --- a/src/video/x11/SDL_x11keyboard.c	Sat Jan 12 16:56:42 2008 +0000
     2.2 +++ b/src/video/x11/SDL_x11keyboard.c	Sat Jan 12 18:07:06 2008 +0000
     2.3 @@ -851,6 +851,8 @@
     2.4      int code;
     2.5      SDLKey sdlkey;
     2.6  
     2.7 +    XAutoRepeatOn(data->display);
     2.8 +
     2.9      /* A random collection of KeySym/SDLKey pairs that should be valid
    2.10         in any keyboard layout (if this isn't the case on yours,
    2.11         please adjust). Using XKeysymToKeycode on these KeySyms
    2.12 @@ -904,7 +906,7 @@
    2.13                  "The key codes of your X server are unknown to SDL. Keys may not be recognized properly. To help get this fixed, report this to the SDL mailing list <sdl@libsdl.org> or to Christian Walther <cwalther@gmx.ch>.\n");
    2.14  #endif
    2.15          data->keyCodeToSDLKTable =
    2.16 -        SDL_malloc(KeyCodeTableSize * sizeof(SDLKey));
    2.17 +            SDL_malloc(KeyCodeTableSize * sizeof(SDLKey));
    2.18          if (data->keyCodeToSDLKTable == NULL) {
    2.19              SDL_OutOfMemory();
    2.20              return -1;
     3.1 --- a/src/video/x11/SDL_x11sym.h	Sat Jan 12 16:56:42 2008 +0000
     3.2 +++ b/src/video/x11/SDL_x11sym.h	Sat Jan 12 18:07:06 2008 +0000
     3.3 @@ -29,6 +29,8 @@
     3.4  SDL_X11_SYM(XSizeHints*,XAllocSizeHints,(void),(),return)
     3.5  SDL_X11_SYM(XStandardColormap *,XAllocStandardColormap,(void),(),return)
     3.6  SDL_X11_SYM(XWMHints*,XAllocWMHints,(void),(),return)
     3.7 +SDL_X11_SYM(int,XAutoRepeatOn,(Display* a),(a),return)
     3.8 +SDL_X11_SYM(int,XAutoRepeatOff,(Display* a),(a),return)
     3.9  SDL_X11_SYM(int,XChangePointerControl,(Display* a,Bool b,Bool c,int d,int e,int f),(a,b,c,d,e,f),return)
    3.10  SDL_X11_SYM(int,XChangeProperty,(Display* a,Window b,Atom c,Atom d,int e,int f,_Xconst unsigned char* g,int h),(a,b,c,d,e,f,g,h),return)
    3.11  SDL_X11_SYM(int,XChangeWindowAttributes,(Display* a,Window b,unsigned long c,XSetWindowAttributes* d),(a,b,c,d),return)