SDL2.0.4 using this code:
SDL_Keycode key = 0;
while(SDL_PollEvent(&(Global->event)) != 0)
{
if(Global->event.type == SDL_QUIT)
{
/* Allow users to exit the game */
break;
}
else if(Global->event.type == SDL_KEYDOWN)
{
/* Actual Keypresses */
key = Global->event.key.keysym.sym;
if(key == getSDLKValue("p-key"))
{
/* ... p key is pressed */
}
else if(key == getSDLKValue("q-key"))
{
/* ... q key is pressed*/
}
}
}
Works fine to get a single p
key press when the key is pressed down. However, when manually compiling, and using 2.0.5 logging shows that a single key press has:
Key pressed: 112
Key pressed: 112
It gets pressed twice in the window, when only once in reality.
Is this a bug with SDL2.0.5? Running on Ubuntu 16.04, manually compiled SDL2.0.5.
.key.repeat
in both cases? \$\endgroup\$make
flags I didn't enable? \$\endgroup\$.repeat
is meant to be used mostly for text input. Try to hold a button and after a moment you will start to receive a lot of "fake" keypresses with.repeat == 1
. I don't think there are special flags to change the behaviour you're seeing. Something tells me that it's a small design decision. \$\endgroup\$