1
0
mirror of synced 2025-01-20 17:48:51 +01:00

Daytona 3 and Xinput Changes

Adds 1 button for all views including special view and fixes Daytona 3 ffb to have deadzone in middle
This commit is contained in:
Aaron M 2019-11-15 11:08:14 +13:00
parent 6881e89810
commit 0aab9817e9
2 changed files with 201 additions and 154 deletions

View File

@ -15,15 +15,19 @@ bool daytonaPressStart = false;
uintptr_t imageBase;
bool shiftup = false;
bool shiftdown = false;
static bool viewchange = false;
static bool keybdleft = false;
static bool keybdright = false;
static bool keybdup = false;
void ShiftUp(BYTE shift)
{
*(BYTE *)(imageBase + 0x15B468C) = shift + 1;
*(BYTE*)(imageBase + 0x15B468C) = shift + 1;
}
void ShiftDown(BYTE shift)
{
*(BYTE *)(imageBase + 0x15B468C) = shift - 1;
*(BYTE*)(imageBase + 0x15B468C) = shift - 1;
}
static void InjectKeys()
@ -35,16 +39,77 @@ static void InjectKeys()
BYTE gas = *ffbOffset3;
BYTE brake = *ffbOffset4;
BYTE gamestate = *(BYTE *)(imageBase + 0x15B5744);
BYTE gear = *(BYTE *)(imageBase + 0x15B468C);
BYTE gamestate = *(BYTE*)(imageBase + 0x15B5744);
BYTE gear = *(BYTE*)(imageBase + 0x15B468C);
BYTE viewread = *(BYTE*)(imageBase + 0x15B5DB0);
*(BYTE *)(imageBase + 0x15B4679) = gas;
*(BYTE *)(imageBase + 0x15B467A) = brake;
*(BYTE*)(imageBase + 0x15B4679) = gas;
*(BYTE*)(imageBase + 0x15B467A) = brake;
DWORD track = *(DWORD *)(imageBase + 0x011B0148);
HWND hWnd = FindWindowA(0, ("Daytona Championship USA"));
//Menu Movement & Game Initial Screen
if (gamestate == 18 || gamestate == 30)
{
if ((wheel <= 0x75) && (wheel > 0x50))
{
//Menu Left
if (!keybdleft)
{
keybdleft = true;
SendMessage(hWnd, WM_KEYDOWN, VK_LEFT, 0);
}
else
{
SendMessage(hWnd, WM_KEYUP, VK_LEFT, 0);
}
}
else if (wheel <= 0x50)
{
SendMessage(hWnd, WM_KEYDOWN, VK_LEFT, 0);
}
else if ((wheel >= 0x89) && (wheel < 0xAE))
{
//Menu Right
if (!keybdright)
{
keybdright = true;
SendMessage(hWnd, WM_KEYDOWN, VK_RIGHT, 0);
}
else
{
SendMessage(hWnd, WM_KEYUP, VK_RIGHT, 0);
}
}
else if (wheel >= 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);
}
}
DWORD track = *(DWORD*)(imageBase + 0x011B0148);
if (track != 0)
{
BYTE track1 = *(BYTE *)(track + 0x4);
BYTE track1 = *(BYTE*)(track + 0x4);
#ifdef _DEBUG
info(true, "%02X %02X", track1, gamestate);
#endif
@ -52,16 +117,16 @@ static void InjectKeys()
{
BYTE reverse = wheel * 0xFF;
if (reverse == 0x00)
*(BYTE *)(imageBase + 0x15B4678) = 0xFF;
*(BYTE*)(imageBase + 0x15B4678) = 0xFF;
else
*(BYTE *)(imageBase + 0x15B4678) = reverse;
*(BYTE*)(imageBase + 0x15B4678) = reverse;
#ifdef _DEBUG
info(true, "Reverse wheel");
#endif
}
else
{
*(BYTE *)(imageBase + 0x15B4678) = wheel;
*(BYTE*)(imageBase + 0x15B4678) = wheel;
#ifdef _DEBUG
info(true, "Normal wheel1");
#endif
@ -69,7 +134,7 @@ static void InjectKeys()
}
else
{
*(BYTE *)(imageBase + 0x15B4678) = wheel;
*(BYTE*)(imageBase + 0x15B4678) = wheel;
#ifdef _DEBUG
info(true, "Normal wheel2");
#endif
@ -84,68 +149,28 @@ static void InjectKeys()
daytonaPressStart = false;
}
if (wheel <= 0x40)
{
//Menu Left
DWORD p = *(DWORD *)(imageBase + 0x1AAFFF0);
if (p != 0)
{
DWORD p1 = *(DWORD *)(p + 0x00);
if (p1 != 0)
{
*(BYTE *)(p1 + 0x25) = 0xFF;
}
}
}
else if (wheel >= 0xC0)
{
//Menu Right
DWORD p = *(DWORD *)(imageBase + 0x1AAFFF0);
if (p != 0)
{
DWORD p1 = *(DWORD *)(p + 0x00);
if (p1 != 0)
{
*(BYTE *)(p1 + 0x27) = 0xFF;
}
}
}
else
{
DWORD p = *(DWORD *)(imageBase + 0x1AAFFF0);
if (p != 0)
{
DWORD p1 = *(DWORD *)(p + 0x00);
if (p1 != 0)
{
*(BYTE *)(p1 + 0x25) = 0x00;
*(BYTE *)(p1 + 0x27) = 0x00;
}
}
}
if (buttons == 0x01)
{
//Inject Start
DWORD p = *(DWORD *)(imageBase + 0x1AB0010);
DWORD p = *(DWORD*)(imageBase + 0x1AB0010);
if (p != 0)
{
DWORD p1 = *(DWORD *)(p + 0x00);
DWORD p1 = *(DWORD*)(p + 0x00);
if (p1 != 0)
{
*(DWORD *)(p1 + 0x08) = 0x01;
*(DWORD*)(p1 + 0x08) = 0x01;
}
}
}
else
{
DWORD p = *(DWORD *)(imageBase + 0x1AB0010);
DWORD p = *(DWORD*)(imageBase + 0x1AB0010);
if (p != 0)
{
DWORD p1 = *(DWORD *)(p + 0x00);
DWORD p1 = *(DWORD*)(p + 0x00);
if (p1 != 0)
{
*(DWORD *)(p1 + 0x08) = 0x00;
*(DWORD*)(p1 + 0x08) = 0x00;
}
}
}
@ -155,7 +180,7 @@ static void InjectKeys()
if (!shiftup)
{
shiftup = true;
ShiftUp(*(BYTE *)(imageBase + 0x15B468C));
ShiftUp(*(BYTE*)(imageBase + 0x15B468C));
}
}
else
@ -168,7 +193,7 @@ static void InjectKeys()
if (!shiftdown)
{
shiftdown = true;
ShiftDown(*(BYTE *)(imageBase + 0x15B468C));
ShiftDown(*(BYTE*)(imageBase + 0x15B468C));
}
}
else
@ -179,69 +204,80 @@ static void InjectKeys()
if (buttons2 == 0x01)
{
//Gear Change 1
*(BYTE *)(imageBase + 0x15B468C) = 0x00;
*(BYTE*)(imageBase + 0x15B468C) = 0x00;
}
if (buttons2 == 0x02)
{
//Gear Change 2
*(BYTE *)(imageBase + 0x15B468C) = 0x01;
*(BYTE*)(imageBase + 0x15B468C) = 0x01;
}
if (buttons2 == 0x04)
{
//Gear Change 3
*(BYTE *)(imageBase + 0x15B468C) = 0x02;
*(BYTE*)(imageBase + 0x15B468C) = 0x02;
}
if (buttons2 == 0x08)
{
//Gear Change 4
*(BYTE *)(imageBase + 0x15B468C) = 0x03;
*(BYTE*)(imageBase + 0x15B468C) = 0x03;
}
if (ToBool(config["General"]["View Change 1 To Cycle All Views"]))
{
if ((buttons2 == 0x10) && (viewread < 4)) //INCLUDES SPECIAL VIEW
{
//View Change 1
if (!viewchange)
{
viewchange = true;
*(BYTE*)(imageBase + 0x15B5DB0) = ++viewread;
}
}
else if ((buttons2 == 0x10) && (viewread == 4))
{
if (!viewchange)
{
viewchange = true;
*(BYTE*)(imageBase + 0x15B5DB0) = 0x00;
}
}
else
{
viewchange = false;
}
}
else
{
if (buttons2 == 0x10)
{
//View Change 1
{
*(DWORD *)(imageBase + 0x15B5DB0) = 0x00;
}
*(DWORD*)(imageBase + 0x15B5DB0) = 0x00;
}
if (buttons2 == 0x20)
{
//View Change 2
{
*(DWORD *)(imageBase + 0x15B5DB0) = 0x01;
}
*(DWORD*)(imageBase + 0x15B5DB0) = 0x01;
}
if (buttons2 == 0x40)
{
//View Change 3
{
*(DWORD *)(imageBase + 0x15B5DB0) = 0x02;
}
*(DWORD*)(imageBase + 0x15B5DB0) = 0x02;
}
if (buttons2 == 0x80)
{
//View Change 4
{
*(DWORD *)(imageBase + 0x15B5DB0) = 0x03;
}
}
if (buttons2 == 0xF0)
{
//View Change 5
{
*(DWORD *)(imageBase + 0x15B5DB0) = 0x04;
*(DWORD*)(imageBase + 0x15B5DB0) = 0x03;
}
}
}
int(__stdcall *g_origControlsFunction)();
int(__stdcall* g_origControlsFunction)();
int __stdcall ControlsFunction()
{
@ -251,7 +287,7 @@ int __stdcall ControlsFunction()
}
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);
@ -275,5 +311,5 @@ static InitFunction Daytona3Func([]()
MH_CreateHook((void*)(imageBase + 0x1E9280), ControlsFunction, (void**)&g_origControlsFunction);
MH_EnableHook(MH_ALL_HOOKS);
}, GameID::Daytona3);
}, GameID::Daytona3);
#endif

