[Change] Made force feedback system a little more robust.

This commit is contained in:
Allanis 2014-05-29 21:50:09 +01:00
parent 9b4175d5a1
commit 521514ba7e

View File

@ -87,7 +87,7 @@ static void spfx_destroy(SPFX* layer, int* nlayer, int spfx);
static void spfx_update_layer(SPFX* layer, int* nlayer, const double dt);
/* Haptic. */
static int spfx_hapticInit(void);
static void spfx_hapticRumble(void);
static void spfx_hapticRumble(double mod);
/**
* @brief Load an SPFX_Base into the stack based on some params.
@ -374,7 +374,7 @@ void spfx_shake(double mod) {
vect_pset(&shake_vel, SHAKE_VEL_MOD*shake_rad, RNGF() * 2. * M_PI);
/* Rumble if it wasn't rumbling before. */
spfx_hapticRumble();
spfx_hapticRumble(mod);
/* Notify that rumble is active. */
shake_off = 0;
@ -409,15 +409,16 @@ static int spfx_hapticInit(void) {
/**
* @brief Run a rumble effect.
* @param mod Current modifier being added.
*/
static void spfx_hapticRumble(void) {
static void spfx_hapticRumble(double mod) {
#if SDL_VERSION_ATLEAST(1,3,0)
SDL_HapticEffect* efx;
double len, mag;
if(haptic_rumble >= 0) {
/* Not time to update yet. */
if((haptic_lastUpdate > 0.) || shake_off)
if((haptic_lastUpdate > 0.) || shake_off || (mod > SHAKE_MAX/3.))
return;
/* Stop the effect if it was playing. */
@ -443,6 +444,8 @@ static void spfx_hapticRumble(void) {
/* Set timer again. */
haptic_lastUpdate = HAPTIC_UPDATE_INTERVAL;
}
#else
(void)mod;
#endif
}