[SDL] Arghhh, this is driving me crazy (SDL_EnableKeyRepeat)

Manuel García Cabrera manugarciac5 at yahoo.com.ar
Sat Jun 9 09:38:38 PDT 2007


Ok, I want to do something when a key is pressed. I'm looping an
SDL_PollEvent to do this, and among others asking for a SDL_KEYDOWN
event in a switch. Well, I noticed that the code inside that case
executes many times if I press a key once, so I want it to wait a bit
before two consecutive KEYDOWN events. I actually managed to do this,
but the code turned out to be quite ugly. Then, I found a function that
seems to do exactly what I want: SDL_EnableKeyRepeat. But I can't get it
to work! This is what I'm doing:


...

SDL_EnableKeyRepeat(200, 200);

while (some_condition){

	SDL_PollEvent(&event);

	switch(event.type){
	case SDL_KEYDOWN:
		... //EXECUTE SOME CODE
		break;
	}
}

...


Is there something wrong with that? It behaves exactly the same when I
comment the EnableKeyRepeat line or use zero's as its arguments.


More information about the SDL mailing list