diff --git a/ChangeAppSettings.sh b/ChangeAppSettings.sh index b9e62ce93..641078031 100755 --- a/ChangeAppSettings.sh +++ b/ChangeAppSettings.sh @@ -277,9 +277,8 @@ fi if [ -z "$AppUsesJoystick" -o -z "$AUTO" ]; then echo -echo "Application uses joystick (y) or (n), the accelerometer (2-axis) or orientation sensor (3-axis)" -echo "will be used as joystick 0, also on-screen DPAD will be used as joystick -" -echo -n "make sure you can navigate all app menus with joystick or mouse ($AppUsesJoystick): " +echo "Application uses joystick (y) or (n), the on-screen DPAD will be used" +echo -n " as joystick 0 axes 0-1, you will also need to set AppNeedsArrowKeys=y ($AppUsesJoystick): " read var if [ -n "$var" ] ; then AppUsesJoystick="$var" @@ -287,13 +286,12 @@ if [ -n "$var" ] ; then fi fi -if [ -z "$AppHandlesJoystickSensitivity" -o -z "$AUTO" ]; then +if [ -z "$AppUsesAccelerometer" -o -z "$AUTO" ]; then echo -echo "Application will handle joystick center and sensitivity itself, " -echo -n "SDL will send raw accelerometer data and won't show 'Accelerometer sensitivity' dialog (y) or (n) ($AppHandlesJoystickSensitivity): " +echo -n "Application uses accelerometer (y) or (n), the accelerometer will be used as joystick 0 axes 2-3 ($AppUsesAccelerometer): " read var if [ -n "$var" ] ; then - AppHandlesJoystickSensitivity="$var" + AppUsesAccelerometer="$var" CHANGED=1 fi fi @@ -301,7 +299,7 @@ fi if [ -z "$AppUsesMultitouch" -o -z "$AUTO" ]; then echo echo "Application uses multitouch (y) or (n), multitouch events are passed as SDL_JOYBUTTONDOWN/SDL_JOYBALLMOTION events" -echo -n " for the first joystick, or additionally as SDL_FINGERDOWN/UP/MOTION events in SDL 1.3 ($AppUsesMultitouch): " +echo -n " for the joystick 0, or additionally as SDL_FINGERDOWN/UP/MOTION events in SDL 1.3 ($AppUsesMultitouch): " read var if [ -n "$var" ] ; then AppUsesMultitouch="$var" @@ -635,7 +633,7 @@ echo ForceRelativeMouseMode=$ForceRelativeMouseMode >> AndroidAppSettings.cfg echo AppNeedsArrowKeys=$AppNeedsArrowKeys >> AndroidAppSettings.cfg echo AppNeedsTextInput=$AppNeedsTextInput >> AndroidAppSettings.cfg echo AppUsesJoystick=$AppUsesJoystick >> AndroidAppSettings.cfg -echo AppHandlesJoystickSensitivity=$AppHandlesJoystickSensitivity >> AndroidAppSettings.cfg +echo AppUsesAccelerometer=$AppUsesAccelerometer >> AndroidAppSettings.cfg echo AppUsesMultitouch=$AppUsesMultitouch >> AndroidAppSettings.cfg echo NonBlockingSwapBuffers=$NonBlockingSwapBuffers >> AndroidAppSettings.cfg echo RedefinedKeys=\"$RedefinedKeys\" >> AndroidAppSettings.cfg @@ -784,10 +782,10 @@ else AppUsesJoystick=false fi -if [ "$AppHandlesJoystickSensitivity" = "y" ] ; then - AppHandlesJoystickSensitivity=true +if [ "$AppUsesAccelerometer" = "y" ] ; then + AppUsesAccelerometer=true else - AppHandlesJoystickSensitivity=false + AppUsesAccelerometer=false fi if [ "$AppUsesMultitouch" = "y" ] ; then @@ -921,7 +919,7 @@ cat project/src/Globals.java | \ sed "s/public static boolean AppNeedsArrowKeys = .*;/public static boolean AppNeedsArrowKeys = $AppNeedsArrowKeys;/" | \ sed "s/public static boolean AppNeedsTextInput = .*;/public static boolean AppNeedsTextInput = $AppNeedsTextInput;/" | \ sed "s/public static boolean AppUsesJoystick = .*;/public static boolean AppUsesJoystick = $AppUsesJoystick;/" | \ - sed "s/public static boolean AppHandlesJoystickSensitivity = .*;/public static boolean AppHandlesJoystickSensitivity = $AppHandlesJoystickSensitivity;/" | \ + sed "s/public static boolean AppUsesAccelerometer = .*;/public static boolean AppUsesAccelerometer = $AppUsesAccelerometer;/" | \ sed "s/public static boolean AppUsesMultitouch = .*;/public static boolean AppUsesMultitouch = $AppUsesMultitouch;/" | \ sed "s/public static boolean NonBlockingSwapBuffers = .*;/public static boolean NonBlockingSwapBuffers = $NonBlockingSwapBuffers;/" | \ sed "s/public static boolean ResetSdlConfigForThisVersion = .*;/public static boolean ResetSdlConfigForThisVersion = $ResetSdlConfigForThisVersion;/" | \ diff --git a/project/java/Accelerometer.java b/project/java/Accelerometer.java index 54e87065c..f930661a9 100644 --- a/project/java/Accelerometer.java +++ b/project/java/Accelerometer.java @@ -44,7 +44,6 @@ class AccelerometerReader implements SensorEventListener public AccelerometerReader(Activity context) { - System.out.println("libSDL: accelerometer start required: " + String.valueOf(Globals.UseAccelerometerAsArrowKeys)); _manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE); start(); } @@ -53,14 +52,13 @@ class AccelerometerReader implements SensorEventListener { if( _manager != null ) { - System.out.println("libSDL: stopping accelerometer"); _manager.unregisterListener(this); } } public synchronized void start() { - if( Globals.UseAccelerometerAsArrowKeys ) + if( Globals.UseAccelerometerAsArrowKeys || Globals.AppUsesAccelerometer ) { if( _manager != null ) { @@ -97,5 +95,3 @@ class AccelerometerReader implements SensorEventListener private native void nativeAccelerometer(float accX, float accY, float accZ); private native void nativeOrientation(float accX, float accY, float accZ); } - - diff --git a/project/java/Globals.java b/project/java/Globals.java index 904270a8c..64126761e 100644 --- a/project/java/Globals.java +++ b/project/java/Globals.java @@ -52,7 +52,7 @@ class Globals public static boolean AppNeedsArrowKeys = true; public static boolean AppNeedsTextInput = true; public static boolean AppUsesJoystick = false; - public static boolean AppHandlesJoystickSensitivity = false; + public static boolean AppUsesAccelerometer = false; public static boolean AppUsesMultitouch = false; public static boolean NonBlockingSwapBuffers = false; public static boolean ResetSdlConfigForThisVersion = false; diff --git a/project/java/MainActivity.java b/project/java/MainActivity.java index fe23ed9f4..e12878fa8 100644 --- a/project/java/MainActivity.java +++ b/project/java/MainActivity.java @@ -240,7 +240,7 @@ public class MainActivity extends Activity return; System.out.println("libSDL: Initializing video and SDL application"); sdlInited = true; - if(Globals.UseAccelerometerAsArrowKeys) + if(Globals.UseAccelerometerAsArrowKeys || Globals.AppUsesAccelerometer) getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); _videoLayout.removeView(_layout); diff --git a/project/java/Settings.java b/project/java/Settings.java index 8fc7b2b6e..6e915b9b5 100644 --- a/project/java/Settings.java +++ b/project/java/Settings.java @@ -845,17 +845,10 @@ class Settings } boolean enabled() { - return Globals.UseAccelerometerAsArrowKeys || ! Globals.AppHandlesJoystickSensitivity; + return Globals.UseAccelerometerAsArrowKeys; } void run (final MainActivity p) { - if( ! Globals.UseAccelerometerAsArrowKeys || Globals.AppHandlesJoystickSensitivity ) - { - Globals.AccelerometerSensitivity = 2; // Slow, full range - showAccelerometerCenterConfig(p); - return; - } - final CharSequence[] items = { p.getResources().getString(R.string.accel_fast), p.getResources().getString(R.string.accel_medium), p.getResources().getString(R.string.accel_slow) }; @@ -885,13 +878,6 @@ class Settings } static void showAccelerometerCenterConfig(final MainActivity p) { - if( ! Globals.UseAccelerometerAsArrowKeys || Globals.AppHandlesJoystickSensitivity ) - { - Globals.AccelerometerCenterPos = 2; // Fixed horizontal center position - goBack(p); - return; - } - final CharSequence[] items = { p.getResources().getString(R.string.accel_floating), p.getResources().getString(R.string.accel_fixed_start), p.getResources().getString(R.string.accel_fixed_horiz) }; @@ -2436,6 +2422,8 @@ class Settings Globals.ShowMouseCursor ? 1 : 0 ); if( Globals.AppUsesJoystick && (Globals.UseAccelerometerAsArrowKeys || Globals.UseTouchscreenKeyboard) ) nativeSetJoystickUsed(); + if( Globals.AppUsesAccelerometer ) + nativeSetAccelerometerUsed(); if( Globals.AppUsesMultitouch ) nativeSetMultitouchUsed(); nativeSetAccelerometerSettings(Globals.AccelerometerSensitivity, Globals.AccelerometerCenterPos); @@ -2592,6 +2580,7 @@ class Settings int relativeMovement, int relativeMovementSpeed, int relativeMovementAccel, int showMouseCursor); private static native void nativeSetJoystickUsed(); + private static native void nativeSetAccelerometerUsed(); private static native void nativeSetMultitouchUsed(); private static native void nativeSetTouchscreenKeyboardUsed(); private static native void nativeSetSmoothVideo(); diff --git a/project/java/Video.java b/project/java/Video.java index 8212baeeb..fba98506d 100644 --- a/project/java/Video.java +++ b/project/java/Video.java @@ -502,9 +502,12 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer { if( ! super.SwapBuffers() && Globals.NonBlockingSwapBuffers ) { - synchronized(this) + if(mRatelimitTouchEvents) { - this.notify(); + synchronized(this) + { + this.notify(); + } } return 0; } @@ -517,9 +520,12 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer } // Unblock event processing thread only after we've finished rendering - synchronized(this) + if(mRatelimitTouchEvents) { - this.notify(); + synchronized(this) + { + this.notify(); + } } return 1; } @@ -662,10 +668,11 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer private boolean mGlContextLost = false; public boolean mGlSurfaceCreated = false; public boolean mPaused = false; - //public boolean mPutToBackground = false; private boolean mFirstTimeStart = true; public int mWidth = 0; public int mHeight = 0; + + public static final boolean mRatelimitTouchEvents = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO); } class DemoGLSurfaceView extends GLSurfaceView_SDL { @@ -682,7 +689,10 @@ class DemoGLSurfaceView extends GLSurfaceView_SDL { public boolean onTouchEvent(final MotionEvent event) { touchInput.process(event); - limitEventRate(event); + if( DemoRenderer.mRatelimitTouchEvents ) + { + limitEventRate(event); + } return true; }; @@ -690,7 +700,10 @@ class DemoGLSurfaceView extends GLSurfaceView_SDL { public boolean onGenericMotionEvent (final MotionEvent event) { touchInput.processGenericEvent(event); - limitEventRate(event); + if( DemoRenderer.mRatelimitTouchEvents ) + { + limitEventRate(event); + } return true; } diff --git a/project/jni/application/ballfield/AndroidAppSettings.cfg b/project/jni/application/ballfield/AndroidAppSettings.cfg index b5f26d345..037908efd 100644 --- a/project/jni/application/ballfield/AndroidAppSettings.cfg +++ b/project/jni/application/ballfield/AndroidAppSettings.cfg @@ -5,7 +5,7 @@ AppName="Ballfield" AppFullName=net.olofson.ballfield ScreenOrientation=h InhibitSuspend=n -AppDataDownloadUrl="Game data is 1 Mb|ballfield2.zip" +AppDataDownloadUrl="Game data is 1 Mb|ballfield3.zip" VideoDepthBpp=16 NeedDepthBuffer=n NeedStencilBuffer=n @@ -20,10 +20,10 @@ AppUsesMouse=y AppNeedsTwoButtonMouse=y ShowMouseCursor=n ForceRelativeMouseMode=n -AppNeedsArrowKeys=n +AppNeedsArrowKeys=y AppNeedsTextInput=y -AppUsesJoystick=n -AppHandlesJoystickSensitivity=n +AppUsesJoystick=y +AppUsesAccelerometer=y AppUsesMultitouch=y NonBlockingSwapBuffers=n RedefinedKeys="SPACE RETURN NO_REMAP NO_REMAP SPACE ESCAPE" diff --git a/project/jni/application/ballfield/AndroidData/ballfield2.zip b/project/jni/application/ballfield/AndroidData/ballfield3.zip similarity index 99% rename from project/jni/application/ballfield/AndroidData/ballfield2.zip rename to project/jni/application/ballfield/AndroidData/ballfield3.zip index 655e4ce19..463c70ee8 100644 Binary files a/project/jni/application/ballfield/AndroidData/ballfield2.zip and b/project/jni/application/ballfield/AndroidData/ballfield3.zip differ diff --git a/project/jni/application/ballfield/ballfield.cpp b/project/jni/application/ballfield/ballfield.cpp index cac0f0376..6097a0daf 100644 --- a/project/jni/application/ballfield/ballfield.cpp +++ b/project/jni/application/ballfield/ballfield.cpp @@ -22,8 +22,8 @@ Definitions... ----------------------------------------------------------*/ -#define SCREEN_W 320 -#define SCREEN_H 200 +#define SCREEN_W 640 +#define SCREEN_H 480 #define BALLS 300 @@ -430,6 +430,13 @@ int main(int argc, char* argv[]) int fps_count = 0; int fps_start = 0; float x_speed, y_speed, z_speed; + enum { MAX_POINTERS = 16 }; + // some random colors + int colors[MAX_POINTERS] = { 0xaaaaaa, 0xffffff, 0x888888, 0xcccccc, 0x666666, 0x999999, 0xdddddd, 0xeeeeee, 0xaaaaaa, 0xffffff, 0x888888, 0xcccccc, 0x666666, 0x999999, 0xdddddd, 0xeeeeee }; + struct TouchPointer_t { int x; int y; int pressure; int pressed; } touchPointers[MAX_POINTERS]; + int accel[2], screenjoy[2]; + SDL_Surface *mouse[4]; + SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK); @@ -516,15 +523,27 @@ int main(int argc, char* argv[]) font_hex = SDL_DisplayFormat(temp_image); SDL_FreeSurface(temp_image); + for(i = 0; i < 4; i++) + { + char name[32]; + sprintf(name, "mouse%d.png", i); + temp_image = IMG_Load(name); + if(!temp_image) + { + fprintf(stderr, "Could not load %s!\n", name); + exit(-1); + } + //mouse[i] = SDL_DisplayFormat(temp_image); + //SDL_FreeSurface(temp_image); + mouse[i] = temp_image; // Keep alpha + } + last_avg_tick = last_tick = SDL_GetTicks(); - enum { MAX_POINTERS = 16, PTR_PRESSED = 4 }; - int touchPointers[MAX_POINTERS][5]; - memset(touchPointers, 0, sizeof(touchPointers)); - SDL_Joystick * joysticks[MAX_POINTERS+1]; - for(i=0; iw; + r.h = mouse[cursorIdx]->h; r.x -= r.w/2; r.y -= r.h/2; - SDL_FillRect(screen, &r, color); + SDL_BlitSurface(mouse[cursorIdx], NULL, screen, &r); SDL_Flip(SDL_GetVideoSurface()); SDL_Event evt; @@ -615,41 +644,29 @@ int main(int argc, char* argv[]) __android_log_print(ANDROID_LOG_INFO, "Ballfield", "SDL resize event: %d x %d", evt.resize.w, evt.resize.h); if(evt.type == SDL_ACTIVEEVENT) __android_log_print(ANDROID_LOG_INFO, "Ballfield", "======= SDL active event: gain %d state %d", evt.active.gain, evt.active.state); - /* - if( evt.type == SDL_ACTIVEEVENT && evt.active.gain == 0 && evt.active.state & SDL_APPACTIVE ) - { - // We've lost GL context, we are not allowed to do any GFX output here, or app will crash! - while( 1 ) - { - SDL_PollEvent(&evt); - if( evt.type == SDL_ACTIVEEVENT && evt.active.gain && evt.active.state & SDL_APPACTIVE ) - { - __android_log_print(ANDROID_LOG_INFO, "Ballfield", "======= SDL active event: gain %d state %d", evt.active.gain, evt.active.state); - SDL_Flip(SDL_GetVideoSurface()); // One SDL_Flip() call is required here to restore OpenGL context - // Re-load all textures, matrixes and all other GL states if we're in SDL+OpenGL mode - // Re-load all images to SDL_Texture if we're using it - // Now we can draw - break; - } - // Process network stuff, maybe play some sounds using SDL_ANDROID_PauseAudioPlayback() / SDL_ANDROID_ResumeAudioPlayback() - SDL_Delay(300); - __android_log_print(ANDROID_LOG_INFO, "Ballfield", "Waiting"); - } - } - */ + // Android-specific events - accelerometer, multitoush, and on-screen joystick if( evt.type == SDL_JOYAXISMOTION ) { - if( evt.jaxis.which == 0 ) // 0 = The accelerometer - continue; - int joyid = evt.jaxis.which - 1; - touchPointers[joyid][evt.jaxis.axis] = evt.jaxis.value; // Axis 0 and 1 are coordinates, 2 and 3 are pressure and touch point radius + if(evt.jaxis.axis < 4) + { + if(evt.jaxis.axis < 2) + screenjoy[evt.jaxis.axis] = evt.jaxis.value; + else + accel[evt.jaxis.axis - 2] = evt.jaxis.value; + } + else + { + touchPointers[evt.jaxis.axis - 4].pressure = evt.jaxis.value; + } } if( evt.type == SDL_JOYBUTTONDOWN || evt.type == SDL_JOYBUTTONUP ) { - if( evt.jbutton.which == 0 ) // 0 = The accelerometer - continue; - int joyid = evt.jbutton.which - 1; - touchPointers[joyid][PTR_PRESSED] = (evt.jbutton.state == SDL_PRESSED); + touchPointers[evt.jbutton.button].pressed = (evt.jbutton.state == SDL_PRESSED); + } + if( evt.type == SDL_JOYBALLMOTION ) + { + touchPointers[evt.jball.ball].x = evt.jball.xrel; + touchPointers[evt.jball.ball].y = evt.jball.yrel; } } diff --git a/project/jni/application/commandergenius/commandergenius b/project/jni/application/commandergenius/commandergenius index 023025901..d1b8a7ae0 160000 --- a/project/jni/application/commandergenius/commandergenius +++ b/project/jni/application/commandergenius/commandergenius @@ -1 +1 @@ -Subproject commit 023025901a1d96a46d826791bf9cf264ddf5c9ee +Subproject commit d1b8a7ae03b1a0960722abbab38bbb8fca98e7cd diff --git a/project/jni/application/test-advertisements/AndroidAppSettings.cfg b/project/jni/application/test-advertisements/AndroidAppSettings.cfg index accbfdadb..3922aeeff 100644 --- a/project/jni/application/test-advertisements/AndroidAppSettings.cfg +++ b/project/jni/application/test-advertisements/AndroidAppSettings.cfg @@ -3,8 +3,8 @@ AppSettingVersion=17 LibSdlVersion=1.2 AppName="Admob test" AppFullName=ws.openarena.sdl -ScreenOrientation=h -InhibitSuspend=n +ScreenOrientation=v +InhibitSuspend=y AppDataDownloadUrl="Game data is 1 Mb|ballfield2.zip" VideoDepthBpp=16 NeedDepthBuffer=n diff --git a/project/jni/application/test-advertisements/ballfield.cpp b/project/jni/application/test-advertisements/ballfield.cpp index 578bd5a68..9c3b974ac 100644 --- a/project/jni/application/test-advertisements/ballfield.cpp +++ b/project/jni/application/test-advertisements/ballfield.cpp @@ -23,8 +23,8 @@ Definitions... ----------------------------------------------------------*/ -#define SCREEN_W 320 -#define SCREEN_H 200 +#define SCREEN_W 480 +#define SCREEN_H 800 #define BALLS 300 diff --git a/project/jni/application/testmultitouch/AndroidAppSettings.cfg b/project/jni/application/testmultitouch/AndroidAppSettings.cfg deleted file mode 100644 index 926a26ee8..000000000 --- a/project/jni/application/testmultitouch/AndroidAppSettings.cfg +++ /dev/null @@ -1,44 +0,0 @@ -# The application settings for Android libSDL port -AppSettingVersion=17 -LibSdlVersion=1.2 -AppName="Example multitouch" -AppFullName=org.libsdl.example.multitouch -ScreenOrientation=h -InhibitSuspend=n -AppDataDownloadUrl="Game data is 1 Mb|ballfield2.zip" -VideoDepthBpp=16 -NeedDepthBuffer=n -NeedStencilBuffer=n -NeedGles2=n -SwVideoMode=y -SdlVideoResize=y -SdlVideoResizeKeepAspect=n -CompatibilityHacks=n -AppUsesMouse=y -AppNeedsTwoButtonMouse=y -ShowMouseCursor=n -ForceRelativeMouseMode=n -AppNeedsArrowKeys=n -AppNeedsTextInput=y -AppUsesJoystick=y -AppHandlesJoystickSensitivity=n -AppUsesMultitouch=y -NonBlockingSwapBuffers=n -RedefinedKeys="SPACE RETURN NO_REMAP NO_REMAP SPACE ESCAPE" -AppTouchscreenKeyboardKeysAmount=0 -AppTouchscreenKeyboardKeysAmountAutoFire=0 -RedefinedKeysScreenKb="1 2 3 4 5 6 1 2 3 4" -StartupMenuButtonTimeout=0 -HiddenMenuOptions='OptionalDownloadConfig' -FirstStartMenuOptions='' -MultiABI=n -AppVersionCode=101 -AppVersionName="1.01" -ResetSdlConfigForThisVersion=n -CompiledLibraries="sdl_mixer sdl_image" -CustomBuildScript=n -AppCflags='-O2 -finline-functions' -AppLdflags='' -AppSubdirsBuild='' -AppCmdline='' -ReadmeText='^Readme text' diff --git a/project/jni/application/testmultitouch/AndroidData/ballfield2.zip b/project/jni/application/testmultitouch/AndroidData/ballfield2.zip deleted file mode 100644 index 7a9b8595a..000000000 Binary files a/project/jni/application/testmultitouch/AndroidData/ballfield2.zip and /dev/null differ diff --git a/project/jni/application/testmultitouch/example.cpp b/project/jni/application/testmultitouch/example.cpp deleted file mode 100644 index 331947366..000000000 --- a/project/jni/application/testmultitouch/example.cpp +++ /dev/null @@ -1,74 +0,0 @@ -#include -#include "SDL.h" - - -int main(int argc, char* argv[]) -{ - SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK); - SDL_Surface * screen = SDL_SetVideoMode(640, 480, 16, 0); - - enum { MAX_POINTERS = 16 }; - // some random colors - int colors[MAX_POINTERS] = { 0xaaaaaa, 0xffffff, 0x888888, 0xcccccc, 0x666666, 0x999999, 0xdddddd, 0xeeeeee, 0xaaaaaa, 0xffffff, 0x888888, 0xcccccc, 0x666666, 0x999999, 0xdddddd, 0xeeeeee }; - struct TouchPointer_t { int x; int y; int pressure; int pressed; } touchPointers[MAX_POINTERS]; - int accel[3]; // Only first 2 coords are used - int i; - - memset(touchPointers, 0, sizeof(touchPointers)); - memset(accel, 0, sizeof(accel)); - SDL_Joystick * joystick = SDL_JoystickOpen(0); - - while(1) - { - SDL_Event evt; - while( SDL_PollEvent(&evt) ) - { - if( evt.type == SDL_JOYAXISMOTION ) - { - if(evt.jaxis.axis < 3) - accel[evt.jaxis.axis] = evt.jaxis.value; // Those events are spammy, don't log them - else - { - __android_log_print(ANDROID_LOG_INFO, "Multitouch", "SDL_JOYAXISMOTION %d value %06d", (int)evt.jaxis.axis, (int)evt.jaxis.value ); - touchPointers[evt.jaxis.axis-3].pressure = evt.jaxis.value; - } - } - if( evt.type == SDL_JOYBUTTONDOWN || evt.type == SDL_JOYBUTTONUP ) - { - __android_log_print(ANDROID_LOG_INFO, "Multitouch", "SDL_JOYBUTTON %d value %d", (int)evt.jbutton.button, (int)evt.jbutton.state ); - touchPointers[evt.jbutton.button].pressed = (evt.jbutton.state == SDL_PRESSED); - } - if( evt.type == SDL_JOYBALLMOTION ) - { - __android_log_print(ANDROID_LOG_INFO, "Multitouch", "SDL_JOYBALLMOTION %d %06d:%06d", (int)evt.jball.ball, (int)evt.jball.xrel, (int)evt.jball.yrel ); - touchPointers[evt.jball.ball].x = evt.jball.xrel; - touchPointers[evt.jball.ball].y = evt.jball.yrel; - } - if(evt.type == SDL_KEYDOWN && evt.key.keysym.sym == SDLK_ESCAPE) - return 0; - } - SDL_FillRect(screen, 0, 0); - SDL_Rect r; - for(i=0; i midZ + dz*2 ) midZ = accZ - dz*2; } - } - - if(SDL_ANDROID_isJoystickUsed) return; + } if( accX < midX - dx ) { @@ -1372,10 +1372,10 @@ void SDL_ANDROID_processAndroidTrackballDampening() int SDL_SYS_JoystickInit(void) { SDL_numjoysticks = 0; - if( SDL_ANDROID_isJoystickUsed ) + if( SDL_ANDROID_isJoystickUsed || isMultitouchUsed || SDL_ANDROID_isAccelerometerUsed ) SDL_numjoysticks = 1; - if( isMultitouchUsed ) - SDL_numjoysticks = MAX_MULTITOUCH_POINTERS+1; + //if( isMultitouchUsed ) + // SDL_numjoysticks = MAX_MULTITOUCH_POINTERS+1; return(SDL_numjoysticks); } @@ -1383,9 +1383,7 @@ int SDL_SYS_JoystickInit(void) /* Function to get the device-dependent name of a joystick */ const char *SDL_SYS_JoystickName(int index) { - if(index) - return("Android multitouch"); - return("Android accelerometer/orientation sensor"); + return("Android accelerometer/multitouch sensor"); } /* Function to open a joystick for use. @@ -1400,19 +1398,14 @@ int SDL_SYS_JoystickOpen(SDL_Joystick *joystick) joystick->nballs = 0; if( joystick->index == 0 ) { - joystick->naxes = 3; + joystick->naxes = 4; // Joystick plus accelerometer if(isMultitouchUsed) { - joystick->naxes = 3 + MAX_MULTITOUCH_POINTERS; // Accelerometer/orientation, plus touch pressure/size + joystick->naxes = 4 + MAX_MULTITOUCH_POINTERS; // Joystick plus accelerometer, plus touch pressure/size joystick->nbuttons = MAX_MULTITOUCH_POINTERS; joystick->nballs = MAX_MULTITOUCH_POINTERS; } } - else - { - joystick->naxes = 4; - joystick->nbuttons = 1; - } SDL_ANDROID_CurrentJoysticks[joystick->index] = joystick; return(0); } @@ -1438,8 +1431,7 @@ void SDL_SYS_JoystickClose(SDL_Joystick *joystick) void SDL_SYS_JoystickQuit(void) { int i; - for(i=0; i