• ### Announcements

#### Archived

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

## 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!

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627638
• Total Posts
2978330

• 10
• 12
• 22
• 13
• 34