Optional SDL 1.2 Key Repeat Behavior in 2.0?

I know I can check the repeat flag in the KEYDOWN event, but my case is more specific.
My loop looks somewhat like this:

while (running) {
SDL_WaitEvent(NULL);
while (SDL_PollEvent(&e)) {
// Handle Useful Events
}
updateStuff();
}

I basically I want to let the updateStuff() run only when there is events that matter for it, and I filter all the stuff I dont need before the main loop.
But SDL 2.0 keep firing KEYDOWN events (with repeat = 1), and updateStuff() is called needlessly.
in SDL 1.2 I can just disable key repeat and it works.
If I need to handle this case, it will complicate the code inside the while loop.

Is there any way to disable key repeat events currently?

Thanks

Looks like it was axed:
http://forums.libsdl.org/viewtopic.php?t=6182&sid=36762cb583d97488f7c5f01505f6ee95

That having been said, it is trivial to modify your code to detect repeat
events and not do anything when the repeat flag is set, e.g:

while (running) {
bool update = false;

SDL_WaitEvent(NULL);
while (SDL_PollEvent(&e)) {
    if(!repeat_event)
        update = true;

}

if(update)
    updateStuff();

}

PatrickOn Wed, Feb 1, 2012 at 4:48 PM, RodrigoCard wrote:

**
I know I can check the repeat flag in the KEYDOWN event, but my case is
more specific.
My loop looks somewhat like this:

while (running) {
SDL_WaitEvent(NULL);
while (SDL_PollEvent(&e)) {
// Handle Useful Events
}
updateStuff();
}

I basically I want to let the updateStuff() run only when there is events
that matter for it, and I filter all the stuff I dont need before the main
loop.
But SDL 2.0 keep firing KEYDOWN events (with repeat = 1), and
updateStuff() is called needlessly.
in SDL 1.2 I can just disable key repeat and it works.
If I need to handle this case, it will complicate the code inside the
while loop.

Is there any way to disable key repeat events currently?

Thanks


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

well, too bad that is not so simple =/
I posted just a simple example of the outside loop.

Inside the while(poolevent) loop I pass the event to another function, which does not have access to the caller. I might need to modify other things, and make my code more coupled. I am even considering using a goto, so I wont need to increase the class coupling (right now it is what i am doing temporally).

I know it is not hard to fix, but it is ugly.------

About the link: It is great that now it is handled by the OS, so much better than the old SDL_EnableKeyRepeat(), but I wish there was still a way to disable it =/

I will use the goto for while, if it becomes unpractical at some point, maybe I will try to patch sdl.

Thanks for the link anyway. \o

Patrick Baggett wrote:

Looks like it was axed:???http://forums.libsdl.org/viewtopic.php?t=6182&sid=36762cb583d97488f7c5f01505f6ee95 (http://forums.libsdl.org/viewtopic.php?t=6182&sid=36762cb583d97488f7c5f01505f6ee95)?

That having been said, it is trivial to modify your code to detect repeat events and not do anything when the repeat flag is set, e.g:

while (running) {
? ? bool update = false;

? ? SDL_WaitEvent(NULL);
? ? while (SDL_PollEvent(&e)) {
? ? ? ? if(!repeat_event)
? ? ? ? ? ? update = true;
? ??
? ? }

? ? if(update)
? ? ? ? updateStuff();
}

Patrick

On Wed, Feb 1, 2012 at 4:48 PM, RodrigoCard <@Rodrigo_C_Rocha (@Rodrigo_C_Rocha)> wrote:

  I know I can check the repeat flag in the KEYDOWN event, but my case is more specific.

My loop looks somewhat like this:

while (running) {
SDL_WaitEvent(NULL);
while (SDL_PollEvent(&e)) {
// Handle Useful Events
}
updateStuff();
}

I basically I want to let the updateStuff() run only when there is events that matter for it, and I filter all the stuff I dont need before the main loop.
But SDL 2.0 keep firing KEYDOWN events (with repeat = 1), and updateStuff() is called needlessly.
in SDL 1.2 I can just disable key repeat and it works.
If I need to handle this case, it will complicate the code inside the while loop.

Is there any way to disable key repeat events currently?

Thanks


SDL mailing list
SDL at lists.libsdl.org (SDL at lists.libsdl.org)
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org (http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)