Jump to content
  • Advertisement
Sign in to follow this  
Lode

SDL_GetMouseState vs SDL_MOUSEMOTION

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

Using SDL 1.2, how does SDL_GetMouseState work compared to the event SDL_MOUSEMOTION?

The problem is that my SDL application still doesn't work correctly in Windows 7 with a touch screen, when using the touch screen instead of a mouse (I'm not talking about touch events or multitouch here, my application only uses regular mouse events, which are also generated by the touch screen).

I don't have a touch laptop myself, I just test my application on a friends touch laptop now and then and see that it's still wrong.

It seems like if you click on a button on the screen, this Windows 7 touch screen sends all events at once during one frame: the mouse motion event, the mouse button down event and the mouse button up event.

I got it correct with the buttons now, by using SDL_PollEvent and taking into account that multiple mouse button events can occur during one frame. But for getting the mouse position, I was still using SDL_GetMouseState now, and apparently, this SDL_GetMouseState still gives the mouse position of the *previous* mouse location, instead of the one where the "button" was pressed now. So does Windows 7 maybe send a mouse move event after the button down and button up event? Or does SDL_GetMouseState lag behind the events you get with SDL_PollEvent? Do you think that if I'll handle mouse motion events in SDL_PollEvent too, that the problem will be fixed?

And a final question out of curiosity: with SDL you can get the mouse state using events from SDL_PollEvent, and with SDL_GetMouseState. If you consume events with SDL_PollEvent, will SDL_GetMouseState itself still get these events? Does SDL_GetMouseState use the same events or a different mechanism internally (as it seems to me now that the position gotten with SDL_GetMouseState lags behind the events)?

Share this post


Link to post
Share on other sites
Advertisement
Quote:

Using SDL 1.2, how does SDL_GetMouseState work compared to the event SDL_MOUSEMOTION?

Looking at the source, they appear to go through the same path. That is, the data for the current mouse state is updated just before the event is added to the queue (source SDL_PrivateMouseMotion() in SDL_mouse.c).

Mouse clicks appear to update the position, if it is given, from SDL_sysmouse.c.

This should mean that the mouse state should never lag behind the event queue. Unfortunately I'm not a WinAPI programmer so I can't discern more than that.

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!