MCPcopy Create free account
hub / github.com/RavEngine/RavEngine / SDL_GetDriverAndSensorIndex

Function SDL_GetDriverAndSensorIndex

deps/SDL2/src/sensor/SDL_sensor.c:121–141  ·  view source on GitHub ↗

* Get the driver and device index for an API device index * This should be called while the sensor lock is held, to prevent another thread from updating the list */

Source from the content-addressed store, hash-verified

119 * This should be called while the sensor lock is held, to prevent another thread from updating the list
120 */
121static SDL_bool
122SDL_GetDriverAndSensorIndex(int device_index, SDL_SensorDriver **driver, int *driver_index)
123{
124 int i, num_sensors, total_sensors = 0;
125
126 if (device_index >= 0) {
127 for (i = 0; i < SDL_arraysize(SDL_sensor_drivers); ++i) {
128 num_sensors = SDL_sensor_drivers[i]->GetCount();
129 if (device_index < num_sensors) {
130 *driver = SDL_sensor_drivers[i];
131 *driver_index = device_index;
132 return SDL_TRUE;
133 }
134 device_index -= num_sensors;
135 total_sensors += num_sensors;
136 }
137 }
138
139 SDL_SetError("There are %d sensors available", total_sensors);
140 return SDL_FALSE;
141}
142
143/*
144 * Get the implementation dependent name of a sensor

Callers 5

SDL_SensorGetDeviceNameFunction · 0.85
SDL_SensorGetDeviceTypeFunction · 0.85
SDL_SensorOpenFunction · 0.85

Calls 1

SDL_SetErrorFunction · 0.85

Tested by

no test coverage detected