KeyRepeat fix

If you switch keys very fast and hold the last one it
doesn’t get repeated because the key release of the first key
occured after the key press of the second key.
Unfortunatly the key release of the first key sets
SDL_KeyRepeat.timestamp = 0; causing the the second key not to repeat.

This should be always reproducable. I’ve only checked this on x86-64
X11.

To fix this I just added another condition to make sure the sym of the
released key matches SDL_KeyRepeat.key.keysym.sym.

Patch file included.

Jon Daniel

-------------- next part --------------
A non-text attachment was scrubbed…
Name: keyrepeat.patch
Type: text/x-patch
Size: 588 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20050102/5d50eed2/attachment.bin

Oops I forgot .evt in the patch.
Here is the corrected file.
-------------- next part --------------
A non-text attachment was scrubbed…
Name: keyrepeat.patch
Type: text/x-patch
Size: 588 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20050102/5b177486/attachment.bin

[…]

Might be worth pointing out that that’s the way keyboard repeat works
on most hardware, OSes, GUI toolkits and other places it can be
implemented. Don’t know why, and I consider it an annoying bug. And
my current desktop, KDE 3.3.0 on XFree86 4.4.0, actually gets it
right… That’s a first for me, I think.

So, I hope this gets included. It makes the built-in repeat a bit more
useful, I think.

Actually, one might want to go one step further: If key ‘A’ is
repeating, one should be able to press ‘B’ until it starts repeating,
and when ‘B’ is released, ‘A’ should start repeating again. That
requires a great deal of extra logic, though, and if you really need
that kind of behavior, you should probably implement your own repeat
logic anyway. (I would like it if text editors did that with the
cursor keys, though…)

//David Olofson - Programmer, Composer, Open Source Advocate

.- Audiality -----------------------------------------------.
| Free/Open Source audio engine for games and multimedia. |
| MIDI, modular synthesis, real time effects, scripting,… |
`-----------------------------------> http://audiality.org -’
http://olofson.nethttp://www.reologica.se —On Sunday 02 January 2005 18.36, Jon Daniel wrote:

If you switch keys very fast and hold the last one it
doesn’t get repeated because the key release of the first key
occured after the key press of the second key.

I thought about a fully customizable KeyRepeat implementation too.
You could turn on/off repeat for every single key and individually
adjust delay and interval. You would be able to create an optional
autofire button with adjustable fire rate easily.

Jon DanielOn Sun, 2 Jan 2005 19:22:54 +0100, David Olofson wrote:

Actually, one might want to go one step further: If key ‘A’ is
repeating, one should be able to press ‘B’ until it starts repeating,
and when ‘B’ is released, ‘A’ should start repeating again. That
requires a great deal of extra logic, though, and if you really need
that kind of behavior, you should probably implement your own repeat
logic anyway. (I would like it if text editors did that with the
cursor keys, though…)

Yeah, that would be nice, but since even basic keyboard repeat is out
of scope of SDL (it’s not wired to the keyboard repeat APIs on any
OS, AFAIK), I think that would be better off as an add-on library
than an API extension.

Then again, if it’s simple and useful enough…

//David Olofson - Programmer, Composer, Open Source Advocate

.- Audiality -----------------------------------------------.
| Free/Open Source audio engine for games and multimedia. |
| MIDI, modular synthesis, real time effects, scripting,… |
`-----------------------------------> http://audiality.org -’
http://olofson.nethttp://www.reologica.se —On Sunday 02 January 2005 19.37, Jon Daniel wrote:

On Sun, 2 Jan 2005 19:22:54 +0100, David Olofson wrote:

Actually, one might want to go one step further: If key ‘A’ is
repeating, one should be able to press ‘B’ until it starts
repeating, and when ‘B’ is released, ‘A’ should start repeating
again. That requires a great deal of extra logic, though, and if
you really need that kind of behavior, you should probably
implement your own repeat logic anyway. (I would like it if text
editors did that with the cursor keys, though…)

I thought about a fully customizable KeyRepeat implementation too.
You could turn on/off repeat for every single key and individually
adjust delay and interval. You would be able to create an optional
autofire button with adjustable fire rate easily.

Thanks, your patch is in CVS.

See ya!
-Sam Lantinga, Software Engineer, Blizzard Entertainment