* 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 */
| 119 | * This should be called while the sensor lock is held, to prevent another thread from updating the list |
| 120 | */ |
| 121 | static SDL_bool |
| 122 | SDL_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 |
no test coverage detected