| Summary: | SDL_AddTouch added too late for Android | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Martin Gerhardy <martin.gerhardy> |
| Component: | *don't know* | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | philipp.wiesemann |
| Version: | HG 2.0 | ||
| Hardware: | All | ||
| OS: | Android (All) | ||
| Attachments: | hg export for add touches in init with JNI | ||
|
Description
Martin Gerhardy
2013-10-04 07:29:22 UTC
Created attachment 1356 [details]
hg export for add touches in init with JNI
The time when SDL_GetNumTouchDevices() returns a valid value seems not be be consistent across platforms. On the other hand it is also not documented when this should be.
I attached a patch which may solve the problem described in the bug report. It adds an additional touch device detection with the video initialization.
On other platforms it works the same way, touches are added as touch events come in. However, I think it would be super useful if we were able to tell how many touch devices are available after initialization. So, I'm adding your patch, thanks! http://hg.libsdl.org/SDL/rev/cfc1285375e1 (In reply to Sam Lantinga from comment #2) > On other platforms it works the same way, touches are added as touch events > come in. From looking at the source I assumed that this would not be the case on X11 and UIKit and both would call SDL_AddTouch() only during initialization. On Windows, Cocoa and Android SDL_AddTouch() was called on touch events. I'm now getting a crash at startup signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0000001c Stack frame #00 pc 0005fe10 /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+19) Stack frame #01 pc 0004a15d /system/lib/libdvm.so Stack frame #02 pc 0003a691 /data/app-lib/org.foobar-1/libSDL2.so (Android_JNI_GetTouchDeviceIds+52): Routine Android_JNI_GetTouchDeviceIds in jni/SDL/src/core/android/SDL_android.c:1194 Stack frame #03 pc 0007b31d /data/app-lib/org.foobar-1/libSDL2.so (Android_InitTouch+4): Routine Android_InitTouch in jni/SDL/src/video/android/SDL_androidtouch.c:61 Stack frame #04 pc 0007b667 /data/app-lib/org.foobar-1/libSDL2.so: Routine Android_VideoInit in jni/SDL/src/video/android/SDL_androidvideo.c:169 Stack frame #05 pc 0007acff /data/app-lib/org.foobar-1/libSDL2.so (SDL_VideoInit+326): Routine SDL_VideoInit in jni/SDL/src/video/SDL_video.c:504 Stack frame #06 pc 0000e9e1 /data/app-lib/org.foobar-1/libSDL2.so (SDL_InitSubSystem+140): Routine SDL_InitSubSystem in jni/SDL/src/SDL.c:166 Stack frame #07 pc 0000ea83 /data/app-lib/org.foobar-1/libSDL2.so (SDL_Init+2): Routine SDL_Init in jni/SDL/src/SDL.c:237 Stack frame #08 pc 0009f48b /data/app-lib/org.foobar-1/libmain.so (SDLFrontend::init(int, int, bool, EventHandler&)+154): Routine init in jni/src/client/SDLFrontend.cpp:501 Stack frame #09 pc 000db0f5 /data/app-lib/org.foobar-1/libmain.so (SDLBackend::init(int, char**)+528): Routine init in jni/src/server/SDLBackend.cpp:103 Stack frame #10 pc 000db207 /data/app-lib/org.foobar-1/libmain.so (SDLBackend::mainLoop(int, char**)+18): Routine mainLoop in jni/src/common/System.h:25 Stack frame #11 pc 0009977f /data/app-lib/org.foobar-1/libmain.so (SDL_main+178): Routine SDL_main in jni/src/foobar.cpp:16 Stack frame #12 pc 00152521 /data/app-lib/org.foobar-1/libmain.so (Java_org_libsdl_app_SDLActivity_nativeInit+28): Routine Java_org_libsdl_app_SDLActivity_nativeInit in jni/src/libs/SDL/src/main/android/SDL_android_main.c:30 Stack frame #13 pc 0001dc4c /system/lib/libdvm.so (dvmPlatformInvoke+112) Stack frame #14 pc 0004decf /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+398) Stack frame #15 pc 0004f8bd /system/lib/libdvm.so (dvmResolveNativeMethod(unsigned int const*, JValue*, Method const*, Thread*)+184) Stack frame #16 pc 00027060 /system/lib/libdvm.so Stack frame #17 pc 0002b5ec /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184) Stack frame #18 pc 0005ff21 /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+292) Stack frame #19 pc 0005ff4b /system/lib/libdvm.so (dvmCallMethod(Thread*, Method const*, Object*, JValue*, ...)+20) Stack frame #20 pc 00054ccb /system/lib/libdvm.so Stack frame #21 pc 0000ca58 /system/lib/libc.so (__thread_entry+72) Stack frame #22 pc 0000cbd4 /system/lib/libc.so (pthread_create+208) (In reply to Martin Gerhardy from comment #4) > I'm now getting a crash at startup Thank you for testing. Which Android version was used? Real device or emulator? And have you updated the SDLActivity.java file? I tried to reproduce the crash you reported (not successful yet) but I get a similar error if I remove the new method there. oh sorry for the trouble. I have forgotten to update the java file, too. Again sorry. |