Archived

This topic is now archived and is closed to further replies.

This topic is 6091 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

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.

Share on other sites
There''s an entire help section on events in SDL (chapter 8 of the docs)

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

Share on other sites
Why do I never read the manuals??
Anyway, thank you very much!

1. 1
Rutin
24
2. 2
3. 3
4. 4
JoeJ
18
5. 5

• 14
• 19
• 11
• 11
• 9
• Forum Statistics

• Total Topics
631760
• Total Posts
3002176
×