SDL 2.0
SDL_sensor_c.h File Reference
#include "SDL_config.h"
#include "SDL_sensor.h"
+ Include dependency graph for SDL_sensor_c.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

SDL_SensorID SDL_GetNextSensorInstanceID (void)
 
int SDL_SensorInit (void)
 
void SDL_SensorQuit (void)
 
int SDL_PrivateSensorUpdate (SDL_Sensor *sensor, float *data, int num_values)
 

Function Documentation

◆ SDL_GetNextSensorInstanceID()

SDL_SensorID SDL_GetNextSensorInstanceID ( void  )

Definition at line 112 of file SDL_sensor.c.

113{
115}
#define SDL_AtomicIncRef(a)
Increment an atomic variable used as a reference count.
Definition: SDL_atomic.h:252
static SDL_atomic_t SDL_next_sensor_instance_id
Definition: SDL_sensor.c:49

References SDL_AtomicIncRef, and SDL_next_sensor_instance_id.

◆ SDL_PrivateSensorUpdate()

int SDL_PrivateSensorUpdate ( SDL_Sensor *  sensor,
float *  data,
int  num_values 
)

Definition at line 476 of file SDL_sensor.c.

477{
478 int posted;
479
480 /* Allow duplicate events, for things like steps and heartbeats */
481
482 /* Update internal sensor state */
483 num_values = SDL_min(num_values, SDL_arraysize(sensor->data));
484 SDL_memcpy(sensor->data, data, num_values*sizeof(*data));
485
486 /* Post the event, if desired */
487 posted = 0;
488#if !SDL_EVENTS_DISABLED
491 event.type = SDL_SENSORUPDATE;
492 event.sensor.which = sensor->instance_id;
493 num_values = SDL_min(num_values, SDL_arraysize(event.sensor.data));
494 SDL_memset(event.sensor.data, 0, sizeof(event.sensor.data));
495 SDL_memcpy(event.sensor.data, data, num_values*sizeof(*data));
496 posted = SDL_PushEvent(&event) == 1;
497 }
498#endif /* !SDL_EVENTS_DISABLED */
499 return posted;
500}
#define SDL_memset
#define SDL_PushEvent
#define SDL_memcpy
@ SDL_SENSORUPDATE
Definition: SDL_events.h:151
@ SDL_JOYAXISMOTION
Definition: SDL_events.h:111
#define SDL_GetEventState(type)
Definition: SDL_events.h:772
#define SDL_ENABLE
Definition: SDL_events.h:759
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1974
struct _cl_event * event
#define SDL_arraysize(array)
Definition: SDL_stdinc.h:115
#define SDL_min(x, y)
Definition: SDL_stdinc.h:406
General event structure.
Definition: SDL_events.h:558

References SDL_arraysize, SDL_ENABLE, SDL_GetEventState, SDL_JOYAXISMOTION, SDL_memcpy, SDL_memset, SDL_min, SDL_PushEvent, and SDL_SENSORUPDATE.

◆ SDL_SensorInit()

int SDL_SensorInit ( void  )

Definition at line 69 of file SDL_sensor.c.

70{
71 int i, status;
72
73 /* Create the sensor list lock */
74 if (!SDL_sensor_lock) {
76 }
77
78#if !SDL_EVENTS_DISABLED
80 return -1;
81 }
82#endif /* !SDL_EVENTS_DISABLED */
83
84 status = -1;
85 for (i = 0; i < SDL_arraysize(SDL_sensor_drivers); ++i) {
86 if (SDL_sensor_drivers[i]->Init() >= 0) {
87 status = 0;
88 }
89 }
90 return status;
91}
#define SDL_INIT_EVENTS
Definition: SDL.h:83
#define SDL_InitSubSystem
#define SDL_CreateMutex
static SDL_mutex * SDL_sensor_lock
Definition: SDL_sensor.c:48
static SDL_SensorDriver * SDL_sensor_drivers[]
Definition: SDL_sensor.c:35
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)
Definition: SDL_x11sym.h:50

References i, SDL_arraysize, SDL_CreateMutex, SDL_INIT_EVENTS, SDL_InitSubSystem, SDL_sensor_drivers, and SDL_sensor_lock.

Referenced by SDL_InitSubSystem().

◆ SDL_SensorQuit()

void SDL_SensorQuit ( void  )

Definition at line 440 of file SDL_sensor.c.

441{
442 int i;
443
444 /* Make sure we're not getting called in the middle of updating sensors */
446
448
449 /* Stop the event polling */
450 while (SDL_sensors) {
451 SDL_sensors->ref_count = 1;
453 }
454
455 /* Quit the sensor setup */
456 for (i = 0; i < SDL_arraysize(SDL_sensor_drivers); ++i) {
458 }
459
461
462#if !SDL_EVENTS_DISABLED
464#endif
465
466 if (SDL_sensor_lock) {
469 }
470}
#define SDL_assert(condition)
Definition: SDL_assert.h:169
#define SDL_DestroyMutex
#define SDL_QuitSubSystem
static SDL_Sensor * SDL_sensors
Definition: SDL_sensor.c:46
static SDL_bool SDL_updating_sensor
Definition: SDL_sensor.c:47
void SDL_SensorClose(SDL_Sensor *sensor)
Definition: SDL_sensor.c:390
static void SDL_LockSensors(void)
Definition: SDL_sensor.c:52
static void SDL_UnlockSensors(void)
Definition: SDL_sensor.c:60
#define NULL
Definition: begin_code.h:167
void(* Quit)(void)
Definition: SDL_syssensor.h:94

References i, NULL, SDL_SensorDriver::Quit, 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().