commit
ba8cb00192
@ -22,8 +22,8 @@ MaxForce=100
|
|||||||
DeviceGUID=
|
DeviceGUID=
|
||||||
;Set to 1 if you want to enable rumble, else 0.
|
;Set to 1 if you want to enable rumble, else 0.
|
||||||
EnableRumble=1
|
EnableRumble=1
|
||||||
; Set to 1 to generate log.txt, else 0. Logs will be appended and not cleared.
|
|
||||||
ReverseRumble=0
|
ReverseRumble=0
|
||||||
|
; Set to 1 to generate log.txt, else 0. Logs will be appended and not cleared.
|
||||||
Logging=0
|
Logging=0
|
||||||
; When a command is set that contradicts a prior command, clear the prior command. Probably should stay as 1.
|
; When a command is set that contradicts a prior command, clear the prior command. Probably should stay as 1.
|
||||||
ResetFeedback=1
|
ResetFeedback=1
|
||||||
@ -247,14 +247,21 @@ Gear6=99
|
|||||||
[WMMT5]
|
[WMMT5]
|
||||||
GameId=9
|
GameId=9
|
||||||
MinForce=0
|
MinForce=0
|
||||||
MaxForce=35
|
MaxForce=100
|
||||||
DefaultCentering=0
|
DefaultCentering=0
|
||||||
FeedbackLength=80
|
FeedbackLength=80
|
||||||
Logging=0
|
Logging=0
|
||||||
AlternativeMinForceLeft=0
|
AlternativeMinForceLeft=0
|
||||||
AlternativeMaxForceLeft=-35
|
AlternativeMaxForceLeft=-100
|
||||||
AlternativeMinForceRight=0
|
AlternativeMinForceRight=0
|
||||||
AlternativeMaxForceRight=35
|
AlternativeMaxForceRight=100
|
||||||
|
SpringStrength=100
|
||||||
|
FrictionStrength=0
|
||||||
|
JointsAndStripesStrength=100
|
||||||
|
CollisionsStrength=100
|
||||||
|
TiresSlipStrength=100
|
||||||
|
HighhSpeedVibrationsStrength=100
|
||||||
|
LimitBetweenHighSpeedVibrationsAndTiresSlip=75
|
||||||
|
|
||||||
[Mame 0199 32bit]
|
[Mame 0199 32bit]
|
||||||
GameId=4
|
GameId=4
|
||||||
|
150
DllMain.cpp
150
DllMain.cpp
@ -1090,7 +1090,8 @@ std::chrono::milliseconds timeOfLastSineEffect = duration_cast<milliseconds>(sys
|
|||||||
std::chrono::milliseconds timeOfLastSpringEffect = duration_cast<milliseconds>(system_clock::now().time_since_epoch());
|
std::chrono::milliseconds timeOfLastSpringEffect = duration_cast<milliseconds>(system_clock::now().time_since_epoch());
|
||||||
std::string lastConstantEffectHash = "";
|
std::string lastConstantEffectHash = "";
|
||||||
std::string lastFrictionEffectHash = "";
|
std::string lastFrictionEffectHash = "";
|
||||||
std::string lastSineEffectHash = "";
|
double lastSineEffectStrength = 0;
|
||||||
|
double lastSineEffectPeriod = 0;
|
||||||
std::string lastSpringEffectHash = "";
|
std::string lastSpringEffectHash = "";
|
||||||
void TriggerConstantEffect(int direction, double strength)
|
void TriggerConstantEffect(int direction, double strength)
|
||||||
{
|
{
|
||||||
@ -1128,7 +1129,11 @@ void TriggerConstantEffect(int direction, double strength)
|
|||||||
SHORT minForce = (SHORT)(strength > 0.001 ? (configAlternativeMinForceLeft / 100.0 * 32767.0) : 0); // strength is a double so we do an epsilon check of 0.001 instead of > 0.
|
SHORT minForce = (SHORT)(strength > 0.001 ? (configAlternativeMinForceLeft / 100.0 * 32767.0) : 0); // strength is a double so we do an epsilon check of 0.001 instead of > 0.
|
||||||
SHORT maxForce = (SHORT)(configAlternativeMaxForceLeft / 100.0 * 32767.0);
|
SHORT maxForce = (SHORT)(configAlternativeMaxForceLeft / 100.0 * 32767.0);
|
||||||
SHORT range = maxForce - minForce;
|
SHORT range = maxForce - minForce;
|
||||||
SHORT level = (SHORT)(strength * range - minForce);
|
SHORT level = (SHORT)(strength * range + minForce);
|
||||||
|
if (level > 0)
|
||||||
|
{
|
||||||
|
level = -32767;
|
||||||
|
}
|
||||||
tempEffect.constant.level = level;
|
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_left_id, &tempEffect);
|
SDL_HapticUpdateEffect(haptic, effects.effect_left_id, &tempEffect);
|
||||||
@ -1143,6 +1148,10 @@ void TriggerConstantEffect(int direction, double strength)
|
|||||||
SHORT maxForce = (SHORT)(configAlternativeMaxForceRight / 100.0 * 32767.0);
|
SHORT maxForce = (SHORT)(configAlternativeMaxForceRight / 100.0 * 32767.0);
|
||||||
SHORT range = maxForce - minForce;
|
SHORT range = maxForce - minForce;
|
||||||
SHORT level = (SHORT)(strength * range + minForce);
|
SHORT level = (SHORT)(strength * range + minForce);
|
||||||
|
if (level < 0)
|
||||||
|
{
|
||||||
|
level = 32767;
|
||||||
|
}
|
||||||
tempEffect.constant.level = level;
|
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_right_id, &tempEffect);
|
SDL_HapticUpdateEffect(haptic, effects.effect_right_id, &tempEffect);
|
||||||
@ -1187,6 +1196,10 @@ void TriggerConstantEffect(int direction, double strength)
|
|||||||
SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0);
|
SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0);
|
||||||
SHORT range = maxForce - minForce;
|
SHORT range = maxForce - minForce;
|
||||||
SHORT level = (SHORT)(strength * range + minForce);
|
SHORT level = (SHORT)(strength * range + minForce);
|
||||||
|
if (level < 0)
|
||||||
|
{
|
||||||
|
level = 32767;
|
||||||
|
}
|
||||||
tempEffect.constant.level = level;
|
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_id, &tempEffect);
|
SDL_HapticUpdateEffect(haptic, effects.effect_id, &tempEffect);
|
||||||
@ -1224,6 +1237,7 @@ void TriggerFrictionEffectWithDefaultOption(double strength, bool isDefault) {
|
|||||||
SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect));
|
SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect));
|
||||||
tempEffect.type = SDL_HAPTIC_FRICTION;
|
tempEffect.type = SDL_HAPTIC_FRICTION;
|
||||||
tempEffect.condition.type = SDL_HAPTIC_FRICTION;
|
tempEffect.condition.type = SDL_HAPTIC_FRICTION;
|
||||||
|
tempEffect.condition.direction.type = SDL_HAPTIC_CARTESIAN;
|
||||||
tempEffect.condition.delay = 0;
|
tempEffect.condition.delay = 0;
|
||||||
tempEffect.condition.length = isDefault ? 0xFFFFFFFF : configFeedbackLength;
|
tempEffect.condition.length = isDefault ? 0xFFFFFFFF : configFeedbackLength;
|
||||||
tempEffect.condition.left_sat[0] = 0xFFFF;
|
tempEffect.condition.left_sat[0] = 0xFFFF;
|
||||||
@ -1233,6 +1247,10 @@ void TriggerFrictionEffectWithDefaultOption(double strength, bool isDefault) {
|
|||||||
SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0);
|
SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0);
|
||||||
SHORT range = maxForce - minForce;
|
SHORT range = maxForce - minForce;
|
||||||
SHORT coeff = (SHORT)(strength * range + 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);
|
||||||
@ -1259,6 +1277,10 @@ void TriggerInertiaEffect(double strength)
|
|||||||
SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0);
|
SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0);
|
||||||
SHORT range = maxForce - minForce;
|
SHORT range = maxForce - minForce;
|
||||||
SHORT coeff = (SHORT)(strength * range + 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);
|
||||||
@ -1272,16 +1294,48 @@ void TriggerInertiaEffect(double strength)
|
|||||||
|
|
||||||
void TriggerTriangleEffect(double strength, double length)
|
void TriggerTriangleEffect(double strength, double length)
|
||||||
{
|
{
|
||||||
|
int direction = 1;
|
||||||
|
if (strength <= -0.001) {
|
||||||
|
strength *= -1;
|
||||||
|
direction = -1;
|
||||||
|
}
|
||||||
|
|
||||||
SDL_HapticEffect tempEffect;
|
SDL_HapticEffect tempEffect;
|
||||||
SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect));
|
SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect));
|
||||||
tempEffect.type = SDL_HAPTIC_TRIANGLE;
|
tempEffect.type = SDL_HAPTIC_TRIANGLE;
|
||||||
tempEffect.condition.type = SDL_HAPTIC_TRIANGLE;
|
tempEffect.condition.type = SDL_HAPTIC_TRIANGLE;
|
||||||
tempEffect.condition.direction.type = SDL_HAPTIC_CARTESIAN;
|
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;
|
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);
|
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 range = maxForce - minForce;
|
||||||
SHORT power = (SHORT)(strength * range + 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.magnitude = power;
|
||||||
tempEffect.periodic.length = length;
|
tempEffect.periodic.length = length;
|
||||||
tempEffect.periodic.attack_length = 1000;
|
tempEffect.periodic.attack_length = 1000;
|
||||||
@ -1306,6 +1360,11 @@ void TriggerDamperEffect(double strength)
|
|||||||
SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0);
|
SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0);
|
||||||
SHORT range = maxForce - minForce;
|
SHORT range = maxForce - minForce;
|
||||||
SHORT coeff = (SHORT)(strength * range + 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;
|
||||||
@ -1327,10 +1386,18 @@ void TriggerRampEffect(double start,double end,double length)
|
|||||||
SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0);
|
SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0);
|
||||||
SHORT range = maxForce - minForce;
|
SHORT range = maxForce - minForce;
|
||||||
SHORT start1 = (SHORT)(start * range + minForce);
|
SHORT start1 = (SHORT)(start * range + minForce);
|
||||||
|
if (start1 < 0)
|
||||||
|
{
|
||||||
|
start1 = 32767;
|
||||||
|
}
|
||||||
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.
|
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.
|
||||||
SHORT maxForce2 = (SHORT)(configMaxForce / 100.0 * 32767.0);
|
SHORT maxForce2 = (SHORT)(configMaxForce / 100.0 * 32767.0);
|
||||||
SHORT range2 = maxForce - minForce;
|
SHORT range2 = maxForce - minForce;
|
||||||
SHORT start2 = (SHORT)(end * range + minForce);
|
SHORT start2 = (SHORT)(end * range + minForce);
|
||||||
|
if (start2 < 0)
|
||||||
|
{
|
||||||
|
start2 = 32767;
|
||||||
|
}
|
||||||
tempEffect.ramp.delay = 0;
|
tempEffect.ramp.delay = 0;
|
||||||
tempEffect.ramp.start = start1;
|
tempEffect.ramp.start = start1;
|
||||||
tempEffect.ramp.end = -start2;
|
tempEffect.ramp.end = -start2;
|
||||||
@ -1351,6 +1418,10 @@ void TriggerSawtoothUpEffect(double strength, double length)
|
|||||||
SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0);
|
SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0);
|
||||||
SHORT range = maxForce - minForce;
|
SHORT range = maxForce - minForce;
|
||||||
SHORT power = (SHORT)(strength * range + minForce);
|
SHORT power = (SHORT)(strength * range + minForce);
|
||||||
|
if (power < 0)
|
||||||
|
{
|
||||||
|
power = 32767;
|
||||||
|
}
|
||||||
tempEffect.periodic.magnitude = power;
|
tempEffect.periodic.magnitude = power;
|
||||||
tempEffect.periodic.length = length;
|
tempEffect.periodic.length = length;
|
||||||
tempEffect.periodic.attack_length = 1000;
|
tempEffect.periodic.attack_length = 1000;
|
||||||
@ -1371,6 +1442,10 @@ void TriggerSawtoothDownEffect(double strength, double length) {
|
|||||||
SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0);
|
SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0);
|
||||||
SHORT range = maxForce - minForce;
|
SHORT range = maxForce - minForce;
|
||||||
SHORT power = (SHORT)(strength * range + minForce);
|
SHORT power = (SHORT)(strength * range + minForce);
|
||||||
|
if (power < 0)
|
||||||
|
{
|
||||||
|
power = 32767;
|
||||||
|
}
|
||||||
tempEffect.periodic.magnitude = power;
|
tempEffect.periodic.magnitude = power;
|
||||||
tempEffect.periodic.length = length;
|
tempEffect.periodic.length = length;
|
||||||
tempEffect.periodic.attack_length = 1000;
|
tempEffect.periodic.attack_length = 1000;
|
||||||
@ -1389,21 +1464,26 @@ void TriggerSineEffect(UINT16 period, UINT16 fadePeriod, double strength)
|
|||||||
{
|
{
|
||||||
std::chrono::milliseconds now = duration_cast<milliseconds>(system_clock::now().time_since_epoch());
|
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();
|
long long elapsedTime = (std::chrono::duration_cast<std::chrono::milliseconds>(now - timeOfLastSineEffect)).count();
|
||||||
std::string effectHash = std::to_string(effects.effect_sine_id) + "_" + std::to_string(period) + "_" + std::to_string(fadePeriod) + "_" + std::to_string(strength);
|
|
||||||
|
|
||||||
// if the effect is the same as the last effect that was sent AND enough time hasn't elapsed, do nothing
|
int direction = 1;
|
||||||
if (effectHash.compare(lastSineEffectHash) == 0 && elapsedTime < configFeedbackLength) {
|
if (strength <= -0.001) {
|
||||||
return; // same effect, do nothing.
|
strength *= -1;
|
||||||
|
direction = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: investigate if we need this
|
// we ignore the new effect until the last one is completed, unless the new one is significantly stronger
|
||||||
if (configResetFeedback || strength <= 0.001) {
|
if (elapsedTime < lastSineEffectPeriod && strength < (lastSineEffectStrength * 2.0)) {
|
||||||
SDL_HapticStopEffect(haptic, effects.effect_sine_id);
|
|
||||||
if (strength <= 0.01) {
|
|
||||||
timeOfLastSineEffect = now;
|
|
||||||
lastSineEffectHash = effectHash;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if no strength, we do nothing
|
||||||
|
if (strength <= 0.001) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// stop previous effect if not completed
|
||||||
|
if (configResetFeedback) {
|
||||||
|
SDL_HapticStopEffect(haptic, effects.effect_sine_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_HapticEffect tempEffect;
|
SDL_HapticEffect tempEffect;
|
||||||
@ -1411,17 +1491,40 @@ void TriggerSineEffect(UINT16 period, UINT16 fadePeriod, double strength)
|
|||||||
hlp.log("Doing sine...");
|
hlp.log("Doing sine...");
|
||||||
tempEffect.type = SDL_HAPTIC_SINE;
|
tempEffect.type = SDL_HAPTIC_SINE;
|
||||||
tempEffect.periodic.direction.type = SDL_HAPTIC_CARTESIAN;
|
tempEffect.periodic.direction.type = SDL_HAPTIC_CARTESIAN;
|
||||||
tempEffect.periodic.direction.dir[0] = 1;
|
tempEffect.periodic.direction.dir[0] = direction;
|
||||||
tempEffect.constant.direction.dir[1] = 0; //Y Position
|
tempEffect.constant.direction.dir[1] = 0; //Y Position
|
||||||
tempEffect.periodic.period = period;
|
tempEffect.periodic.period = period;
|
||||||
|
|
||||||
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.
|
int confMinForce = configMinForce;
|
||||||
SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0);
|
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 range = maxForce - minForce;
|
||||||
SHORT magnitude = (SHORT)(strength * range + 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 = configFeedbackLength;
|
tempEffect.periodic.length = period;
|
||||||
tempEffect.periodic.attack_length = fadePeriod;
|
tempEffect.periodic.attack_length = fadePeriod;
|
||||||
tempEffect.periodic.fade_length = fadePeriod;
|
tempEffect.periodic.fade_length = fadePeriod;
|
||||||
|
|
||||||
@ -1432,7 +1535,8 @@ void TriggerSineEffect(UINT16 period, UINT16 fadePeriod, double strength)
|
|||||||
hlp.log((char *)std::to_string(supported).c_str());*/
|
hlp.log((char *)std::to_string(supported).c_str());*/
|
||||||
|
|
||||||
timeOfLastSineEffect = now;
|
timeOfLastSineEffect = now;
|
||||||
lastSineEffectHash = effectHash;
|
lastSineEffectStrength = strength;
|
||||||
|
lastSineEffectPeriod = period;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerSpringEffectWithDefaultOption(double strength, bool isDefault) {
|
void TriggerSpringEffectWithDefaultOption(double strength, bool isDefault) {
|
||||||
@ -1471,6 +1575,10 @@ void TriggerSpringEffectWithDefaultOption(double strength, bool isDefault) {
|
|||||||
SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0);
|
SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0);
|
||||||
SHORT range = maxForce - minForce;
|
SHORT range = maxForce - minForce;
|
||||||
SHORT coeff = (SHORT)(strength * range + 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);
|
||||||
@ -1505,6 +1613,10 @@ void TriggerSpringEffectInfinite(double strength)
|
|||||||
SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0);
|
SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0);
|
||||||
SHORT range = maxForce - minForce;
|
SHORT range = maxForce - minForce;
|
||||||
SHORT coeff = (SHORT)(strength * range + 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);
|
||||||
|
@ -14,57 +14,113 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include "WMMT5.h"
|
#include "WMMT5.h"
|
||||||
|
|
||||||
|
bool gameFfbStarted = false;
|
||||||
|
wchar_t* settingsWMMT5 = TEXT(".\\FFBPlugin.ini");
|
||||||
|
int SpringStrengthWMMT5 = GetPrivateProfileInt(TEXT("Settings"), TEXT("SpringStrength"), 0, settingsWMMT5);
|
||||||
|
int FrictionStrengthWMMT5 = GetPrivateProfileInt(TEXT("Settings"), TEXT("FrictionStrength"), 0, settingsWMMT5);
|
||||||
|
int JointsAndStripesStrengthWMMT5 = GetPrivateProfileInt(TEXT("Settings"), TEXT("JointsAndStripesStrength"), 0, settingsWMMT5);
|
||||||
|
int CollisionsStrengthWMMT5 = GetPrivateProfileInt(TEXT("Settings"), TEXT("CollisionsStrength"), 0, settingsWMMT5);
|
||||||
|
int TiresSlipStrengthWMMT5 = GetPrivateProfileInt(TEXT("Settings"), TEXT("TiresSlipStrength"), 0, settingsWMMT5);
|
||||||
|
int HighhSpeedVibrationsStrengthWMMT5 = GetPrivateProfileInt(TEXT("Settings"), TEXT("HighhSpeedVibrationsStrength"), 0, settingsWMMT5);
|
||||||
|
int LimitBetweenHighSpeedVibrationsAndTiresSlipWMMT5 = GetPrivateProfileInt(TEXT("Settings"), TEXT("LimitBetweenHighSpeedVibrationsAndTiresSlip"), 0, settingsWMMT5);
|
||||||
|
|
||||||
void WMMT5::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) {
|
void WMMT5::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) {
|
||||||
|
|
||||||
float roll = helpers->ReadFloat32(0x196F194, /* isRelativeOffset*/ true);
|
float spring = helpers->ReadFloat32(0x196F18C, /* isRelativeOffset*/ true);
|
||||||
float friction = helpers->ReadFloat32(0x196F18C, /* isRelativeOffset*/ true);
|
float friction = helpers->ReadFloat32(0x196F190, /* isRelativeOffset*/ true);
|
||||||
float sine = helpers->ReadFloat32(0x196F188, /* isRelativeOffset*/ true);
|
float collisions = helpers->ReadFloat32(0x196F194, /* isRelativeOffset*/ true);
|
||||||
|
float tiresSlip = helpers->ReadFloat32(0x196F188, /* isRelativeOffset*/ true);
|
||||||
helpers->log("got value: ");
|
helpers->log("got value: ");
|
||||||
std::string ffs = std::to_string(roll);
|
std::string ffs = "spring: " + std::to_string(spring);
|
||||||
helpers->log((char *)ffs.c_str());
|
helpers->log((char*)ffs.c_str());
|
||||||
|
ffs = "friction: " + std::to_string(friction);
|
||||||
|
helpers->log((char*)ffs.c_str());
|
||||||
|
ffs = "collisions: " + std::to_string(collisions);
|
||||||
|
helpers->log((char*)ffs.c_str());
|
||||||
|
ffs = "tires slip: " + std::to_string(tiresSlip);
|
||||||
|
helpers->log((char*)ffs.c_str());
|
||||||
|
|
||||||
|
double percentForce;
|
||||||
|
if (0 < spring)
|
||||||
{
|
{
|
||||||
//Trigger Spring the entire time like real cabinet
|
if (!gameFfbStarted)
|
||||||
double percentForce = 0.7;
|
{
|
||||||
triggers->Springi(percentForce);
|
helpers->log("game's FFB started");
|
||||||
|
gameFfbStarted = true;
|
||||||
}
|
}
|
||||||
|
percentForce = (1.0 * spring) * SpringStrengthWMMT5 / 100.0;
|
||||||
if (0 < roll)
|
triggers->Spring(percentForce);
|
||||||
{
|
|
||||||
helpers->log("moving wheel right");
|
|
||||||
double percentForce = (1.0 - roll);
|
|
||||||
double percentLength = (250);
|
|
||||||
// direction from right => makes wheel turn left
|
|
||||||
triggers->LeftRight(percentForce, 0, percentLength);
|
|
||||||
triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (0 > roll)
|
else if (!gameFfbStarted)
|
||||||
{
|
{
|
||||||
helpers->log("moving wheel left");
|
helpers->log("fake spring/friction until game's FFB starts");
|
||||||
double percentForce = (roll + 1.0);
|
percentForce = 0.4 * SpringStrengthWMMT5 / 100.0;
|
||||||
double percentLength = (250);
|
triggers->Spring(percentForce);
|
||||||
// direction from left => makes wheel turn right
|
percentForce = 0.5 * FrictionStrengthWMMT5 / 100.0;
|
||||||
triggers->LeftRight(0, percentForce, percentLength);
|
|
||||||
triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce);
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (0 < friction)
|
|
||||||
{
|
|
||||||
helpers->log("moving wheel right");
|
|
||||||
double percentForce = (0.7 - friction);
|
|
||||||
triggers->Friction(percentForce);
|
triggers->Friction(percentForce);
|
||||||
}
|
}
|
||||||
else if (0 < sine)
|
if (0 < friction)
|
||||||
{
|
{
|
||||||
helpers->log("moving wheel right");
|
percentForce = (1.0 * friction) * FrictionStrengthWMMT5 / 100.0;
|
||||||
double percentForce = (0.6 - sine);
|
triggers->Friction(percentForce);
|
||||||
triggers->Sine(120, 120, percentForce);
|
|
||||||
}
|
}
|
||||||
else if (0 > sine)
|
if (0 < collisions)
|
||||||
{
|
{
|
||||||
helpers->log("moving wheel left");
|
if (0.209 <= collisions && 0.311 >= collisions)
|
||||||
double percentForce = (sine + 0.6);
|
{
|
||||||
triggers->Sine(120, 120, percentForce);
|
helpers->log("joint/stripe on the right");
|
||||||
|
percentForce = (1.0 * collisions) * JointsAndStripesStrengthWMMT5 / 100.0;
|
||||||
|
triggers->Sine(80, 80, percentForce);
|
||||||
|
triggers->LeftRight(0, percentForce, 150);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
helpers->log("collision on the right");
|
||||||
|
percentForce = (1.0 * collisions) * CollisionsStrengthWMMT5 / 100.0;
|
||||||
|
triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce);
|
||||||
|
triggers->LeftRight(0, percentForce, 150);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (0 > collisions)
|
||||||
|
{
|
||||||
|
if (-0.209 >= collisions && -0.311 <= collisions)
|
||||||
|
{
|
||||||
|
helpers->log("joint/stripe on the left");
|
||||||
|
percentForce = (1.0 * collisions) * JointsAndStripesStrengthWMMT5 / 100.0;
|
||||||
|
triggers->Sine(80, 80, percentForce);
|
||||||
|
triggers->LeftRight(0, -1.0 * percentForce, 150);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
helpers->log("collision on the left");
|
||||||
|
percentForce = (-1.0 * collisions) * CollisionsStrengthWMMT5 / 100.0;
|
||||||
|
triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce);
|
||||||
|
triggers->LeftRight(0, percentForce, 150);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (0 < tiresSlip)
|
||||||
|
{
|
||||||
|
helpers->log("tires slip left");
|
||||||
|
bool highSpeedVibrations = (1.0 * tiresSlip) < (LimitBetweenHighSpeedVibrationsAndTiresSlipWMMT5 / 1000.0);
|
||||||
|
percentForce = (-1.0 * tiresSlip) * (highSpeedVibrations ? HighhSpeedVibrationsStrengthWMMT5 : TiresSlipStrengthWMMT5) / 100.0;
|
||||||
|
triggers->Sine(100, 100, percentForce);
|
||||||
|
|
||||||
|
if (!highSpeedVibrations && ((0 == JointsAndStripesStrengthWMMT5 && 0 == CollisionsStrengthWMMT5) || (0.001 > collisions && -0.001 < collisions)))
|
||||||
|
{
|
||||||
|
triggers->LeftRight(0, -1.0 * percentForce, 150);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (0 > tiresSlip)
|
||||||
|
{
|
||||||
|
helpers->log("tires slip right");
|
||||||
|
bool highSpeedVibrations = (-1.0 * tiresSlip) < (LimitBetweenHighSpeedVibrationsAndTiresSlipWMMT5 / 1000.0);
|
||||||
|
percentForce = (-1.0 * tiresSlip) * (highSpeedVibrations ? HighhSpeedVibrationsStrengthWMMT5 : TiresSlipStrengthWMMT5) / 100.0;
|
||||||
|
triggers->Sine(100, 100, percentForce);
|
||||||
|
|
||||||
|
if (!highSpeedVibrations && ((0 == JointsAndStripesStrengthWMMT5 && 0 == CollisionsStrengthWMMT5) || (0.001 > collisions && -0.001 < collisions)))
|
||||||
|
{
|
||||||
|
triggers->LeftRight(0, percentForce, 150);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user