Integrated Michi's changes to accelerometer joystick and to video aspect ratio

This commit is contained in:
pelya
2010-10-15 16:04:42 +03:00
parent ebaff58990
commit a8f3d8b6b7
19 changed files with 152 additions and 65 deletions

View File

@@ -1,5 +1,5 @@
// This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount
package de.schwardtnet.alienblaster;
package org.enigmagame.enigma;
import android.app.Activity;
import android.content.Context;
@@ -52,16 +52,19 @@ class AccelerometerReader implements SensorEventListener {
if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER)
{
if( Globals.HorizontalOrientation )
nativeAccelerometer(event.values[1], -event.values[0], event.values[2]);
// TODO: it feels better for me to use tilt as X value instead of intuitive horizontal phone orientation
// because then I can hold device comfortably, we need another user-configurable option for that
// nativeOrientation(event.values[1], -event.values[2], event.values[0]); // Comfortable setting
nativeAccelerometer(event.values[1], -event.values[0], event.values[2]); // Intuitive setting
else
nativeAccelerometer(event.values[0], event.values[1], event.values[2]);
}
else
{
if( Globals.HorizontalOrientation )
nativeOrientation(event.values[1], -event.values[0], event.values[2]);
nativeOrientation(event.values[1], -event.values[2], event.values[0]);
else
nativeOrientation(event.values[0], event.values[1], event.values[2]);
nativeOrientation(event.values[2], event.values[1], event.values[0]);
}
}

View File

@@ -1,6 +1,6 @@
// This string is autogenerated by ChangeAppSettings.sh, do not change
// spaces amount
package de.schwardtnet.alienblaster;
package org.enigmagame.enigma;
import java.util.zip.*;
import java.io.*;

View File

