1
0
mirror of synced 2024-11-28 16:40:55 +01:00
FFBArcadePlugin/Game Files/WMMT5.cpp

86 lines
3.8 KiB
C++
Raw Normal View History

2019-09-14 03:13:05 +02:00
/*This file is part of FFB Arcade Plugin.
FFB Arcade Plugin is free software : you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
FFB Arcade Plugin is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
*/
#include <string>
2019-04-07 07:16:19 +02:00
#include "WMMT5.h"
2019-09-23 19:15:12 +02:00
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 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);
2019-04-07 07:16:19 +02:00
void WMMT5::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) {
2019-09-23 19:15:12 +02:00
float spring = helpers->ReadFloat32(0x196F18C, /* isRelativeOffset*/ true);
float friction = helpers->ReadFloat32(0x196F190, /* isRelativeOffset*/ true);
float collisions = helpers->ReadFloat32(0x196F194, /* isRelativeOffset*/ true);
float tiresSlip = helpers->ReadFloat32(0x196F188, /* isRelativeOffset*/ true);
2019-04-07 07:16:19 +02:00
helpers->log("got value: ");
2019-09-23 19:15:12 +02:00
std::string ffs = "spring: " + std::to_string(spring);
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());
2019-04-07 07:16:19 +02:00
2019-09-23 19:15:12 +02:00
if (0 < spring)
2019-04-07 07:16:19 +02:00
{
2019-09-23 19:15:12 +02:00
double percentForce = (1.0 * spring) * SpringStrengthWMMT5 / 100.0;
triggers->Spring(percentForce);
2019-04-07 07:16:19 +02:00
}
2019-09-23 19:15:12 +02:00
if (0 < friction)
{
2019-09-23 19:19:44 +02:00
double percentForce = (1.0 * friction) * FrictionStrengthWMMT5 / 100.0;
2019-09-23 19:15:12 +02:00
triggers->Friction(percentForce);
}
if (0 < collisions)
2019-04-07 07:16:19 +02:00
{
2019-09-23 19:15:12 +02:00
helpers->log("collision on the left");
double percentForce = (1.0 * collisions) * CollisionsStrengthWMMT5 / 100.0;
2019-04-07 07:16:19 +02:00
double percentLength = (250);
// direction from right => makes wheel turn left
triggers->LeftRight(percentForce, 0, percentLength);
2019-09-23 19:15:12 +02:00
// triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce);
triggers->Sine(100, 120, percentForce);
2019-04-07 07:16:19 +02:00
}
2019-09-23 19:15:12 +02:00
else if (0 > collisions)
2019-04-07 07:16:19 +02:00
{
2019-09-23 19:15:12 +02:00
helpers->log("collision on the right");
double percentForce = (-1.0 * collisions) * CollisionsStrengthWMMT5 / 100.0;
2019-04-07 07:16:19 +02:00
double percentLength = (250);
// direction from left => makes wheel turn right
triggers->LeftRight(0, percentForce, percentLength);
2019-09-23 19:15:12 +02:00
// triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce);
2019-04-07 07:16:19 +02:00
2019-09-23 19:37:15 +02:00
percentForce = (1.0 * collisions) * CollisionsStrengthWMMT5 / 100.0;
triggers->Sine(100, 120, percentForce);
2019-04-07 07:16:19 +02:00
}
2019-09-23 19:15:12 +02:00
if (0 < tiresSlip)
2019-04-07 07:16:19 +02:00
{
2019-09-23 19:15:12 +02:00
helpers->log("tires slip left");
bool highSpeedVibrations = tiresSlip < 0.06;
double percentForce = (-1.0 * tiresSlip) * (highSpeedVibrations ? HighhSpeedVibrationsStrengthWMMT5 : TiresSlipStrengthWMMT5) / 100.0;
triggers->Sine(highSpeedVibrations ? 100 : 120, 120, percentForce);
2019-04-07 07:16:19 +02:00
}
2019-09-23 19:15:12 +02:00
else if (0 > tiresSlip)
2019-04-07 07:16:19 +02:00
{
2019-09-23 19:15:12 +02:00
helpers->log("tires slip right");
bool highSpeedVibrations = tiresSlip > -0.06;
double percentForce = (-1.0 * tiresSlip) * (highSpeedVibrations ? HighhSpeedVibrationsStrengthWMMT5 : TiresSlipStrengthWMMT5) / 100.0;
triggers->Sine(highSpeedVibrations ? 100 : 120, 120, percentForce);
2019-04-07 07:16:19 +02:00
}
}