src/haptic/windows/SDL_syshaptic.c
changeset 7855 a022d3d782d2
parent 7850 ad4dc7a15ce0
child 7857 6388f5229bb7
equal deleted inserted replaced
7854:6d79888998f5 7855:a022d3d782d2
  1324         XINPUT_VIBRATION *vib = &effect->hweffect->vibration;
  1324         XINPUT_VIBRATION *vib = &effect->hweffect->vibration;
  1325         SDL_assert(effect->effect.type == SDL_HAPTIC_LEFTRIGHT);  /* should catch this at higher level */
  1325         SDL_assert(effect->effect.type == SDL_HAPTIC_LEFTRIGHT);  /* should catch this at higher level */
  1326         SDL_LockMutex(haptic->hwdata->mutex);
  1326         SDL_LockMutex(haptic->hwdata->mutex);
  1327         if(effect->effect.leftright.length == SDL_HAPTIC_INFINITY || iterations == SDL_HAPTIC_INFINITY) {
  1327         if(effect->effect.leftright.length == SDL_HAPTIC_INFINITY || iterations == SDL_HAPTIC_INFINITY) {
  1328             haptic->hwdata->stopTicks = SDL_HAPTIC_INFINITY;
  1328             haptic->hwdata->stopTicks = SDL_HAPTIC_INFINITY;
       
  1329         } else if ((!effect->effect.leftright.length) || (!iterations)) {
       
  1330             /* do nothing. Effect runs for zero milliseconds. */
  1329         } else {
  1331         } else {
  1330             haptic->hwdata->stopTicks = SDL_GetTicks() + (effect->effect.leftright.length * iterations);
  1332             haptic->hwdata->stopTicks = SDL_GetTicks() + (effect->effect.leftright.length * iterations);
       
  1333             if ((haptic->hwdata->stopTicks == SDL_HAPTIC_INFINITY) || (haptic->hwdata->stopTicks == 0)) {
       
  1334                 haptic->hwdata->stopTicks = 1;  /* fix edge cases. */
       
  1335             }
  1331         }
  1336         }
  1332         SDL_UnlockMutex(haptic->hwdata->mutex);
  1337         SDL_UnlockMutex(haptic->hwdata->mutex);
  1333         return (XINPUTSETSTATE(haptic->hwdata->userid, vib) == ERROR_SUCCESS) ? 0 : -1;
  1338         return (XINPUTSETSTATE(haptic->hwdata->userid, vib) == ERROR_SUCCESS) ? 0 : -1;
  1334     }
  1339     }
  1335 
  1340