1
0
mirror of synced 2024-11-27 16:10:52 +01:00

Add WMMT6 and WMMT6R FFB Support

This commit is contained in:
Aaron M 2021-02-20 11:44:55 +13:00
parent 7965d74479
commit 8191f827a7
8 changed files with 726 additions and 0 deletions

View File

@ -418,6 +418,40 @@ EnableForceTimeUp=0
ForceFinishButton=99
ForceTimeUpButton=99
[WMMT6]
GameId=52
DefaultCentering=0
FeedbackLength=80
Logging=0
SpringStrength=100
FrictionStrength=0
JointsAndStripesStrength=100
CollisionsStrength=100
TiresSlipStrength=100
HighSpeedVibrationsStrength=100
WheelSpinStrength=100
GearChangeStrength=20
GearChangeDelay=250
GearChangeLength=200
LimitBetweenHighSpeedVibrationsAndTiresSlip=75
[WMMT6R]
GameId=53
DefaultCentering=0
FeedbackLength=80
Logging=0
SpringStrength=100
FrictionStrength=0
JointsAndStripesStrength=100
CollisionsStrength=100
TiresSlipStrength=100
HighSpeedVibrationsStrength=100
WheelSpinStrength=100
GearChangeStrength=20
GearChangeDelay=250
GearChangeLength=200
LimitBetweenHighSpeedVibrationsAndTiresSlip=75
[Sonic & Sega All Stars Racing]
GameId=21
FeedbackLength=500

View File

@ -51,6 +51,8 @@
<ClInclude Include="Game Files\LGI3D.h" />
<ClInclude Include="Game Files\StormRacerG.h" />
<ClInclude Include="Game Files\SWDC2018.h" />
<ClInclude Include="Game Files\WMMT6.h" />
<ClInclude Include="Game Files\WMMT6R.h" />
<ClInclude Include="resource.h" />
<None Include="Config\FFBPlugin.ini">
<FileType>Document</FileType>
@ -113,6 +115,8 @@
<ClCompile Include="Game Files\WMMT5.cpp" />
<ClCompile Include="Game Files\InitialD4Japan.cpp" />
<ClCompile Include="Game Files\GTIClub3.cpp" />
<ClCompile Include="Game Files\WMMT6.cpp" />
<ClCompile Include="Game Files\WMMT6R.cpp" />
<ClCompile Include="IDirectInputDevice.cpp" />
<ClCompile Include="Game Files\MarioKartGPDX1.10.cpp" />
<ClCompile Include="Game Files\InitialD5.cpp" />

View File

@ -135,6 +135,8 @@
<ClCompile Include="Game Files\InitialD0v211.cpp" />
<ClCompile Include="Game Files\SWDC2018.cpp" />
<ClCompile Include="Game Files\MarioKartGPDXUSA.cpp" />
<ClCompile Include="Game Files\WMMT6.cpp" />
<ClCompile Include="Game Files\WMMT6R.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Game Files\Daytona3.h">
@ -309,6 +311,12 @@
<ClInclude Include="Game Files\MarioKartGPDXUSA.h">
<Filter>Common Header Files</Filter>
</ClInclude>
<ClInclude Include="Game Files\WMMT6.h">
<Filter>Common Header Files</Filter>
</ClInclude>
<ClInclude Include="Game Files\WMMT6R.h">
<Filter>Common Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<MASM Include="DLLWrapper.asm" />

View File

