1
0
mirror of synced 2024-11-24 06:50:11 +01:00

Add code for ffb to not work if rumble is enabled

This commit is contained in:
Aaron M 2019-10-29 19:27:58 +13:00
parent 33b2805f89
commit 2d00338254
2 changed files with 405 additions and 364 deletions

View File

@ -1081,6 +1081,8 @@ double lastSineEffectStrength = 0;
double lastSineEffectPeriod = 0;
void TriggerConstantEffect(int direction, double strength)
{
if (EnableRumble != 1)
{
SDL_HapticEffect tempEffect;
SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect));
tempEffect.type = SDL_HAPTIC_CONSTANT;
@ -1121,13 +1123,16 @@ void TriggerConstantEffect(int direction, double strength)
}
tempEffect.constant.level = level;
hlp.log((char *)(std::to_string(level)).c_str());
hlp.log((char*)(std::to_string(level)).c_str());
SDL_HapticUpdateEffect(haptic, effects.effect_constant_id, &tempEffect);
SDL_HapticRunEffect(haptic, effects.effect_constant_id, 1);
}
}
void TriggerFrictionEffectWithDefaultOption(double strength, bool isDefault)
{
if (EnableRumble != 1)
{
SDL_HapticEffect tempEffect;
SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect));
tempEffect.type = SDL_HAPTIC_FRICTION;
@ -1151,10 +1156,14 @@ void TriggerFrictionEffectWithDefaultOption(double strength, bool isDefault)
tempEffect.condition.right_coeff[0] = (short)(coeff);
SDL_HapticUpdateEffect(haptic, effects.effect_friction_id, &tempEffect);
SDL_HapticRunEffect(haptic, effects.effect_friction_id, 1);
}
}
void TriggerInertiaEffect(double strength)
{
if (EnableRumble != 1)
{
SDL_HapticEffect tempEffect;
SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect));
tempEffect.type = SDL_HAPTIC_INERTIA;
@ -1181,10 +1190,13 @@ void TriggerInertiaEffect(double strength)
SDL_HapticUpdateEffect(haptic, effects.effect_inertia_id, &tempEffect);
SDL_HapticRunEffect(haptic, effects.effect_inertia_id, 1);
}
}
void TriggerTriangleEffect(double strength, double length)
{
if (EnableRumble != 1)
{
int direction = 1;
if (strength <= -0.001) {
strength *= -1;
@ -1234,10 +1246,13 @@ void TriggerTriangleEffect(double strength, double length)
SDL_HapticUpdateEffect(haptic, effects.effect_triangle_id, &tempEffect);
SDL_HapticRunEffect(haptic, effects.effect_triangle_id, 1);
}
}
void TriggerDamperEffect(double strength)
{
if (EnableRumble != 1)
{
SDL_HapticEffect tempEffect;
SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect));
tempEffect.type = SDL_HAPTIC_DAMPER;
@ -1263,10 +1278,13 @@ void TriggerDamperEffect(double strength)
SDL_HapticUpdateEffect(haptic, effects.effect_damper_id, &tempEffect);
SDL_HapticRunEffect(haptic, effects.effect_damper_id, 1);
}
}
void TriggerRampEffect(double start,double end,double length)
{
if (EnableRumble != 1)
{
SDL_HapticEffect tempEffect;
SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect));
tempEffect.type = SDL_HAPTIC_RAMP;
@ -1295,10 +1313,13 @@ void TriggerRampEffect(double start,double end,double length)
SDL_HapticUpdateEffect(haptic, effects.effect_ramp_id, &tempEffect);
SDL_HapticRunEffect(haptic, effects.effect_ramp_id, 1);
}
}
void TriggerSawtoothUpEffect(double strength, double length)
{
if (EnableRumble != 1)
{
SDL_HapticEffect tempEffect;
SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect));
tempEffect.type = SDL_HAPTIC_SAWTOOTHUP;
@ -1320,9 +1341,13 @@ void TriggerSawtoothUpEffect(double strength, double length)
SDL_HapticUpdateEffect(haptic, effects.effect_sawtoothup_id, &tempEffect);
SDL_HapticRunEffect(haptic, effects.effect_sawtoothup_id, 1);
}
}
void TriggerSawtoothDownEffect(double strength, double length) {
void TriggerSawtoothDownEffect(double strength, double length)
{
if (EnableRumble != 1)
{
SDL_HapticEffect tempEffect;
SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect));
tempEffect.type = SDL_HAPTIC_SAWTOOTHDOWN;
@ -1344,15 +1369,21 @@ void TriggerSawtoothDownEffect(double strength, double length) {
SDL_HapticUpdateEffect(haptic, effects.effect_sawtoothdown_id, &tempEffect);
SDL_HapticRunEffect(haptic, effects.effect_sawtoothdown_id, 1);
}
}
void TriggerFrictionEffect(double strength)
{
if (EnableRumble != 1)
{
TriggerFrictionEffectWithDefaultOption(strength, false);
}
}
void TriggerSineEffect(UINT16 period, UINT16 fadePeriod, double strength)
{
if (EnableRumble != 1)
{
std::chrono::milliseconds now = duration_cast<milliseconds>(system_clock::now().time_since_epoch());
long long elapsedTime = (std::chrono::duration_cast<std::chrono::milliseconds>(now - timeOfLastSineEffect)).count();
@ -1423,10 +1454,13 @@ void TriggerSineEffect(UINT16 period, UINT16 fadePeriod, double strength)
timeOfLastSineEffect = now;
lastSineEffectStrength = strength;
lastSineEffectPeriod = period;
}
}
void TriggerSpringEffectWithDefaultOption(double strength, bool isDefault)
{
if (EnableRumble != 1)
{
SDL_HapticEffect tempEffect;
SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect));
tempEffect.type = SDL_HAPTIC_SPRING;
@ -1454,10 +1488,13 @@ void TriggerSpringEffectWithDefaultOption(double strength, bool isDefault)
SDL_HapticUpdateEffect(haptic, effects.effect_spring_id, &tempEffect);
SDL_HapticRunEffect(haptic, effects.effect_spring_id, 1);
}
}
void TriggerSpringEffectInfinite(double strength)
{
if (EnableRumble != 1)
{
SDL_HapticEffect tempEffect;
SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect));
@ -1486,29 +1523,14 @@ void TriggerSpringEffectInfinite(double strength)
SDL_HapticUpdateEffect(haptic, effects.effect_spring_id, &tempEffect);
SDL_HapticRunEffect(haptic, effects.effect_spring_id, 1);
}
}
void TriggerLeftRightEffect(double smallstrength, double largestrength, double length)
{
if (EnableRumble == 1)
{
if (ReverseRumble == 0)
{
SDL_HapticEffect tempEffect;
tempEffect.type = SDL_HAPTIC_LEFTRIGHT;
tempEffect.leftright.length = length;
SHORT minForce = (SHORT)(smallstrength > 0.001 ? (configMinForce / 100.0 * 32767.0) : 0); // strength is a double so we do an epsilon check of 0.001 instead of > 0.
SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0);
SHORT range = maxForce - minForce;
tempEffect.leftright.small_magnitude = (SHORT)(smallstrength * range + minForce);
SHORT minForce1 = (SHORT)(largestrength > 0.001 ? (configMinForce / 100.0 * 32767.0) : 0); // strength is a double so we do an epsilon check of 0.001 instead of > 0.
SHORT maxForce1 = (SHORT)(configMaxForce / 100.0 * 32767.0);
SHORT range1 = maxForce1 - minForce1;
tempEffect.leftright.large_magnitude = (SHORT)(largestrength * range1 + minForce1);
SDL_HapticUpdateEffect(haptic, effects.effect_leftright_id, &tempEffect);
SDL_HapticRunEffect(haptic, effects.effect_leftright_id, 1);
}
else if (ReverseRumble == 1)
if (ReverseRumble == 1)
{
SDL_HapticEffect tempEffect;
tempEffect.type = SDL_HAPTIC_LEFTRIGHT;
@ -1524,6 +1546,22 @@ void TriggerLeftRightEffect(double smallstrength, double largestrength, double l
SDL_HapticUpdateEffect(haptic, effects.effect_leftright_id, &tempEffect);
SDL_HapticRunEffect(haptic, effects.effect_leftright_id, 1);
}
else
{
SDL_HapticEffect tempEffect;
tempEffect.type = SDL_HAPTIC_LEFTRIGHT;
tempEffect.leftright.length = length;
SHORT minForce = (SHORT)(smallstrength > 0.001 ? (configMinForce / 100.0 * 32767.0) : 0); // strength is a double so we do an epsilon check of 0.001 instead of > 0.
SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0);
SHORT range = maxForce - minForce;
tempEffect.leftright.small_magnitude = (SHORT)(smallstrength * range + minForce);
SHORT minForce1 = (SHORT)(largestrength > 0.001 ? (configMinForce / 100.0 * 32767.0) : 0); // strength is a double so we do an epsilon check of 0.001 instead of > 0.
SHORT maxForce1 = (SHORT)(configMaxForce / 100.0 * 32767.0);
SHORT range1 = maxForce1 - minForce1;
tempEffect.leftright.large_magnitude = (SHORT)(largestrength * range1 + minForce1);
SDL_HapticUpdateEffect(haptic, effects.effect_leftright_id, &tempEffect);
SDL_HapticRunEffect(haptic, effects.effect_leftright_id, 1);
}
}
}
@ -1531,23 +1569,7 @@ void TriggerLeftRightDevice2Effect(double smallstrength, double largestrength, d
{
if (EnableRumble == 1)
{
if (ReverseRumble == 0)
{
SDL_HapticEffect tempEffect;
tempEffect.type = SDL_HAPTIC_LEFTRIGHT;
tempEffect.leftright.length = length;
SHORT minForce = (SHORT)(smallstrength > 0.001 ? (configMinForce / 100.0 * 32767.0) : 0); // strength is a double so we do an epsilon check of 0.001 instead of > 0.
SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0);
SHORT range = maxForce - minForce;
tempEffect.leftright.small_magnitude = (SHORT)(smallstrength * range + minForce);
SHORT minForce1 = (SHORT)(largestrength > 0.001 ? (configMinForce / 100.0 * 32767.0) : 0); // strength is a double so we do an epsilon check of 0.001 instead of > 0.
SHORT maxForce1 = (SHORT)(configMaxForce / 100.0 * 32767.0);
SHORT range1 = maxForce1 - minForce1;
tempEffect.leftright.large_magnitude = (SHORT)(largestrength * range1 + minForce1);
SDL_HapticUpdateEffect(haptic2, effects.effect_leftright_id, &tempEffect);
SDL_HapticRunEffect(haptic2, effects.effect_leftright_id, 1);
}
else if (ReverseRumble == 1)
if (ReverseRumble == 1)
{
SDL_HapticEffect tempEffect;
tempEffect.type = SDL_HAPTIC_LEFTRIGHT;
@ -1563,6 +1585,22 @@ void TriggerLeftRightDevice2Effect(double smallstrength, double largestrength, d
SDL_HapticUpdateEffect(haptic2, effects.effect_leftright_id, &tempEffect);
SDL_HapticRunEffect(haptic2, effects.effect_leftright_id, 1);
}
else
{
SDL_HapticEffect tempEffect;
tempEffect.type = SDL_HAPTIC_LEFTRIGHT;
tempEffect.leftright.length = length;
SHORT minForce = (SHORT)(smallstrength > 0.001 ? (configMinForce / 100.0 * 32767.0) : 0); // strength is a double so we do an epsilon check of 0.001 instead of > 0.
SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0);
SHORT range = maxForce - minForce;
tempEffect.leftright.small_magnitude = (SHORT)(smallstrength * range + minForce);
SHORT minForce1 = (SHORT)(largestrength > 0.001 ? (configMinForce / 100.0 * 32767.0) : 0); // strength is a double so we do an epsilon check of 0.001 instead of > 0.
SHORT maxForce1 = (SHORT)(configMaxForce / 100.0 * 32767.0);
SHORT range1 = maxForce1 - minForce1;
tempEffect.leftright.large_magnitude = (SHORT)(largestrength * range1 + minForce1);
SDL_HapticUpdateEffect(haptic2, effects.effect_leftright_id, &tempEffect);
SDL_HapticRunEffect(haptic2, effects.effect_leftright_id, 1);
}
}
}
@ -1576,7 +1614,10 @@ void TriggerRumbleEffect(double strength, double length)
void TriggerSpringEffect(double strength)
{
if (EnableRumble != 1)
{
TriggerSpringEffectWithDefaultOption(strength, false);
}
}
DWORD WINAPI FFBLoop(LPVOID lpParam)