[PATCH]Bug with SDL_EnableKeyRepeat when pressing a few keys in quick succession

There’s a small bug in SDL_EnableKeyRepeat. Under certain situations, the
pressed key won’t repeat at all.

Here’s how to reproduce the bug :

  • press a key
  • press a second key before the autorepeat of the first key acts
  • release one of the 2 keys

Then, there won’t be an autorepeat. It is important that the 2 keys pressed
have the same keysym.sym value. You can test that easily with the left and
right arrow key for example.

Here’s a patch for SDL_keyboard.c Sorry but I don’t have access to a better
way to make the patch right now.

— SDL_keyboard.c~ 2005-08-21 08:18:54.000000000 +0200
+++ SDL_keyboard.c 2005-09-17 01:16:19.000000000 +0200
@@ -495,7 +495,7 @@
* jk 991215 - Added
*/
if ( SDL_KeyRepeat.timestamp &&

  •                        SDL_KeyRepeat.evt.key.keysym.sym ==
    

keysym->sym ) {

  •                        SDL_KeyRepeat.evt.key.keysym.scancode ==
    

keysym->scancode ) {
SDL_KeyRepeat.timestamp = 0;
}
break;

Christophe Cavalaria wrote:

There’s a small bug in SDL_EnableKeyRepeat. Under certain situations, the
pressed key won’t repeat at all.

Here’s how to reproduce the bug :

  • press a key
  • press a second key before the autorepeat of the first key acts
  • release one of the 2 keys

Then, there won’t be an autorepeat. It is important that the 2 keys
pressed have the same keysym.sym value. You can test that easily with the
left and right arrow key for example.

Here’s a patch for SDL_keyboard.c Sorry but I don’t have access to a
better way to make the patch right now.

— SDL_keyboard.c~ 2005-08-21 08:18:54.000000000 +0200
+++ SDL_keyboard.c 2005-09-17 01:16:19.000000000 +0200
@@ -495,7 +495,7 @@
* jk 991215 - Added
*/
if ( SDL_KeyRepeat.timestamp &&

  •                        SDL_KeyRepeat.evt.key.keysym.sym ==
    

keysym->sym ) {

  •                        SDL_KeyRepeat.evt.key.keysym.scancode ==
    

keysym->scancode ) {
SDL_KeyRepeat.timestamp = 0;
}
break;

Oups, I noticed now that the only reason that patch works must be because I
upgraded my libSDL version at the same time I’ve written it. Sorry I won’t
bother you with 1AM patches anymore.