Sign in to follow this  
jdaniel

SDL_ShowCursor(SDL_DISABLE) and SDL_WarpMouse - anomaly

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this