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 114 of file SDL_sensor.c.

115 {
117 }
#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:51

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 478 of file SDL_sensor.c.

479 {
480  int posted;
481 
482  /* Allow duplicate events, for things like steps and heartbeats */
483 
484  /* Update internal sensor state */
485  num_values = SDL_min(num_values, SDL_arraysize(sensor->data));
486  SDL_memcpy(sensor->data, data, num_values*sizeof(*data));
487 
488  /* Post the event, if desired */
489  posted = 0;
490 #if !SDL_EVENTS_DISABLED
493  event.type = SDL_SENSORUPDATE;
494  event.sensor.which = sensor->instance_id;
495  num_values = SDL_min(num_values, SDL_arraysize(event.sensor.data));
496  SDL_memset(event.sensor.data, 0, sizeof(event.sensor.data));
497  SDL_memcpy(event.sensor.data, data, num_values*sizeof(*data));
498  posted = SDL_PushEvent(&event) == 1;
499  }
500 #endif /* !SDL_EVENTS_DISABLED */
501  return posted;
502 }
#define SDL_memset
#define SDL_PushEvent
#define SDL_memcpy
@ SDL_SENSORUPDATE
Definition: SDL_events.h:157
#define SDL_GetEventState(type)
Definition: SDL_events.h:808
#define SDL_ENABLE
Definition: SDL_events.h:795
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:121
#define SDL_min(x, y)
Definition: SDL_stdinc.h:412
General event structure.
Definition: SDL_events.h:592

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

◆ SDL_SensorInit()

int SDL_SensorInit ( void  )

Definition at line 71 of file SDL_sensor.c.

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

443 {
444  int i;
445 
446  /* Make sure we're not getting called in the middle of updating sensors */
448 
449  SDL_LockSensors();
450 
451  /* Stop the event polling */
452  while (SDL_sensors) {
453  SDL_sensors->ref_count = 1;
455  }
456 
457  /* Quit the sensor setup */
458  for (i = 0; i < SDL_arraysize(SDL_sensor_drivers); ++i) {
460  }
461 
463 
464 #if !SDL_EVENTS_DISABLED
466 #endif
467 
468  if (SDL_sensor_lock) {
471  }
472 }
#define SDL_assert(condition)
Definition: SDL_assert.h:171
#define SDL_DestroyMutex
#define SDL_QuitSubSystem
static SDL_Sensor * SDL_sensors
Definition: SDL_sensor.c:48
void SDL_UnlockSensors(void)
Definition: SDL_sensor.c:62
static SDL_bool SDL_updating_sensor
Definition: SDL_sensor.c:49
void SDL_SensorClose(SDL_Sensor *sensor)
Definition: SDL_sensor.c:392
void SDL_LockSensors(void)
Definition: SDL_sensor.c:54
#define NULL
Definition: begin_code.h:163
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().