Hello there, this post is not inherently referring to a bug, but I’d really like to know if anyone has a good approach to deal with my following problem. I have been checking on the forum for a similar topic and didn’t find anything related, so here it goes.
As expected, my app retrieves events following the structure:
while( SDL_PollEvent(&event) )
{
switch (event.type)
{
...
case SDL_FINGERDOWN:
// Do stuff
break;
case SDL_FINGERUP:
// Do stuff
break;
case SDL_FINGERMOTION:
// Do stuff
break;
case SDL_MULTIGESTURE:
if( event.mgesture.numFingers == 3 )
{
// Do stuff
}
break;
...
}
}
My problem comes on the SDL_MULTIGESTURE
event. I want to handle a 3 fingers gesture, so I do as shown on the code. The thing is, when pressing the 3 fingers on the screen, it obviously triggers 3 separate SDL_FINGERDOWN
which do whatever they are intended to do correctly (if only one finger was used). So what I want is, when there is a SDL_MULTIGESTURE
event, I don’t want the SDL_FINGERDOWN
to trigger.
My initial thought was to first store all event on a queue, then remove the unwanted events, and then launch the switch again. Something like:
SDL_Event event;
queue<SDL_Event> events;
while( SDL_PollEvent(&event) )
{
events.push_back(event);
}
CleanMyEventsVector(events);
while( !events.empty() )
{
event = events.pop();
switch (event.type)
{
...
case SDL_FINGERDOWN:
// Do stuff
break;
case SDL_FINGERUP:
// Do stuff
break;
case SDL_FINGERMOTION:
// Do stuff
break;
case SDL_MULTIGESTURE:
// Do stuff
break;
...
}
}
But I really don’t like this approach. That PollEvent function is run once every app cycle, and I am not sure how SDL retrieves the events, so if at every app cycle it doesn’t get the 3 SDL_FINGERDOWN
and SDL_MULTIGESTURE
, the CleanMyEventsVector()
is meant to fail at some point.
My second thought was, maybe there is some SDL_HINT
to change SDL behaviour for multi-gestures, but after looking for it didn’t find any.
Did someone have a similar problem, or is anyone coming up with a better solution?
Many thanks in advance.