Revert EnableRumble
This commit is contained in:
parent
2e3f8f2149
commit
d816224f72
@ -21,7 +21,7 @@ MaxForce=100
|
|||||||
; Set Device GUID to connect to specific joystick or controller.
|
; Set Device GUID to connect to specific joystick or controller.
|
||||||
DeviceGUID=
|
DeviceGUID=
|
||||||
;Set to 1 if you want to enable rumble, else 0.
|
;Set to 1 if you want to enable rumble, else 0.
|
||||||
FFBorRumble=0
|
EnableRumble=0
|
||||||
ReverseRumble=0
|
ReverseRumble=0
|
||||||
; Set to 1 to generate log.txt, else 0. Logs will be appended and not cleared.
|
; Set to 1 to generate log.txt, else 0. Logs will be appended and not cleared.
|
||||||
Logging=0
|
Logging=0
|
||||||
@ -91,7 +91,7 @@ GearChangeLength=80
|
|||||||
|
|
||||||
[AfterburnerClimax]
|
[AfterburnerClimax]
|
||||||
GameId=15
|
GameId=15
|
||||||
FFBorRumble=1
|
EnableRumble=1
|
||||||
Rumble1Strength=50
|
Rumble1Strength=50
|
||||||
Rumble2Strength=100
|
Rumble2Strength=100
|
||||||
Rumble1Length=200
|
Rumble1Length=200
|
||||||
@ -100,7 +100,7 @@ Rumble2Length=200
|
|||||||
[HOTD4]
|
[HOTD4]
|
||||||
GameId=4
|
GameId=4
|
||||||
FeedbackLength=100
|
FeedbackLength=100
|
||||||
FFBorRumble=1
|
EnableRumble=1
|
||||||
Device2GUID=
|
Device2GUID=
|
||||||
Bullet1pStrength=50
|
Bullet1pStrength=50
|
||||||
Grenade1pStrength=70
|
Grenade1pStrength=70
|
||||||
@ -115,7 +115,7 @@ HowtoRumbleHealthEffect=0
|
|||||||
[LGI]
|
[LGI]
|
||||||
GameId=31
|
GameId=31
|
||||||
FeedbackLength=100
|
FeedbackLength=100
|
||||||
FFBorRumble=1
|
EnableRumble=1
|
||||||
Device2GUID=
|
Device2GUID=
|
||||||
Knock1pStrength=50
|
Knock1pStrength=50
|
||||||
Motor1pStrength=60
|
Motor1pStrength=60
|
||||||
@ -130,7 +130,7 @@ HowtoRumbleHealthEffect=0
|
|||||||
[LGI3D]
|
[LGI3D]
|
||||||
GameId=30
|
GameId=30
|
||||||
FeedbackLength=100
|
FeedbackLength=100
|
||||||
FFBorRumble=1
|
EnableRumble=1
|
||||||
Device2GUID=
|
Device2GUID=
|
||||||
Knock1pStrength=50
|
Knock1pStrength=50
|
||||||
Motor1pStrength=60
|
Motor1pStrength=60
|
||||||
@ -200,7 +200,7 @@ MaxForce=100
|
|||||||
|
|
||||||
[Machstorm]
|
[Machstorm]
|
||||||
GameId=14
|
GameId=14
|
||||||
FFBorRumble=1
|
EnableRumble=1
|
||||||
Power1RumbleStrength=10
|
Power1RumbleStrength=10
|
||||||
Power2RumbleStrength=20
|
Power2RumbleStrength=20
|
||||||
Power3RumbleStrength=30
|
Power3RumbleStrength=30
|
||||||
@ -224,7 +224,7 @@ Power10RumbleLength=100
|
|||||||
|
|
||||||
[PokkenTournament]
|
[PokkenTournament]
|
||||||
GameId=19
|
GameId=19
|
||||||
FFBorRumble=1
|
EnableRumble=1
|
||||||
RumbleStrength=100
|
RumbleStrength=100
|
||||||
RumbleLength=500
|
RumbleLength=500
|
||||||
HowtoRumble=0
|
HowtoRumble=0
|
||||||
@ -397,7 +397,7 @@ leverRightDevice2=99
|
|||||||
|
|
||||||
[Button Rumble 32bit]
|
[Button Rumble 32bit]
|
||||||
GameId=28
|
GameId=28
|
||||||
FFBorRumble=1
|
EnableRumble=1
|
||||||
ShowButtonNumbersForSetup=0
|
ShowButtonNumbersForSetup=0
|
||||||
BothRumbleMotor=1
|
BothRumbleMotor=1
|
||||||
LeftRumbleMotor=0
|
LeftRumbleMotor=0
|
||||||
@ -428,7 +428,7 @@ Button10Device2Rumble=99
|
|||||||
|
|
||||||
[Button Rumble 64bit]
|
[Button Rumble 64bit]
|
||||||
GameId=28
|
GameId=28
|
||||||
FFBorRumble=1
|
EnableRumble=1
|
||||||
ShowButtonNumbersForSetup=0
|
ShowButtonNumbersForSetup=0
|
||||||
BothRumbleMotor=1
|
BothRumbleMotor=1
|
||||||
LeftRumbleMotor=0
|
LeftRumbleMotor=0
|
||||||
|
760
DllMain.cpp
760
DllMain.cpp
@ -850,7 +850,7 @@ wchar_t *settingsFilename = TEXT(".\\FFBPlugin.ini");
|
|||||||
int configMinForce = GetPrivateProfileInt(TEXT("Settings"), TEXT("MinForce"), 0, settingsFilename);
|
int configMinForce = GetPrivateProfileInt(TEXT("Settings"), TEXT("MinForce"), 0, settingsFilename);
|
||||||
int configMaxForce = GetPrivateProfileInt(TEXT("Settings"), TEXT("MaxForce"), 100, settingsFilename);
|
int configMaxForce = GetPrivateProfileInt(TEXT("Settings"), TEXT("MaxForce"), 100, settingsFilename);
|
||||||
int enableLogging = GetPrivateProfileInt(TEXT("Settings"), TEXT("Logging"), 0, settingsFilename);
|
int enableLogging = GetPrivateProfileInt(TEXT("Settings"), TEXT("Logging"), 0, settingsFilename);
|
||||||
int FFBorRumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("FFBorRumble"), 0, settingsFilename);
|
int EnableRumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("EnableRumble"), 0, settingsFilename);
|
||||||
int ReverseRumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("ReverseRumble"), 0, settingsFilename);
|
int ReverseRumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("ReverseRumble"), 0, settingsFilename);
|
||||||
wchar_t *deviceGUIDString = new wchar_t[256];
|
wchar_t *deviceGUIDString = new wchar_t[256];
|
||||||
int DeviceGUID = GetPrivateProfileString(TEXT("Settings"), TEXT("DeviceGUID"), NULL, deviceGUIDString, 256, settingsFilename);
|
int DeviceGUID = GetPrivateProfileString(TEXT("Settings"), TEXT("DeviceGUID"), NULL, deviceGUIDString, 256, settingsFilename);
|
||||||
@ -982,7 +982,7 @@ void Initialize(int device_index)
|
|||||||
hlp.log(firstJoystickSelectedText);
|
hlp.log(firstJoystickSelectedText);
|
||||||
}
|
}
|
||||||
haptic = ControllerHaptic;
|
haptic = ControllerHaptic;
|
||||||
if ((SDL_HapticRumbleSupported(haptic) == SDL_TRUE && FFBorRumble == 1))
|
if ((SDL_HapticRumbleSupported(haptic) == SDL_TRUE && EnableRumble == 1))
|
||||||
{
|
{
|
||||||
SDL_HapticRumbleInit(ControllerHaptic);
|
SDL_HapticRumbleInit(ControllerHaptic);
|
||||||
hlp.log("Rumble Init");
|
hlp.log("Rumble Init");
|
||||||
@ -1081,119 +1081,111 @@ double lastSineEffectStrength = 0;
|
|||||||
double lastSineEffectPeriod = 0;
|
double lastSineEffectPeriod = 0;
|
||||||
void TriggerConstantEffect(int direction, double strength)
|
void TriggerConstantEffect(int direction, double strength)
|
||||||
{
|
{
|
||||||
if (FFBorRumble == 0)
|
SDL_HapticEffect tempEffect;
|
||||||
|
SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect));
|
||||||
|
tempEffect.type = SDL_HAPTIC_CONSTANT;
|
||||||
|
tempEffect.constant.direction.type = SDL_HAPTIC_CARTESIAN;
|
||||||
|
tempEffect.constant.direction.dir[0] = direction;
|
||||||
|
tempEffect.constant.length = configFeedbackLength;
|
||||||
|
tempEffect.constant.delay = 0;
|
||||||
|
|
||||||
|
int confMinForce = configMinForce;
|
||||||
|
int confMaxForce = configMaxForce;
|
||||||
|
|
||||||
|
if (AlternativeFFB == 1)
|
||||||
{
|
{
|
||||||
SDL_HapticEffect tempEffect;
|
if (direction == -1)
|
||||||
SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect));
|
|
||||||
tempEffect.type = SDL_HAPTIC_CONSTANT;
|
|
||||||
tempEffect.constant.direction.type = SDL_HAPTIC_CARTESIAN;
|
|
||||||
tempEffect.constant.direction.dir[0] = direction;
|
|
||||||
tempEffect.constant.length = configFeedbackLength;
|
|
||||||
tempEffect.constant.delay = 0;
|
|
||||||
|
|
||||||
int confMinForce = configMinForce;
|
|
||||||
int confMaxForce = configMaxForce;
|
|
||||||
|
|
||||||
if (AlternativeFFB == 1)
|
|
||||||
{
|
{
|
||||||
if (direction == -1)
|
confMinForce = configAlternativeMinForceLeft;
|
||||||
{
|
confMaxForce = configAlternativeMaxForceLeft;
|
||||||
confMinForce = configAlternativeMinForceLeft;
|
|
||||||
confMaxForce = configAlternativeMaxForceLeft;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
confMinForce = configAlternativeMinForceRight;
|
|
||||||
confMaxForce = configAlternativeMaxForceRight;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
SHORT MinForce = (SHORT)(strength > 0.001 ? (confMinForce / 100.0 * 32767.0) : 0);
|
|
||||||
SHORT MaxForce = (SHORT)(confMaxForce / 100.0 * 32767.0);
|
|
||||||
SHORT range = MaxForce - MinForce;
|
|
||||||
SHORT level = (SHORT)(strength * range + MinForce);
|
|
||||||
|
|
||||||
if (range > 0 && level < 0)
|
|
||||||
{
|
{
|
||||||
level = 32767;
|
confMinForce = configAlternativeMinForceRight;
|
||||||
}
|
confMaxForce = configAlternativeMaxForceRight;
|
||||||
else if (range < 0 && level > 0)
|
|
||||||
{
|
|
||||||
level = -32767;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tempEffect.constant.level = level;
|
SHORT MinForce = (SHORT)(strength > 0.001 ? (confMinForce / 100.0 * 32767.0) : 0);
|
||||||
hlp.log((char*)(std::to_string(level)).c_str());
|
SHORT MaxForce = (SHORT)(confMaxForce / 100.0 * 32767.0);
|
||||||
SDL_HapticUpdateEffect(haptic, effects.effect_constant_id, &tempEffect);
|
SHORT range = MaxForce - MinForce;
|
||||||
SDL_HapticRunEffect(haptic, effects.effect_constant_id, 1);
|
SHORT level = (SHORT)(strength * range + MinForce);
|
||||||
}
|
|
||||||
|
if (range > 0 && level < 0)
|
||||||
|
{
|
||||||
|
level = 32767;
|
||||||
|
}
|
||||||
|
else if (range < 0 && level > 0)
|
||||||
|
{
|
||||||
|
level = -32767;
|
||||||
|
}
|
||||||
|
|
||||||
|
tempEffect.constant.level = level;
|
||||||
|
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)
|
void TriggerFrictionEffectWithDefaultOption(double strength, bool isDefault)
|
||||||
{
|
{
|
||||||
if (FFBorRumble == 0)
|
SDL_HapticEffect tempEffect;
|
||||||
|
SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect));
|
||||||
|
tempEffect.type = SDL_HAPTIC_FRICTION;
|
||||||
|
tempEffect.condition.type = SDL_HAPTIC_FRICTION;
|
||||||
|
tempEffect.condition.direction.type = SDL_HAPTIC_CARTESIAN;
|
||||||
|
tempEffect.condition.delay = 0;
|
||||||
|
tempEffect.condition.length = isDefault ? SDL_HAPTIC_INFINITY : configFeedbackLength;
|
||||||
|
tempEffect.condition.left_sat[0] = 0xFFFF;
|
||||||
|
tempEffect.condition.right_sat[0] = 0xFFFF;
|
||||||
|
|
||||||
|
SHORT minForce = (SHORT)(strength > 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;
|
||||||
|
SHORT coeff = (SHORT)(strength * range + minForce);
|
||||||
|
if (coeff < 0)
|
||||||
{
|
{
|
||||||
SDL_HapticEffect tempEffect;
|
coeff = 32767;
|
||||||
SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect));
|
}
|
||||||
tempEffect.type = SDL_HAPTIC_FRICTION;
|
|
||||||
tempEffect.condition.type = SDL_HAPTIC_FRICTION;
|
|
||||||
tempEffect.condition.direction.type = SDL_HAPTIC_CARTESIAN;
|
|
||||||
tempEffect.condition.delay = 0;
|
|
||||||
tempEffect.condition.length = isDefault ? SDL_HAPTIC_INFINITY : configFeedbackLength;
|
|
||||||
tempEffect.condition.left_sat[0] = 0xFFFF;
|
|
||||||
tempEffect.condition.right_sat[0] = 0xFFFF;
|
|
||||||
|
|
||||||
SHORT minForce = (SHORT)(strength > 0.001 ? (configMinForce / 100.0 * 32767.0) : 0); // strength is a double so we do an epsilon check of 0.001 instead of > 0.
|
tempEffect.condition.left_coeff[0] = (short)(coeff);
|
||||||
SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0);
|
tempEffect.condition.right_coeff[0] = (short)(coeff);
|
||||||
SHORT range = maxForce - minForce;
|
SDL_HapticUpdateEffect(haptic, effects.effect_friction_id, &tempEffect);
|
||||||
SHORT coeff = (SHORT)(strength * range + minForce);
|
SDL_HapticRunEffect(haptic, effects.effect_friction_id, 1);
|
||||||
if (coeff < 0)
|
|
||||||
{
|
|
||||||
coeff = 32767;
|
|
||||||
}
|
|
||||||
|
|
||||||
tempEffect.condition.left_coeff[0] = (short)(coeff);
|
|
||||||
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)
|
void TriggerInertiaEffect(double strength)
|
||||||
{
|
{
|
||||||
if (FFBorRumble == 0)
|
SDL_HapticEffect tempEffect;
|
||||||
|
SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect));
|
||||||
|
tempEffect.type = SDL_HAPTIC_INERTIA;
|
||||||
|
tempEffect.condition.type = SDL_HAPTIC_INERTIA;
|
||||||
|
tempEffect.condition.direction.type = SDL_HAPTIC_CARTESIAN;
|
||||||
|
tempEffect.condition.delay = 0;
|
||||||
|
tempEffect.condition.length = configFeedbackLength;
|
||||||
|
tempEffect.condition.direction.dir[0] = 1;
|
||||||
|
tempEffect.condition.direction.dir[1] = 1; //Y Position
|
||||||
|
SHORT minForce = (SHORT)(strength > 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;
|
||||||
|
SHORT coeff = (SHORT)(strength * range + minForce);
|
||||||
|
if (coeff < 0)
|
||||||
{
|
{
|
||||||
SDL_HapticEffect tempEffect;
|
coeff = 32767;
|
||||||
SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect));
|
}
|
||||||
tempEffect.type = SDL_HAPTIC_INERTIA;
|
|
||||||
tempEffect.condition.type = SDL_HAPTIC_INERTIA;
|
|
||||||
tempEffect.condition.direction.type = SDL_HAPTIC_CARTESIAN;
|
|
||||||
tempEffect.condition.delay = 0;
|
|
||||||
tempEffect.condition.length = configFeedbackLength;
|
|
||||||
tempEffect.condition.direction.dir[0] = 1;
|
|
||||||
tempEffect.condition.direction.dir[1] = 1; //Y Position
|
|
||||||
SHORT minForce = (SHORT)(strength > 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;
|
|
||||||
SHORT coeff = (SHORT)(strength * range + minForce);
|
|
||||||
if (coeff < 0)
|
|
||||||
{
|
|
||||||
coeff = 32767;
|
|
||||||
}
|
|
||||||
|
|
||||||
tempEffect.condition.left_coeff[0] = (short)(coeff);
|
tempEffect.condition.left_coeff[0] = (short)(coeff);
|
||||||
tempEffect.condition.right_coeff[0] = (short)(coeff);
|
tempEffect.condition.right_coeff[0] = (short)(coeff);
|
||||||
tempEffect.condition.left_sat[0] = (short)(coeff) * 10;
|
tempEffect.condition.left_sat[0] = (short)(coeff) * 10;
|
||||||
tempEffect.condition.right_sat[0] = (short)(coeff) * 10;
|
tempEffect.condition.right_sat[0] = (short)(coeff) * 10;
|
||||||
tempEffect.condition.center[0] = 0;
|
tempEffect.condition.center[0] = 0;
|
||||||
|
|
||||||
SDL_HapticUpdateEffect(haptic, effects.effect_inertia_id, &tempEffect);
|
SDL_HapticUpdateEffect(haptic, effects.effect_inertia_id, &tempEffect);
|
||||||
SDL_HapticRunEffect(haptic, effects.effect_inertia_id, 1);
|
SDL_HapticRunEffect(haptic, effects.effect_inertia_id, 1);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerTriangleEffect(double strength, double length)
|
void TriggerTriangleEffect(double strength, double length)
|
||||||
{
|
{
|
||||||
|
<<<<<<< HEAD
|
||||||
if (FFBorRumble == 0)
|
if (FFBorRumble == 0)
|
||||||
{
|
{
|
||||||
int direction = 1;
|
int direction = 1;
|
||||||
@ -1201,191 +1193,180 @@ void TriggerTriangleEffect(double strength, double length)
|
|||||||
strength *= -1;
|
strength *= -1;
|
||||||
direction = -1;
|
direction = -1;
|
||||||
}
|
}
|
||||||
|
=======
|
||||||
SDL_HapticEffect tempEffect;
|
int direction = 1;
|
||||||
SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect));
|
if (strength <= -0.001) {
|
||||||
tempEffect.type = SDL_HAPTIC_TRIANGLE;
|
strength *= -1;
|
||||||
tempEffect.condition.type = SDL_HAPTIC_TRIANGLE;
|
direction = -1;
|
||||||
tempEffect.condition.direction.type = SDL_HAPTIC_CARTESIAN;
|
|
||||||
tempEffect.condition.direction.dir[0] = direction;
|
|
||||||
tempEffect.condition.direction.dir[1] = 0; //Y Position
|
|
||||||
tempEffect.periodic.period = 500;
|
|
||||||
|
|
||||||
int confMinForce = configMinForce;
|
|
||||||
int confMaxForce = configMaxForce;
|
|
||||||
if (AlternativeFFB == 1)
|
|
||||||
{
|
|
||||||
if (direction == -1)
|
|
||||||
{
|
|
||||||
confMinForce = configAlternativeMinForceLeft;
|
|
||||||
confMaxForce = configAlternativeMaxForceLeft;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
confMinForce = configAlternativeMinForceRight;
|
|
||||||
confMaxForce = configAlternativeMaxForceRight;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SHORT minForce = (SHORT)(strength > 0.001 ? (confMinForce / 100.0 * 32767.0) : 0); // strength is a double so we do an epsilon check of 0.001 instead of > 0.
|
|
||||||
SHORT maxForce = (SHORT)(confMaxForce / 100.0 * 32767.0);
|
|
||||||
SHORT range = maxForce - minForce;
|
|
||||||
SHORT power = (SHORT)(strength * range + minForce);
|
|
||||||
if (range > 0 && power < 0)
|
|
||||||
{
|
|
||||||
power = 32767;
|
|
||||||
}
|
|
||||||
else if (range < 0 && power > 0)
|
|
||||||
{
|
|
||||||
power = -32767;
|
|
||||||
}
|
|
||||||
tempEffect.periodic.magnitude = power;
|
|
||||||
tempEffect.periodic.length = length;
|
|
||||||
tempEffect.periodic.attack_length = 1000;
|
|
||||||
tempEffect.periodic.fade_length = 1000;
|
|
||||||
|
|
||||||
SDL_HapticUpdateEffect(haptic, effects.effect_triangle_id, &tempEffect);
|
|
||||||
SDL_HapticRunEffect(haptic, effects.effect_triangle_id, 1);
|
|
||||||
}
|
}
|
||||||
|
>>>>>>> parent of 779758b... Now Choose FFB or Rumble
|
||||||
|
|
||||||
|
SDL_HapticEffect tempEffect;
|
||||||
|
SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect));
|
||||||
|
tempEffect.type = SDL_HAPTIC_TRIANGLE;
|
||||||
|
tempEffect.condition.type = SDL_HAPTIC_TRIANGLE;
|
||||||
|
tempEffect.condition.direction.type = SDL_HAPTIC_CARTESIAN;
|
||||||
|
tempEffect.condition.direction.dir[0] = direction;
|
||||||
|
tempEffect.condition.direction.dir[1] = 0; //Y Position
|
||||||
|
tempEffect.periodic.period = 500;
|
||||||
|
|
||||||
|
int confMinForce = configMinForce;
|
||||||
|
int confMaxForce = configMaxForce;
|
||||||
|
if (AlternativeFFB == 1)
|
||||||
|
{
|
||||||
|
if (direction == -1)
|
||||||
|
{
|
||||||
|
confMinForce = configAlternativeMinForceLeft;
|
||||||
|
confMaxForce = configAlternativeMaxForceLeft;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
confMinForce = configAlternativeMinForceRight;
|
||||||
|
confMaxForce = configAlternativeMaxForceRight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SHORT minForce = (SHORT)(strength > 0.001 ? (confMinForce / 100.0 * 32767.0) : 0); // strength is a double so we do an epsilon check of 0.001 instead of > 0.
|
||||||
|
SHORT maxForce = (SHORT)(confMaxForce / 100.0 * 32767.0);
|
||||||
|
SHORT range = maxForce - minForce;
|
||||||
|
SHORT power = (SHORT)(strength * range + minForce);
|
||||||
|
if (range > 0 && power < 0)
|
||||||
|
{
|
||||||
|
power = 32767;
|
||||||
|
}
|
||||||
|
else if (range < 0 && power > 0)
|
||||||
|
{
|
||||||
|
power = -32767;
|
||||||
|
}
|
||||||
|
tempEffect.periodic.magnitude = power;
|
||||||
|
tempEffect.periodic.length = length;
|
||||||
|
tempEffect.periodic.attack_length = 1000;
|
||||||
|
tempEffect.periodic.fade_length = 1000;
|
||||||
|
|
||||||
|
SDL_HapticUpdateEffect(haptic, effects.effect_triangle_id, &tempEffect);
|
||||||
|
SDL_HapticRunEffect(haptic, effects.effect_triangle_id, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerDamperEffect(double strength)
|
void TriggerDamperEffect(double strength)
|
||||||
{
|
{
|
||||||
if (FFBorRumble == 0)
|
SDL_HapticEffect tempEffect;
|
||||||
|
SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect));
|
||||||
|
tempEffect.type = SDL_HAPTIC_DAMPER;
|
||||||
|
tempEffect.condition.type = SDL_HAPTIC_DAMPER;
|
||||||
|
tempEffect.condition.direction.type = SDL_HAPTIC_CARTESIAN;
|
||||||
|
tempEffect.condition.delay = 0;
|
||||||
|
tempEffect.condition.length = configFeedbackLength;
|
||||||
|
tempEffect.condition.direction.dir[0] = 1; // not used
|
||||||
|
tempEffect.condition.direction.dir[1] = 0; //Y Position
|
||||||
|
SHORT minForce = (SHORT)(strength > 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;
|
||||||
|
SHORT coeff = (SHORT)(strength * range + minForce);
|
||||||
|
if (coeff < 0)
|
||||||
{
|
{
|
||||||
SDL_HapticEffect tempEffect;
|
coeff = 32767;
|
||||||
SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect));
|
}
|
||||||
tempEffect.type = SDL_HAPTIC_DAMPER;
|
|
||||||
tempEffect.condition.type = SDL_HAPTIC_DAMPER;
|
|
||||||
tempEffect.condition.direction.type = SDL_HAPTIC_CARTESIAN;
|
|
||||||
tempEffect.condition.delay = 0;
|
|
||||||
tempEffect.condition.length = configFeedbackLength;
|
|
||||||
tempEffect.condition.direction.dir[0] = 1; // not used
|
|
||||||
tempEffect.condition.direction.dir[1] = 0; //Y Position
|
|
||||||
SHORT minForce = (SHORT)(strength > 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;
|
|
||||||
SHORT coeff = (SHORT)(strength * range + minForce);
|
|
||||||
if (coeff < 0)
|
|
||||||
{
|
|
||||||
coeff = 32767;
|
|
||||||
}
|
|
||||||
|
|
||||||
tempEffect.condition.left_coeff[0] = (short)(coeff);
|
tempEffect.condition.left_coeff[0] = (short)(coeff);
|
||||||
tempEffect.condition.right_coeff[0] = (short)(coeff);
|
tempEffect.condition.right_coeff[0] = (short)(coeff);
|
||||||
tempEffect.condition.left_sat[0] = (short)(coeff) * 10;
|
tempEffect.condition.left_sat[0] = (short)(coeff) * 10;
|
||||||
tempEffect.condition.right_sat[0] = (short)(coeff) * 10;
|
tempEffect.condition.right_sat[0] = (short)(coeff) * 10;
|
||||||
|
|
||||||
SDL_HapticUpdateEffect(haptic, effects.effect_damper_id, &tempEffect);
|
SDL_HapticUpdateEffect(haptic, effects.effect_damper_id, &tempEffect);
|
||||||
SDL_HapticRunEffect(haptic, effects.effect_damper_id, 1);
|
SDL_HapticRunEffect(haptic, effects.effect_damper_id, 1);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerRampEffect(double start,double end,double length)
|
void TriggerRampEffect(double start,double end,double length)
|
||||||
{
|
{
|
||||||
if (FFBorRumble == 0)
|
SDL_HapticEffect tempEffect;
|
||||||
|
SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect));
|
||||||
|
tempEffect.type = SDL_HAPTIC_RAMP;
|
||||||
|
tempEffect.ramp.type = SDL_HAPTIC_RAMP;
|
||||||
|
tempEffect.ramp.direction.type = SDL_HAPTIC_CARTESIAN;
|
||||||
|
tempEffect.ramp.length = length;
|
||||||
|
SHORT minForce = (SHORT)(start > 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;
|
||||||
|
SHORT start1 = (SHORT)(start * range + minForce);
|
||||||
|
if (start1 < 0)
|
||||||
{
|
{
|
||||||
SDL_HapticEffect tempEffect;
|
start1 = 32767;
|
||||||
SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect));
|
}
|
||||||
tempEffect.type = SDL_HAPTIC_RAMP;
|
SHORT minForce2 = (SHORT)(end > 0.001 ? (configMinForce / 100.0 * 32767.0) : 0); // strength is a double so we do an epsilon check of 0.001 instead of > 0.
|
||||||
tempEffect.ramp.type = SDL_HAPTIC_RAMP;
|
SHORT maxForce2 = (SHORT)(configMaxForce / 100.0 * 32767.0);
|
||||||
tempEffect.ramp.direction.type = SDL_HAPTIC_CARTESIAN;
|
SHORT range2 = maxForce - minForce;
|
||||||
tempEffect.ramp.length = length;
|
SHORT start2 = (SHORT)(end * range + minForce);
|
||||||
SHORT minForce = (SHORT)(start > 0.001 ? (configMinForce / 100.0 * 32767.0) : 0); // strength is a double so we do an epsilon check of 0.001 instead of > 0.
|
if (start2 < 0)
|
||||||
SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0);
|
{
|
||||||
SHORT range = maxForce - minForce;
|
start2 = 32767;
|
||||||
SHORT start1 = (SHORT)(start * range + minForce);
|
}
|
||||||
if (start1 < 0)
|
tempEffect.ramp.delay = 0;
|
||||||
{
|
tempEffect.ramp.start = start1;
|
||||||
start1 = 32767;
|
tempEffect.ramp.end = -start2;
|
||||||
}
|
|
||||||
SHORT minForce2 = (SHORT)(end > 0.001 ? (configMinForce / 100.0 * 32767.0) : 0); // strength is a double so we do an epsilon check of 0.001 instead of > 0.
|
SDL_HapticUpdateEffect(haptic, effects.effect_ramp_id, &tempEffect);
|
||||||
SHORT maxForce2 = (SHORT)(configMaxForce / 100.0 * 32767.0);
|
SDL_HapticRunEffect(haptic, effects.effect_ramp_id, 1);
|
||||||
SHORT range2 = maxForce - minForce;
|
|
||||||
SHORT start2 = (SHORT)(end * range + minForce);
|
|
||||||
if (start2 < 0)
|
|
||||||
{
|
|
||||||
start2 = 32767;
|
|
||||||
}
|
|
||||||
tempEffect.ramp.delay = 0;
|
|
||||||
tempEffect.ramp.start = start1;
|
|
||||||
tempEffect.ramp.end = -start2;
|
|
||||||
|
|
||||||
SDL_HapticUpdateEffect(haptic, effects.effect_ramp_id, &tempEffect);
|
|
||||||
SDL_HapticRunEffect(haptic, effects.effect_ramp_id, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerSawtoothUpEffect(double strength, double length)
|
void TriggerSawtoothUpEffect(double strength, double length)
|
||||||
{
|
{
|
||||||
if (FFBorRumble == 0)
|
SDL_HapticEffect tempEffect;
|
||||||
|
SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect));
|
||||||
|
tempEffect.type = SDL_HAPTIC_SAWTOOTHUP;
|
||||||
|
tempEffect.condition.type = SDL_HAPTIC_SAWTOOTHUP;
|
||||||
|
tempEffect.condition.direction.type = SDL_HAPTIC_CARTESIAN;
|
||||||
|
tempEffect.periodic.period = 500;
|
||||||
|
SHORT minForce = (SHORT)(strength > 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;
|
||||||
|
SHORT power = (SHORT)(strength * range + minForce);
|
||||||
|
if (power < 0)
|
||||||
{
|
{
|
||||||
SDL_HapticEffect tempEffect;
|
power = 32767;
|
||||||
SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect));
|
}
|
||||||
tempEffect.type = SDL_HAPTIC_SAWTOOTHUP;
|
tempEffect.periodic.magnitude = power;
|
||||||
tempEffect.condition.type = SDL_HAPTIC_SAWTOOTHUP;
|
tempEffect.periodic.length = length;
|
||||||
tempEffect.condition.direction.type = SDL_HAPTIC_CARTESIAN;
|
tempEffect.periodic.attack_length = 1000;
|
||||||
tempEffect.periodic.period = 500;
|
tempEffect.periodic.fade_length = 1000;
|
||||||
SHORT minForce = (SHORT)(strength > 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;
|
|
||||||
SHORT power = (SHORT)(strength * range + minForce);
|
|
||||||
if (power < 0)
|
|
||||||
{
|
|
||||||
power = 32767;
|
|
||||||
}
|
|
||||||
tempEffect.periodic.magnitude = power;
|
|
||||||
tempEffect.periodic.length = length;
|
|
||||||
tempEffect.periodic.attack_length = 1000;
|
|
||||||
tempEffect.periodic.fade_length = 1000;
|
|
||||||
|
|
||||||
SDL_HapticUpdateEffect(haptic, effects.effect_sawtoothup_id, &tempEffect);
|
SDL_HapticUpdateEffect(haptic, effects.effect_sawtoothup_id, &tempEffect);
|
||||||
SDL_HapticRunEffect(haptic, effects.effect_sawtoothup_id, 1);
|
SDL_HapticRunEffect(haptic, effects.effect_sawtoothup_id, 1);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerSawtoothDownEffect(double strength, double length)
|
void TriggerSawtoothDownEffect(double strength, double length) {
|
||||||
{
|
SDL_HapticEffect tempEffect;
|
||||||
if (FFBorRumble == 0)
|
SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect));
|
||||||
|
tempEffect.type = SDL_HAPTIC_SAWTOOTHDOWN;
|
||||||
|
tempEffect.condition.type = SDL_HAPTIC_SAWTOOTHDOWN;
|
||||||
|
tempEffect.condition.direction.type = SDL_HAPTIC_CARTESIAN;
|
||||||
|
tempEffect.periodic.period = 500;
|
||||||
|
SHORT minForce = (SHORT)(strength > 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;
|
||||||
|
SHORT power = (SHORT)(strength * range + minForce);
|
||||||
|
if (power < 0)
|
||||||
{
|
{
|
||||||
SDL_HapticEffect tempEffect;
|
power = 32767;
|
||||||
SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect));
|
}
|
||||||
tempEffect.type = SDL_HAPTIC_SAWTOOTHDOWN;
|
tempEffect.periodic.magnitude = power;
|
||||||
tempEffect.condition.type = SDL_HAPTIC_SAWTOOTHDOWN;
|
tempEffect.periodic.length = length;
|
||||||
tempEffect.condition.direction.type = SDL_HAPTIC_CARTESIAN;
|
tempEffect.periodic.attack_length = 1000;
|
||||||
tempEffect.periodic.period = 500;
|
tempEffect.periodic.fade_length = 1000;
|
||||||
SHORT minForce = (SHORT)(strength > 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;
|
|
||||||
SHORT power = (SHORT)(strength * range + minForce);
|
|
||||||
if (power < 0)
|
|
||||||
{
|
|
||||||
power = 32767;
|
|
||||||
}
|
|
||||||
tempEffect.periodic.magnitude = power;
|
|
||||||
tempEffect.periodic.length = length;
|
|
||||||
tempEffect.periodic.attack_length = 1000;
|
|
||||||
tempEffect.periodic.fade_length = 1000;
|
|
||||||
|
|
||||||
SDL_HapticUpdateEffect(haptic, effects.effect_sawtoothdown_id, &tempEffect);
|
SDL_HapticUpdateEffect(haptic, effects.effect_sawtoothdown_id, &tempEffect);
|
||||||
SDL_HapticRunEffect(haptic, effects.effect_sawtoothdown_id, 1);
|
SDL_HapticRunEffect(haptic, effects.effect_sawtoothdown_id, 1);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerFrictionEffect(double strength)
|
void TriggerFrictionEffect(double strength)
|
||||||
{
|
{
|
||||||
if (FFBorRumble == 0)
|
TriggerFrictionEffectWithDefaultOption(strength, false);
|
||||||
{
|
|
||||||
TriggerFrictionEffectWithDefaultOption(strength, false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerSineEffect(UINT16 period, UINT16 fadePeriod, double strength)
|
void TriggerSineEffect(UINT16 period, UINT16 fadePeriod, double strength)
|
||||||
{
|
{
|
||||||
if (FFBorRumble == 0)
|
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();
|
||||||
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();
|
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
int direction = 1;
|
int direction = 1;
|
||||||
if (strength < -0.001) {
|
if (strength < -0.001) {
|
||||||
strength *= -1;
|
strength *= -1;
|
||||||
@ -1401,152 +1382,145 @@ void TriggerSineEffect(UINT16 period, UINT16 fadePeriod, double strength)
|
|||||||
if (elapsedTime < lastSineEffectPeriod && strength < (lastSineEffectStrength * 1.5)) {
|
if (elapsedTime < lastSineEffectPeriod && strength < (lastSineEffectStrength * 1.5)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
=======
|
||||||
|
int direction = 1;
|
||||||
|
if (strength <= -0.001) {
|
||||||
|
strength *= -1;
|
||||||
|
direction = -1;
|
||||||
|
}
|
||||||
|
|
||||||
SDL_HapticEffect tempEffect;
|
// we ignore the new effect until the last one is completed, unless the new one is significantly stronger
|
||||||
SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect));
|
if (elapsedTime < lastSineEffectPeriod && strength < (lastSineEffectStrength * 2.0)) {
|
||||||
hlp.log("Doing sine...");
|
return;
|
||||||
tempEffect.type = SDL_HAPTIC_SINE;
|
}
|
||||||
tempEffect.periodic.direction.type = SDL_HAPTIC_CARTESIAN;
|
|
||||||
tempEffect.periodic.direction.dir[0] = direction;
|
|
||||||
tempEffect.constant.direction.dir[1] = 0; //Y Position
|
|
||||||
tempEffect.periodic.period = period;
|
|
||||||
|
|
||||||
int confMinForce = configMinForce;
|
// if no strength, we do nothing
|
||||||
int confMaxForce = configMaxForce;
|
if (strength <= 0.001) {
|
||||||
if (AlternativeFFB == 1)
|
return;
|
||||||
|
}
|
||||||
|
>>>>>>> parent of 779758b... Now Choose FFB or Rumble
|
||||||
|
|
||||||
|
SDL_HapticEffect tempEffect;
|
||||||
|
SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect));
|
||||||
|
hlp.log("Doing sine...");
|
||||||
|
tempEffect.type = SDL_HAPTIC_SINE;
|
||||||
|
tempEffect.periodic.direction.type = SDL_HAPTIC_CARTESIAN;
|
||||||
|
tempEffect.periodic.direction.dir[0] = direction;
|
||||||
|
tempEffect.constant.direction.dir[1] = 0; //Y Position
|
||||||
|
tempEffect.periodic.period = period;
|
||||||
|
|
||||||
|
int confMinForce = configMinForce;
|
||||||
|
int confMaxForce = configMaxForce;
|
||||||
|
if (AlternativeFFB == 1)
|
||||||
|
{
|
||||||
|
if (direction == -1)
|
||||||
{
|
{
|
||||||
if (direction == -1)
|
confMinForce = configAlternativeMinForceLeft;
|
||||||
{
|
confMaxForce = configAlternativeMaxForceLeft;
|
||||||
confMinForce = configAlternativeMinForceLeft;
|
|
||||||
confMaxForce = configAlternativeMaxForceLeft;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
confMinForce = configAlternativeMinForceRight;
|
|
||||||
confMaxForce = configAlternativeMaxForceRight;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
SHORT minForce = (SHORT)(strength > 0.001 ? (confMinForce / 100.0 * 32767.0) : 0); // strength is a double so we do an epsilon check of 0.001 instead of > 0.
|
else
|
||||||
SHORT maxForce = (SHORT)(confMaxForce / 100.0 * 32767.0);
|
|
||||||
SHORT range = maxForce - minForce;
|
|
||||||
SHORT magnitude = (SHORT)(strength * range + minForce);
|
|
||||||
if (range > 0 && magnitude < 0)
|
|
||||||
{
|
{
|
||||||
magnitude = 32767;
|
confMinForce = configAlternativeMinForceRight;
|
||||||
}
|
confMaxForce = configAlternativeMaxForceRight;
|
||||||
else if (range < 0 && magnitude > 0)
|
|
||||||
{
|
|
||||||
magnitude = -32767;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
SHORT minForce = (SHORT)(strength > 0.001 ? (confMinForce / 100.0 * 32767.0) : 0); // strength is a double so we do an epsilon check of 0.001 instead of > 0.
|
||||||
|
SHORT maxForce = (SHORT)(confMaxForce / 100.0 * 32767.0);
|
||||||
|
SHORT range = maxForce - minForce;
|
||||||
|
SHORT magnitude = (SHORT)(strength * range + minForce);
|
||||||
|
if (range > 0 && magnitude < 0)
|
||||||
|
{
|
||||||
|
magnitude = 32767;
|
||||||
|
}
|
||||||
|
else if (range < 0 && magnitude > 0)
|
||||||
|
{
|
||||||
|
magnitude = -32767;
|
||||||
|
}
|
||||||
|
|
||||||
tempEffect.periodic.magnitude = (SHORT)(magnitude);
|
tempEffect.periodic.magnitude = (SHORT)(magnitude);
|
||||||
tempEffect.periodic.length = period;
|
tempEffect.periodic.length = period;
|
||||||
tempEffect.periodic.attack_length = fadePeriod;
|
tempEffect.periodic.attack_length = fadePeriod;
|
||||||
tempEffect.periodic.fade_length = fadePeriod;
|
tempEffect.periodic.fade_length = fadePeriod;
|
||||||
|
|
||||||
SDL_HapticUpdateEffect(haptic, effects.effect_sine_id, &tempEffect);
|
SDL_HapticUpdateEffect(haptic, effects.effect_sine_id, &tempEffect);
|
||||||
SDL_HapticRunEffect(haptic, effects.effect_sine_id, 1);
|
SDL_HapticRunEffect(haptic, effects.effect_sine_id, 1);
|
||||||
|
|
||||||
/*int supported = SDL_HapticEffectSupported(haptic, &tempEffect);
|
/*int supported = SDL_HapticEffectSupported(haptic, &tempEffect);
|
||||||
hlp.log((char *)std::to_string(supported).c_str());*/
|
hlp.log((char *)std::to_string(supported).c_str());*/
|
||||||
|
|
||||||
timeOfLastSineEffect = now;
|
timeOfLastSineEffect = now;
|
||||||
lastSineEffectStrength = strength;
|
lastSineEffectStrength = strength;
|
||||||
lastSineEffectPeriod = period;
|
lastSineEffectPeriod = period;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerSpringEffectWithDefaultOption(double strength, bool isDefault)
|
void TriggerSpringEffectWithDefaultOption(double strength, bool isDefault)
|
||||||
{
|
{
|
||||||
if (FFBorRumble == 0)
|
SDL_HapticEffect tempEffect;
|
||||||
|
SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect));
|
||||||
|
tempEffect.type = SDL_HAPTIC_SPRING;
|
||||||
|
tempEffect.condition.type = SDL_HAPTIC_SPRING;
|
||||||
|
tempEffect.condition.direction.type = SDL_HAPTIC_CARTESIAN;
|
||||||
|
tempEffect.condition.delay = 0;
|
||||||
|
tempEffect.condition.length = isDefault ? SDL_HAPTIC_INFINITY : configFeedbackLength;
|
||||||
|
tempEffect.condition.direction.dir[0] = 1;
|
||||||
|
tempEffect.constant.direction.dir[1] = 0; //Y Position
|
||||||
|
|
||||||
|
SHORT minForce = (SHORT)(strength > 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;
|
||||||
|
SHORT coeff = (SHORT)(strength * range + minForce);
|
||||||
|
if (coeff < 0)
|
||||||
{
|
{
|
||||||
SDL_HapticEffect tempEffect;
|
coeff = 32767;
|
||||||
SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect));
|
}
|
||||||
tempEffect.type = SDL_HAPTIC_SPRING;
|
|
||||||
tempEffect.condition.type = SDL_HAPTIC_SPRING;
|
|
||||||
tempEffect.condition.direction.type = SDL_HAPTIC_CARTESIAN;
|
|
||||||
tempEffect.condition.delay = 0;
|
|
||||||
tempEffect.condition.length = isDefault ? SDL_HAPTIC_INFINITY : configFeedbackLength;
|
|
||||||
tempEffect.condition.direction.dir[0] = 1;
|
|
||||||
tempEffect.constant.direction.dir[1] = 0; //Y Position
|
|
||||||
|
|
||||||
SHORT minForce = (SHORT)(strength > 0.001 ? (configMinForce / 100.0 * 32767.0) : 0); // strength is a double so we do an epsilon check of 0.001 instead of > 0.
|
tempEffect.condition.left_coeff[0] = (short)(coeff);
|
||||||
SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0);
|
tempEffect.condition.right_coeff[0] = (short)(coeff);
|
||||||
SHORT range = maxForce - minForce;
|
tempEffect.condition.left_sat[0] = (short)(coeff); //Needed for Logitech G920 wheel
|
||||||
SHORT coeff = (SHORT)(strength * range + minForce);
|
tempEffect.condition.right_sat[0] = (short)(coeff); //Needed for Logitech G920 wheel
|
||||||
if (coeff < 0)
|
tempEffect.condition.center[0] = 0;
|
||||||
{
|
|
||||||
coeff = 32767;
|
|
||||||
}
|
|
||||||
|
|
||||||
tempEffect.condition.left_coeff[0] = (short)(coeff);
|
SDL_HapticUpdateEffect(haptic, effects.effect_spring_id, &tempEffect);
|
||||||
tempEffect.condition.right_coeff[0] = (short)(coeff);
|
SDL_HapticRunEffect(haptic, effects.effect_spring_id, 1);
|
||||||
tempEffect.condition.left_sat[0] = (short)(coeff); //Needed for Logitech G920 wheel
|
|
||||||
tempEffect.condition.right_sat[0] = (short)(coeff); //Needed for Logitech G920 wheel
|
|
||||||
tempEffect.condition.center[0] = 0;
|
|
||||||
|
|
||||||
SDL_HapticUpdateEffect(haptic, effects.effect_spring_id, &tempEffect);
|
|
||||||
SDL_HapticRunEffect(haptic, effects.effect_spring_id, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerSpringEffectInfinite(double strength)
|
void TriggerSpringEffectInfinite(double strength)
|
||||||
{
|
{
|
||||||
if (FFBorRumble == 0)
|
SDL_HapticEffect tempEffect;
|
||||||
|
SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect));
|
||||||
|
|
||||||
|
tempEffect.type = SDL_HAPTIC_SPRING;
|
||||||
|
tempEffect.condition.type = SDL_HAPTIC_SPRING;
|
||||||
|
tempEffect.condition.direction.type = SDL_HAPTIC_CARTESIAN;
|
||||||
|
tempEffect.condition.delay = 0;
|
||||||
|
tempEffect.condition.length = SDL_HAPTIC_INFINITY;
|
||||||
|
tempEffect.condition.direction.dir[0] = 1;
|
||||||
|
tempEffect.constant.direction.dir[1] = 1; //Y Position
|
||||||
|
|
||||||
|
SHORT minForce = (SHORT)(strength > 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;
|
||||||
|
SHORT coeff = (SHORT)(strength * range + minForce);
|
||||||
|
if (coeff < 0)
|
||||||
{
|
{
|
||||||
SDL_HapticEffect tempEffect;
|
coeff = 32767;
|
||||||
SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect));
|
}
|
||||||
|
|
||||||
tempEffect.type = SDL_HAPTIC_SPRING;
|
tempEffect.condition.left_coeff[0] = (short)(coeff);
|
||||||
tempEffect.condition.type = SDL_HAPTIC_SPRING;
|
tempEffect.condition.right_coeff[0] = (short)(coeff);
|
||||||
tempEffect.condition.direction.type = SDL_HAPTIC_CARTESIAN;
|
tempEffect.condition.left_sat[0] = (short)(coeff) * 10; //Needed for Logitech G920 wheel
|
||||||
tempEffect.condition.delay = 0;
|
tempEffect.condition.right_sat[0] = (short)(coeff) * 10; //Needed for Logitech G920 wheel
|
||||||
tempEffect.condition.length = SDL_HAPTIC_INFINITY;
|
tempEffect.condition.center[0] = 0;
|
||||||
tempEffect.condition.direction.dir[0] = 1;
|
|
||||||
tempEffect.constant.direction.dir[1] = 1; //Y Position
|
|
||||||
|
|
||||||
SHORT minForce = (SHORT)(strength > 0.001 ? (configMinForce / 100.0 * 32767.0) : 0); // strength is a double so we do an epsilon check of 0.001 instead of > 0.
|
SDL_HapticUpdateEffect(haptic, effects.effect_spring_id, &tempEffect);
|
||||||
SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0);
|
SDL_HapticRunEffect(haptic, effects.effect_spring_id, 1);
|
||||||
SHORT range = maxForce - minForce;
|
|
||||||
SHORT coeff = (SHORT)(strength * range + minForce);
|
|
||||||
if (coeff < 0)
|
|
||||||
{
|
|
||||||
coeff = 32767;
|
|
||||||
}
|
|
||||||
|
|
||||||
tempEffect.condition.left_coeff[0] = (short)(coeff);
|
|
||||||
tempEffect.condition.right_coeff[0] = (short)(coeff);
|
|
||||||
tempEffect.condition.left_sat[0] = (short)(coeff) * 10; //Needed for Logitech G920 wheel
|
|
||||||
tempEffect.condition.right_sat[0] = (short)(coeff) * 10; //Needed for Logitech G920 wheel
|
|
||||||
tempEffect.condition.center[0] = 0;
|
|
||||||
|
|
||||||
SDL_HapticUpdateEffect(haptic, effects.effect_spring_id, &tempEffect);
|
|
||||||
SDL_HapticRunEffect(haptic, effects.effect_spring_id, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerLeftRightEffect(double smallstrength, double largestrength, double length)
|
void TriggerLeftRightEffect(double smallstrength, double largestrength, double length)
|
||||||
{
|
{
|
||||||
if (FFBorRumble == 1)
|
if (EnableRumble == 1)
|
||||||
{
|
{
|
||||||
if (ReverseRumble == 1)
|
if (ReverseRumble == 0)
|
||||||
{
|
|
||||||
SDL_HapticEffect tempEffect;
|
|
||||||
tempEffect.type = SDL_HAPTIC_LEFTRIGHT;
|
|
||||||
tempEffect.leftright.length = length;
|
|
||||||
SHORT minForce = (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 maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0);
|
|
||||||
SHORT range = maxForce - minForce;
|
|
||||||
tempEffect.leftright.small_magnitude = (SHORT)(largestrength * range + minForce);
|
|
||||||
SHORT minForce1 = (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 maxForce1 = (SHORT)(configMaxForce / 100.0 * 32767.0);
|
|
||||||
SHORT range1 = maxForce1 - minForce1;
|
|
||||||
tempEffect.leftright.large_magnitude = (SHORT)(smallstrength * range1 + minForce1);
|
|
||||||
SDL_HapticUpdateEffect(haptic, effects.effect_leftright_id, &tempEffect);
|
|
||||||
SDL_HapticRunEffect(haptic, effects.effect_leftright_id, 1);
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
SDL_HapticEffect tempEffect;
|
SDL_HapticEffect tempEffect;
|
||||||
tempEffect.type = SDL_HAPTIC_LEFTRIGHT;
|
tempEffect.type = SDL_HAPTIC_LEFTRIGHT;
|
||||||
@ -1562,31 +1536,30 @@ void TriggerLeftRightEffect(double smallstrength, double largestrength, double l
|
|||||||
SDL_HapticUpdateEffect(haptic, effects.effect_leftright_id, &tempEffect);
|
SDL_HapticUpdateEffect(haptic, effects.effect_leftright_id, &tempEffect);
|
||||||
SDL_HapticRunEffect(haptic, effects.effect_leftright_id, 1);
|
SDL_HapticRunEffect(haptic, effects.effect_leftright_id, 1);
|
||||||
}
|
}
|
||||||
|
else if (ReverseRumble == 1)
|
||||||
|
{
|
||||||
|
SDL_HapticEffect tempEffect;
|
||||||
|
tempEffect.type = SDL_HAPTIC_LEFTRIGHT;
|
||||||
|
tempEffect.leftright.length = length;
|
||||||
|
SHORT minForce = (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 maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0);
|
||||||
|
SHORT range = maxForce - minForce;
|
||||||
|
tempEffect.leftright.small_magnitude = (SHORT)(largestrength * range + minForce);
|
||||||
|
SHORT minForce1 = (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 maxForce1 = (SHORT)(configMaxForce / 100.0 * 32767.0);
|
||||||
|
SHORT range1 = maxForce1 - minForce1;
|
||||||
|
tempEffect.leftright.large_magnitude = (SHORT)(smallstrength * range1 + minForce1);
|
||||||
|
SDL_HapticUpdateEffect(haptic, effects.effect_leftright_id, &tempEffect);
|
||||||
|
SDL_HapticRunEffect(haptic, effects.effect_leftright_id, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerLeftRightDevice2Effect(double smallstrength, double largestrength, double length)
|
void TriggerLeftRightDevice2Effect(double smallstrength, double largestrength, double length)
|
||||||
{
|
{
|
||||||
if (FFBorRumble == 1)
|
if (EnableRumble == 1)
|
||||||
{
|
{
|
||||||
if (ReverseRumble == 1)
|
if (ReverseRumble == 0)
|
||||||
{
|
|
||||||
SDL_HapticEffect tempEffect;
|
|
||||||
tempEffect.type = SDL_HAPTIC_LEFTRIGHT;
|
|
||||||
tempEffect.leftright.length = length;
|
|
||||||
SHORT minForce = (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 maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0);
|
|
||||||
SHORT range = maxForce - minForce;
|
|
||||||
tempEffect.leftright.small_magnitude = (SHORT)(largestrength * range + minForce);
|
|
||||||
SHORT minForce1 = (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 maxForce1 = (SHORT)(configMaxForce / 100.0 * 32767.0);
|
|
||||||
SHORT range1 = maxForce1 - minForce1;
|
|
||||||
tempEffect.leftright.large_magnitude = (SHORT)(smallstrength * range1 + minForce1);
|
|
||||||
SDL_HapticUpdateEffect(haptic2, effects.effect_leftright_id, &tempEffect);
|
|
||||||
SDL_HapticRunEffect(haptic2, effects.effect_leftright_id, 1);
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
SDL_HapticEffect tempEffect;
|
SDL_HapticEffect tempEffect;
|
||||||
tempEffect.type = SDL_HAPTIC_LEFTRIGHT;
|
tempEffect.type = SDL_HAPTIC_LEFTRIGHT;
|
||||||
@ -1602,12 +1575,28 @@ void TriggerLeftRightDevice2Effect(double smallstrength, double largestrength, d
|
|||||||
SDL_HapticUpdateEffect(haptic2, effects.effect_leftright_id, &tempEffect);
|
SDL_HapticUpdateEffect(haptic2, effects.effect_leftright_id, &tempEffect);
|
||||||
SDL_HapticRunEffect(haptic2, effects.effect_leftright_id, 1);
|
SDL_HapticRunEffect(haptic2, effects.effect_leftright_id, 1);
|
||||||
}
|
}
|
||||||
|
else if (ReverseRumble == 1)
|
||||||
|
{
|
||||||
|
SDL_HapticEffect tempEffect;
|
||||||
|
tempEffect.type = SDL_HAPTIC_LEFTRIGHT;
|
||||||
|
tempEffect.leftright.length = length;
|
||||||
|
SHORT minForce = (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 maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0);
|
||||||
|
SHORT range = maxForce - minForce;
|
||||||
|
tempEffect.leftright.small_magnitude = (SHORT)(largestrength * range + minForce);
|
||||||
|
SHORT minForce1 = (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 maxForce1 = (SHORT)(configMaxForce / 100.0 * 32767.0);
|
||||||
|
SHORT range1 = maxForce1 - minForce1;
|
||||||
|
tempEffect.leftright.large_magnitude = (SHORT)(smallstrength * range1 + minForce1);
|
||||||
|
SDL_HapticUpdateEffect(haptic2, effects.effect_leftright_id, &tempEffect);
|
||||||
|
SDL_HapticRunEffect(haptic2, effects.effect_leftright_id, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerRumbleEffect(double strength, double length)
|
void TriggerRumbleEffect(double strength, double length)
|
||||||
{
|
{
|
||||||
if (FFBorRumble == 1)
|
if (EnableRumble == 1)
|
||||||
{
|
{
|
||||||
SDL_HapticRumblePlay(haptic, strength, length);
|
SDL_HapticRumblePlay(haptic, strength, length);
|
||||||
}
|
}
|
||||||
@ -1615,10 +1604,7 @@ void TriggerRumbleEffect(double strength, double length)
|
|||||||
|
|
||||||
void TriggerSpringEffect(double strength)
|
void TriggerSpringEffect(double strength)
|
||||||
{
|
{
|
||||||
if (FFBorRumble == 0)
|
TriggerSpringEffectWithDefaultOption(strength, false);
|
||||||
{
|
|
||||||
TriggerSpringEffectWithDefaultOption(strength, false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD WINAPI FFBLoop(LPVOID lpParam)
|
DWORD WINAPI FFBLoop(LPVOID lpParam)
|
||||||
@ -1630,7 +1616,7 @@ DWORD WINAPI FFBLoop(LPVOID lpParam)
|
|||||||
Sleep(2500);
|
Sleep(2500);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FFBorRumble == 1)
|
if (EnableRumble == 1)
|
||||||
{
|
{
|
||||||
//SPECIAL K DISABLES RUMBLE BY DEFAULT. WRITE IT TO FALSE
|
//SPECIAL K DISABLES RUMBLE BY DEFAULT. WRITE IT TO FALSE
|
||||||
char RumbleDisableChar[256];
|
char RumbleDisableChar[256];
|
||||||
|
@ -413,7 +413,7 @@ MaxForce= **Maximum FFB force with 100 being highest value available**
|
|||||||
|
|
||||||
DeviceGUID= **Set Device GUID to connect to specific wheel or controller**
|
DeviceGUID= **Set Device GUID to connect to specific wheel or controller**
|
||||||
|
|
||||||
FFBorRumble= **Turn to 0 if using wheel & want Force Feedback effects. For controllers change to 1 to enable rumble**
|
EnableRumble= **Turn Off (0) if your wheel supports rumble effect. For controllers, turn on (1)**
|
||||||
|
|
||||||
Logging= **Turn On (1) to allow log.txt to be made to log plugin. Device GUID is given in here**
|
Logging= **Turn On (1) to allow log.txt to be made to log plugin. Device GUID is given in here**
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user