@ -61,6 +61,8 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
#include "Game Files/SnoCross.h"
#include "Game Files/WackyRaces.h"
#include "Game Files/WMMT5.h"
#include "Game Files/WMMT6.h"
#include "Game Files/WMMT6R.h"
#include "Game Files/Machstorm.h"
#include "Game Files/AfterburnerClimax.h"
#include "Game Files/PokkenTournament.h"
@ -1008,6 +1010,8 @@ const int Storm_Racer_G = 48;
const int INITIAL_D_0_211 = 49;
const int SWDC_2018 = 50;
const int MARIO_KART_GPDX_USA = 51;
const int WMMT_6 = 52;
const int WMMT_6_R = 53;
HINSTANCE Get_hInstance()
{
@ -2440,6 +2444,12 @@ DWORD WINAPI FFBLoop(LPVOID lpParam)
case SWDC_2018:
game = new SWDC;
break;
case WMMT_6:
game = new WMMT6;
break;
case WMMT_6_R:
game = new WMMT6R;
break;
case TEST_GAME_CONST:
case TEST_GAME_FRICTION:
case TEST_GAME_SINE:

316
Game Files/WMMT6.cpp Normal file
View File

@ -0,0 +1,316 @@
/*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>
#include "WMMT6.h"
#include "SDL.h"
static EffectTriggers* myTriggers;
static EffectConstants* myConstants;
static Helpers* myHelpers;
extern SDL_Event e;
static UINT8 oldgear = 0;
static bool init = false;
static bool gameFfbStarted = false;
static wchar_t* settingsFilename = TEXT(".\\FFBPlugin.ini");
static int SpringStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("SpringStrength"), 100, settingsFilename);
static int FrictionStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("FrictionStrength"), 0, settingsFilename);
static int JointsAndStripesStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("JointsAndStripesStrength"), 100, settingsFilename);
static int CollisionsStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("CollisionsStrength"), 100, settingsFilename);
static int TiresSlipStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("TiresSlipStrength"), 100, settingsFilename);
static int HighSpeedVibrationsStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("HighSpeedVibrationsStrength"), 100, settingsFilename);
static int LimitBetweenHighSpeedVibrationsAndTiresSlip = GetPrivateProfileInt(TEXT("Settings"), TEXT("LimitBetweenHighSpeedVibrationsAndTiresSlip"), 75, settingsFilename);
static int GearChangeStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("GearChangeStrength"), 20, settingsFilename);
static int GearChangeDelay = GetPrivateProfileInt(TEXT("Settings"), TEXT("GearChangeDelay"), 250, settingsFilename);
static int GearChangeLength = GetPrivateProfileInt(TEXT("Settings"), TEXT("GearChangeLength"), 200, settingsFilename);
static int WheelSpinStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("WheelSpinStrength"), 100, settingsFilename);
static int ShowButtonNumbersForSetup = GetPrivateProfileInt(TEXT("Settings"), TEXT("ShowButtonNumbersForSetup"), 0, settingsFilename);
//static int ForceFullTune = GetPrivateProfileInt(TEXT("Settings"), TEXT("ForceFullTune"), 0, settingsFilename);
//static int DisableRaceTimer = GetPrivateProfileInt(TEXT("Settings"), TEXT("DisableRaceTimer"), 0, settingsFilename);
//static int EnableForceFinish = GetPrivateProfileInt(TEXT("Settings"), TEXT("EnableForceFinish"), 0, settingsFilename);
//static int EnableForceTimeUp = GetPrivateProfileInt(TEXT("Settings"), TEXT("EnableForceTimeUp"), 0, settingsFilename);
//static int ForceFinishButton = GetPrivateProfileInt(TEXT("Settings"), TEXT("ForceFinishButton"), 99, settingsFilename);
//static int ForceTimeUpButton = GetPrivateProfileInt(TEXT("Settings"), TEXT("ForceTimeUpButton"), 99, settingsFilename);
//static int InputThread(void* ptr)
//{
// if (1 != EnableForceFinish && 1 != EnableForceTimeUp)
// {
// return 0;
// }
//
// myHelpers->log("starting input thread");
// while (SDL_WaitEvent(&e) != 0)
// {
// if (e.type == SDL_JOYBUTTONDOWN)
// {
// myHelpers->log("button pressed");
// if (1 == EnableForceFinish && e.jbutton.button == ForceFinishButton)
// {
// INT_PTR ptr1 = myHelpers->ReadIntPtr(0x199A468, true);
// myHelpers->WriteByte(ptr1 + 0x28, 8, false);
// }
// else if (1 == EnableForceTimeUp && e.jbutton.button == ForceTimeUpButton)
// {
// int tempDisableRaceTimer = DisableRaceTimer;
// DisableRaceTimer = 0;
// myHelpers->WriteFloat32(0x199AE18, 0, true);
// if (1 == tempDisableRaceTimer)
// {
// Sleep(10000);
// DisableRaceTimer = tempDisableRaceTimer;
// }
// }
// }
// }
// myHelpers->log("input thread stopped");
// return 0;
//}
//
//static int SpamThread(void* ptr)
//{
// if (1 != ForceFullTune && 1 != DisableRaceTimer)
// {
// return 0;
// }
//
// Sleep(5000); // To avoid crashes
// myHelpers->log("starting spam thread");
// while (1)
// {
// if (1 == ForceFullTune)
// {
// INT_PTR ptr1 = myHelpers->ReadIntPtr(0x1948F10, true);
// INT_PTR ptr2 = myHelpers->ReadIntPtr(ptr1 + 0x180 + 0xa8 + 0x18, false);
// UINT8 car = myHelpers->ReadByte(ptr2 + 0x2C, false);
// std::string msg = "car: " + std::to_string(car);
// myHelpers->log((char*)msg.c_str());
//
// if (0x00 < car)
// {
// UINT8 power = myHelpers->ReadByte(ptr2 + 0x98, false);
// UINT8 handling = myHelpers->ReadByte(ptr2 + 0x9C, false);
// msg = "power: " + std::to_string(power) + " | handling: " + std::to_string(handling);
// myHelpers->log((char*)msg.c_str());
//
// if (0x20 != (power + handling))
// {
// myHelpers->log("forcing full tune");
// myHelpers->WriteByte(ptr2 + 0x98, 0x10, false);
// myHelpers->WriteByte(ptr2 + 0x9C, 0x10, false);
// }
// }
// }
//
// if (1 == DisableRaceTimer)
// {
// myHelpers->WriteFloat32(0x199AE18, 999.99, true);
// }
//
// Sleep(500); // We don't need to spam too much
// }
// myHelpers->log("spam thread stopped");
// return 0;
//}
static int GearChangeThread(void* ptr)
{
if (GearChangeDelay > 0)
{
Sleep(GearChangeDelay);
}
myHelpers->log("gear change");
double percentForce = GearChangeStrength / 100.0;
myTriggers->Sine(GearChangeLength, GearChangeLength, percentForce);
myTriggers->Rumble(0, percentForce, 150);
return 0;
}
void WMMT6::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* triggers)
{
if (!init)
{
init = true;
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
//SDL_CreateThread(InputThread, "InputThread", (void*)NULL);
//SDL_CreateThread(SpamThread, "SpamThread", (void*)NULL);
}
float spring = helpers->ReadFloat32(0x1E3C614, true);
float friction = helpers->ReadFloat32(0x1E3C618, true);
float collisions = helpers->ReadFloat32(0x1E3C61C, true);
float tiresSlip = helpers->ReadFloat32(0x1E3C610, true);
int speed = helpers->ReadInt32(0x1E3D4DC, true);
std::string msg = "spring: " + std::to_string(spring) + " | friction: " + std::to_string(friction)
+ " | collisions: " + std::to_string(collisions) + " | tires slip: " + std::to_string(tiresSlip)
+ " | speed: " + std::to_string(speed);
helpers->log((char*)msg.c_str());
double percentForce;
if (0.001 > spring && !gameFfbStarted)
{
helpers->log("fake spring+friction until game's FFB starts");
percentForce = 0.3 * SpringStrength / 100.0;
triggers->Spring(percentForce);
percentForce = 0.5 * FrictionStrength / 100.0;
triggers->Friction(percentForce);
}
else
{
if (!gameFfbStarted)
{
helpers->log("game's FFB started");
gameFfbStarted = true;
}
percentForce = (1.0 * spring) * SpringStrength / 100.0;
triggers->Spring(percentForce);
percentForce = (1.0 * friction) * FrictionStrength / 100.0;
triggers->Friction(percentForce);
}
if (0 < collisions)
{
if (0.209 <= collisions && 0.311 >= collisions)
{
helpers->log("joint/stripe on the right");
percentForce = (1.0 * collisions) * JointsAndStripesStrength / 100.0;
triggers->Sine(80, 80, percentForce);
triggers->Rumble(0, percentForce, 150);
}
else
{
helpers->log("collision on the right");
percentForce = (1.0 * collisions) * CollisionsStrength / 100.0;
triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce);
triggers->Rumble(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) * JointsAndStripesStrength / 100.0;
triggers->Sine(80, 80, percentForce);
triggers->Rumble(0, -1.0 * percentForce, 150);
}
else
{
helpers->log("collision on the left");
percentForce = (-1.0 * collisions) * CollisionsStrength / 100.0;
triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce);
triggers->Rumble(0, percentForce, 150);
}
}
else
{
helpers->log("resetting collision");
triggers->Constant(constants->DIRECTION_FROM_LEFT, 0);
}
if (0 < tiresSlip)
{
helpers->log("tires slip left");
bool highSpeedVibrations = (294 <= speed) && (1.0 * tiresSlip) < (LimitBetweenHighSpeedVibrationsAndTiresSlip / 1000.0);
percentForce = (-1.0 * tiresSlip) * (highSpeedVibrations ? HighSpeedVibrationsStrength : TiresSlipStrength) / 100.0;
triggers->Sine(100, 100, percentForce);
if (!highSpeedVibrations && ((0 == JointsAndStripesStrength && 0 == CollisionsStrength) || (0.001 > collisions && -0.001 < collisions)))
{
triggers->Rumble(0, -1.0 * percentForce, 150);
}
}
else if (0 > tiresSlip)
{
helpers->log("tires slip right");
bool highSpeedVibrations = (294 <= speed) && (-1.0 * tiresSlip) < (LimitBetweenHighSpeedVibrationsAndTiresSlip / 1000.0);
percentForce = (-1.0 * tiresSlip) * (highSpeedVibrations ? HighSpeedVibrationsStrength : TiresSlipStrength) / 100.0;
triggers->Sine(100, 100, percentForce);
if (!highSpeedVibrations && ((0 == JointsAndStripesStrength && 0 == CollisionsStrength) || (0.001 > collisions && -0.001 < collisions)))
{
triggers->Rumble(0, percentForce, 150);
}
}
INT_PTR ptr1 = helpers->ReadIntPtr(0x1E5B5B0, true);
UINT8 gear = helpers->ReadByte(ptr1 + 0x3A8, false);
if (0 < WheelSpinStrength)
{
//INT_PTR ptr1 = myHelpers->ReadIntPtr(0x1948F10, true);
//INT_PTR ptr2 = myHelpers->ReadIntPtr(ptr1 + 0x180 + 0xa8 + 0x18, false);
//UINT8 power = myHelpers->ReadByte(ptr2 + 0x98, false);
UINT8 power = 16;
int rpm = helpers->ReadInt32(0x1E3D64C, true);
int diff = 0x0A <= power ? 0 : 20;
if (
1 == gear && 10 < speed && (
((30 - diff) > speed && 3500 < rpm)
|| ((55 - diff) > speed && 5500 < rpm)
|| ((75 - diff) > speed && 7000 < rpm)
|| ((100 - diff) > speed && 7800 < rpm)
)
)
{
percentForce = (((100.0 - speed) / 100.0) * ((rpm * 100.0 / 8500.0) / 100.0)) * WheelSpinStrength / 100.0;
triggers->Sine(120, 120, percentForce);
triggers->Rumble(0, percentForce, 150);
msg = "tires spin: gear: " + std::to_string(gear) + " | speed: " + std::to_string(speed)
+ " | rpm: " + std::to_string(rpm) + " | force: " + std::to_string(percentForce);
helpers->log((char*)msg.c_str());
}
else if (
2 == gear && 10 < speed && (
((110 - (2 * diff)) > speed && 5000 < rpm)
|| ((130 - (2 * diff)) > speed && 6000 < rpm)
|| ((145 - (2 * diff)) > speed && 6500 < rpm)
|| ((160 - (2 * diff)) > speed && 7000 < rpm)
)
)
{
percentForce = (((160.0 - speed) / 150.0) * ((rpm * 100.0 / 8500.0) / 100.0)) * WheelSpinStrength / 100.0;
triggers->Sine(120, 120, percentForce);
triggers->Rumble(0, percentForce, 150);
msg = "tires spin: gear: " + std::to_string(gear) + " | speed: " + std::to_string(speed)
+ " | rpm: " + std::to_string(rpm) + " | force: " + std::to_string(percentForce);
helpers->log((char*)msg.c_str());
}
}
if (0 < GearChangeStrength)
{
INT_PTR ptrtime = helpers->ReadIntPtr(0x1E3CB18, true);
INT_PTR ptrtimeA = helpers->ReadIntPtr(ptrtime + 0x08, false);
INT_PTR ptrtimeB = helpers->ReadIntPtr(ptrtimeA + 0x00, false);
float time = helpers->ReadFloat32(ptrtimeB + 0x730, false);
if (oldgear != gear && 0 < gear && 0 < time)
{
msg = "oldgear: " + std::to_string(oldgear) + " | gear: " + std::to_string(gear)
+ " | time: " + std::to_string(time) + " | speed: " + std::to_string(speed);
helpers->log((char*)msg.c_str());
}
if (oldgear != gear && 0 < gear && 0.5 < time && 0.1 <= speed)
{
SDL_CreateThread(GearChangeThread, "GearChangeThread", (void*)NULL);
}
oldgear = gear;
}
}

20
Game Files/WMMT6.h Normal file
View File

@ -0,0 +1,20 @@
/*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/>.
*/
#pragma once
#include "../Common Files/Game.h"
class WMMT6 : public Game {
public:
void FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* triggers);
};

