mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-05 09:26:25 +00:00
Fixed bug 4898 - No rumble because of integer overflow in SDL_JoystickRumble
meyraud705 On a Dualshock 4 controller using hidapi driver, calling SDL_JoystickRumble with a duration too long (SDL_HAPTIC_INFINITY for example) causes the rumble to stop immediately. This happens because of integer overflow on line 301 of SDL_hidapi_ps4.c (https://hg.libsdl.org/SDL/file/a3077169ad23/src/joystick/hidapi/SDL_hidapi_ps4.c#l301), which sets expiration time in the past.
This commit is contained in:
@@ -298,7 +298,7 @@ HIDAPI_DriverPS4_Rumble(SDL_Joystick *joystick, hid_device *dev, void *context,
|
||||
}
|
||||
|
||||
if ((low_frequency_rumble || high_frequency_rumble) && duration_ms) {
|
||||
ctx->rumble_expiration = SDL_GetTicks() + duration_ms;
|
||||
ctx->rumble_expiration = SDL_GetTicks() + SDL_min(duration_ms, SDL_MAX_RUMBLE_DURATION_MS);
|
||||
} else {
|
||||
ctx->rumble_expiration = 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user