[Android] Made the remaining sensors available

This commit is contained in:
Jonathan De Wachter 2014-06-08 08:12:50 +02:00
parent 2874ac4aab
commit 60c34bff19

View File

@ -29,6 +29,11 @@
#include <SFML/System/Time.hpp> #include <SFML/System/Time.hpp>
#include <android/looper.h> #include <android/looper.h>
// Define missing constants
#define ASENSOR_TYPE_GRAVITY 0x00000009
#define ASENSOR_TYPE_LINEAR_ACCELERATION 0x0000000a
#define ASENSOR_TYPE_ORIENTATION 0x00000003
namespace namespace
{ {
ALooper* looper; ALooper* looper;
@ -127,15 +132,10 @@ void SensorImpl::setEnabled(bool enabled)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
ASensor const* SensorImpl::getDefaultSensor(Sensor::Type sensor) ASensor const* SensorImpl::getDefaultSensor(Sensor::Type sensor)
{ {
// These sensors are unavailable from the Android C API
if ((sensor == Sensor::Gravity) ||
(sensor == Sensor::UserAcceleration) ||
(sensor == Sensor::Orientation))
return NULL;
// Find the Android sensor type // Find the Android sensor type
static int types[] = {ASENSOR_TYPE_ACCELEROMETER, static int types[] = {ASENSOR_TYPE_ACCELEROMETER, ASENSOR_TYPE_GYROSCOPE,
ASENSOR_TYPE_GYROSCOPE, ASENSOR_TYPE_MAGNETIC_FIELD}; ASENSOR_TYPE_MAGNETIC_FIELD, ASENSOR_TYPE_GRAVITY, ASENSOR_TYPE_LINEAR_ACCELERATION,
ASENSOR_TYPE_ORIENTATION};
int type = types[sensor]; int type = types[sensor];