| Summary: | Android: SDL_EventState(SDL_DOLLARGESTURE,SDL_IGNORE) etc. has no effect | ||
|---|---|---|---|
| Product: | SDL | Reporter: | wboe <w.boeke> |
| Component: | events | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | philipp.wiesemann, sylvain.becker |
| Version: | HG 2.0 | ||
| Hardware: | All | ||
| OS: | Android (All) | ||
| Attachments: | patch | ||
|
Description
wboe
2012-12-13 01:53:26 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)? (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. 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);
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.
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. |