From d710399671c3d7abc437438925fb716876f9118d Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 20 Oct 2013 23:38:19 -0400 Subject: [PATCH] Fix some edge cases in XInput haptic timing. --- src/haptic/windows/SDL_syshaptic.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/haptic/windows/SDL_syshaptic.c b/src/haptic/windows/SDL_syshaptic.c index e8867bc683c21..68447a9b10b4a 100644 --- a/src/haptic/windows/SDL_syshaptic.c +++ b/src/haptic/windows/SDL_syshaptic.c @@ -1326,8 +1326,13 @@ SDL_SYS_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_LockMutex(haptic->hwdata->mutex); if(effect->effect.leftright.length == SDL_HAPTIC_INFINITY || iterations == SDL_HAPTIC_INFINITY) { haptic->hwdata->stopTicks = SDL_HAPTIC_INFINITY; + } else if ((!effect->effect.leftright.length) || (!iterations)) { + /* do nothing. Effect runs for zero milliseconds. */ } else { haptic->hwdata->stopTicks = SDL_GetTicks() + (effect->effect.leftright.length * iterations); + if ((haptic->hwdata->stopTicks == SDL_HAPTIC_INFINITY) || (haptic->hwdata->stopTicks == 0)) { + haptic->hwdata->stopTicks = 1; /* fix edge cases. */ + } } SDL_UnlockMutex(haptic->hwdata->mutex); return (XINPUTSETSTATE(haptic->hwdata->userid, vib) == ERROR_SUCCESS) ? 0 : -1;