SDL
2.0
|
#include "../SDL_internal.h"
#include "SDL.h"
#include "SDL_atomic.h"
#include "SDL_events.h"
#include "SDL_syssensor.h"
#include "SDL_assert.h"
#include "../events/SDL_events_c.h"
Go to the source code of this file.
Functions | |
static void | SDL_LockSensors (void) |
static void | SDL_UnlockSensors (void) |
int | SDL_SensorInit (void) |
int | SDL_NumSensors (void) |
Count the number of sensors attached to the system right now. More... | |
SDL_SensorID | SDL_GetNextSensorInstanceID () |
static SDL_bool | SDL_GetDriverAndSensorIndex (int device_index, SDL_SensorDriver **driver, int *driver_index) |
const char * | SDL_SensorGetDeviceName (int device_index) |
Get the implementation dependent name of a sensor. More... | |
SDL_SensorType | SDL_SensorGetDeviceType (int device_index) |
Get the type of a sensor. More... | |
SDL_SensorType | SDL_SensorGetDeviceNonPortableType (int device_index) |
Get the platform dependent type of a sensor. More... | |
SDL_SensorID | SDL_SensorGetDeviceInstanceID (int device_index) |
Get the instance ID of a sensor. More... | |
SDL_Sensor * | SDL_SensorOpen (int device_index) |
Open a sensor for use. More... | |
SDL_Sensor * | SDL_SensorFromInstanceID (SDL_SensorID instance_id) |
static int | SDL_PrivateSensorValid (SDL_Sensor *sensor) |
const char * | SDL_SensorGetName (SDL_Sensor *sensor) |
Get the implementation dependent name of a sensor. More... | |
SDL_SensorType | SDL_SensorGetType (SDL_Sensor *sensor) |
Get the type of a sensor. More... | |
int | SDL_SensorGetNonPortableType (SDL_Sensor *sensor) |
Get the platform dependent type of a sensor. More... | |
SDL_SensorID | SDL_SensorGetInstanceID (SDL_Sensor *sensor) |
Get the instance ID of a sensor. More... | |
int | SDL_SensorGetData (SDL_Sensor *sensor, float *data, int num_values) |
void | SDL_SensorClose (SDL_Sensor *sensor) |
void | SDL_SensorQuit (void) |
int | SDL_PrivateSensorUpdate (SDL_Sensor *sensor, float *data, int num_values) |
void | SDL_SensorUpdate (void) |
Variables | |
static SDL_SensorDriver * | SDL_sensor_drivers [] |
static SDL_Sensor * | SDL_sensors = NULL |
static SDL_bool | SDL_updating_sensor = SDL_FALSE |
static SDL_mutex * | SDL_sensor_lock = NULL |
static SDL_atomic_t | SDL_next_sensor_instance_id |
|
static |
Definition at line 122 of file SDL_sensor.c.
References i, SDL_arraysize, SDL_FALSE, SDL_sensor_drivers, SDL_SetError, and SDL_TRUE.
Referenced by SDL_SensorGetDeviceInstanceID(), SDL_SensorGetDeviceName(), SDL_SensorGetDeviceNonPortableType(), SDL_SensorGetDeviceType(), and SDL_SensorOpen().
SDL_SensorID SDL_GetNextSensorInstanceID | ( | ) |
Definition at line 112 of file SDL_sensor.c.
References SDL_AtomicIncRef, and SDL_next_sensor_instance_id.
Definition at line 52 of file SDL_sensor.c.
References SDL_LockMutex, and SDL_sensor_lock.
Referenced by SDL_NumSensors(), SDL_SensorClose(), SDL_SensorFromInstanceID(), SDL_SensorGetDeviceInstanceID(), SDL_SensorGetDeviceName(), SDL_SensorGetDeviceNonPortableType(), SDL_SensorGetDeviceType(), SDL_SensorOpen(), SDL_SensorQuit(), and SDL_SensorUpdate().
int SDL_NumSensors | ( | void | ) |
Count the number of sensors attached to the system right now.
Gyroscope sensor
The gyroscope returns the current rate of rotation in radians per second. The rotation is positive in the counter-clockwise direction. That is, an observer looking from a positive location on one of the axes would see positive rotation on that axis when it appeared to be rotating counter-clockwise.
values[0]: Angular speed around the x axis values[1]: Angular speed around the y axis values[2]: Angular speed around the z axis
For phones held in portrait mode, the axes are defined as follows: -X ... +X : left ... right -Y ... +Y : bottom ... top -Z ... +Z : farther ... closer
The axis data is not changed when the phone is rotated.
Definition at line 97 of file SDL_sensor.c.
References i, SDL_arraysize, SDL_LockSensors(), SDL_sensor_drivers, and SDL_UnlockSensors().
int SDL_PrivateSensorUpdate | ( | SDL_Sensor * | sensor, |
float * | data, | ||
int | num_values | ||
) |
Definition at line 476 of file SDL_sensor.c.
References SDL_arraysize, SDL_ENABLE, SDL_GetEventState, SDL_memcpy, SDL_memset, SDL_min, SDL_PushEvent, and SDL_SENSORUPDATE.
|
static |
Definition at line 305 of file SDL_sensor.c.
References NULL, and SDL_SetError.
Referenced by SDL_SensorClose(), SDL_SensorGetData(), SDL_SensorGetInstanceID(), SDL_SensorGetName(), SDL_SensorGetNonPortableType(), and SDL_SensorGetType().
void SDL_SensorClose | ( | SDL_Sensor * | sensor | ) |
Close a sensor previously opened with SDL_SensorOpen()
Definition at line 390 of file SDL_sensor.c.
References NULL, SDL_free, SDL_LockSensors(), SDL_PrivateSensorValid(), SDL_sensors, SDL_UnlockSensors(), and SDL_updating_sensor.
Referenced by SDL_SensorQuit(), and SDL_SensorUpdate().
SDL_Sensor* SDL_SensorFromInstanceID | ( | SDL_SensorID | instance_id | ) |
Return the SDL_Sensor associated with an instance id.
Definition at line 287 of file SDL_sensor.c.
References SDL_LockSensors(), SDL_sensors, and SDL_UnlockSensors().
int SDL_SensorGetData | ( | SDL_Sensor * | sensor, |
float * | data, | ||
int | num_values | ||
) |
Get the current state of an opened sensor.
The number of values and interpretation of the data is sensor dependent.
sensor | The sensor to query |
data | A pointer filled with the current sensor state |
num_values | The number of values to write to data |
Definition at line 375 of file SDL_sensor.c.
References SDL_arraysize, SDL_memcpy, SDL_min, and SDL_PrivateSensorValid().
SDL_SensorID SDL_SensorGetDeviceInstanceID | ( | int | device_index | ) |
Get the instance ID of a sensor.
This can be called before any sensors are opened.
Definition at line 193 of file SDL_sensor.c.
References SDL_GetDriverAndSensorIndex(), SDL_LockSensors(), and SDL_UnlockSensors().
const char* SDL_SensorGetDeviceName | ( | int | device_index | ) |
Get the implementation dependent name of a sensor.
This can be called before any sensors are opened.
Definition at line 147 of file SDL_sensor.c.
References NULL, SDL_GetDriverAndSensorIndex(), SDL_LockSensors(), and SDL_UnlockSensors().
SDL_SensorType SDL_SensorGetDeviceNonPortableType | ( | int | device_index | ) |
Get the platform dependent type of a sensor.
This can be called before any sensors are opened.
Definition at line 178 of file SDL_sensor.c.
References SDL_GetDriverAndSensorIndex(), SDL_LockSensors(), and SDL_UnlockSensors().
SDL_SensorType SDL_SensorGetDeviceType | ( | int | device_index | ) |
Get the type of a sensor.
This can be called before any sensors are opened.
Definition at line 163 of file SDL_sensor.c.
References SDL_GetDriverAndSensorIndex(), SDL_LockSensors(), SDL_SENSOR_INVALID, and SDL_UnlockSensors().
SDL_SensorID SDL_SensorGetInstanceID | ( | SDL_Sensor * | sensor | ) |
Get the instance ID of a sensor.
This can be called before any sensors are opened.
Definition at line 362 of file SDL_sensor.c.
References SDL_PrivateSensorValid().
const char* SDL_SensorGetName | ( | SDL_Sensor * | sensor | ) |
Get the implementation dependent name of a sensor.
Definition at line 323 of file SDL_sensor.c.
References NULL, and SDL_PrivateSensorValid().
int SDL_SensorGetNonPortableType | ( | SDL_Sensor * | sensor | ) |
Get the platform dependent type of a sensor.
This can be called before any sensors are opened.
Definition at line 349 of file SDL_sensor.c.
References SDL_PrivateSensorValid().
SDL_SensorType SDL_SensorGetType | ( | SDL_Sensor * | sensor | ) |
Get the type of a sensor.
This can be called before any sensors are opened.
Definition at line 336 of file SDL_sensor.c.
References SDL_PrivateSensorValid(), and SDL_SENSOR_INVALID.
int SDL_SensorInit | ( | void | ) |
Definition at line 69 of file SDL_sensor.c.
References i, SDL_arraysize, SDL_CreateMutex, SDL_INIT_EVENTS, SDL_InitSubSystem, SDL_sensor_drivers, and SDL_sensor_lock.
Referenced by SDL_InitSubSystem().
SDL_Sensor* SDL_SensorOpen | ( | int | device_index | ) |
Open a sensor for use.
The index passed as an argument refers to the N'th sensor on the system.
Definition at line 215 of file SDL_sensor.c.
References NULL, SDL_calloc, SDL_free, SDL_GetDriverAndSensorIndex(), SDL_LockSensors(), SDL_OutOfMemory, SDL_sensors, SDL_strdup, and SDL_UnlockSensors().
Definition at line 440 of file SDL_sensor.c.
References i, NULL, SDL_arraysize, SDL_assert, SDL_DestroyMutex, SDL_INIT_EVENTS, SDL_LockSensors(), SDL_QuitSubSystem, SDL_sensor_drivers, SDL_sensor_lock, SDL_SensorClose(), SDL_sensors, SDL_UnlockSensors(), and SDL_updating_sensor.
Referenced by SDL_QuitSubSystem().
Update the current state of the open sensors.
This is called automatically by the event loop if sensor events are enabled.
This needs to be called from the thread that initialized the sensor subsystem.
Definition at line 503 of file SDL_sensor.c.
References i, SDL_arraysize, SDL_FALSE, SDL_INIT_SENSOR, SDL_LockSensors(), SDL_sensor_drivers, SDL_SensorClose(), SDL_sensors, SDL_TRUE, SDL_UnlockSensors(), SDL_updating_sensor, and SDL_WasInit.
Definition at line 60 of file SDL_sensor.c.
References SDL_sensor_lock, and SDL_UnlockMutex.
Referenced by SDL_NumSensors(), SDL_SensorClose(), SDL_SensorFromInstanceID(), SDL_SensorGetDeviceInstanceID(), SDL_SensorGetDeviceName(), SDL_SensorGetDeviceNonPortableType(), SDL_SensorGetDeviceType(), SDL_SensorOpen(), SDL_SensorQuit(), and SDL_SensorUpdate().
|
static |
Definition at line 49 of file SDL_sensor.c.
Referenced by SDL_GetNextSensorInstanceID().
|
static |
Definition at line 35 of file SDL_sensor.c.
Referenced by SDL_GetDriverAndSensorIndex(), SDL_NumSensors(), SDL_SensorInit(), SDL_SensorQuit(), and SDL_SensorUpdate().
Definition at line 48 of file SDL_sensor.c.
Referenced by SDL_LockSensors(), SDL_SensorInit(), SDL_SensorQuit(), and SDL_UnlockSensors().
|
static |
Definition at line 46 of file SDL_sensor.c.
Referenced by SDL_SensorClose(), SDL_SensorFromInstanceID(), SDL_SensorOpen(), SDL_SensorQuit(), and SDL_SensorUpdate().
Definition at line 47 of file SDL_sensor.c.
Referenced by SDL_SensorClose(), SDL_SensorQuit(), and SDL_SensorUpdate().