diff -r 2494f667555c Android.mk --- a/Android.mk Fri Feb 08 07:14:50 2013 -0800 +++ b/Android.mk Mon Feb 11 16:41:03 2013 +0100 @@ -28,6 +28,8 @@ $(wildcard $(LOCAL_PATH)/src/haptic/dummy/*.c) \ $(wildcard $(LOCAL_PATH)/src/joystick/*.c) \ $(wildcard $(LOCAL_PATH)/src/joystick/android/*.c) \ + $(wildcard $(LOCAL_PATH)/src/sensor/*.c) \ + $(wildcard $(LOCAL_PATH)/src/sensor/android/*.c) \ $(wildcard $(LOCAL_PATH)/src/loadso/dlopen/*.c) \ $(wildcard $(LOCAL_PATH)/src/power/*.c) \ $(wildcard $(LOCAL_PATH)/src/power/android/*.c) \ @@ -42,6 +44,6 @@ $(wildcard $(LOCAL_PATH)/src/video/android/*.c)) LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -LOCAL_LDLIBS := -ldl -lGLESv1_CM -lGLESv2 -llog +LOCAL_LDLIBS := -ldl -lGLESv1_CM -lGLESv2 -llog -landroid include $(BUILD_SHARED_LIBRARY) diff -r 2494f667555c android-project/src/org/libsdl/app/SDLActivity.java --- a/android-project/src/org/libsdl/app/SDLActivity.java Fri Feb 08 07:14:50 2013 -0800 +++ b/android-project/src/org/libsdl/app/SDLActivity.java Mon Feb 11 16:41:03 2013 +0100 @@ -161,7 +161,6 @@ public static native void onNativeTouch(int touchDevId, int pointerFingerId, int action, float x, float y, float p); - public static native void onNativeAccel(float x, float y, float z); public static native void nativeRunAudioThread(); @@ -461,10 +460,7 @@ Because of this, that's where we set up the SDL thread */ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, - View.OnKeyListener, View.OnTouchListener, SensorEventListener { - - // Sensors - private static SensorManager mSensorManager; + View.OnKeyListener, View.OnTouchListener { // Keep track of the surface size to normalize touch events private static float mWidth, mHeight; @@ -480,8 +476,6 @@ setOnKeyListener(this); setOnTouchListener(this); - mSensorManager = (SensorManager)context.getSystemService("sensor"); - // Some arbitrary defaults to avoid a potential division by zero mWidth = 1.0f; mHeight = 1.0f; @@ -491,7 +485,6 @@ public void surfaceCreated(SurfaceHolder holder) { Log.v("SDL", "surfaceCreated()"); holder.setType(SurfaceHolder.SURFACE_TYPE_GPU); - enableSensor(Sensor.TYPE_ACCELEROMETER, true); } // Called when we lose the surface @@ -501,7 +494,6 @@ SDLActivity.mIsPaused = true; SDLActivity.nativePause(); } - enableSensor(Sensor.TYPE_ACCELEROMETER, false); } // Called when the surface is resized @@ -616,31 +608,6 @@ return true; } - // Sensor events - public void enableSensor(int sensortype, boolean enabled) { - // TODO: This uses getDefaultSensor - what if we have >1 accels? - if (enabled) { - mSensorManager.registerListener(this, - mSensorManager.getDefaultSensor(sensortype), - SensorManager.SENSOR_DELAY_GAME, null); - } else { - mSensorManager.unregisterListener(this, - mSensorManager.getDefaultSensor(sensortype)); - } - } - - public void onAccuracyChanged(Sensor sensor, int accuracy) { - // TODO - } - - public void onSensorChanged(SensorEvent event) { - if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) { - SDLActivity.onNativeAccel(event.values[0] / SensorManager.GRAVITY_EARTH, - event.values[1] / SensorManager.GRAVITY_EARTH, - event.values[2] / SensorManager.GRAVITY_EARTH); - } - } - } /* This is a fake invisible editor view that receives the input and defines the diff -r 2494f667555c include/SDL.h --- a/include/SDL.h Fri Feb 08 07:14:50 2013 -0800 +++ b/include/SDL.h Mon Feb 11 16:41:03 2013 +0100 @@ -92,6 +92,7 @@ #include "SDL_thread.h" #include "SDL_timer.h" #include "SDL_version.h" +#include "SDL_sensor.h" #include "SDL_video.h" #include "begin_code.h" @@ -117,6 +118,7 @@ #define SDL_INIT_JOYSTICK 0x00000200 #define SDL_INIT_HAPTIC 0x00001000 #define SDL_INIT_GAMECONTROLLER 0x00002000 /**< turn on game controller also implicitly does JOYSTICK */ +#define SDL_INIT_SENSOR 0x00004000 #define SDL_INIT_NOPARACHUTE 0x00100000 /**< Don't catch fatal signals */ #define SDL_INIT_EVERYTHING 0x0000FFFF /*@}*/ diff -r 2494f667555c include/SDL_config_android.h --- a/include/SDL_config_android.h Fri Feb 08 07:14:50 2013 -0800 +++ b/include/SDL_config_android.h Mon Feb 11 16:41:03 2013 +0100 @@ -111,6 +111,7 @@ /* Enable various input drivers */ #define SDL_JOYSTICK_ANDROID 1 #define SDL_HAPTIC_DUMMY 1 +#define SDL_SENSOR_ANDROID 1 /* Enable various shared object loading systems */ #define SDL_LOADSO_DLOPEN 1 diff -r 2494f667555c include/SDL_config_iphoneos.h --- a/include/SDL_config_iphoneos.h Fri Feb 08 07:14:50 2013 -0800 +++ b/include/SDL_config_iphoneos.h Mon Feb 11 16:41:03 2013 +0100 @@ -143,6 +143,9 @@ /* enable joystick subsystem */ #define SDL_JOYSTICK_DISABLED 0 +/* use dummy sensor driver */ +#define SDL_SENSOR_DUMMY 1 + /* Set max recognized G-force from accelerometer See src/joystick/uikit/SDLUIAccelerationDelegate.m for notes on why this is needed */ diff -r 2494f667555c include/SDL_config_macosx.h --- a/include/SDL_config_macosx.h Fri Feb 08 07:14:50 2013 -0800 +++ b/include/SDL_config_macosx.h Mon Feb 11 16:41:03 2013 +0100 @@ -117,6 +117,9 @@ #define SDL_JOYSTICK_IOKIT 1 #define SDL_HAPTIC_IOKIT 1 +/* use dummy sensor driver */ +#define SDL_SENSOR_DUMMY 1 + /* Enable various shared object loading systems */ #define SDL_LOADSO_DLOPEN 1 diff -r 2494f667555c include/SDL_config_minimal.h --- a/include/SDL_config_minimal.h Fri Feb 08 07:14:50 2013 -0800 +++ b/include/SDL_config_minimal.h Mon Feb 11 16:41:03 2013 +0100 @@ -56,6 +56,9 @@ /* Enable the stub joystick driver (src/joystick/dummy/\*.c) */ #define SDL_JOYSTICK_DISABLED 1 +/* Enable dummy sensor driver */ +#define SDL_SENSOR_DUMMY 1 + /* Enable the stub haptic driver (src/haptic/dummy/\*.c) */ #define SDL_HAPTIC_DISABLED 1 diff -r 2494f667555c include/SDL_config_nintendods.h --- a/include/SDL_config_nintendods.h Fri Feb 08 07:14:50 2013 -0800 +++ b/include/SDL_config_nintendods.h Mon Feb 11 16:41:03 2013 +0100 @@ -100,6 +100,9 @@ #define SDL_JOYSTICK_NDS 1 /*#define SDL_JOYSTICK_DUMMY 1 TODO: uncomment this later*/ +/* use dummy sensor driver */ +#define SDL_SENSOR_DUMMY 1 + /* DS has no dynamic linking afaik */ #define SDL_LOADSO_DISABLED 1 diff -r 2494f667555c include/SDL_config_pandora.h --- a/include/SDL_config_pandora.h Fri Feb 08 07:14:50 2013 -0800 +++ b/include/SDL_config_pandora.h Mon Feb 11 16:41:03 2013 +0100 @@ -107,6 +107,7 @@ #define SDL_INPUT_TSLIB 1 #define SDL_JOYSTICK_LINUX 1 #define SDL_HAPTIC_LINUX 1 +#define SDL_SENSOR_DUMMY 1 #define SDL_LOADSO_DLOPEN 1 diff -r 2494f667555c include/SDL_config_windows.h --- a/include/SDL_config_windows.h Fri Feb 08 07:14:50 2013 -0800 +++ b/include/SDL_config_windows.h Mon Feb 11 16:41:03 2013 +0100 @@ -153,6 +153,9 @@ #define SDL_JOYSTICK_DINPUT 1 #define SDL_HAPTIC_DINPUT 1 +/* Enable dummy sensor driver */ +#define SDL_SENSOR_DUMMY 1 + /* Enable various shared object loading systems */ #define SDL_LOADSO_WINDOWS 1 diff -r 2494f667555c include/SDL_config_wiz.h --- a/include/SDL_config_wiz.h Fri Feb 08 07:14:50 2013 -0800 +++ b/include/SDL_config_wiz.h Mon Feb 11 16:41:03 2013 +0100 @@ -103,6 +103,7 @@ #define SDL_INPUT_TSLIB 1 #define SDL_JOYSTICK_LINUX 1 #define SDL_HAPTIC_LINUX 1 +#define SDL_SENSOR_DUMMY 1 #define SDL_LOADSO_DLOPEN 1 diff -r 2494f667555c include/SDL_sensor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/SDL_sensor.h Mon Feb 11 16:41:03 2013 +0100 @@ -0,0 +1,193 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_sensor.h + * + * Include file for SDL sensor event handling + * + * The term "device_index" identifies currently plugged in joystick devices between 0 and SDL_NumJoysticks, with the exact joystick + * behind a device_index changing as joysticks are plugged and unplugged. + * + * The term "instance_id" is the current instantiation of a joystick device in the system, if the joystick is removed and then re-inserted + * then it will get a new instance_id, instance_id's are monotonically increasing identifiers of a joystick plugged in. + * + * The term JoystickGUID is a stable 128-bit identifier for a joystick device that does not change over time, it identifies class of + * the device (a X360 wired controller for example). This identifier is platform dependent. + * + * + */ + +#ifndef _SDL_sensor_h +#define _SDL_sensor_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +/* *INDENT-OFF* */ +extern "C" { +/* *INDENT-ON* */ +#endif + +/** + * \file SDL_sensor.h + * + * In order to use these functions, SDL_Init() must have been called + * with the ::SDL_INIT_JOYSTICK flag. This causes SDL to scan the system + * for joysticks, and load appropriate drivers. + */ + +/* The joystick structure used to identify an SDL joystick */ +struct _SDL_Sensor; +typedef struct _SDL_Sensor SDL_Sensor; + +/* A structure that encodes the stable unique id for a joystick device */ +typedef struct { + Uint8 data[16]; +} SDL_SensorGUID; + +typedef int SDL_SensorID; + +/* The different sensor types */ +typedef enum +{ + SDL_SENSOR_UNKNOWN = 0x00000000, /**< unknown sensor type */ + SDL_SENSOR_ACCEL = 0x00000001, /**< accelerometer */ + SDL_SENSOR_MAGNET = 0x00000002, /**< magnetometer */ + SDL_SENSOR_ORIENTATION = 0x00000003, /**< orientation sensor */ + SDL_SENSOR_GYRO = 0x00000004, /**< gyroscope */ + SDL_SENSOR_LIGHT = 0x00000005, /**< light sensor */ + SDL_SENSOR_PRESSURE = 0x00000006, /**< pressure sensor */ + SDL_SENSOR_TEMPERATURE = 0x00000007, /**< temperature sensor */ + SDL_SENSOR_PROXIMITY = 0x00000008, /**< proximity sensor */ + SDL_SENSOR_GRAVITY = 0x00000009, /**< gravity sensor */ + SDL_SENSOR_LACCEL = 0x0000000a, /**< linear acceleration sensor */ + SDL_SENSOR_ROTVECTOR = 0x0000000b, /**< rotation vector sensor */ + SDL_SENSOR_RHUMIDITY = 0x0000000c /**< relative humidity sensor */ +} SDL_SensorFlags; + +/* Function prototypes */ +/** + * Count the number of sensors attached to the system right now + */ +extern DECLSPEC int SDLCALL SDL_NumSensors(void); + +/** + * Get the implementation dependent name of a sensor. + * This can be called before any sensors are opened. + * If no name can be found, this function returns NULL. + */ +extern DECLSPEC const char *SDLCALL SDL_SensorNameForIndex(int device_index); + +/** + * Open a sensor for use. + * The index passed as an argument refers tothe N'th sensor on the system. + * This index is the value which will identify this sensor in future sensor + * events. + * + * \return A sensor identifier, or NULL if an error occurred. + */ +extern DECLSPEC SDL_Sensor *SDLCALL SDL_SensorOpen(int device_index); + +/** + * Return the name for this currently opened sensor. + * If no name can be found, this function returns NULL. + */ +extern DECLSPEC const char *SDLCALL SDL_SensorName(SDL_Sensor * sensor); + +/** + * Returns SDL_TRUE if the sensor has been opened and currently connected, or SDL_FALSE if it has not. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_SensorGetAttached(SDL_Sensor * sensor); + +/** + * Get the instance ID of an opened sensor. + */ +extern DECLSPEC SDL_SensorID SDLCALL SDL_SensorInstanceID(SDL_Sensor * sensor); + +/** + * Get the number of general axis controls on a sensor. + */ +extern DECLSPEC int SDLCALL SDL_SensorNumAxes(SDL_Sensor * sensor); + +/** + * Get the sensor type for an opened sensor. + */ +extern DECLSPEC Uint8 SDL_SensorType(SDL_Sensor * sensor); + +/** + * Update the current state of the open sensors. + * + * This is called automatically by the event loop if any sensor + * events are enabled. + */ +extern DECLSPEC void SDLCALL SDL_SensorUpdate(void); + +/** + * Enable/disable sensor event polling. + * + * If sensor events are disabled, you must call SDL_SensorUpdate() + * yourself and check the state of the sensor when you want sensor + * information. + * + * The state can be one of ::SDL_QUERY, ::SDL_ENABLE or ::SDL_IGNORE. + */ +extern DECLSPEC int SDLCALL SDL_SensorEventState(int state); + +/** + * Get the current state of an axis on a sensor. + * + * The state is a value ranging from -32768 to 32767. + * + * The axis indices start at index 0. + */ +extern DECLSPEC Sint16 SDLCALL SDL_SensorGetAxis(SDL_Sensor * sensor, + int axis); + +/** + * Get the current resolution of an axis on a sensor. + * + * The state is a value ranging from -32768 to 32767. + * + * The axis indices start at index 0. + */ +extern DECLSPEC float SDLCALL SDL_SensorGetResolution(SDL_Sensor * sensor); + +/** + * Close a sensor previously opened with SDL_SensorOpen(). + */ +extern DECLSPEC void SDLCALL SDL_SensorClose(SDL_Sensor * sensor); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +/* *INDENT-OFF* */ +} +/* *INDENT-ON* */ +#endif +#include "close_code.h" + +#endif /* _SDL_sensor_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -r 2494f667555c src/SDL.c --- a/src/SDL.c Fri Feb 08 07:14:50 2013 -0800 +++ b/src/SDL.c Mon Feb 11 16:41:03 2013 +0100 @@ -152,6 +152,25 @@ } #endif +#if !SDL_SENSOR_DISABLED + /* Initialize the sensor subsystem */ + if ((flags & SDL_INIT_SENSOR) ) { + SDL_SubsystemRefCount[ msb32_idx(SDL_INIT_SENSOR) ]++; + SDL_assert( SDL_SubsystemRefCount[ msb32_idx(SDL_INIT_SENSOR) ] < 254 ); + if ( !(SDL_initialized & SDL_INIT_SENSOR)) { + if (SDL_SensorInit(NULL) < 0) { + return (-1); + } + SDL_initialized |= SDL_INIT_SENSOR; + } + } +#else + if (flags & SDL_INIT_SENSOR) { + SDL_SetError("SDL not built with sensor support"); + return (-1); + } +#endif + #if !SDL_HAPTIC_DISABLED /* Initialize the haptic subsystem */ if ((flags & SDL_INIT_HAPTIC) ) { diff -r 2494f667555c src/core/android/SDL_android.cpp --- a/src/core/android/SDL_android.cpp Fri Feb 08 07:14:50 2013 -0800 +++ b/src/core/android/SDL_android.cpp Mon Feb 11 16:41:03 2013 +0100 @@ -76,10 +76,6 @@ static jmethodID midAudioWriteByteBuffer; static jmethodID midAudioQuit; -// Accelerometer data storage -static float fLastAccelerometer[3]; -static bool bHasNewData; - /******************************************************************************* Functions called by JNI *******************************************************************************/ @@ -130,8 +126,6 @@ midAudioQuit = mEnv->GetStaticMethodID(mActivityClass, "audioQuit", "()V"); - bHasNewData = false; - if(!midCreateGLContext || !midFlipBuffers || !midAudioInit || !midAudioWriteShortBuffer || !midAudioWriteByteBuffer || !midAudioQuit) { __android_log_print(ANDROID_LOG_WARN, "SDL", "SDL: Couldn't locate Java callbacks, check that they're named and typed correctly"); @@ -170,17 +164,6 @@ Android_OnTouch(touch_device_id_in, pointer_finger_id_in, action, x, y, p); } -// Accelerometer -extern "C" void Java_org_libsdl_app_SDLActivity_onNativeAccel( - JNIEnv* env, jclass jcls, - jfloat x, jfloat y, jfloat z) -{ - fLastAccelerometer[0] = x; - fLastAccelerometer[1] = y; - fLastAccelerometer[2] = z; - bHasNewData = true; -} - // Quit extern "C" void Java_org_libsdl_app_SDLActivity_nativeQuit( JNIEnv* env, jclass cls) @@ -347,22 +330,6 @@ } } -extern "C" SDL_bool Android_JNI_GetAccelerometerValues(float values[3]) -{ - int i; - SDL_bool retval = SDL_FALSE; - - if (bHasNewData) { - for (i = 0; i < 3; ++i) { - values[i] = fLastAccelerometer[i]; - } - bHasNewData = false; - retval = SDL_TRUE; - } - - return retval; -} - static void Android_JNI_ThreadDestroyed(void* value) { /* The thread is being destroyed, detach it from the Java VM and set the mThreadKey value to NULL as required */ JNIEnv *env = (JNIEnv*) value; diff -r 2494f667555c src/joystick/android/SDL_sysjoystick.c --- a/src/joystick/android/SDL_sysjoystick.c Fri Feb 08 07:14:50 2013 -0800 +++ b/src/joystick/android/SDL_sysjoystick.c Mon Feb 11 16:41:03 2013 +0100 @@ -33,8 +33,6 @@ #include "../SDL_joystick_c.h" #include "../../core/android/SDL_android.h" -static const char *accelerometerName = "Android accelerometer"; - /* Function to scan the system for joysticks. * This function should set SDL_numjoysticks to the number of available * joysticks. Joystick 0 should be the system default joystick. @@ -48,7 +46,7 @@ int SDL_SYS_NumJoysticks() { - return 1; + return 0; } void SDL_SYS_JoystickDetect() @@ -64,7 +62,8 @@ const char * SDL_SYS_JoystickNameForDeviceIndex(int device_index) { - return accelerometerName; + SDL_SetError("Logic error: No joysticks available"); + return (NULL); } /* Function to perform the mapping from device index to the instance id for this index */ @@ -81,16 +80,8 @@ int SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index) { - if (device_index == 0) { - joystick->nbuttons = 0; - joystick->nhats = 0; - joystick->nballs = 0; - joystick->naxes = 3; - return 0; - } else { - SDL_SetError("No joystick available with that index"); - return (-1); - } + SDL_SetError("Logic error: No joysticks available"); + return (-1); } /* Function to determine is this joystick is attached to the system right now */ @@ -107,28 +98,21 @@ void SDL_SYS_JoystickUpdate(SDL_Joystick * joystick) { - int i; - Sint16 value; - float values[3]; - - if (Android_JNI_GetAccelerometerValues(values)) { - for ( i = 0; i < 3; i++ ) { - value = (Sint16)(values[i] * 32767.0f); - SDL_PrivateJoystickAxis(joystick, i, value); - } - } + return; } /* Function to close a joystick after use */ void SDL_SYS_JoystickClose(SDL_Joystick * joystick) { + return; } /* Function to perform any system-specific joystick related cleanup */ void SDL_SYS_JoystickQuit(void) { + return; } SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index ) diff -r 2494f667555c src/sensor/SDL_sensor.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/sensor/SDL_sensor.c Mon Feb 11 16:41:03 2013 +0100 @@ -0,0 +1,420 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +/* This is the sensor API for Simple DirectMedia Layer */ + +#include "SDL_events.h" +#include "SDL_syssensor.h" +#include "SDL_assert.h" + +#if !SDL_EVENTS_DISABLED +#include "../events/SDL_events_c.h" +#endif + +static SDL_Sensor *SDL_sensors = NULL; +static SDL_Sensor *SDL_updating_sensor = NULL; + +int +SDL_SensorInit(void) +{ + int status; + + status = SDL_SYS_SensorInit(); + if (status >= 0) { + status = 0; + } + return (status); +} + +/* + * Count the number of sensors attached to the system + */ +int +SDL_NumSensors(void) +{ + return SDL_SYS_NumSensors(); +} + +/* + * Get the implementation dependent name of a sensor + */ +const char * +SDL_SensorNameForIndex(int device_index) +{ + if ((device_index < 0) || (device_index >= SDL_NumSensors())) { + SDL_SetError("There are %d sensors available", SDL_NumSensors()); + return (NULL); + } + return (SDL_SYS_SensorNameForDeviceIndex(device_index)); +} + +/* + * Open a sensor for use - the index passed as an argument refers to + * the N'th sensor on the system. This index is the value which will + * identify this sensor in future sensor events. + * + * This function returns a sensor identifier, or NULL if an error occurred. + */ +SDL_Sensor * +SDL_SensorOpen(int device_index) +{ + SDL_Sensor *sensor; + SDL_Sensor *sensorlist; + const char *sensorname = NULL; + + if ((device_index < 0) || (device_index >= SDL_NumSensors())) { + SDL_SetError("There are %d sensors available", SDL_NumSensors()); + return (NULL); + } + + sensorlist = SDL_sensors; + /* If the sensor is already open, return it + * it is important that we have a single sensor * for each instance id + */ + while ( sensorlist ) + { + if ( SDL_SYS_GetInstanceIdOfDeviceIndex(device_index) == sensorlist->instance_id ) { + sensor = sensorlist; + ++sensor->ref_count; + return (sensor); + } + sensorlist = sensorlist->next; + } + + /* Create and initialize the sensor */ + sensor = (SDL_Sensor *) SDL_malloc((sizeof *sensor)); + if (sensor == NULL) { + SDL_OutOfMemory(); + return NULL; + } + + SDL_memset(sensor, 0, (sizeof *sensor)); + if (SDL_SYS_SensorOpen(sensor, device_index) < 0) { + SDL_free(sensor); + return NULL; + } + + sensorname = SDL_SYS_SensorNameForDeviceIndex( device_index ); + if ( sensorname ) + sensor->name = SDL_strdup( sensorname ); + else + sensor->name = NULL; + + if (sensor->naxes > 0) { + sensor->axes = (Sint16 *) SDL_malloc + (sensor->naxes * sizeof(Sint16)); + } + if ( (sensor->naxes > 0) && (!sensor->axes) ) { + SDL_OutOfMemory(); + SDL_SensorClose(sensor); + return NULL; + } + if (sensor->axes) { + SDL_memset(sensor->axes, 0, sensor->naxes * sizeof(Sint16)); + } + + /* Add sensor to list */ + ++sensor->ref_count; + /* Link the sensor in the list */ + sensor->next = SDL_sensors; + SDL_sensors = sensor; + + SDL_SYS_SensorUpdate( sensor ); + + return (sensor); +} + + +/* + * Checks to make sure the sensor is valid. + */ +int +SDL_PrivatesensorValid(SDL_Sensor * sensor) +{ + int valid; + + if ( sensor == NULL ) { + SDL_SetError("sensor hasn't been opened yet"); + valid = 0; + } else { + valid = 1; + } + + if ( sensor && sensor->closed ) + { + valid = 0; + } + + return valid; +} + +/* + * Get the number of multi-dimensional axis controls on a sensor + */ +int +SDL_SensorNumAxes(SDL_Sensor * sensor) +{ + if (!SDL_PrivatesensorValid(sensor)) { + return (-1); + } + return (sensor->naxes); +} + +/* + * Get the number of multi-dimensional axis controls on a sensor + */ +Uint8 +SDL_SensorType(SDL_Sensor * sensor) +{ + if (!SDL_PrivatesensorValid(sensor)) { + return (-1); + } + return (sensor->type); +} + +/* + * Get the current state of an axis control on a sensor + */ +Sint16 +SDL_SensorGetAxis(SDL_Sensor * sensor, int axis) +{ + Sint16 state; + + if (!SDL_PrivatesensorValid(sensor)) { + return (0); + } + if (axis < sensor->naxes) { + state = sensor->axes[axis]; + } else { + SDL_SetError("sensor only has %d axes", sensor->naxes); + state = 0; + } + return (state); +} + +/* + * Get the current resolution of an axis control on a sensor + */ +float +SDL_SensorGetResolution(SDL_Sensor * sensor) +{ + float state; + + if (!SDL_PrivatesensorValid(sensor)) { + return (0); + } + + return sensor->resolution; +} + +/* + * Return if the sensor in question is currently attached to the system, + * \return 0 if not plugged in, 1 if still present. + */ +SDL_bool +SDL_SensorGetAttached(SDL_Sensor * sensor) +{ + if (!SDL_PrivatesensorValid(sensor)) { + return SDL_FALSE; + } + + return SDL_SYS_SensorAttached(sensor); +} + +/* + * Get the instance id for this opened sensor + */ +SDL_SensorID +SDL_SensorInstanceID(SDL_Sensor * sensor) +{ + if (!SDL_PrivatesensorValid(sensor)) { + return (-1); + } + + return (sensor->instance_id); +} + +/* + * Get the friendly name of this sensor + */ +const char * +SDL_SensorName(SDL_Sensor * sensor) +{ + if (!SDL_PrivatesensorValid(sensor)) { + return (NULL); + } + + return (sensor->name); +} + +/* + * Close a sensor previously opened with SDL_SensorOpen() + */ +void +SDL_SensorClose(SDL_Sensor * sensor) +{ + SDL_Sensor *sensorlist; + SDL_Sensor *sensorlistprev; + + if (!sensor) { + return; + } + + /* First decrement ref count */ + if (--sensor->ref_count > 0) { + return; + } + + if (sensor == SDL_updating_sensor) { + return; + } + + SDL_SYS_SensorClose(sensor); + + sensorlist = SDL_sensors; + sensorlistprev = NULL; + while ( sensorlist ) + { + if (sensor == sensorlist) + { + if ( sensorlistprev ) + { + // unlink this entry + sensorlistprev->next = sensorlist->next; + } + else + { + SDL_sensors = sensor->next; + } + + break; + } + sensorlistprev = sensorlist; + sensorlist = sensorlist->next; + } + + if (sensor->name) + SDL_free(sensor->name); + + /* Free the data associated with this sensor */ + if (sensor->axes) { + SDL_free(sensor->axes); + } + SDL_free(sensor); +} + +void +SDL_SensorQuit(void) +{ + /* Make sure we're not getting called in the middle of updating sensors */ + SDL_assert(!SDL_updating_sensor); + + /* Stop the event polling */ + while ( SDL_sensors ) + { + SDL_sensors->ref_count = 1; + SDL_SensorClose(SDL_sensors); + } + + /* Quit the sensor setup */ + SDL_SYS_SensorQuit(); +} + + +/* These are global for SDL_syssensor.c and SDL_events.c */ + +int +SDL_PrivatesensorAxis(SDL_Sensor * sensor, Uint8 axis, Sint16 value) +{ + int posted; + + /* Make sure we're not getting garbage events */ + if (axis >= sensor->naxes) { + return 0; + } + + /* Update internal sensor state */ + if (value == sensor->axes[axis]) { + return 0; + } + sensor->axes[axis] = value; + + /* Post the event, if desired */ + posted = 0; + return (posted); +} + +void +SDL_SensorUpdate(void) +{ + SDL_Sensor *sensor; + + sensor = SDL_sensors; + while ( sensor ) + { + SDL_Sensor *sensornext; + /* save off the next pointer, the Update call may cause a sensor removed event + * and cause our sensor pointer to be freed + */ + sensornext = sensor->next; + + SDL_updating_sensor = sensor; + + SDL_SYS_SensorUpdate( sensor ); + + if ( sensor->closed && sensor->uncentered ) + { + int i; + sensor->uncentered = 0; + + /* Tell the app that everything is centered/unpressed... */ + for (i = 0; i < sensor->naxes; i++) + { + SDL_PrivatesensorAxis(sensor, i, 0); + } + } + + SDL_updating_sensor = NULL; + + /* If the sensor was closed while updating, free it here */ + if ( sensor->ref_count <= 0 ) { + SDL_SensorClose(sensor); + } + + sensor = sensornext; + } + + SDL_SYS_SensorDetect(); +} + +/* return 1 if you want to run the sensor update loop this frame, used by hotplug support */ +SDL_bool +SDL_PrivatesensorNeedsPolling() +{ + if (SDL_sensors != NULL) { + return SDL_TRUE; + } else { + return SDL_SYS_SensorNeedsPolling(); + } +} + +/* vi: set ts=4 sw=4 expandtab: */ diff -r 2494f667555c src/sensor/SDL_sensor_c.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/sensor/SDL_sensor_c.h Mon Feb 11 16:41:03 2013 +0100 @@ -0,0 +1,37 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +/* Useful functions and variables from SDL_joystick.c */ +#include "SDL_sensor.h" + +/* Initialization and shutdown functions */ +extern int SDL_SensorInit(void); +extern void SDL_SensorQuit(void); + + +/* Helper function to let lower sys layer tell the event system if the joystick code needs to think */ +extern SDL_bool SDL_PrivateSensorNeedsPolling(); + +/* Internal sanity checking functions */ +extern int SDL_PrivateSensorValid(SDL_Sensor * sensor); + +/* vi: set ts=4 sw=4 expandtab: */ diff -r 2494f667555c src/sensor/SDL_syssensor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/sensor/SDL_syssensor.h Mon Feb 11 16:41:03 2013 +0100 @@ -0,0 +1,92 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +/* This is the system specific header for the SDL sensor API */ + +#include "SDL_sensor.h" +#include "SDL_sensor_c.h" + +/* The SDL sensor structure */ +struct _SDL_Sensor +{ + int instance_id; /* Device instance, monotonically increasing from 0 */ + char *name; /* Sensor name - system dependent */ + Uint8 type; /* Type of sensor */ + + int naxes; /* Number of axis controls on the sensor */ + Sint16 *axes; /* Current axis states */ + float resolution; /* Resolution for this sensor */ + + struct sensor_hwdata *hwdata; /* Driver dependent information */ + + int ref_count; /* Reference count for multiple opens */ + + Uint8 closed; /* 1 if this device is no longer valid */ + Uint8 uncentered; /* 1 if this device needs to have its state reset to 0 */ + struct _SDL_Sensor *next; /* pointer to next sensor we have allocated */ +}; + +/* Function to scan the system for sensors. + * sensor 0 should be the system default sensor. + * This function should return the number of available sensors, or -1 + * on an unrecoverable fatal error. + */ +extern int SDL_SYS_SensorInit(void); + +/* Function to return the number of sensor devices plugged in right now */ +extern int SDL_SYS_NumSensors(); + +/* Function to cause any queued sensor insertions to be processed */ +extern void SDL_SYS_SensorDetect(); + +/* Function to determine if the sensor loop needs to run right now */ +extern SDL_bool SDL_SYS_SensorNeedsPolling(); + +/* Function to get the device-dependent name of a sensor */ +extern const char *SDL_SYS_SensorNameForDeviceIndex(int device_index); + +/* Function to open a sensor for use. + The sensor to open is specified by the index field of the sensor. + This should fill the nbuttons and naxes fields of the sensor structure. + It returns 0, or -1 if there is an error. + */ +extern int SDL_SYS_SensorOpen(SDL_Sensor * sensor, int device_index); + +/* Function to query if the sensor is currently attached + * It returns 1 if attached, 0 otherwise. + */ +extern SDL_bool SDL_SYS_SensorAttached(SDL_Sensor * sensor); + +/* Function to update the state of a sensor - called as a device poll. + * This function shouldn't update the sensor structure directly, + * but instead should call SDL_PrivateSensor*() to deliver events + * and update sensor device state. + */ +extern void SDL_SYS_SensorUpdate(SDL_Sensor * sensor); + +/* Function to close a sensor after use */ +extern void SDL_SYS_SensorClose(SDL_Sensor * sensor); + +/* Function to perform any system-specific sensor related cleanup */ +extern void SDL_SYS_SensorQuit(void); + +/* vi: set ts=4 sw=4 expandtab: */ diff -r 2494f667555c src/sensor/android/SDL_androidsensor.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/sensor/android/SDL_androidsensor.c Mon Feb 11 16:41:03 2013 +0100 @@ -0,0 +1,288 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_config.h" + +#ifdef SDL_SENSOR_ANDROID + +/* This is the system specific header for the SDL sensor API */ +#include /* For the definition of NULL */ +#include + +#include "SDL_error.h" +#include "SDL_events.h" +#include "SDL_sensor.h" +#include "SDL_androidsensor.h" +#include "../SDL_syssensor.h" +#include "../SDL_sensor_c.h" +#include "../../core/android/SDL_android.h" + +static ASensorManager* mSensorManager; +static ASensorEventQueue* eventqueue; +static ALooper* looper; +static int open_sensors=0; + +/* Function to scan the system for sensors. + * Sensor 0 should be the system default sensor. + * It should return 0, or -1 on an unrecoverable fatal error. + */ +int +SDL_SYS_SensorInit(void) +{ + mSensorManager = ASensorManager_getInstance(); + looper = ALooper_forThread(); + if(! looper) { + looper = ALooper_prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS); + if(! looper) { + return -1; + } + } + + return 0; +} + +int SDL_SYS_NumSensors() +{ + return ASensorManager_getSensorList(mSensorManager, NULL); +} + +SDL_bool SDL_SYS_SensorNeedsPolling() +{ + return SDL_FALSE; +} + +/* Function to get the device-dependent name of a sensor + * Should be callable even before opening the sensor */ +const char * +SDL_SYS_SensorNameForDeviceIndex(int device_index) +{ + int n=0; + ASensorList list; + + n = ASensorManager_getSensorList(mSensorManager, &list); + if (device_index > n || ! list) { + return ""; + } + + return ASensor_getName(list[device_index]); +} + +/* Function to open a sensor for use. + The sensor to open is specified by the index field of the sensor. + This should fill the naxes fields of the sensor structure. + It returns 0, or -1 if there is an error. + */ +int +SDL_SYS_SensorOpen(SDL_Sensor *sensor, int device_index) +{ + int type=0; + ASensorList list; + + if (device_index > ASensorManager_getSensorList(mSensorManager, &list) || ! list) { + return -1; + } + + sensor->hwdata = (struct sensor_hwdata *) + SDL_malloc(sizeof(*sensor->hwdata)); + if (sensor->hwdata == NULL) { + SDL_OutOfMemory(); + return -1; + } + + sensor->hwdata->asensor = list[device_index]; + + type = ASensor_getType(list[device_index]); + switch(type) { + case 0x00000001: + sensor->type = SDL_SENSOR_ACCEL; + sensor->naxes = 3; + break; + case 0x00000002: + sensor->type = SDL_SENSOR_MAGNET; + sensor->naxes = 3; + break; + case 0x00000003: + sensor->type = SDL_SENSOR_ORIENTATION; + sensor->naxes = 3; + break; + case 0x00000004: + sensor->type = SDL_SENSOR_GYRO; + sensor->naxes = 3; + break; + case 0x00000005: + sensor->type = SDL_SENSOR_LIGHT; + sensor->naxes = 1; + break; + case 0x00000006: + sensor->type = SDL_SENSOR_PRESSURE; + sensor->naxes = 1; + break; + case 0x00000007: + sensor->type = SDL_SENSOR_TEMPERATURE; + sensor->naxes = 1; + break; + case 0x00000008: + sensor->type = SDL_SENSOR_PROXIMITY; + sensor->naxes = 1; + break; + case 0x00000009: + sensor->type = SDL_SENSOR_GRAVITY; + sensor->naxes = 1; + break; + case 0x0000000a: + sensor->type = SDL_SENSOR_LACCEL; + sensor->naxes = 3; + break; + case 0x0000000b: + sensor->type = SDL_SENSOR_ROTVECTOR; + sensor->naxes = 3; + break; + case 0x0000000c: + sensor->type = SDL_SENSOR_RHUMIDITY; + sensor->naxes = 1; + break; + default: + sensor->type = SDL_SENSOR_UNKNOWN; + sensor->naxes = 3; // Just in case + } + + sensor->resolution = ASensor_getResolution(list[device_index]); + + // If there were no open sensors, open the event queue and associate + // it to the looper + if(open_sensors == 0) { + eventqueue = ASensorManager_createEventQueue(mSensorManager, looper, 3 /* LOOPER_ID_USER */, NULL, NULL); + } + open_sensors++; + + ASensorEventQueue_enableSensor(eventqueue, list[device_index]); + + return 0; +} + +/* Function to update the state of a sensor - called as a device poll. + * This function shouldn't update the sensor structure directly, + * but instead should call SDL_PrivateSensor*() to deliver events + * and update sensor device state. + * There's some useful information on what the Android sensors give you at: + * http://developer.android.com/reference/android/hardware/SensorEvent.html + */ +void +SDL_SYS_SensorUpdate(SDL_Sensor* sensor) +{ + int events; + ASensorEvent event; + struct android_poll_source* source; + + while (ALooper_pollAll(0, NULL, &events, (void**)&source) == 3 /* LOOPER_ID_USER */ ) { + // If a sensor has data, process it now. + // TODO: Make some sense from this data... + while (ASensorEventQueue_getEvents(eventqueue, + &event, 1) > 0) { + switch(event.type) { + case 0x00000001: + SDL_PrivatesensorAxis(sensor, 0, event.acceleration.x); + SDL_PrivatesensorAxis(sensor, 1, event.acceleration.y); + SDL_PrivatesensorAxis(sensor, 2, event.acceleration.z); + break; + case 0x00000002: + SDL_PrivatesensorAxis(sensor, 0, event.magnetic.x); + SDL_PrivatesensorAxis(sensor, 1, event.magnetic.y); + SDL_PrivatesensorAxis(sensor, 2, event.magnetic.z); + break; + case 0x00000003: + SDL_PrivatesensorAxis(sensor, 0, event.vector.azimuth); + SDL_PrivatesensorAxis(sensor, 1, event.vector.pitch); + SDL_PrivatesensorAxis(sensor, 2, event.vector.roll); + break; + case 0x00000004: + SDL_PrivatesensorAxis(sensor, 0, event.vector.x); + SDL_PrivatesensorAxis(sensor, 1, event.vector.y); + SDL_PrivatesensorAxis(sensor, 2, event.vector.z); + break; + case 0x00000005: + SDL_PrivatesensorAxis(sensor, 0, event.light); + break; + case 0x00000006: + SDL_PrivatesensorAxis(sensor, 0, event.pressure); + break; + case 0x00000007: + SDL_PrivatesensorAxis(sensor, 0, event.temperature); + break; + case 0x00000008: + SDL_PrivatesensorAxis(sensor, 0, event.distance); + break; + case 0x00000009: + SDL_PrivatesensorAxis(sensor, 0, event.vector.x); + SDL_PrivatesensorAxis(sensor, 1, event.vector.y); + SDL_PrivatesensorAxis(sensor, 2, event.vector.z); + break; + case 0x0000000a: + SDL_PrivatesensorAxis(sensor, 0, event.acceleration.x); + SDL_PrivatesensorAxis(sensor, 1, event.acceleration.y); + SDL_PrivatesensorAxis(sensor, 2, event.acceleration.z); + break; + case 0x0000000b: + SDL_PrivatesensorAxis(sensor, 0, event.vector.x); + SDL_PrivatesensorAxis(sensor, 1, event.vector.y); + SDL_PrivatesensorAxis(sensor, 2, event.vector.z); + break; + case 0x0000000c: + // Is this OK? + SDL_PrivatesensorAxis(sensor, 0, event.data[0]); + break; + default: + break; + } + } + } +} + +/* Function to determine is this sensor is attached to the system right now */ +SDL_bool SDL_SYS_SensorAttached(SDL_Sensor *sensor) +{ + return SDL_TRUE; +} + +/* Function to close a sensor after use */ +void +SDL_SYS_SensorClose(SDL_Sensor * sensor) +{ + SDL_free(sensor->hwdata); + open_sensors--; + + ASensorEventQueue_enableSensor(eventqueue, sensor->hwdata->asensor); + + // Don't read the sensors if no SDL_Sensor is open + if(! open_sensors) { + ASensorManager_destroyEventQueue(mSensorManager, eventqueue); + } +} + +/* Function to perform any system-specific sensor related cleanup */ +void +SDL_SYS_SensorQuit(void) +{ +} + +#endif /* SDL_SENSOR_ANDROID */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -r 2494f667555c src/sensor/android/SDL_androidsensor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/sensor/android/SDL_androidsensor.h Mon Feb 11 16:41:03 2013 +0100 @@ -0,0 +1,30 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +/* The private structure used to keep track of a sensor */ +struct sensor_hwdata +{ + ASensor const* asensor; +}; + + +/* vi: set ts=4 sw=4 expandtab: */ diff -r 2494f667555c src/sensor/dummy/SDL_syssensor.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/sensor/dummy/SDL_syssensor.c Mon Feb 11 16:41:03 2013 +0100 @@ -0,0 +1,103 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#if defined(SDL_SENSOR_DUMMY) || defined(SDL_SENSOR_DISABLED) + +/* This is the system specific header for the SDL sensor API */ + +#include "SDL_sensor.h" +#include "../SDL_syssensor.h" +#include "../SDL_sensor_c.h" + +/* Function to scan the system for joysticks. + * It should return 0, or -1 on an unrecoverable fatal error. + */ +int +SDL_SYS_SensorInit(void) +{ + return (0); +} + +int SDL_SYS_NumSensors() +{ + return 0; +} + +SDL_bool SDL_SYS_SensorNeedsPolling() +{ + return SDL_FALSE; +} + +/* Function to get the device-dependent name of a sensor */ +const char * +SDL_SYS_SensorNameForDeviceIndex(int device_index) +{ + SDL_SetError("Logic error: No sensors available"); + return (NULL); +} + +/* Function to determine is this sensor is attached to the system right now */ +SDL_bool SDL_SYS_SensorAttached(SDL_Sensor *sensor) +{ + return SDL_FALSE; +} + +/* Function to open a sensor for use. + The sensor to open is specified by the index field of the sensor. + This should fill the naxes fields of the sensor structure. + It returns 0, or -1 if there is an error. + */ +int +SDL_SYS_SensorOpen(SDL_Sensor *sensor, int device_index) +{ + SDL_SetError("Logic error: No sensors available"); + return (-1); +} + +/* Function to update the state of a sensor - called as a device poll. + * This function shouldn't update the sensor structure directly, + * but instead should call SDL_PrivateSensor*() to deliver events + * and update sensor device state. + */ +void +SDL_SYS_SensorUpdate(SDL_Sensor* sensor) +{ + return; +} + +/* Function to close a sensor after use */ +void +SDL_SYS_SensorClose(SDL_Sensor * sensor) +{ + return; +} + +/* Function to perform any system-specific sensor related cleanup */ +void +SDL_SYS_SensorQuit(void) +{ + return; +} + +#endif /* SDL_SENSOR_DUMMY || SDL_SENSOR_DISABLED */ + +/* vi: set ts=4 sw=4 expandtab: */