We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 1663 - Android: SDL_EventState(SDL_DOLLARGESTURE,SDL_IGNORE) etc. has no effect
Summary: Android: SDL_EventState(SDL_DOLLARGESTURE,SDL_IGNORE) etc. has no effect
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: events (show other bugs)
Version: HG 2.0
Hardware: All Android (All)
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-13 01:53 UTC by wboe
Modified: 2019-08-24 18:42 UTC (History)
2 users (show)

See Also:


Attachments
patch (6.89 KB, patch)
2017-10-17 11:08 UTC, Sylvain
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description wboe 2012-12-13 01:53:26 UTC
For Android, the following statements don't work:

  SDL_EventState(SDL_DOLLARGESTURE,SDL_IGNORE);
  SDL_EventState(SDL_DOLLARRECORD,SDL_IGNORE);
  SDL_EventState(SDL_MULTIGESTURE,SDL_IGNORE);

The are still present, which is a pity because the take much CPU time.
I work with the latest hg distribution.
Comment 1 Philipp Wiesemann 2012-12-15 02:53:30 UTC
It is possible to disable some of the gesture code by removing the #define ENABLE_DOLLAR in SDL_gesture.c.
This reduces the overhead a bit [1] and prevents spamming of SDL_GetError() with "ERROR: NumPoints = 0" for every touch if you no gestures are used at all.

[1] The path's length in dollarNormalize() is calculated for every touch even though there is comment that it is not (change in HG from 2010-11-30)?
Comment 2 wboe 2013-01-04 05:32:53 UTC
(In reply to comment #0)
> For Android, the following statements don't work:
> 
>   SDL_EventState(SDL_DOLLARGESTURE,SDL_IGNORE);
>   SDL_EventState(SDL_DOLLARRECORD,SDL_IGNORE);
>   SDL_EventState(SDL_MULTIGESTURE,SDL_IGNORE);
> 
> The are still present, which is a pity because the take much CPU time.
> I work with the latest hg distribution.

Small erratum:
SDL_EventState(SDL_DOLLARGESTURE,SDL_IGNORE) actually does work.

Big new complaint:
I tried an SDL app that works correctly on my Android 4.0 tablet on several other 4.0 and 4.1 tablets. I went to a big store where you can play with many tablets, and downloaded the apk file that I placed on a website beforehand. And guess what... none of them worked. The initial screen of the app did appear correctly, but as soon as the screen was touched it went black. If I touched some area where I knew there was a widget, that widget re-appeared. Widgets that should be sensitive to SDL_FINGERDOWN only, also seemed to receive SDL_FINGERMOTION events.

Summarizing: I looks as if the typing of events is broken for several Android devices.
Comment 3 wboe 2013-01-10 01:47:55 UTC
In order to save Mr Lantinga some work, here is my solution for the ignore problem. I do not include a patch file, for events/SDL_gesture.c seems to be 'work in progress' because of the many out-commented source lines.

So:

In events/SDL_events.c, line 380:
    if (SDL_GetEventState(SDL_DOLLARGESTURE) == SDL_ENABLE ||
        SDL_GetEventState(SDL_DOLLARRECORD) == SDL_ENABLE ||
        SDL_GetEventState(SDL_MULTIGESTURE) == SDL_ENABLE) {
          SDL_GestureProcessEvent(event);
    }

In events/SDL_gesture.c, function SDL_GestureProcessEvent:
add to declarations:
    SDL_bool dollar = SDL_GetEventState(SDL_DOLLARRECORD) == SDL_ENABLE ||
                      SDL_GetEventState(SDL_DOLLARGESTURE) == SDL_ENABLE;
    SDL_bool multigesture = SDL_GetEventState(SDL_MULTIGESTURE) == SDL_ENABLE;

replace:
#ifdef ENABLE_DOLLAR
with:
   if (dollar) {

line 629 becomes:
   if (multigesture)
         SDL_SendGestureMulti(inTouch,dtheta,dDist);
Comment 4 Sylvain 2017-10-17 11:08:24 UTC
Created attachment 3000 [details]
patch

simple patch

- make use of SDL_GetEventState() to send events if desired.
  in case of SDL_MULTIGESTURE, it also skips some computation for gesture recognition. 

- place SDL_QUERY use-case at first, since it is the most frequent

- fix a warning in SDL_events.c


From the previous comments : 
- I am not sure that the whole GestureProcessEvent should be disabled since it does some internal processing. if you enable/disable very quickly, the gesture you can miss some detection. of course, a corner case.
Comment 5 Sylvain 2019-08-24 18:42:43 UTC
Fixed https://hg.libsdl.org/SDL/rev/7693573f862d
this makes the SDL_SetEventState work for SDL_DOLLARGESTURE, SDL_DOLLARRECORD,SDL_MULTIGESTURE.
It doesn't remove the processing though.