diff --git a/Config/FFBPlugin.ini b/Config/FFBPlugin.ini index 2afdbfc..ed1308b 100644 --- a/Config/FFBPlugin.ini +++ b/Config/FFBPlugin.ini @@ -114,12 +114,21 @@ DefaultCentering=15 EnableDamper=0 DamperStrength=100 -[GRID] +[GRID Real] GameId=10 FeedbackLength=80 EnableDamper=0 DamperStrength=100 +[GRID Custom] +GameId=71 +FeedbackLength=80 +EnableDamper=0 +DamperStrength=100 +SpringStrength=65 +GearChangeStrength=50 +GearChangeLength=80 + [Afterburner Climax] GameId=15 RumbleStrength=100 @@ -465,18 +474,24 @@ GameId=70 FeedbackLength=80 EnableDamper=0 DamperStrength=100 +SpringEnable=1 +SpringStrength=65 [Mario Kart Arcade GP DX v110 Real] GameId=69 FeedbackLength=80 EnableDamper=0 DamperStrength=100 +SpringEnable=1 +SpringStrength=65 [Mario Kart Arcade GP DX v118 Real] GameId=68 FeedbackLength=80 EnableDamper=0 DamperStrength=100 +SpringEnable=1 +SpringStrength=65 [Mario Kart Arcade GP DX v100 Custom] GameId=11 diff --git a/Dinput8Wrapper.vcxproj b/Dinput8Wrapper.vcxproj index 1b80d9a..ab496c4 100644 --- a/Dinput8Wrapper.vcxproj +++ b/Dinput8Wrapper.vcxproj @@ -34,7 +34,8 @@ - + + @@ -94,7 +95,8 @@ - + + diff --git a/Dinput8Wrapper.vcxproj.filters b/Dinput8Wrapper.vcxproj.filters index bb7111b..f29dc8c 100644 --- a/Dinput8Wrapper.vcxproj.filters +++ b/Dinput8Wrapper.vcxproj.filters @@ -151,10 +151,11 @@ - + + @@ -371,7 +372,7 @@ Common Header Files - + Common Header Files @@ -383,6 +384,9 @@ Common Header Files + + Common Header Files + diff --git a/DllMain.cpp b/DllMain.cpp index dda5422..c9e494c 100644 --- a/DllMain.cpp +++ b/DllMain.cpp @@ -46,7 +46,8 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>. #include "Game Files/FordRacing.h" #include "Game Files/FordRacingOther.h" #include "Game Files/GaelcoTuningRace.h" -#include "Game Files/GRID.h" +#include "Game Files/GRIDReal.h" +#include "Game Files/GRIDCustom.h" #include "Game Files/GoldenGun.h" #include "Game Files/InitialD0v131.h" #include "Game Files/InitialD0v211.h" @@ -995,7 +996,7 @@ const int SEGA_RALLY_3 = 6; const int FORD_RACING = 7; const int INITIAL_D_6 = 8; const int WMMT_5 = 9; -const int GRID_ = 10; +const int GRID_Real = 10; const int MARIO_KART_GPDX_CUSTOM = 11; const int OUTRUN_2Fake = 12; const int BG4_JP = 13; @@ -1054,6 +1055,7 @@ const int INITIAL_D_0_230 = 67; const int MARIO_KART_GPDX_118_REAL = 68; const int MARIO_KART_GPDX_110_REAL = 69; const int MARIO_KART_GPDX_USA_REAL = 70; +const int GRID_Custom = 71; HINSTANCE Get_hInstance() { @@ -2378,8 +2380,8 @@ DWORD WINAPI FFBLoop(LPVOID lpParam) case FORD_RACING_OTHER: game = new FordRacingOther; break; - case GRID_: - game = new GRID; + case GRID_Real: + game = new GRIDReal; break; case Golden_Gun: game = new GoldenGun; @@ -2555,6 +2557,9 @@ DWORD WINAPI FFBLoop(LPVOID lpParam) case MARIO_KART_GPDX_USA_REAL: game = new MarioKartGPDXUSAReal; break; + case GRID_Custom: + game = new GRIDCustom; + break; case TEST_GAME_CONST: case TEST_GAME_FRICTION: case TEST_GAME_SINE: diff --git a/Game Files/GRIDCustom.cpp b/Game Files/GRIDCustom.cpp new file mode 100644 index 0000000..3633991 --- /dev/null +++ b/Game Files/GRIDCustom.cpp @@ -0,0 +1,115 @@ +/*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 +#include "GRIDCustom.h" +#include "SDL.h" +static EffectTriggers* myTriggers; +static EffectConstants* myConstants; +static Helpers* myHelpers; +static bool gearshift = false; +extern int EnableDamper; +extern int DamperStrength; + +static wchar_t* settingsFilename = TEXT(".\\FFBPlugin.ini"); +static int SpringStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("SpringStrength"), 0, settingsFilename); +static int GearChangeStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("GearChangeStrength"), 20, settingsFilename); +static int GearChangeLength = GetPrivateProfileInt(TEXT("Settings"), TEXT("GearChangeLength"), 200, settingsFilename); + +void GRIDCustom::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* triggers) { + + INT_PTR WallBase = helpers->ReadIntPtr(0xB1B7F0, true); + INT_PTR WallBase1 = helpers->ReadIntPtr(WallBase + 0x730, false); + INT_PTR WallBase2 = helpers->ReadIntPtr(WallBase1 + 0x4, false); + INT_PTR WallBase3 = helpers->ReadIntPtr(WallBase2 + 0x4, false); + float WallBase4 = helpers->ReadFloat32(WallBase3 + 0x118, false); + INT_PTR PanelBase = helpers->ReadIntPtr(0xA3FA34, true); + INT_PTR PanelBase1 = helpers->ReadIntPtr(PanelBase + 0x678, false); + INT_PTR PanelBase2 = helpers->ReadIntPtr(PanelBase1 + 0x14, false); + INT_PTR PanelBase3 = helpers->ReadIntPtr(PanelBase2 + 0x30, false); + UINT8 PanelBase4 = helpers->ReadByte(PanelBase3 + 0x2C, false); + UINT8 Wheels = helpers->ReadByte(PanelBase3 + 0xB4, false); + UINT8 Skids = helpers->ReadByte(PanelBase3 + 0x100, false); + UINT8 AI = helpers->ReadByte(PanelBase3 + 0x3D4, false); + UINT8 gear = helpers->ReadByte(0x414F7898, false); + INT_PTR speedoBase = helpers->ReadIntPtr(0x28C008, true); + INT_PTR speedoBase1 = helpers->ReadIntPtr(speedoBase + 0xD0, false); + INT_PTR speedoBase2 = helpers->ReadIntPtr(speedoBase1 + 0x460, false); + INT_PTR speedoBase3 = helpers->ReadIntPtr(speedoBase2 + 0x184, false); + float speedo = helpers->ReadFloat32(speedoBase3 + 0x4F4, false); + + UINT8 static oldgear = 0; + UINT8 newgear = gear; + + triggers->Springi(SpringStrength / 100.0); + + if (EnableDamper == 1) + { + triggers->Damper(DamperStrength / 100.0); + } + + if ((oldgear != newgear) && (speedo > 0)) + { + gearshift = true; + } + + if (gearshift) + { + myHelpers->log("gear change"); + double percentForce = GearChangeStrength / 100.0; + myTriggers->Sine(GearChangeLength, 0, percentForce); + myTriggers->Rumble(0, percentForce, 150); + gearshift = false; + } + + if (Wheels > 0) + { + double percentForce = Wheels / 37.0; + double percentLength = 100; + triggers->Rumble(percentForce, percentForce, percentLength); + triggers->Sine(80, 80, percentForce); + } + + if ((Skids > 12) && (speedo > 0)) + { + double percentForce = ((Skids - 12) / 8.0); + double percentLength = 100; + triggers->Rumble(percentForce, 0, percentLength); + } + + if ((AI > 0) && (PanelBase4 > 0)) + { + double percentForce = (PanelBase4) / 8.0; + double percentLength = 100; + triggers->Rumble(percentForce, percentForce, percentLength); + } + + if ((WallBase4 > 0) && (PanelBase4 > 0)) + { + double percentForce = (PanelBase4) / 8.0; + double percentLength = 100; + triggers->Rumble(percentForce, 0, percentLength); + triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); + } + else if ((WallBase4 < 0) && (PanelBase4 > 0)) + { + double percentForce = (PanelBase4) / 8.0; + double percentLength = 100; + triggers->Rumble(0, percentForce, percentLength); + triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); + } + oldgear = newgear; + myTriggers = triggers; + myConstants = constants; + myHelpers = helpers; +} \ No newline at end of file diff --git a/Game Files/GRIDCustom.h b/Game Files/GRIDCustom.h new file mode 100644 index 0000000..9fa8322 --- /dev/null +++ b/Game Files/GRIDCustom.h @@ -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 GRIDCustom : public Game { +public: + void FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* triggers); +}; diff --git a/Game Files/GRID.cpp b/Game Files/GRIDReal.cpp similarity index 94% rename from Game Files/GRID.cpp rename to Game Files/GRIDReal.cpp index a7a94be..68336c3 100644 --- a/Game Files/GRID.cpp +++ b/Game Files/GRIDReal.cpp @@ -12,7 +12,7 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>. */ #include -#include "GRID.h" +#include "GRIDReal.h" #include "SDL.h" static EffectTriggers* myTriggers; @@ -65,7 +65,7 @@ static int __fastcall EnableFFBHook(int a1, double a2) return 0; } -void GRID::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* triggers) { +void GRIDReal::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* triggers) { if (!init) { init = true; diff --git a/Game Files/GRID.h b/Game Files/GRIDReal.h similarity index 96% rename from Game Files/GRID.h rename to Game Files/GRIDReal.h index 90c8a2a..6833fa8 100644 --- a/Game Files/GRID.h +++ b/Game Files/GRIDReal.h @@ -14,7 +14,7 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>. #pragma once #include "../Common Files/Game.h" -class GRID : public Game { +class GRIDReal : public Game { public: void FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* triggers); }; diff --git a/Game Files/MarioKartGPDX1.10Real.cpp b/Game Files/MarioKartGPDX1.10Real.cpp index c5783dc..8d47d36 100644 --- a/Game Files/MarioKartGPDX1.10Real.cpp +++ b/Game Files/MarioKartGPDX1.10Real.cpp @@ -17,11 +17,18 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>. extern int EnableDamper; extern int DamperStrength; +static wchar_t* settingsFilename = TEXT(".\\FFBPlugin.ini"); +static int SpringEnable = GetPrivateProfileInt(TEXT("Settings"), TEXT("SpringEnable"), 0, settingsFilename); +static int SpringStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("SpringStrength"), 0, settingsFilename); + void MarioKartGPDX110Real::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* triggers) { if (EnableDamper) triggers->Damper(DamperStrength / 100.0); + if (SpringEnable) + triggers->Springi(SpringStrength / 100.0); + DWORD Base = helpers->ReadInt32(0xA2FE20, true); DWORD BaseOff0 = helpers->ReadInt32(Base + 0x08, false); float FFB = helpers->ReadFloat32(BaseOff0 + 0xA44, false); diff --git a/Game Files/MarioKartGPDX1.18Real.cpp b/Game Files/MarioKartGPDX1.18Real.cpp index 79ef602..ff07832 100644 --- a/Game Files/MarioKartGPDX1.18Real.cpp +++ b/Game Files/MarioKartGPDX1.18Real.cpp @@ -17,11 +17,18 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>. extern int EnableDamper; extern int DamperStrength; +static wchar_t* settingsFilename = TEXT(".\\FFBPlugin.ini"); +static int SpringEnable = GetPrivateProfileInt(TEXT("Settings"), TEXT("SpringEnable"), 0, settingsFilename); +static int SpringStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("SpringStrength"), 0, settingsFilename); + void MarioKartGPDX118Real::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* triggers) { if (EnableDamper) triggers->Damper(DamperStrength / 100.0); + if (SpringEnable) + triggers->Springi(SpringStrength / 100.0); + DWORD Base = helpers->ReadInt32(0xAAEEA0, true); DWORD BaseOff0 = helpers->ReadInt32(Base + 0x08, false); float FFB = helpers->ReadFloat32(BaseOff0 + 0xBC8, false); diff --git a/Game Files/MarioKartGPDXUSAReal.cpp b/Game Files/MarioKartGPDXUSAReal.cpp index f2b76a9..9d80db3 100644 --- a/Game Files/MarioKartGPDXUSAReal.cpp +++ b/Game Files/MarioKartGPDXUSAReal.cpp @@ -17,11 +17,18 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>. extern int EnableDamper; extern int DamperStrength; +static wchar_t* settingsFilename = TEXT(".\\FFBPlugin.ini"); +static int SpringEnable = GetPrivateProfileInt(TEXT("Settings"), TEXT("SpringEnable"), 0, settingsFilename); +static int SpringStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("SpringStrength"), 0, settingsFilename); + void MarioKartGPDXUSAReal::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* triggers) { if (EnableDamper) triggers->Damper(DamperStrength / 100.0); + if (SpringEnable) + triggers->Springi(SpringStrength / 100.0); + DWORD Base = helpers->ReadInt32(0xB47B48, true); DWORD BaseOff0 = helpers->ReadInt32(Base + 0x08, false); float FFB = helpers->ReadFloat32(BaseOff0 + 0x2FC, false);