Archived

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

T Bag

SDL input

Recommended Posts

T Bag    122
I''m making a game with MS VC++ using OpenGL for graphics and trying to use SDL to get keyboard input. SDL_Init works fine and returns a 0, but SDL_PollEvent never comes up with anything - it always returns 0. I assume there''s just some small change I have to make, but I haven''t found anything to tell me what. Does it matter that I''m adding SDL to an OpenGL program instead of using SDL to set OpenGL up? ----------hang ten, -> T*Bag

Share this post


Link to post
Share on other sites
soehrimnir    122
Have you already tried to use SDL_GetKeyState() instead? This way you can poll for specific keys yourself instead of relying on the SDL_KEYDOWN event. Here is a little example:

  
Uint8* keys;
while (true)
{
// retrieve the current keyboard state

keys = SDL_GetKeyState(NULL);

// if a key is being pressed down it contains a value of 1

// else if contains 0

if (keys[SDLK_ESCAPE]) break;

// do other stuff

}

Share this post


Link to post
Share on other sites
T Bag    122
I hadn't heard of SDL_GetKeyState, but I just tried this:

  
Uint8 *keyboarder;
...
keyboarder = SDL_GetKeyState(NULL);

for(x = SDLK_FIRST; x <= SDLK_LAST; x++)
{
if( keyboarder[x] )
{
//some stuff was here to tell me if it worked

}
}

and that didn't work either.

----------hang ten,
-> T*Bag

Edited by - T Bag on January 31, 2002 4:16:44 PM

Share this post


Link to post
Share on other sites