diff --git a/alienblaster/project/sdl/sdl-1.3/src/audio/android/SDL_androidaudio.c b/alienblaster/project/sdl/sdl-1.3/src/audio/android/SDL_androidaudio.c index ec463bb18..aa863c66f 100644 --- a/alienblaster/project/sdl/sdl-1.3/src/audio/android/SDL_androidaudio.c +++ b/alienblaster/project/sdl/sdl-1.3/src/audio/android/SDL_androidaudio.c @@ -155,6 +155,7 @@ static int ANDROIDAUD_OpenAudio (_THIS, SDL_AudioSpec *spec) { SDL_AudioSpec *audioFormat = spec; #endif + int bytesPerSample; JNIEnv * jniEnv = NULL; @@ -197,7 +198,7 @@ static int ANDROIDAUD_OpenAudio (_THIS, SDL_AudioSpec *spec) SDL_CalculateAudioSpec(audioFormat); - return(0); + return(1); } static void ANDROIDAUD_CloseAudio(_THIS) diff --git a/alienblaster/project/sdl/sdl-1.3/src/video/android/SDL_androidinput.c b/alienblaster/project/sdl/sdl-1.3/src/video/android/SDL_androidinput.c index 11a7eb24b..1911502a3 100644 --- a/alienblaster/project/sdl/sdl-1.3/src/video/android/SDL_androidinput.c +++ b/alienblaster/project/sdl/sdl-1.3/src/video/android/SDL_androidinput.c @@ -542,95 +542,94 @@ int processAndroidTrackball(int key, int action) { static int leftPressed = 0, rightPressed = 0, upPressed = 0, downPressed = 0; SDL_keysym keysym; + + if( ! action && ( + key == KEYCODE_DPAD_UP || + key == KEYCODE_DPAD_DOWN || + key == KEYCODE_DPAD_LEFT || + key == KEYCODE_DPAD_RIGHT ) ) + return 1; if( key == KEYCODE_DPAD_UP ) { - downPressed = 0; - SDL_SendKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_DOWN ,&keysym) ); + if( downPressed ) + { + downPressed = 0; + SDL_SendKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_DOWN ,&keysym) ); + return 1; + } if( !upPressed ) { - if( action ) - { - upPressed = 1; - SDL_SendKeyboardKey( SDL_PRESSED, TranslateKey(key ,&keysym) ); - } + upPressed = 1; + SDL_SendKeyboardKey( SDL_PRESSED, TranslateKey(key ,&keysym) ); } else { - if( action ) - { - SDL_SendKeyboardKey( SDL_RELEASED, TranslateKey(key ,&keysym) ); - SDL_SendKeyboardKey( SDL_PRESSED, TranslateKey(key ,&keysym) ); - } + SDL_SendKeyboardKey( SDL_RELEASED, TranslateKey(key ,&keysym) ); + SDL_SendKeyboardKey( SDL_PRESSED, TranslateKey(key ,&keysym) ); } return 1; } if( key == KEYCODE_DPAD_DOWN ) { - upPressed = 0; - SDL_SendKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_UP ,&keysym) ); + if( upPressed ) + { + upPressed = 0; + SDL_SendKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_UP ,&keysym) ); + return 1; + } if( !upPressed ) { - if( action ) - { - downPressed = 1; - SDL_SendKeyboardKey( SDL_PRESSED, TranslateKey(key ,&keysym) ); - } + downPressed = 1; + SDL_SendKeyboardKey( SDL_PRESSED, TranslateKey(key ,&keysym) ); } else { - if( action ) - { - SDL_SendKeyboardKey( SDL_RELEASED, TranslateKey(key ,&keysym) ); - SDL_SendKeyboardKey( SDL_PRESSED, TranslateKey(key ,&keysym) ); - } + SDL_SendKeyboardKey( SDL_RELEASED, TranslateKey(key ,&keysym) ); + SDL_SendKeyboardKey( SDL_PRESSED, TranslateKey(key ,&keysym) ); } return 1; } if( key == KEYCODE_DPAD_LEFT ) { - rightPressed = 0; - SDL_SendKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_RIGHT ,&keysym) ); + if( rightPressed ) + { + rightPressed = 0; + SDL_SendKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_RIGHT ,&keysym) ); + return 1; + } if( !leftPressed ) { - if( action ) - { - leftPressed = 1; - SDL_SendKeyboardKey( SDL_PRESSED, TranslateKey(key ,&keysym) ); - } + leftPressed = 1; + SDL_SendKeyboardKey( SDL_PRESSED, TranslateKey(key ,&keysym) ); } else { - if( action ) - { - SDL_SendKeyboardKey( SDL_RELEASED, TranslateKey(key ,&keysym) ); - SDL_SendKeyboardKey( SDL_PRESSED, TranslateKey(key ,&keysym) ); - } + SDL_SendKeyboardKey( SDL_RELEASED, TranslateKey(key ,&keysym) ); + SDL_SendKeyboardKey( SDL_PRESSED, TranslateKey(key ,&keysym) ); } return 1; } if( key == KEYCODE_DPAD_RIGHT ) { - leftPressed = 0; - SDL_SendKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_LEFT ,&keysym) ); + if( leftPressed ) + { + leftPressed = 0; + SDL_SendKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_LEFT ,&keysym) ); + return 1; + } if( !rightPressed ) { - if( action ) - { - rightPressed = 1; - SDL_SendKeyboardKey( SDL_PRESSED, TranslateKey(key ,&keysym) ); - } + rightPressed = 1; + SDL_SendKeyboardKey( SDL_PRESSED, TranslateKey(key ,&keysym) ); } else { - if( action ) - { - SDL_SendKeyboardKey( SDL_RELEASED, TranslateKey(key ,&keysym) ); - SDL_SendKeyboardKey( SDL_PRESSED, TranslateKey(key ,&keysym) ); - } + SDL_SendKeyboardKey( SDL_RELEASED, TranslateKey(key ,&keysym) ); + SDL_SendKeyboardKey( SDL_PRESSED, TranslateKey(key ,&keysym) ); } return 1; } diff --git a/alienblaster/project/src/Accelerometer.java b/alienblaster/project/src/Accelerometer.java index f9b6a2fe0..dd696158e 100644 --- a/alienblaster/project/src/Accelerometer.java +++ b/alienblaster/project/src/Accelerometer.java @@ -51,11 +51,17 @@ class AccelerometerReader implements SensorEventListener { if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) { - nativeAccelerometer(event.values[0], event.values[1], event.values[2]); + if( Globals.HorizontalOrientation ) + nativeAccelerometer(event.values[1], -event.values[0], event.values[2]); + else + nativeAccelerometer(event.values[0], event.values[1], event.values[2]); } else { - nativeOrientation(event.values[0], event.values[1], event.values[2]); + if( Globals.HorizontalOrientation ) + nativeOrientation(event.values[1], -event.values[0], event.values[2]); + else + nativeOrientation(event.values[0], event.values[1], event.values[2]); } } diff --git a/alienblaster/project/src/Globals.java b/alienblaster/project/src/Globals.java index 99f3318f9..8966479e2 100644 --- a/alienblaster/project/src/Globals.java +++ b/alienblaster/project/src/Globals.java @@ -31,6 +31,8 @@ class Globals { public static boolean AppNeedsArrowKeys = true; public static boolean AppUsesJoystick = false; + + public static boolean PhoneHasTrackball = false; } class LoadLibrary { diff --git a/alienblaster/project/src/Settings.java b/alienblaster/project/src/Settings.java index c991ba2e4..b00768ba5 100644 --- a/alienblaster/project/src/Settings.java +++ b/alienblaster/project/src/Settings.java @@ -24,6 +24,7 @@ class Settings ObjectInputStream settingsFile = new ObjectInputStream(new FileInputStream( p.getFilesDir().getAbsolutePath() + "/" + SettingsFileName )); Globals.DownloadToSdcard = settingsFile.readBoolean(); Globals.AppNeedsArrowKeys = settingsFile.readBoolean(); + Globals.PhoneHasTrackball = settingsFile.readBoolean(); startDownloader(p); return; @@ -31,6 +32,8 @@ class Settings } catch( SecurityException e ) { } catch ( IOException e ) {}; + // This code fails for both of my phones! + /* Configuration c = new Configuration(); c.setToDefaults(); @@ -40,7 +43,15 @@ class Settings { Globals.AppNeedsArrowKeys = false; } - + + System.out.println( "libSDL: Phone keypad type: " + + ( + c.navigation == Configuration.NAVIGATION_TRACKBALL ? "Trackball" : + c.navigation == Configuration.NAVIGATION_DPAD ? "Dpad" : + c.navigation == Configuration.NAVIGATION_WHEEL ? "Wheel" : + c.navigation == Configuration.NAVIGATION_NONAV ? "None" : + "Unknown" ) ); + */ final CharSequence[] items = {"Phone storage", "SD card"}; @@ -53,7 +64,7 @@ class Settings Globals.DownloadToSdcard = (item == 1); dialog.dismiss(); - showAccelermoeterConfig(p); + showKeyboardConfig(p); } }); AlertDialog alert = builder.create(); @@ -61,6 +72,35 @@ class Settings alert.show(); }; + + static void showKeyboardConfig(final MainActivity p) + { + if( ! Globals.AppNeedsArrowKeys ) + { + Save(p); + startDownloader(p); + return; + } + + final CharSequence[] items = {"Arrows / joystick / dpad", "Trackball", "None, only touchscreen"}; + + AlertDialog.Builder builder = new AlertDialog.Builder(p); + builder.setTitle("What kind of navigation keys does your phone have?"); + builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() + { + public void onClick(DialogInterface dialog, int item) + { + Globals.AppNeedsArrowKeys = (item == 2); + Globals.PhoneHasTrackball = (item == 1); + + dialog.dismiss(); + showAccelermoeterConfig(p); + } + }); + AlertDialog alert = builder.create(); + alert.setOwnerActivity(p); + alert.show(); + } static void showAccelermoeterConfig(final MainActivity p) { @@ -74,7 +114,7 @@ class Settings final CharSequence[] items = {"Do not use accelerometer", "Use accelerometer as navigation keys"}; AlertDialog.Builder builder = new AlertDialog.Builder(p); - builder.setTitle("Your phone has navigation keys, you may optionally use accelerometer as another navigation keys"); + builder.setTitle("You may optionally use accelerometer as another navigation keys"); builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) @@ -97,6 +137,7 @@ class Settings ObjectOutputStream out = new ObjectOutputStream(p.openFileOutput( SettingsFileName, p.MODE_WORLD_READABLE )); out.writeBoolean(Globals.DownloadToSdcard); out.writeBoolean(Globals.AppNeedsArrowKeys); + out.writeBoolean(Globals.PhoneHasTrackball); out.close(); } catch( FileNotFoundException e ) { } catch( SecurityException e ) { @@ -107,13 +148,9 @@ class Settings static void Apply() { nativeIsSdcardUsed( Globals.DownloadToSdcard ? 1 : 0 ); - Configuration c = new Configuration(); - c.setToDefaults(); - if( c.navigation == Configuration.NAVIGATION_TRACKBALL ) - { + if( Globals.PhoneHasTrackball ) nativeSetTrackballUsed(); - } if( Globals.AppUsesMouse ) nativeSetMouseUsed(); if( Globals.AppUsesJoystick && !Globals.AppNeedsArrowKeys )