one keyboard event creates two events in the program |
ChliHug
|
You're calling SDL_GetKeyboardState twice and then check an entry in the state table with SDL_KEYDOWN. This will not have the desired effect because SDL_KEYDOWN is a event type and not a scancode. You want to compare SDL_KEYDOWN to event.type instead. Depending if you want key repeats or not, you can exclude them here too. It's probably also a good idea to loop over all events. The event queue can fill up pretty quick if you just pop one event every 10 ms.
|
|||||||||||||
|
one keyboard event creates two events in the program |
Rainer Deyke
Guest
|
On 10.06.2016 08:11, bilsch01 wrote:
These lines are clearly incorrect. If you want to check for event type, you're going to look at the actual event object. The second line should look something like this: if (e.type == SDL_KEYDOWN && e.key.keysym.scancode == SDL_SCANCODE_S) ...and the first line shouldn't exist at all. -- Rainer Deyke _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
one keyboard event creates two events in the program |
Rainer Deyke
Guest
|
On 10.06.2016 13:26, Rainer Deyke wrote:
...where 'e' is the event object, which you called 'event', so the actual code would be: if (event.type == SDL_KEYDOWN && event.key.keysym.scancode == SDL_SCANCODE_S) -- Rainer Deyke _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|