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_SensorID SDL_GetNextSensorInstanceID ( void  )

Definition at line 112 of file SDL_sensor.c.

References SDL_AtomicIncRef.

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

Definition at line 476 of file SDL_sensor.c.

References SDL_SensorEvent::data, SDL_arraysize, SDL_ENABLE, SDL_GetEventState, SDL_JOYAXISMOTION, SDL_memcpy, SDL_memset, SDL_min, SDL_PushEvent, SDL_SENSORUPDATE, and SDL_Event::sensor.

{
int posted;
/* Allow duplicate events, for things like steps and heartbeats */
/* Update internal sensor state */
num_values = SDL_min(num_values, SDL_arraysize(sensor->data));
SDL_memcpy(sensor->data, data, num_values*sizeof(*data));
/* Post the event, if desired */
posted = 0;
#if !SDL_EVENTS_DISABLED
event.type = SDL_SENSORUPDATE;
event.sensor.which = sensor->instance_id;
num_values = SDL_min(num_values, SDL_arraysize(event.sensor.data));
SDL_memset(event.sensor.data, 0, sizeof(event.sensor.data));
SDL_memcpy(event.sensor.data, data, num_values*sizeof(*data));
posted = SDL_PushEvent(&event) == 1;
}
#endif /* !SDL_EVENTS_DISABLED */
return posted;
}
int SDL_SensorInit ( void  )

Definition at line 69 of file SDL_sensor.c.

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

Referenced by SDL_InitSubSystem().

{
int i, status;
/* Create the sensor list lock */
}
#if !SDL_EVENTS_DISABLED
return -1;
}
#endif /* !SDL_EVENTS_DISABLED */
status = -1;
for (i = 0; i < SDL_arraysize(SDL_sensor_drivers); ++i) {
if (SDL_sensor_drivers[i]->Init() >= 0) {
status = 0;
}
}
return status;
}
void SDL_SensorQuit ( void  )

Definition at line 440 of file SDL_sensor.c.

References i, NULL, SDL_SensorDriver::Quit, SDL_arraysize, SDL_assert, SDL_DestroyMutex, SDL_INIT_EVENTS, SDL_LockSensors(), SDL_QuitSubSystem, SDL_SensorClose, SDL_sensors, SDL_UnlockSensors(), and SDL_updating_sensor.

Referenced by SDL_QuitSubSystem().

{
int i;
/* Make sure we're not getting called in the middle of updating sensors */
/* Stop the event polling */
while (SDL_sensors) {
SDL_sensors->ref_count = 1;
}
/* Quit the sensor setup */
for (i = 0; i < SDL_arraysize(SDL_sensor_drivers); ++i) {
}
#if !SDL_EVENTS_DISABLED
#endif
}
}