Jump to content
  • Advertisement

Archived

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

T Bag

SDL input

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
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
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
also, throwing SDL_PumpEvents before that last one doesn't help

Edited by - T Bag on February 1, 2002 4:37:22 PM

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!