• Advertisement
Sign in to follow this  

SDL disable keyboard and mouse input

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