Skip to content

Commit

Permalink
Fix some edge cases in XInput haptic timing.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Oct 21, 2013
1 parent dddb878 commit d710399
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/haptic/windows/SDL_syshaptic.c
Expand Up @@ -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;
Expand Down

0 comments on commit d710399

Please sign in to comment.