I have a problem with SDL-1.3.0-6116 on the latest OSX Lion on a Macbook Air (2011). When a keyboard key is pressed and held down, SDL_KEYDOWN events are sent repeatedly which is not intended behavior from what I could read on the documentation. Or is it?
Here is a minimal example provoking the behavior:
Code:
#include <SDL.h>
// Push any key 5 times to quit
// BUG: Holding down a key works as well…
int main(int argc, char* argv[]) {
SDL_Init(SDL_INIT_VIDEO);
SDL_SetVideoMode(400, 400, 32, SDL_HWSURFACE);
SDL_Event event;
int keypressCount = 0;
while(keypressCount<5) {
while(SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_KEYDOWN:
keypressCount++;
break;
}
}
}
SDL_Quit();
return 0;
}
Making sure that there is no repetition via “SDL_EnableKeyRepeat(0,0)” doesn’t change anything either.