Fixed stuck keys when changing the video mode
authorSam Lantinga <slouken@lokigames.com>
Tue, 01 May 2001 21:12:57 +0000
changeset 14c3e9d4a623c1
parent 13 e30a8ce27c22
child 15 ac67f6758d63
Fixed stuck keys when changing the video mode
docs.html
src/events/SDL_keyboard.c
src/video/SDL_video.c
src/video/x11/SDL_x11events.c
     1.1 --- a/docs.html	Sun Apr 29 23:00:03 2001 +0000
     1.2 +++ b/docs.html	Tue May 01 21:12:57 2001 +0000
     1.3 @@ -16,6 +16,7 @@
     1.4  Major changes since SDL 1.0.0:
     1.5  </H2>
     1.6  <UL>
     1.7 +	<LI> 1.2.1: Fixed stuck keys when changing the video mode
     1.8  	<LI> 1.2.1: Fixed double-mouse event bug on Windows using OpenGL
     1.9  	<LI> 1.2.1: Fixed 320x200 video mode on framebuffer console
    1.10  	<LI> 1.2.1: Improved robustness for the ELO touchpad (thanks Alex!)
     2.1 --- a/src/events/SDL_keyboard.c	Sun Apr 29 23:00:03 2001 +0000
     2.2 +++ b/src/events/SDL_keyboard.c	Tue May 01 21:12:57 2001 +0000
     2.3 @@ -335,6 +335,7 @@
     2.4  			SDL_PrivateKeyboard(SDL_RELEASED, &keysym);
     2.5  		}
     2.6  	}
     2.7 +	SDL_KeyRepeat.timestamp = 0;
     2.8  }
     2.9  
    2.10  int SDL_EnableUNICODE(int enable)
     3.1 --- a/src/video/SDL_video.c	Sun Apr 29 23:00:03 2001 +0000
     3.2 +++ b/src/video/SDL_video.c	Tue May 01 21:12:57 2001 +0000
     3.3 @@ -567,6 +567,9 @@
     3.4  		flags &= ~(SDL_HWSURFACE|SDL_DOUBLEBUF);
     3.5  	}
     3.6  
     3.7 +	/* Reset the keyboard here so event callbacks can run */
     3.8 +	SDL_ResetKeyboard();
     3.9 +
    3.10  	/* Clean up any previous video mode */
    3.11  	if ( SDL_PublicSurface != NULL ) {
    3.12  		SDL_PublicSurface = NULL;
     4.1 --- a/src/video/x11/SDL_x11events.c	Sun Apr 29 23:00:03 2001 +0000
     4.2 +++ b/src/video/x11/SDL_x11events.c	Tue May 01 21:12:57 2001 +0000
     4.3 @@ -54,6 +54,9 @@
     4.4  #include "SDL_x11events_c.h"
     4.5  
     4.6  
     4.7 +/* Define this if you want to debug X11 events */
     4.8 +/*#define DEBUG_XEVENTS*/
     4.9 +
    4.10  /* The translation tables from an X11 keysym to a SDL keysym */
    4.11  static SDLKey ODD_keymap[256];
    4.12  static SDLKey MISC_keymap[256];
    4.13 @@ -219,6 +222,9 @@
    4.14  
    4.15  	    /* Generated upon EnterWindow and FocusIn */
    4.16  	    case KeymapNotify: {
    4.17 +#ifdef DEBUG_XEVENTS
    4.18 +printf("KeymapNotify!\n");
    4.19 +#endif
    4.20  		X11_SetKeyboardState(SDL_Display, xevent.xkeymap.key_vector);
    4.21  	    }
    4.22  	    break;
    4.23 @@ -263,6 +269,10 @@
    4.24  	    /* Key press? */
    4.25  	    case KeyPress: {
    4.26  		SDL_keysym keysym;
    4.27 +
    4.28 +#ifdef DEBUG_XEVENTS
    4.29 +printf("KeyPress (X11 keycode = 0x%X)\n", xevent.xkey.keycode);
    4.30 +#endif
    4.31  		posted = SDL_PrivateKeyboard(SDL_PRESSED,
    4.32  				X11_TranslateKey(SDL_Display, &xevent.xkey,
    4.33  						 xevent.xkey.keycode,
    4.34 @@ -274,6 +284,9 @@
    4.35  	    case KeyRelease: {
    4.36  		SDL_keysym keysym;
    4.37  
    4.38 +#ifdef DEBUG_XEVENTS
    4.39 +printf("KeyRelease (X11 keycode = 0x%X)\n", xevent.xkey.keycode);
    4.40 +#endif
    4.41  		/* Check to see if this is a repeated key */
    4.42  		if ( ! X11_KeyRepeat(SDL_Display, &xevent) ) {
    4.43  			posted = SDL_PrivateKeyboard(SDL_RELEASED,