Archived

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

soehrimnir

what about buffered input?

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 this post


Link to post
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 this post


Link to post
Share on other sites