Jump to content
  • Advertisement
Sign in to follow this  
jdaniel

SDL_ShowCursor(SDL_DISABLE) and SDL_WarpMouse - anomaly

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

Hi. I am currently having trouble with the SDL_ShowCursor(SDL_DISABLE) command. When I set this SDL state, my cursor disappears as requested. I then want to warp the mouse position to SDL_WarpMouse(width/2, height/2). The problem I encounter is that the mouse warp does not seem to register correctly. For example, SDL_ShowCursor(SDL_DISABLE); SDL_WarpMouse(960, 600); The next very slight mouse motion would generate a mouse position of, say, 508,530. However, // SDL_ShowCursor(SDL_DISABLE); SDL_WarpMouse(960, 600); would generate a mouse position of 961, 600 after the same slight movement of the mouse. All mouse motions that occur after the initial strange position seem to be correct. Is there anyway to avoid this anomaly? Could anyone be kind enough to take the time to enlighten me? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
I was able to correct this problem by surrounding all my setup code with:


SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE);

// setup all game and opengl state

SDL_EventState(SDL_MOUSEMOTION, SDL_ENABLE);

while(1) {
// message pump
// draw screen
}


It appears that a mouse motion event was being generated during the initialization calls.

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!