Use a separate sensor watching function for gamepad events to avoid reliance on system sensor events and prevent a potential deadlock

This commit is contained in:
Sam Lantinga
2023-06-19 16:17:34 -07:00
parent 70e43c150e
commit 20ea35138f
3 changed files with 53 additions and 33 deletions

View File

@@ -27,6 +27,7 @@
#ifndef SDL_EVENTS_DISABLED
#include "../events/SDL_events_c.h"
#endif
#include "../joystick/SDL_gamepad_c.h"
static SDL_SensorDriver *SDL_sensor_drivers[] = {
#ifdef SDL_SENSOR_ANDROID
@@ -501,6 +502,9 @@ int SDL_SendSensorUpdate(Uint64 timestamp, SDL_Sensor *sensor, Uint64 sensor_tim
posted = SDL_PushEvent(&event) == 1;
}
#endif /* !SDL_EVENTS_DISABLED */
SDL_GamepadSensorWatcher(timestamp, sensor->instance_id, sensor_timestamp, data, num_values);
return posted;
}