|
@@ -130,6 +130,7 @@ static int
|
|
SDL_ANDROID_SensorOpen(SDL_Sensor *sensor, int device_index)
|
|
SDL_ANDROID_SensorOpen(SDL_Sensor *sensor, int device_index)
|
|
{
|
|
{
|
|
struct sensor_hwdata *hwdata;
|
|
struct sensor_hwdata *hwdata;
|
|
|
|
+ int delay_us, min_delay_us;
|
|
|
|
|
|
hwdata = (struct sensor_hwdata *)SDL_calloc(1, sizeof(*hwdata));
|
|
hwdata = (struct sensor_hwdata *)SDL_calloc(1, sizeof(*hwdata));
|
|
if (hwdata == NULL) {
|
|
if (hwdata == NULL) {
|
|
@@ -149,7 +150,14 @@ SDL_ANDROID_SensorOpen(SDL_Sensor *sensor, int device_index)
|
|
return SDL_SetError("Couldn't enable sensor");
|
|
return SDL_SetError("Couldn't enable sensor");
|
|
}
|
|
}
|
|
|
|
|
|
- /* FIXME: What rate should we set for this sensor? 60 FPS? Let's try the default rate for now... */
|
|
|
|
|
|
+ /* Use 60 Hz update rate if possible */
|
|
|
|
+ /* FIXME: Maybe add a hint for this? */
|
|
|
|
+ delay_us = 1000000 / 60;
|
|
|
|
+ min_delay_us = ASensor_getMinDelay(hwdata->asensor);
|
|
|
|
+ if (delay_us < min_delay_us) {
|
|
|
|
+ delay_us = min_delay_us;
|
|
|
|
+ }
|
|
|
|
+ ASensorEventQueue_setEventRate(hwdata->eventqueue, hwdata->asensor, delay_us);
|
|
|
|
|
|
sensor->hwdata = hwdata;
|
|
sensor->hwdata = hwdata;
|
|
return 0;
|
|
return 0;
|