Go to the documentation of this file.
21 #include "../SDL_internal.h"
31 #if !SDL_EVENTS_DISABLED
32 #include "../events/SDL_events_c.h"
36 #ifdef SDL_SENSOR_ANDROID
39 #ifdef SDL_SENSOR_COREMOTION
42 #if defined(SDL_SENSOR_DUMMY) || defined(SDL_SENSOR_DISABLED)
78 #if !SDL_EVENTS_DISABLED
99 int i, total_sensors = 0;
105 return total_sensors;
124 int i, num_sensors, total_sensors = 0;
126 if (device_index >= 0) {
129 if (device_index < num_sensors) {
131 *driver_index = device_index;
134 device_index -= num_sensors;
135 total_sensors += num_sensors;
139 SDL_SetError(
"There are %d sensors available", total_sensors);
220 SDL_Sensor *sensorlist;
221 const char *sensorname =
NULL;
236 if (instance_id == sensorlist->instance_id) {
242 sensorlist = sensorlist->next;
246 sensor = (SDL_Sensor *)
SDL_calloc(
sizeof(*sensor), 1);
247 if (sensor ==
NULL) {
252 sensor->driver = driver;
253 sensor->instance_id = instance_id;
257 if (driver->
Open(sensor, device_index) < 0) {
292 for (sensor =
SDL_sensors; sensor; sensor = sensor->next) {
293 if (sensor->instance_id == instance_id) {
309 if (sensor ==
NULL) {
355 return sensor->non_portable_type;
368 return sensor->instance_id;
392 SDL_Sensor *sensorlist;
393 SDL_Sensor *sensorlistprev;
402 if (--sensor->ref_count > 0) {
412 sensor->driver->Close(sensor);
413 sensor->hwdata =
NULL;
416 sensorlistprev =
NULL;
418 if (sensor == sensorlist) {
419 if (sensorlistprev) {
421 sensorlistprev->next = sensorlist->next;
427 sensorlistprev = sensorlist;
428 sensorlist = sensorlist->next;
462 #if !SDL_EVENTS_DISABLED
488 #if !SDL_EVENTS_DISABLED
492 event.sensor.which = sensor->instance_id;
525 for (sensor =
SDL_sensors; sensor; sensor = sensor->next) {
526 sensor->driver->Update(sensor);
534 for (sensor =
SDL_sensors; sensor; sensor = sensor->next) {
535 if (sensor->ref_count <= 0) {
const char *(* GetDeviceName)(int device_index)
int SDL_PrivateSensorUpdate(SDL_Sensor *sensor, float *data, int num_values)
static SDL_bool SDL_updating_sensor
int(* GetDeviceNonPortableType)(int device_index)
SDL_SensorDriver SDL_DUMMY_SensorDriver
static void SDL_LockSensors(void)
SDL_SensorID(* GetDeviceInstanceID)(int device_index)
#define SDL_AtomicIncRef(a)
Increment an atomic variable used as a reference count.
#define SDL_QuitSubSystem
const char * SDL_SensorGetDeviceName(int device_index)
Get the implementation dependent name of a sensor.
static SDL_bool SDL_GetDriverAndSensorIndex(int device_index, SDL_SensorDriver **driver, int *driver_index)
#define SDL_InitSubSystem
const char * SDL_SensorGetName(SDL_Sensor *sensor)
Get the implementation dependent name of a sensor.
SDL_SensorType(* GetDeviceType)(int device_index)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
void SDL_SensorQuit(void)
SDL_Sensor * SDL_SensorFromInstanceID(SDL_SensorID instance_id)
void SDL_SensorUpdate(void)
SDL_SensorType SDL_SensorGetDeviceType(int device_index)
Get the type of a sensor.
SDL_SensorDriver SDL_COREMOTION_SensorDriver
#define SDL_GetEventState(type)
GLuint const GLchar * name
int(* Open)(SDL_Sensor *sensor, int device_index)
SDL_SensorID SDL_SensorGetInstanceID(SDL_Sensor *sensor)
Get the instance ID of a sensor.
#define SDL_assert(condition)
SDL_SensorID SDL_SensorGetDeviceInstanceID(int device_index)
Get the instance ID of a sensor.
#define SDL_OutOfMemory()
SDL_SensorDriver SDL_ANDROID_SensorDriver
static SDL_SensorDriver * SDL_sensor_drivers[]
#define SDL_arraysize(array)
static SDL_atomic_t SDL_next_sensor_instance_id
void SDL_SensorClose(SDL_Sensor *sensor)
SDL_SensorType SDL_SensorGetDeviceNonPortableType(int device_index)
Get the platform dependent type of a sensor.
A type representing an atomic integer value. It is a struct so people don't accidentally use numeric ...
static SDL_Sensor * SDL_sensors
static int SDL_PrivateSensorValid(SDL_Sensor *sensor)
static SDL_mutex * SDL_sensor_lock
SDL_Sensor * SDL_SensorOpen(int device_index)
Open a sensor for use.
int SDL_NumSensors(void)
Count the number of sensors attached to the system right now.
SDL_SensorID SDL_GetNextSensorInstanceID()
int SDL_SensorGetData(SDL_Sensor *sensor, float *data, int num_values)
GLuint GLuint GLsizei GLenum type
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
int SDL_SensorGetNonPortableType(SDL_Sensor *sensor)
Get the platform dependent type of a sensor.
static void SDL_UnlockSensors(void)
SDL_SensorType SDL_SensorGetType(SDL_Sensor *sensor)
Get the type of a sensor.
void(* Update)(SDL_Sensor *sensor)