mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-16 11:06:49 +01:00
Don't send controller gyro and accelerometer updates if the values haven't changed.
This keeps SDL_PollEvent() from returning data continuously when polling controller state.
This commit is contained in:
parent
463d84a860
commit
51ea6a6d44
@ -2569,14 +2569,13 @@ int SDL_PrivateJoystickSensor(SDL_Joystick *joystick, SDL_SensorType type, const
|
|||||||
|
|
||||||
if (sensor->type == type) {
|
if (sensor->type == type) {
|
||||||
if (sensor->enabled) {
|
if (sensor->enabled) {
|
||||||
/* Allow duplicate events, for things like gyro updates */
|
num_values = SDL_min(num_values, SDL_arraysize(sensor->data));
|
||||||
|
if (SDL_memcmp(data, sensor->data, num_values*sizeof(*data)) != 0) {
|
||||||
|
|
||||||
/* Update internal sensor state */
|
/* Update internal sensor state */
|
||||||
num_values = SDL_min(num_values, SDL_arraysize(sensor->data));
|
|
||||||
SDL_memcpy(sensor->data, data, num_values*sizeof(*data));
|
SDL_memcpy(sensor->data, data, num_values*sizeof(*data));
|
||||||
|
|
||||||
/* Post the event, if desired */
|
/* Post the event, if desired */
|
||||||
posted = 0;
|
|
||||||
#if !SDL_EVENTS_DISABLED
|
#if !SDL_EVENTS_DISABLED
|
||||||
if (SDL_GetEventState(SDL_CONTROLLERSENSORUPDATE) == SDL_ENABLE) {
|
if (SDL_GetEventState(SDL_CONTROLLERSENSORUPDATE) == SDL_ENABLE) {
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
@ -2590,6 +2589,7 @@ int SDL_PrivateJoystickSensor(SDL_Joystick *joystick, SDL_SensorType type, const
|
|||||||
}
|
}
|
||||||
#endif /* !SDL_EVENTS_DISABLED */
|
#endif /* !SDL_EVENTS_DISABLED */
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user