Add code for ffb to not work if rumble is enabled
This commit is contained in:
parent
33b2805f89
commit
2d00338254
111
DllMain.cpp
111
DllMain.cpp
@ -1080,6 +1080,8 @@ std::chrono::milliseconds timeOfLastSineEffect = duration_cast<milliseconds>(sys
|
||||
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));
|
||||
@ -1125,8 +1127,11 @@ void TriggerConstantEffect(int direction, double strength)
|
||||
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));
|
||||
@ -1153,7 +1158,11 @@ void TriggerFrictionEffectWithDefaultOption(double strength, bool isDefault)
|
||||
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));
|
||||
@ -1182,8 +1191,11 @@ 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) {
|
||||
@ -1235,8 +1247,11 @@ 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));
|
||||
@ -1264,8 +1279,11 @@ 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));
|
||||
@ -1296,8 +1314,11 @@ 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));
|
||||
@ -1321,8 +1342,12 @@ 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;
|
||||
@ -1345,13 +1370,19 @@ 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();
|
||||
@ -1424,8 +1455,11 @@ void TriggerSineEffect(UINT16 period, UINT16 fadePeriod, double strength)
|
||||
lastSineEffectStrength = strength;
|
||||
lastSineEffectPeriod = period;
|
||||
}
|
||||
}
|
||||
|
||||
void TriggerSpringEffectWithDefaultOption(double strength, bool isDefault)
|
||||
{
|
||||
if (EnableRumble != 1)
|
||||
{
|
||||
SDL_HapticEffect tempEffect;
|
||||
SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect));
|
||||
@ -1455,8 +1489,11 @@ 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));
|
||||
@ -1487,28 +1524,13 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1575,9 +1613,12 @@ void TriggerRumbleEffect(double strength, double length)
|
||||
}
|
||||
|
||||
void TriggerSpringEffect(double strength)
|
||||
{
|
||||
if (EnableRumble != 1)
|
||||
{
|
||||
TriggerSpringEffectWithDefaultOption(strength, false);
|
||||
}
|
||||
}
|
||||
|
||||
DWORD WINAPI FFBLoop(LPVOID lpParam)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user