Teeworlds: read proximity sensor

This commit is contained in:
Sergii Pylypenko
2015-07-31 21:46:46 +03:00
parent 4b96594339
commit 4eced8345f
3 changed files with 58 additions and 3 deletions

View File

@@ -7,10 +7,10 @@ AppName="TeeWorlds"
AppFullName=com.teeworlds
# Application version code (integer)
AppVersionCode=06324
AppVersionCode=06325
# Application user-visible version name (string)
AppVersionName="0.6.3.24"
AppVersionName="0.6.3.25"
# Specify path to download application data in zip archive in the form 'Description|URL|MirrorURL^Description2|URL2|MirrorURL2^...'
# If you'll start Description with '!' symbol it will be enabled by default, other downloads should be selected by user from startup config menu

View File

@@ -0,0 +1,55 @@
diff --git a/project/java/Accelerometer.java b/project/java/Accelerometer.java
index 3e93b82..9796355 100644
--- a/project/java/Accelerometer.java
+++ b/project/java/Accelerometer.java
@@ -45,6 +45,7 @@ class AccelerometerReader implements SensorEventListener
public boolean openedBySDL = false;
public static final GyroscopeListener gyro = new GyroscopeListener();
public static final OrientationListener orientation = new OrientationListener();
+ public static final ProximityListener proximity = new ProximityListener();
public AccelerometerReader(Activity context)
{
@@ -59,6 +60,7 @@ class AccelerometerReader implements SensorEventListener
_manager.unregisterListener(this);
_manager.unregisterListener(gyro);
_manager.unregisterListener(orientation);
+ _manager.unregisterListener(proximity);
}
}
@@ -84,6 +86,11 @@ class AccelerometerReader implements SensorEventListener
Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 ? Sensor.TYPE_GAME_ROTATION_VECTOR : Sensor.TYPE_ROTATION_VECTOR),
SensorManager.SENSOR_DELAY_GAME);
}
+ if( _manager != null && _manager.getDefaultSensor(Sensor.TYPE_PROXIMITY) != null )
+ {
+ Log.i("SDL", "libSDL: starting proximity sensor");
+ _manager.registerListener(proximity, _manager.getDefaultSensor(Sensor.TYPE_PROXIMITY), SensorManager.SENSOR_DELAY_GAME);
+ }
}
public void onSensorChanged(SensorEvent event)
@@ -168,7 +175,22 @@ class AccelerometerReader implements SensorEventListener
}
}
+ static class ProximityListener implements SensorEventListener
+ {
+ public ProximityListener()
+ {
+ }
+ public void onSensorChanged(SensorEvent event)
+ {
+ nativeProximity(event.values[0]);
+ }
+ public void onAccuracyChanged(Sensor s, int a)
+ {
+ }
+ }
+
private static native void nativeAccelerometer(float accX, float accY, float accZ);
private static native void nativeGyroscope(float X, float Y, float Z);
private static native void nativeOrientation(float X, float Y, float Z);
+ private static native void nativeProximity(float X);
}