SDL 2.0 - Good way of handling mouse input?

I'm trying to create a method that deduces mouse motion WHILE the left button is clicked. Does anyone know a way to do this?
1) Catch the MouseButtonPressed event. Set a boolean value to indicate the L button is clicked.

2) Catch the MouseButtonReleased event. When L button is released, clear your boolean.

3) Catch the MouseMove event. Only process when your boolean indicates the L button is clicked.
Thanks, had some trouble catching the release because of SDL_Delay used in my fps limiter. Ended up polling for events 2 times, before and after the fps limiter.
Events should say in the queue until you pull them out. How long you delay wouldn't matter.

There might be multiple events in the queue, so you should always empty the queue with a while() statement and not a single if statement:

1
2
3
4
while( wnd.pollEvent(...) )  // <- while, not if
{
    // handle event
}
Topic archived. No new replies allowed.