Skip to content

Commit

Permalink
Fixed stuck keys when changing the video mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Lantinga committed May 1, 2001
1 parent 8b4194d commit 8e0efc5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs.html
Expand Up @@ -16,6 +16,7 @@ <H2>
Major changes since SDL 1.0.0:
</H2>
<UL>
<LI> 1.2.1: Fixed stuck keys when changing the video mode
<LI> 1.2.1: Fixed double-mouse event bug on Windows using OpenGL
<LI> 1.2.1: Fixed 320x200 video mode on framebuffer console
<LI> 1.2.1: Improved robustness for the ELO touchpad (thanks Alex!)
Expand Down
1 change: 1 addition & 0 deletions src/events/SDL_keyboard.c
Expand Up @@ -335,6 +335,7 @@ void SDL_ResetKeyboard(void)
SDL_PrivateKeyboard(SDL_RELEASED, &keysym);
}
}
SDL_KeyRepeat.timestamp = 0;
}

int SDL_EnableUNICODE(int enable)
Expand Down
3 changes: 3 additions & 0 deletions src/video/SDL_video.c
Expand Up @@ -567,6 +567,9 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags)
flags &= ~(SDL_HWSURFACE|SDL_DOUBLEBUF);
}

/* Reset the keyboard here so event callbacks can run */
SDL_ResetKeyboard();

/* Clean up any previous video mode */
if ( SDL_PublicSurface != NULL ) {
SDL_PublicSurface = NULL;
Expand Down
13 changes: 13 additions & 0 deletions src/video/x11/SDL_x11events.c
Expand Up @@ -54,6 +54,9 @@ static char rcsid =
#include "SDL_x11events_c.h"


/* Define this if you want to debug X11 events */
/*#define DEBUG_XEVENTS*/

/* The translation tables from an X11 keysym to a SDL keysym */
static SDLKey ODD_keymap[256];
static SDLKey MISC_keymap[256];
Expand Down Expand Up @@ -219,6 +222,9 @@ printf("FocusOut!\n");

/* Generated upon EnterWindow and FocusIn */
case KeymapNotify: {
#ifdef DEBUG_XEVENTS
printf("KeymapNotify!\n");
#endif
X11_SetKeyboardState(SDL_Display, xevent.xkeymap.key_vector);
}
break;
Expand Down Expand Up @@ -263,6 +269,10 @@ printf("FocusOut!\n");
/* Key press? */
case KeyPress: {
SDL_keysym keysym;

#ifdef DEBUG_XEVENTS
printf("KeyPress (X11 keycode = 0x%X)\n", xevent.xkey.keycode);
#endif
posted = SDL_PrivateKeyboard(SDL_PRESSED,
X11_TranslateKey(SDL_Display, &xevent.xkey,
xevent.xkey.keycode,
Expand All @@ -274,6 +284,9 @@ printf("FocusOut!\n");
case KeyRelease: {
SDL_keysym keysym;

#ifdef DEBUG_XEVENTS
printf("KeyRelease (X11 keycode = 0x%X)\n", xevent.xkey.keycode);
#endif
/* Check to see if this is a repeated key */
if ( ! X11_KeyRepeat(SDL_Display, &xevent) ) {
posted = SDL_PrivateKeyboard(SDL_RELEASED,
Expand Down

0 comments on commit 8e0efc5

Please sign in to comment.