Fixed accelerometer input
This commit is contained in:
@@ -43,15 +43,22 @@ class AccelerometerReader implements SensorListener {
|
||||
|
||||
public synchronized void onSensorChanged(int sensor, float[] values) {
|
||||
|
||||
v[0] = values[0];
|
||||
v[1] = values[1];
|
||||
v[2] = values[2];
|
||||
|
||||
if (sensor == SensorManager.SENSOR_ACCELEROMETER) {
|
||||
if( values.length >= 1 )
|
||||
v[0] = values[0];
|
||||
if( values.length >= 2 )
|
||||
v[1] = values[1];
|
||||
if( values.length >= 3 )
|
||||
v[2] = values[2];
|
||||
if( Globals.HorizontalOrientation )
|
||||
{
|
||||
v[0] = values[1];
|
||||
v[1] = values[2];
|
||||
v[2] = values[0];
|
||||
}
|
||||
nativeAccelerometer(v[0], v[1], v[2]);
|
||||
}
|
||||
if (sensor == SensorManager.SENSOR_ORIENTATION) {
|
||||
nativeOrientation(v[0], v[1], v[2]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -68,6 +75,7 @@ class AccelerometerReader implements SensorListener {
|
||||
};
|
||||
|
||||
private native void nativeAccelerometer(float accX, float accY, float accZ);
|
||||
private native void nativeOrientation(float accX, float accY, float accZ);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -18,6 +18,9 @@ class Globals {
|
||||
|
||||
// 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;
|
||||
|
||||
// Readme text to be shown on download page
|
||||
public static String ReadmeText = "^Use accelerometer to navigate menus and control ship^Press \"Menu\" to select menu and for secondary fire^Press \"Call\" or touch screen for primary fire^Press \"Volume Up/Down\" to cycle through weapons".replace("^","\n");
|
||||
|
||||
@@ -49,7 +49,7 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer {
|
||||
System.loadLibrary("sdl_main");
|
||||
|
||||
nativeInit(); // Calls main() and never returns, hehe - we'll call eglSwapBuffers() from native code
|
||||
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
public int swapBuffers() // Called from native code, returns 1 on success, 0 when GL context lost (user put app to background)
|
||||
|
||||
Reference in New Issue
Block a user