/* * Stops the haptic effect on the device. */ int SDL_HapticStopEffect(SDL_Haptic * haptic, int effect) { if (!ValidHaptic(haptic) || !ValidEffect(haptic, effect)) { return -1; } /* Stop the effect */ if (SDL_SYS_HapticStopEffect(haptic, &haptic->effects[effect]) < 0) { return -1; } return 0; }
/* * Stops all the currently playing effects. */ int SDL_SYS_HapticStopAll(SDL_Haptic * haptic) { int i, ret; /* Linux does not support this natively so we have to loop. */ for (i = 0; i < haptic->neffects; i++) { if (haptic->effects[i].hweffect != NULL) { ret = SDL_SYS_HapticStopEffect(haptic, &haptic->effects[i]); if (ret < 0) { SDL_SetError ("Haptic: Error while trying to stop all playing effects."); return -1; } } } return 0; }
/* * Frees the effect. */ void SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect *effect) { HRESULT ret; if (haptic->hwdata->bXInputHaptic) { SDL_SYS_HapticStopEffect(haptic, effect); } else { ret = IDirectInputEffect_Unload(effect->hweffect->ref); if (FAILED(ret)) { DI_SetError("Removing effect from the device", ret); } SDL_SYS_HapticFreeDIEFFECT(&effect->hweffect->effect, effect->effect.type); } SDL_free(effect->hweffect); effect->hweffect = NULL; }