diff --git a/OpenParrot/src/Functions/Games/Other/Daytona3.cpp b/OpenParrot/src/Functions/Games/Other/Daytona3.cpp index ee739ce..c3d57e2 100644 --- a/OpenParrot/src/Functions/Games/Other/Daytona3.cpp +++ b/OpenParrot/src/Functions/Games/Other/Daytona3.cpp @@ -41,7 +41,14 @@ static void InjectKeys() if (track != 0) { BYTE track1 = *(BYTE *)(track + 0x4); +<<<<<<< HEAD +======= +#ifdef _DEBUG + info(true, "%02X %02X", track1, gamestate); +#endif + if ((track1 == 2 || track1 == 4) && (gamestate == 0x16)) +>>>>>>> c000b7c7ca96e0804e4505624bbd470887a189d8 { info(true, "%02X %02X", track1, gamestate); if ((track1 == 2 || track1 == 4) && (gamestate == 0x16)) @@ -54,16 +61,32 @@ static void InjectKeys() info(true, "Reverse wheel"); } else +<<<<<<< HEAD { *(BYTE *)(imageBase + 0x15B4678) = wheel; info(true, "Normal wheel1"); } +======= + *(BYTE *)(imageBase + 0x15B4678) = reverse; +#ifdef _DEBUG + info(true, "Reverse wheel"); +#endif + } + else + { + *(BYTE *)(imageBase + 0x15B4678) = wheel; +#ifdef _DEBUG + info(true, "Normal wheel1"); +#endif +>>>>>>> c000b7c7ca96e0804e4505624bbd470887a189d8 } } else { *(BYTE *)(imageBase + 0x15B4678) = wheel; +#ifdef _DEBUG info(true, "Normal wheel2"); +#endif } @@ -225,8 +248,18 @@ static void InjectKeys() } } +int(__stdcall *g_origControlsFunction)(); + +int __stdcall ControlsFunction() +{ + int result = g_origControlsFunction(); + InjectKeys(); + return result; +} + static InitFunction Daytona3Func([]() { + imageBase = (uintptr_t)GetModuleHandleA(0); injector::WriteMemoryRaw(imageBase + 0xDD697, "\x90\x90\x90\x90\x90\x90\x38\x05\xC8\xF9\x5A\x01\x90\x90\x90\x90\x90\x90", 18, true); injector::WriteMemoryRaw(imageBase + 0x12958F, "\x33\xC0\x8A\x45\x08\x90\x90\x90\x90\x72\x08\x66\xA3\x46\xFC\x5A\x01\xEB\x06\x66\xA3\x44\xFC\x5A\x01\x31\xFF\x31\xF6\x47\xBE\x0F\x00\x00\x00\xEB\x4C\x90\x90\x90\x90", 41, true); @@ -236,7 +269,9 @@ static InitFunction Daytona3Func([]() injector::MakeNOP(imageBase + 0x1DE10D, 6); injector::MakeNOP(imageBase + 0x29B481, 3); injector::MakeNOP(imageBase + 0x29B513, 4); + MH_Initialize(); + MH_CreateHook((void*)(imageBase + 0x1E9280), ControlsFunction, (void**)&g_origControlsFunction); + MH_EnableHook(MH_ALL_HOOKS); - injector::MakeCALL(imageBase + 0x1DDDFA, InjectKeys); }, GameID::Daytona3); #endif \ No newline at end of file diff --git a/OpenParrot/src/Functions/Nesica_Libs/FastIoEmu.cpp b/OpenParrot/src/Functions/Nesica_Libs/FastIoEmu.cpp index 1f22c28..20bad97 100644 --- a/OpenParrot/src/Functions/Nesica_Libs/FastIoEmu.cpp +++ b/OpenParrot/src/Functions/Nesica_Libs/FastIoEmu.cpp @@ -1,6 +1,5 @@ #include #include "Utility/InitFunction.h" - #include static uint8_t g_fastIOValues[64]; diff --git a/OpenParrot/src/Functions/PokkenXInputEmu.cpp b/OpenParrot/src/Functions/PokkenXInputEmu.cpp index a3a1e9c..7742c4e 100644 --- a/OpenParrot/src/Functions/PokkenXInputEmu.cpp +++ b/OpenParrot/src/Functions/PokkenXInputEmu.cpp @@ -23,6 +23,8 @@ HANDLE XboxOneControllerMutex[4] = { 0 }; static unsigned short idVendor = 0x045E; static unsigned short idProduct = 0x02D1; +static bool daytonaPressStart = false; + int configuration = 1; int interface = 0; int endpointIn = 0x81; @@ -72,7 +74,15 @@ DWORD WINAPI XInputGetState { XINPUT_GAMEPAD gamepadState = { 0 }; + if (GameDetect::currentGame == GameID::Daytona3) gamepadState.wButtons |= *ffbOffset; + else + gamepadState.wButtons |= 0; + + if (GameDetect::currentGame == GameID::Daytona3) + { + gamepadState.bRightTrigger = daytonaPressStart ? 0xFF : 0x00; + } if (pState->dwPacketNumber == UINT_MAX) pState->dwPacketNumber = 0; @@ -267,7 +277,15 @@ DWORD WINAPI XInputGetStateEx { XINPUT_GAMEPAD gamepadState = { 0 }; - gamepadState.wButtons = *ffbOffset; + if (GameDetect::currentGame == GameID::Daytona3) + gamepadState.wButtons = *ffbOffset; + else + gamepadState.wButtons = 0; + + if (GameDetect::currentGame == GameID::Daytona3) + { + gamepadState.bRightTrigger = daytonaPressStart ? 0xFF : 0x00; + } if (pState->dwPacketNumber == UINT_MAX) pState->dwPacketNumber = 0; @@ -308,6 +326,7 @@ __in XINPUT_VIBRATION_EX* pVibration // The vibration information to send to } } +<<<<<<< HEAD LPCWSTR libName = L"xinput1_3.dll"; LPCWSTR daytonalibName = L"xinput9_1_0.dll"; LPCWSTR ptrToUse; @@ -338,4 +357,37 @@ static InitFunction XInputHook([]() MH_EnableHook(MH_ALL_HOOKS); } }); -#pragma optimize("", on)´ \ No newline at end of file +#pragma optimize("", on)´ +======= +LPCWSTR libName = L"xinput1_3.dll"; +LPCWSTR daytonalibName = L"xinput9_1_0.dll"; +LPCWSTR ptrToUse; + +static InitFunction XInputHook([]() +{ + if (GameDetect::currentGame == GameID::PokkenTournament || GameDetect::currentGame == GameID::SchoolOfRagnarok || GameDetect::currentGame == GameID::Daytona3) + { + controllerInit = true; + + MH_Initialize(); + + if (GameDetect::currentGame == GameID::Daytona3) + ptrToUse = daytonalibName; + else + ptrToUse = libName; + + MH_CreateHookApi(ptrToUse, "XInputGetState", &XInputGetState, NULL); + MH_CreateHookApi(ptrToUse, "XInputSetState", &XInputSetState, NULL); + MH_CreateHookApi(ptrToUse, "XInputGetCapabilities", &XInputGetCapabilities, NULL); + MH_CreateHookApi(ptrToUse, "XInputEnable", &XInputEnable, NULL); + MH_CreateHookApi(ptrToUse, "XInputGetDSoundAudioDeviceGuids", &XInputGetDSoundAudioDeviceGuids, NULL); + MH_CreateHookApi(ptrToUse, "XInputGetBatteryInformation", &XInputGetBatteryInformation, NULL); + MH_CreateHookApi(ptrToUse, "XInputGetKeystroke", &XInputGetKeystroke, NULL); + MH_CreateHookApi(ptrToUse, "XInputGetStateEx", &XInputGetStateEx, NULL); + MH_CreateHookApi(ptrToUse, "XInputSetStateEx", &XInputSetStateEx, NULL); + + MH_EnableHook(MH_ALL_HOOKS); + } +}); +#pragma optimize("", on) +>>>>>>> c000b7c7ca96e0804e4505624bbd470887a189d8 diff --git a/OpenParrot/src/Utility/GameDetect.cpp b/OpenParrot/src/Utility/GameDetect.cpp index 61e0ec9..0c70edc 100644 --- a/OpenParrot/src/Utility/GameDetect.cpp +++ b/OpenParrot/src/Utility/GameDetect.cpp @@ -369,6 +369,12 @@ void GameDetect::DetectCurrentGame() currentGame = GameID::MachStorm; break; } + if(*(uint32_t*)(moduleBase + 0xABB7) == 0x00E445C7 && + *(uint32_t*)(moduleBase + 0xABB7 + 4) == 0xC7000100) + { + currentGame = GameID::Daytona3; + break; + } #else // X64 // School of Ragnarok