View File

@ -6,7 +6,7 @@
struct XboxOneControllerHandler
{
struct usb_dev_handle *handle;
struct usb_dev_handle* handle;
bool isConnected;
XBOXONE_STATE controllerState;
@ -16,7 +16,7 @@ struct XboxOneControllerHandler
XINPUT_GAMEPAD lastGamepadState;
};
XboxOneControllerHandler *controllerHandler[4] = { NULL, NULL, NULL, NULL };
XboxOneControllerHandler* controllerHandler[4] = { NULL, NULL, NULL, NULL };
HANDLE XboxOneControllerThread[4] = { 0 };
HANDLE XboxOneControllerMutex[4] = { 0 };
@ -162,7 +162,18 @@ DWORD WINAPI XInputGetState
if (GameDetect::currentGame == GameID::Daytona3)
{
gamepadState.bRightTrigger = daytonaPressStart ? 0xFF : 0x00;
gamepadState.sThumbLX |= (-(33024 - *ffbOffset2) * 255);
if (*ffbOffset2 < 1)
{
gamepadState.sThumbLX |= 257 - (-(32767 - *ffbOffset2) * 257);
}
else if ((*ffbOffset2 >= 121) && (*ffbOffset2 <= 133)) //Deadzone for FFB
{
gamepadState.sThumbLX == 32768;
}
else
{
gamepadState.sThumbLX |= (-(32768 - *ffbOffset2) * 257);
}
}
#endif
if (pState->dwPacketNumber == UINT_MAX)
@ -414,7 +425,7 @@ 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 || GameDetect::currentGame == GameID::GHA || GameDetect::currentGame == GameID::JLeague)
{
controllerInit = true;
@ -438,5 +449,5 @@ static InitFunction XInputHook([]()
MH_EnableHook(MH_ALL_HOOKS);
}
});
});
#pragma optimize("", on)´