@@ -1,5 +1,5 @@
// This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount
package de.schwardtnet.alienblaster;
package org.enigmagame.enigma;
import android.app.Activity;
@@ -23,6 +23,7 @@ class AudioThread {
private Activity mParent;
private AudioTrack mAudio;
private byte[] mAudioBuffer;
private int mVirtualBufSize;
public AudioThread(Activity parent)
{
@@ -34,7 +35,7 @@ class AudioThread {
public int fillBuffer()
{
mAudio.write( mAudioBuffer, 0, mAudioBuffer.length );
mAudio.write( mAudioBuffer, 0, mVirtualBufSize );
return 1;
}
@@ -47,11 +48,15 @@ class AudioThread {
encoding = ( encoding == 1 ) ? AudioFormat.ENCODING_PCM_16BIT :
AudioFormat.ENCODING_PCM_8BIT;
mVirtualBufSize = bufSize;
if( AudioTrack.getMinBufferSize( rate, channels, encoding ) > bufSize )
bufSize = AudioTrack.getMinBufferSize( rate, channels, encoding );
bufSize = (int)((float)bufSize * (((float)Globals.AudioBufferConfig * 2.5f) + 1.0f));
if(Globals.AudioBufferConfig != 0) { // application's choice - use minimal buffer
bufSize = (int)((float)bufSize * (((float)(Globals.AudioBufferConfig - 1) * 2.5f) + 1.0f));
mVirtualBufSize = bufSize;
}
mAudioBuffer = new byte[bufSize];
mAudio = new AudioTrack(AudioManager.STREAM_MUSIC,
@@ -62,7 +67,7 @@ class AudioThread {
AudioTrack.MODE_STREAM );
mAudio.play();
}
return mAudioBuffer.length;
return mVirtualBufSize;
}
public byte[] getBuffer()

View File

@@ -1,5 +1,5 @@
// This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount
package de.schwardtnet.alienblaster;
package org.enigmagame.enigma;
import android.app.Activity;
import android.content.Context;

View File

@@ -18,7 +18,7 @@
fixed with a hammer and rasp to work with libSDL port */
// This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount
package de.schwardtnet.alienblaster;
package org.enigmagame.enigma;
import java.io.Writer;
import java.util.ArrayList;

View File

@@ -1,37 +1,40 @@
// This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount anywhere
package de.schwardtnet.alienblaster;
package org.enigmagame.enigma;
import android.app.Activity;
import android.content.Context;
class Globals {
public static String ApplicationName = "AlienBlaster";
public static String ApplicationName = "enigma";
// Should be zip file
public static String DataDownloadUrl = "Data size is 2 Mb|alienblaster110_data.zip|http://sites.google.com/site/xpelyax/Home/alienblaster110_data.zip?attredirects=0%26d=1|http://sitesproxy.goapk.com/site/xpelyax/Home/alienblaster110_data.zip";
public static String DataDownloadUrl = "Enigma Game Data (6.5 MiB)|http://sites.google.com/site/droidsdl/data/enigma-data32.zip?attredirects=0%26d=1";
// Set this value to true if you're planning to render 3D using OpenGL - it eats some GFX resources, so disabled for 2D
public static boolean NeedDepthBuffer = false;
// Set this value to true if you're planning to render 3D using OpenGL - it eats some GFX resources, so disabled for 2D
public static boolean HorizontalOrientation = true;
// prevent device from going to suspend mode
public static boolean InhibitSuspend = true;
// Readme text to be shown on download page
public static String ReadmeText = "^You can press \"Home\" now - the data will be downloaded in background^In game press \"Menu\" for secondary fire, \"Volume Up/Down\" to cycle weapons".replace("^","\n");
public static String ReadmeText = "^You can press \"Home\" now - the data will be downloaded in background^Have fun playing enigma!^".replace("^","\n");
public static boolean AppUsesMouse = false;
public static boolean AppUsesMouse = true;
public static boolean AppNeedsArrowKeys = true;
public static boolean AppNeedsArrowKeys = false;
public static boolean AppUsesJoystick = false;
public static boolean AppUsesJoystick = true;
public static boolean AppUsesMultitouch = false;
public static boolean NonBlockingSwapBuffers = false;
public static int AppTouchscreenKeyboardKeysAmount = 4;
public static int AppTouchscreenKeyboardKeysAmount = 0;
public static int AppTouchscreenKeyboardKeysAmountAutoFire = 1;
public static int AppTouchscreenKeyboardKeysAmountAutoFire = 0;
// Phone-specific config
// It will download app data to /sdcard/alienblaster if set to true,
@@ -50,5 +53,5 @@ class Globals {
}
class LoadLibrary {
public LoadLibrary() { System.loadLibrary("sdl-1.3"); System.loadLibrary("sdl_mixer"); System.loadLibrary("sdl_image"); };
public LoadLibrary() { System.loadLibrary("sdl-1.2"); System.loadLibrary("sdl_mixer"); System.loadLibrary("sdl_image"); System.loadLibrary("sdl_ttf"); System.loadLibrary("intl"); System.loadLibrary("lua"); };
}

View File

@@ -1,5 +1,5 @@
// This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount
package de.schwardtnet.alienblaster;
package org.enigmagame.enigma;
import android.app.Activity;
import android.content.Context;
@@ -21,6 +21,11 @@ public class MainActivity extends Activity {
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
if(Globals.InhibitSuspend)
getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
_tv = new TextView(this);
_tv.setText(R.string.init);

View File

@@ -1,5 +1,5 @@
// This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount
package de.schwardtnet.alienblaster;
package org.enigmagame.enigma;
import android.app.Activity;
import android.content.Context;
@@ -433,7 +433,8 @@ class Settings
static void showAudioConfig(final MainActivity p)
{
final CharSequence[] items = { p.getResources().getString(R.string.audiobuf_small),
final CharSequence[] items = { p.getResources().getString(R.string.audiobuf_verysmall),
p.getResources().getString(R.string.audiobuf_small),
p.getResources().getString(R.string.audiobuf_medium),
p.getResources().getString(R.string.audiobuf_large) };

View File

@@ -1,5 +1,5 @@
// This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount
package de.schwardtnet.alienblaster;
package org.enigmagame.enigma;
import javax.microedition.khronos.opengles.GL10;