Jump to content
  • Advertisement
Sign in to follow this  
woody1987

SDL disable keyboard and mouse input

This topic is 3559 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

Im writing a simple game and at some point the user has a to move an object across the screen by first clicking the object and then clicking where they would like it placed, this part is working fine, what i want to be able to do is disable all input from the mouse and keyboard while the object is moving. Any help is appreciated.

Share this post


Link to post
Share on other sites
Advertisement
Yeah, this is just a programming problem, not specifically SDL. Just use a test for your condition like so:


SDL_Event event;
bool done = false;
while(!done)
{
while(PollEvent(&event))
{
if(event.type == SDL_QUIT)
done = true;
if(objectIsMoving)
{
// Keyboard and mouse input stuff here
}
}

// Drawing, updating, etc.
}




Note that you still need to poll the events, so that you actually discard them. Otherwise, the event queue will fill up and you'll get weird results. Using SDL_ShowCursor(SDL_DISABLE) will hide the mouse cursor, but does not stop events. It is useful when you want to display your own cursor (image) rather than the default one.

Share this post


Link to post
Share on other sites
Sign in to follow this  

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