SDL_GetMouseState vs SDL_MOUSEMOTION

Started by
0 comments, last by rip-off 13 years, 6 months ago
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)?
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.

This topic is closed to new replies.

Advertisement