From 34174939c555a7fe71d710140befaebfe438cccc Mon Sep 17 00:00:00 2001 From: Boomslangnz Date: Sun, 19 Nov 2023 18:27:50 +1300 Subject: [PATCH] Daytona 3 changes etc --- Config/FFBPlugin.ini | 13 +- DInput8Wrapper.aps | Bin 2740 -> 2740 bytes DInput8Wrapper.rc | Bin 5212 -> 5212 bytes DllMain.cpp | 4 +- Game Files/Daytona3.cpp | 275 ++++++++++++++----------------------- Game Files/Daytona3NSE.cpp | 16 +-- 6 files changed, 114 insertions(+), 194 deletions(-) diff --git a/Config/FFBPlugin.ini b/Config/FFBPlugin.ini index 12e284e..fc1fdc4 100644 --- a/Config/FFBPlugin.ini +++ b/Config/FFBPlugin.ini @@ -77,19 +77,10 @@ AlternativeMinForceLeft=0 AlternativeMaxForceLeft=-90 AlternativeMinForceRight=0 AlternativeMaxForceRight=90 -FeedbackLength=500 -ShowButtonNumbersForSetup=0 -ChangeGearsViaPlugin=0 +FeedbackLength=80 EscapeKeyExitViaPlugin=0 -MenuMovementViaPlugin=0 EnableDamper=0 DamperStrength=100 -Gear1=99 -Gear2=99 -Gear3=99 -Gear4=99 -GearUp=99 -GearDown=99 HideCursor=0 [Wacky Races] @@ -780,7 +771,7 @@ Gear6=99 [Daytona Championship USA NSE] GameId=59 -FeedbackLength=120 +FeedbackLength=80 EnableDamper=0 DamperStrength=100 DoubleSine=0 diff --git a/DInput8Wrapper.aps b/DInput8Wrapper.aps index 130784df3bca4dd72438de4fab16a37a1dcd0b61..d5686c9ab827d9680768682734753a90b6aa7c35 100644 GIT binary patch delta 36 ncmdlYx&8k0|+oNsBBJUQ)FZ`+uY8s4Wc%4FfsuEk|76# delta 36 ncmdlYx&8+0|+oNC~i(=Q)FZ`-rUZv4Wc%4FfsuEkyr&0@^G9@sSHb delta 38 rcmcbkaYtiA7&oKw&0@^G9@Tv. #include #include "Daytona3.h" -#include "SDL.h" -#include -static bool keybdleft = false; -static bool keybdright = false; -static bool keybdup = false; -static bool init = false; extern int EnableDamper; extern int DamperStrength; -static EffectTriggers *myTriggers; -static EffectConstants *myConstants; -static Helpers *myHelpers; -extern SDL_Event e; + static wchar_t *settingsFilename = TEXT(".\\FFBPlugin.ini"); -static int ShowButtonNumbersForSetup = GetPrivateProfileInt(TEXT("Settings"), TEXT("ShowButtonNumbersForSetup"), 0, settingsFilename); -static int ChangeGearsViaPlugin = GetPrivateProfileInt(TEXT("Settings"), TEXT("ChangeGearsViaPlugin"), 0, settingsFilename); static int EscapeKeyExitViaPlugin = GetPrivateProfileInt(TEXT("Settings"), TEXT("EscapeKeyExitViaPlugin"), 0, settingsFilename); -static int MenuMovementViaPlugin = GetPrivateProfileInt(TEXT("Settings"), TEXT("MenuMovementViaPlugin"), 0, settingsFilename); -static int Gear1 = GetPrivateProfileInt(TEXT("Settings"), TEXT("Gear1"), 0, settingsFilename); -static int Gear2 = GetPrivateProfileInt(TEXT("Settings"), TEXT("Gear2"), 0, settingsFilename); -static int Gear3 = GetPrivateProfileInt(TEXT("Settings"), TEXT("Gear3"), 0, settingsFilename); -static int Gear4 = GetPrivateProfileInt(TEXT("Settings"), TEXT("Gear4"), 0, settingsFilename); -static int GearUp = GetPrivateProfileInt(TEXT("Settings"), TEXT("GearUp"), 0, settingsFilename); -static int GearDown = GetPrivateProfileInt(TEXT("Settings"), TEXT("GearDown"), 0, settingsFilename); static int HideCursor = GetPrivateProfileInt(TEXT("Settings"), TEXT("HideCursor"), 0, settingsFilename); +static int OriginalFFB = GetPrivateProfileInt(TEXT("Settings"), TEXT("OriginalFFB"), 0, settingsFilename); -static int ThreadLoop() -{ - while (SDL_WaitEvent(&e) != 0) - { - UINT8 gear = myHelpers->ReadByte(0x019B468C, /* isRelativeOffset */ false); +void Daytona3::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) { - if (ShowButtonNumbersForSetup == 1) - { - if (e.type == SDL_JOYBUTTONDOWN) - { - if (e.jbutton.button >= 0) - { - char buff[100]; - sprintf_s(buff, "Button %d Pressed", e.jbutton.button); - MessageBoxA(NULL, buff, "", NULL); - } - } - } - - if (e.type == SDL_JOYBUTTONDOWN) - { - if (ChangeGearsViaPlugin) - { - if (e.jbutton.button == Gear1) - { - myHelpers->WriteByte(0x019B468C, 0x00, false); - } - else if (e.jbutton.button == Gear2) - { - myHelpers->WriteByte(0x019B468C, 0x02, false); - } - else if (e.jbutton.button == Gear3) - { - myHelpers->WriteByte(0x019B468C, 0x01, false); - } - else if (e.jbutton.button == Gear4) - { - myHelpers->WriteByte(0x019B468C, 0x03, false); - } - else if (e.jbutton.button == GearDown && gear > 0x00) - { - myHelpers->WriteByte(0x019B468C, --gear, false); - } - else if (e.jbutton.button == GearUp && gear < 0x03) - { - myHelpers->WriteByte(0x019B468C, ++gear, false); - } - } - } - } - return 0; -} - -static DWORD WINAPI RunningLoop(LPVOID lpParam) -{ - while (true) - { - ThreadLoop(); - Sleep(16); - } -} - -void Daytona3::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) { - - if (!init) - { - myTriggers = triggers; - myConstants = constants; - myHelpers = helpers; - CreateThread(NULL, 0, RunningLoop, NULL, 0, NULL); - init = true; - } - - UINT8 steering = helpers->ReadByte(0x019B4678, false); - UINT8 gamestate = helpers->ReadByte(0x19B5744, false); - UINT8 ff = helpers->ReadByte(0x15AFC46, false); HWND hWnd = FindWindowA(0, ("Daytona Championship USA")); if (HideCursor) - SetCursorPos(2000, 2000); + ShowCursor(false); if (GetAsyncKeyState(VK_ESCAPE) && EscapeKeyExitViaPlugin) { if (hWnd > NULL) { - //SendMessage(hWnd, WM_CLOSE, NULL, NULL); system("taskkill /f /im InpWrapper.exe"); ExitProcess(0); } } - if (MenuMovementViaPlugin == 1) - { - //Menu Movement & Game Initial Screen - if (gamestate == 18 || gamestate == 30) - { - if (steering <= 0x75 && steering > 0x50) - { - //Menu Left - if (!keybdleft) - { - keybdleft = true; - SendMessage(hWnd, WM_KEYDOWN, VK_LEFT, 0); - } - else - { - SendMessage(hWnd, WM_KEYUP, VK_LEFT, 0); - } - } - else if (steering <= 0x50) - { - SendMessage(hWnd, WM_KEYDOWN, VK_LEFT, 0); - } - else if ((steering >= 0x89) && (steering < 0xAE)) - { - //Menu Right - if (!keybdright) - { - keybdright = true; - SendMessage(hWnd, WM_KEYDOWN, VK_RIGHT, 0); - } - else - { - SendMessage(hWnd, WM_KEYUP, VK_RIGHT, 0); - } - } - else if (steering >= 0xAE) - { - SendMessage(hWnd, WM_KEYDOWN, VK_RIGHT, 0); - } - else - { - keybdleft = false; - keybdright = false; - SendMessage(hWnd, WM_KEYUP, VK_RIGHT, 0); - SendMessage(hWnd, WM_KEYUP, VK_LEFT, 0); - } - keybdup = false; - } - else - { - if (!keybdup) - { - keybdup = true; - keybdleft = false; - keybdright = false; - SendMessage(hWnd, WM_KEYUP, VK_RIGHT, 0); - SendMessage(hWnd, WM_KEYUP, VK_LEFT, 0); - } - } - } - if (EnableDamper) triggers->Damper(DamperStrength / 100.0); - if (ff > 15) + if (OriginalFFB) { - double percentForce = (31 - ff) / 15.0; - double percentLength = 100; - triggers->Rumble(percentForce, 0, percentLength); - triggers->Constant(myConstants->DIRECTION_FROM_LEFT, percentForce); - } - else if (ff > 0) - { - double percentForce = (16 - ff) / 15.0; - double percentLength = 100; - triggers->Rumble(0, percentForce, percentLength); - triggers->Constant(myConstants->DIRECTION_FROM_RIGHT, percentForce); - } + UINT8 FFB = helpers->ReadByte(0x131FEC9, true); + UINT8 GameState = helpers->ReadByte(0x15B5744, true); + DWORD TrackSelectedBase = helpers->ReadInt32(0x11B0148, true); + UINT8 TrackSelected = helpers->ReadByte(TrackSelectedBase + 0x4, false); - myTriggers = triggers; - myConstants = constants; - myHelpers = helpers; + if (FFB > 0x80 && FFB <= 0x8F) // ???? + { + double percentForce = (144 - FFB) / 15.0; + double percentLength = 100.0; + triggers->Spring(percentForce); + } + + if (FFB > 0x90 && FFB <= 0x9F) // Roll Right + { + double percentForce = (160 - FFB) / 15.0; + double percentLength = 100.0; + + if ((TrackSelected == 2 || TrackSelected == 4) && GameState == 0x16) + { + triggers->Rumble(0, percentForce, percentLength); + triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); + } + else + { + triggers->Rumble(percentForce, 0, percentLength); + triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); + } + } + + if (FFB > 0xA0 && FFB <= 0xAF) // Roll Left + { + double percentForce = (176 - FFB) / 15.0; + double percentLength = 100.0; + + if ((TrackSelected == 2 || TrackSelected == 4) && GameState == 0x16) + { + triggers->Rumble(percentForce, 0, percentLength); + triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); + } + else + { + triggers->Rumble(0, percentForce, percentLength); + triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); + } + } + + if (FFB > 0xB0 && FFB <= 0xBF) // Shaking across grass etc + { + double percentForce = (192 - FFB) / 15.0; + double percentLength = 100.0; + triggers->Sine(180, 0, percentForce); + triggers->Rumble(percentForce, percentForce, percentLength); + } + + if (FFB > 0xC0 && FFB <= 0xCF) // Spring + Rumble on wheel while racing + { + double percentForce = (207 - FFB) / 15.0; + double SinepercentForce = (FFB - 192) / 96.0; + triggers->Spring(percentForce); + triggers->Sine(40, 0, SinepercentForce); + } + + if (FFB > 0xD0 && FFB <= 0xDF) // Wheel loose as tyres spin (no effect) + { + double percentForce = (224 - FFB) / 15.0; + } + + if (FFB > 0xE0 && FFB <= 0xEF) // Big crash ? + { + double percentForce = (FFB - 224) / 15.0; + triggers->Spring(percentForce); + } + + if (FFB > 0xF0 && FFB <= 0xFF) // Menu only + { + double percentForce = (FFB - 240) / 15.0; + triggers->Spring(percentForce); + } + } + else + { + UINT8 ff = helpers->ReadByte(0x15AFC46, false); + + if (ff > 15) + { + double percentForce = (31 - ff) / 15.0; + double percentLength = 100; + triggers->Rumble(percentForce, 0, percentLength); + triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); + } + else if (ff > 0) + { + double percentForce = (16 - ff) / 15.0; + double percentLength = 100; + triggers->Rumble(0, percentForce, percentLength); + triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); + } + } } \ No newline at end of file diff --git a/Game Files/Daytona3NSE.cpp b/Game Files/Daytona3NSE.cpp index 8018fdd..9ad983b 100644 --- a/Game Files/Daytona3NSE.cpp +++ b/Game Files/Daytona3NSE.cpp @@ -25,14 +25,14 @@ void Daytona3NSE::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTr if (FFB > 0x80 && FFB <= 0x8F) // ???? { - double percentForce = (144 - FFB) / 16.0; + double percentForce = (144 - FFB) / 15.0; double percentLength = 100.0; triggers->Spring(percentForce); } if (FFB > 0x90 && FFB <= 0x9F) // Roll Right { - double percentForce = (160 - FFB) / 16.0; + double percentForce = (160 - FFB) / 15.0; double percentLength = 100.0; if ((TrackSelected == 2 || TrackSelected == 4) && GameState == 0x16) @@ -49,7 +49,7 @@ void Daytona3NSE::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTr if (FFB > 0xA0 && FFB <= 0xAF) // Roll Left { - double percentForce = (176 - FFB) / 16.0; + double percentForce = (176 - FFB) / 15.0; double percentLength = 100.0; if ((TrackSelected == 2 || TrackSelected == 4) && GameState == 0x16) @@ -66,7 +66,7 @@ void Daytona3NSE::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTr if (FFB > 0xB0 && FFB <= 0xBF) // Shaking across grass etc { - double percentForce = (192 - FFB) / 16.0; + double percentForce = (192 - FFB) / 15.0; double percentLength = 100.0; triggers->Sine(180, 0, percentForce); triggers->Rumble(percentForce, percentForce, percentLength); @@ -74,7 +74,7 @@ void Daytona3NSE::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTr if (FFB > 0xC0 && FFB <= 0xCF) // Spring + Rumble on wheel while racing { - double percentForce = (207 - FFB) / 16.0; + double percentForce = (207 - FFB) / 15.0; double SinepercentForce = (FFB - 192) / 96.0; triggers->Spring(percentForce); triggers->Sine(40, 0, SinepercentForce); @@ -82,18 +82,18 @@ void Daytona3NSE::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTr if (FFB > 0xD0 && FFB <= 0xDF) // Wheel loose as tyres spin (no effect) { - double percentForce = (224 - FFB) / 16.0; + double percentForce = (224 - FFB) / 15.0; } if (FFB > 0xE0 && FFB <= 0xEF) // Big crash ? { - double percentForce = (FFB - 224) / 16.0; + double percentForce = (FFB - 224) / 15.0; triggers->Spring(percentForce); } if (FFB > 0xF0 && FFB <= 0xFF) // Menu only { - double percentForce = (FFB - 240) / 16.0; + double percentForce = (FFB - 240) / 15.0; triggers->Spring(percentForce); } } \ No newline at end of file