314
Game Files/WMMT6R.cpp Normal file
View File

@ -0,0 +1,314 @@
/*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>
#include "WMMT6R.h"
#include "SDL.h"
static EffectTriggers* myTriggers;
static EffectConstants* myConstants;
static Helpers* myHelpers;
extern SDL_Event e;
static UINT8 oldgear = 0;
static bool init = false;
static bool gameFfbStarted = false;
static wchar_t* settingsFilename = TEXT(".\\FFBPlugin.ini");
static int SpringStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("SpringStrength"), 100, settingsFilename);
static int FrictionStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("FrictionStrength"), 0, settingsFilename);
static int JointsAndStripesStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("JointsAndStripesStrength"), 100, settingsFilename);
static int CollisionsStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("CollisionsStrength"), 100, settingsFilename);
static int TiresSlipStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("TiresSlipStrength"), 100, settingsFilename);
static int HighSpeedVibrationsStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("HighSpeedVibrationsStrength"), 100, settingsFilename);
static int LimitBetweenHighSpeedVibrationsAndTiresSlip = GetPrivateProfileInt(TEXT("Settings"), TEXT("LimitBetweenHighSpeedVibrationsAndTiresSlip"), 75, settingsFilename);
static int GearChangeStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("GearChangeStrength"), 20, settingsFilename);
static int GearChangeDelay = GetPrivateProfileInt(TEXT("Settings"), TEXT("GearChangeDelay"), 250, settingsFilename);
static int GearChangeLength = GetPrivateProfileInt(TEXT("Settings"), TEXT("GearChangeLength"), 200, settingsFilename);
static int WheelSpinStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("WheelSpinStrength"), 100, settingsFilename);
static int ShowButtonNumbersForSetup = GetPrivateProfileInt(TEXT("Settings"), TEXT("ShowButtonNumbersForSetup"), 0, settingsFilename);
//static int ForceFullTune = GetPrivateProfileInt(TEXT("Settings"), TEXT("ForceFullTune"), 0, settingsFilename);
//static int DisableRaceTimer = GetPrivateProfileInt(TEXT("Settings"), TEXT("DisableRaceTimer"), 0, settingsFilename);
//static int EnableForceFinish = GetPrivateProfileInt(TEXT("Settings"), TEXT("EnableForceFinish"), 0, settingsFilename);
//static int EnableForceTimeUp = GetPrivateProfileInt(TEXT("Settings"), TEXT("EnableForceTimeUp"), 0, settingsFilename);
//static int ForceFinishButton = GetPrivateProfileInt(TEXT("Settings"), TEXT("ForceFinishButton"), 99, settingsFilename);
//static int ForceTimeUpButton = GetPrivateProfileInt(TEXT("Settings"), TEXT("ForceTimeUpButton"), 99, settingsFilename);
//static int InputThread(void* ptr)
//{
// if (1 != EnableForceFinish && 1 != EnableForceTimeUp)
// {
// return 0;
// }
//
// myHelpers->log("starting input thread");
// while (SDL_WaitEvent(&e) != 0)
// {
// if (e.type == SDL_JOYBUTTONDOWN)
// {
// myHelpers->log("button pressed");
// if (1 == EnableForceFinish && e.jbutton.button == ForceFinishButton)
// {
// INT_PTR ptr1 = myHelpers->ReadIntPtr(0x199A468, true);
// myHelpers->WriteByte(ptr1 + 0x28, 8, false);
// }
// else if (1 == EnableForceTimeUp && e.jbutton.button == ForceTimeUpButton)
// {
// int tempDisableRaceTimer = DisableRaceTimer;
// DisableRaceTimer = 0;
// myHelpers->WriteFloat32(0x199AE18, 0, true);
// if (1 == tempDisableRaceTimer)
// {
// Sleep(10000);
// DisableRaceTimer = tempDisableRaceTimer;
// }
// }
// }
// }
// myHelpers->log("input thread stopped");
// return 0;
//}
//
//static int SpamThread(void* ptr)
//{
// if (1 != ForceFullTune && 1 != DisableRaceTimer)
// {
// return 0;
// }
//
// Sleep(5000); // To avoid crashes
// myHelpers->log("starting spam thread");
// while (1)
// {
// if (1 == ForceFullTune)
// {
// INT_PTR ptr1 = myHelpers->ReadIntPtr(0x1948F10, true);
// INT_PTR ptr2 = myHelpers->ReadIntPtr(ptr1 + 0x180 + 0xa8 + 0x18, false);
// UINT8 car = myHelpers->ReadByte(ptr2 + 0x2C, false);
// std::string msg = "car: " + std::to_string(car);
// myHelpers->log((char*)msg.c_str());
//
// if (0x00 < car)
// {
// UINT8 power = myHelpers->ReadByte(ptr2 + 0x98, false);
// UINT8 handling = myHelpers->ReadByte(ptr2 + 0x9C, false);
// msg = "power: " + std::to_string(power) + " | handling: " + std::to_string(handling);
// myHelpers->log((char*)msg.c_str());
//
// if (0x20 != (power + handling))
// {
// myHelpers->log("forcing full tune");
// myHelpers->WriteByte(ptr2 + 0x98, 0x10, false);
// myHelpers->WriteByte(ptr2 + 0x9C, 0x10, false);
// }
// }
// }
//
// if (1 == DisableRaceTimer)
// {
// myHelpers->WriteFloat32(0x199AE18, 999.99, true);
// }
//
// Sleep(500); // We don't need to spam too much
// }
// myHelpers->log("spam thread stopped");
// return 0;
//}
static int GearChangeThread(void* ptr)
{
if (GearChangeDelay > 0)
{
Sleep(GearChangeDelay);
}
myHelpers->log("gear change");
double percentForce = GearChangeStrength / 100.0;
myTriggers->Sine(GearChangeLength, GearChangeLength, percentForce);
myTriggers->Rumble(0, percentForce, 150);
return 0;
}
void WMMT6R::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* triggers)
{
if (!init)
{
init = true;
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
//SDL_CreateThread(InputThread, "InputThread", (void*)NULL);
//SDL_CreateThread(SpamThread, "SpamThread", (void*)NULL);
}
float spring = helpers->ReadFloat32(0x204712C, true);
float friction = helpers->ReadFloat32(0x2047130, true);
float collisions = helpers->ReadFloat32(0x2047134, true);
float tiresSlip = helpers->ReadFloat32(0x2047128, true);
int speed = helpers->ReadInt32(0x204809C, true);
std::string msg = "spring: " + std::to_string(spring) + " | friction: " + std::to_string(friction)
+ " | collisions: " + std::to_string(collisions) + " | tires slip: " + std::to_string(tiresSlip)
+ " | speed: " + std::to_string(speed);
helpers->log((char*)msg.c_str());
double percentForce;
if (0.001 > spring && !gameFfbStarted)
{
helpers->log("fake spring+friction until game's FFB starts");
percentForce = 0.3 * SpringStrength / 100.0;
triggers->Spring(percentForce);
percentForce = 0.5 * FrictionStrength / 100.0;
triggers->Friction(percentForce);
}
else
{
if (!gameFfbStarted)
{
helpers->log("game's FFB started");
gameFfbStarted = true;
}
percentForce = (1.0 * spring) * SpringStrength / 100.0;
triggers->Spring(percentForce);
percentForce = (1.0 * friction) * FrictionStrength / 100.0;
triggers->Friction(percentForce);
}
if (0 < collisions)
{
if (0.209 <= collisions && 0.311 >= collisions)
{
helpers->log("joint/stripe on the right");
percentForce = (1.0 * collisions) * JointsAndStripesStrength / 100.0;
triggers->Sine(80, 80, percentForce);
triggers->Rumble(0, percentForce, 150);
}
else
{
helpers->log("collision on the right");
percentForce = (1.0 * collisions) * CollisionsStrength / 100.0;
triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce);
triggers->Rumble(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) * JointsAndStripesStrength / 100.0;
triggers->Sine(80, 80, percentForce);
triggers->Rumble(0, -1.0 * percentForce, 150);
}
else
{
helpers->log("collision on the left");
percentForce = (-1.0 * collisions) * CollisionsStrength / 100.0;
triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce);
triggers->Rumble(0, percentForce, 150);
}
}
else
{
helpers->log("resetting collision");
triggers->Constant(constants->DIRECTION_FROM_LEFT, 0);
}
if (0 < tiresSlip)
{
helpers->log("tires slip left");
bool highSpeedVibrations = (294 <= speed) && (1.0 * tiresSlip) < (LimitBetweenHighSpeedVibrationsAndTiresSlip / 1000.0);
percentForce = (-1.0 * tiresSlip) * (highSpeedVibrations ? HighSpeedVibrationsStrength : TiresSlipStrength) / 100.0;
triggers->Sine(100, 100, percentForce);
if (!highSpeedVibrations && ((0 == JointsAndStripesStrength && 0 == CollisionsStrength) || (0.001 > collisions && -0.001 < collisions)))
{
triggers->Rumble(0, -1.0 * percentForce, 150);
}
}
else if (0 > tiresSlip)
{
helpers->log("tires slip right");
bool highSpeedVibrations = (294 <= speed) && (-1.0 * tiresSlip) < (LimitBetweenHighSpeedVibrationsAndTiresSlip / 1000.0);
percentForce = (-1.0 * tiresSlip) * (highSpeedVibrations ? HighSpeedVibrationsStrength : TiresSlipStrength) / 100.0;
triggers->Sine(100, 100, percentForce);
if (!highSpeedVibrations && ((0 == JointsAndStripesStrength && 0 == CollisionsStrength) || (0.001 > collisions && -0.001 < collisions)))
{
triggers->Rumble(0, percentForce, 150);
}
}
INT_PTR ptr1 = helpers->ReadIntPtr(0x20681C0, true);
UINT8 gear = helpers->ReadByte(ptr1 + 0x3AC, false);
if (0 < WheelSpinStrength)
{
//INT_PTR ptr1 = myHelpers->ReadIntPtr(0x1948F10, true);
//INT_PTR ptr2 = myHelpers->ReadIntPtr(ptr1 + 0x180 + 0xa8 + 0x18, false);
//UINT8 power = myHelpers->ReadByte(ptr2 + 0x98, false);
UINT8 power = 16;
int rpm = helpers->ReadInt32(0x204820C, true);
int diff = 0x0A <= power ? 0 : 20;
if (
1 == gear && 10 < speed && (
((30 - diff) > speed && 3500 < rpm)
|| ((55 - diff) > speed && 5500 < rpm)
|| ((75 - diff) > speed && 7000 < rpm)
|| ((100 - diff) > speed && 7800 < rpm)
)
)
{
percentForce = (((100.0 - speed) / 100.0) * ((rpm * 100.0 / 8500.0) / 100.0)) * WheelSpinStrength / 100.0;
triggers->Sine(120, 120, percentForce);
triggers->Rumble(0, percentForce, 150);
msg = "tires spin: gear: " + std::to_string(gear) + " | speed: " + std::to_string(speed)
+ " | rpm: " + std::to_string(rpm) + " | force: " + std::to_string(percentForce);
helpers->log((char*)msg.c_str());
}
else if (
2 == gear && 10 < speed && (
((110 - (2 * diff)) > speed && 5000 < rpm)
|| ((130 - (2 * diff)) > speed && 6000 < rpm)
|| ((145 - (2 * diff)) > speed && 6500 < rpm)
|| ((160 - (2 * diff)) > speed && 7000 < rpm)
)
)
{
percentForce = (((160.0 - speed) / 150.0) * ((rpm * 100.0 / 8500.0) / 100.0)) * WheelSpinStrength / 100.0;
triggers->Sine(120, 120, percentForce);
triggers->Rumble(0, percentForce, 150);
msg = "tires spin: gear: " + std::to_string(gear) + " | speed: " + std::to_string(speed)
+ " | rpm: " + std::to_string(rpm) + " | force: " + std::to_string(percentForce);
helpers->log((char*)msg.c_str());
}
}
if (0 < GearChangeStrength)
{
INT_PTR ptrtime = helpers->ReadIntPtr(0x20681D8, true);
float time = helpers->ReadFloat32(ptrtime + 0x18, false);
if (oldgear != gear && 0 < gear && 0 < time)
{
msg = "oldgear: " + std::to_string(oldgear) + " | gear: " + std::to_string(gear)
+ " | time: " + std::to_string(time) + " | speed: " + std::to_string(speed);
helpers->log((char*)msg.c_str());
}
if (oldgear != gear && 0 < gear && 0.5 < time && 0.1 <= speed)
{
SDL_CreateThread(GearChangeThread, "GearChangeThread", (void*)NULL);
}
oldgear = gear;
}
}

20
Game Files/WMMT6R.h Normal file
View File

@ -0,0 +1,20 @@
/*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/>.
*/
#pragma once
#include "../Common Files/Game.h"
class WMMT6R : public Game {
public:
void FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* triggers);
};