what about buffered input?
Hey everyone,
is it possible to do BufferedInput in SDL? Something similar that you can do with DirectX. What I mean is if there is a way to use input by not doing a SDL_GetKeyState() every time, but instead use something like events.
There''s an entire help section on events in SDL (chapter 8 of the docs)
To give you a short example:
A list of SDLK_ constants can be found in docs/html/sdlkey.html
You can also tell SDL to give you a Unicode (well, pseudo-Unicode as it''s only 16 bit) representation of the entered character (found in event.key.keysym.unicode). You''ll have to call SDL_EnableUNICODE() first tho.
cu,
Prefect
To give you a short example:
while(SDL_PollEvent(&event)) { switch(event.type) { case SDL_KEYDOWN: switch(event.key.keysym.sym) { case SDLK_ESCAPE: running = 0; break; default: break; } break; case SDL_QUIT: running = 0; break; } }
A list of SDLK_ constants can be found in docs/html/sdlkey.html
You can also tell SDL to give you a Unicode (well, pseudo-Unicode as it''s only 16 bit) representation of the entered character (found in event.key.keysym.unicode). You''ll have to call SDL_EnableUNICODE() first tho.
cu,
Prefect
Widelands - laid back, free software strategy
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement