Fixed accelerometer input

This commit is contained in:
pelya
2010-07-09 17:43:46 +03:00
parent e901c4971e
commit 048735ac4a
5 changed files with 82 additions and 11 deletions

View File

@@ -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);
}