Add Cubic Scaled Deadband option to Daytona Championship USA
hopefully help sensitivity with controllers Credit http://www.mimirgames.com/articles/games/joystick-input-and-using-deadbands/
This commit is contained in:
parent
0fe76287fd
commit
42ad314538
@ -20,6 +20,26 @@ static bool keybdleft = false;
|
||||
static bool keybdright = false;
|
||||
static bool keybdup = false;
|
||||
|
||||
float Cubic(const float x, const float weight)
|
||||
{
|
||||
return weight * x * x * x + (1.0 - weight) * x;
|
||||
}
|
||||
|
||||
float joystickCubicScaledDeadband(const float x)
|
||||
{
|
||||
const float deadbandCutoff = 0.2f;
|
||||
const float weight = 0.5f;
|
||||
|
||||
if (fabs(x) < deadbandCutoff)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (Cubic(x, weight) - (fabs(x) / x) * Cubic(deadbandCutoff, weight)) / (1.0 - Cubic(deadbandCutoff, weight));
|
||||
}
|
||||
}
|
||||
|
||||
void ShiftUp(BYTE shift)
|
||||
{
|
||||
*(BYTE*)(imageBase + 0x15B468C) = shift + 1;
|
||||
@ -30,9 +50,8 @@ void ShiftDown(BYTE shift)
|
||||
*(BYTE*)(imageBase + 0x15B468C) = shift - 1;
|
||||
}
|
||||
|
||||
static void InjectKeys()
|
||||
static int ThreadLoop()
|
||||
{
|
||||
|
||||
DWORD buttons2 = *wheelSection;
|
||||
DWORD buttons = *ffbOffset;
|
||||
BYTE wheel = *ffbOffset2;
|
||||
@ -48,6 +67,15 @@ static void InjectKeys()
|
||||
|
||||
HWND hWnd = FindWindowA(0, ("Daytona Championship USA"));
|
||||
|
||||
if (ToBool(config["General"]["Cubic Scaled Deadband"]))
|
||||
{
|
||||
float joycubicdeadband = joystickCubicScaledDeadband((*ffbOffset2 - 128) / 128.0);
|
||||
wheel = 128 + (joycubicdeadband * 128.0);
|
||||
|
||||
if (wheel >= 251)
|
||||
wheel = 255;
|
||||
}
|
||||
|
||||
//Menu Movement & Game Initial Screen
|
||||
if (gamestate == 18 || gamestate == 30)
|
||||
{
|
||||
@ -277,13 +305,13 @@ static void InjectKeys()
|
||||
}
|
||||
}
|
||||
|
||||
int(__stdcall* g_origControlsFunction)();
|
||||
|
||||
int __stdcall ControlsFunction()
|
||||
static DWORD WINAPI RunningLoop(LPVOID lpParam)
|
||||
{
|
||||
int result = g_origControlsFunction();
|
||||
InjectKeys();
|
||||
return result;
|
||||
while (true)
|
||||
{
|
||||
ThreadLoop();
|
||||
Sleep(16);
|
||||
}
|
||||
}
|
||||
|
||||
static InitFunction Daytona3Func([]()
|
||||
@ -299,17 +327,18 @@ static InitFunction Daytona3Func([]()
|
||||
injector::MakeNOP(imageBase + 0x1DE10D, 6);
|
||||
injector::MakeNOP(imageBase + 0x29B481, 3);
|
||||
injector::MakeNOP(imageBase + 0x29B513, 4);
|
||||
|
||||
if (ToBool(config["General"]["MSAA4X Disable"]))
|
||||
{
|
||||
injector::WriteMemoryRaw(imageBase + 0x17CD3D, "\x00", 1, true);
|
||||
}
|
||||
|
||||
if (ToBool(config["General"]["Hide Cursor"]))
|
||||
{
|
||||
SetCursorPos(20000, 20000);
|
||||
}
|
||||
MH_Initialize();
|
||||
MH_CreateHook((void*)(imageBase + 0x1E9280), ControlsFunction, (void**)&g_origControlsFunction);
|
||||
MH_EnableHook(MH_ALL_HOOKS);
|
||||
|
||||
CreateThread(NULL, 0, RunningLoop, NULL, 0, NULL);
|
||||
|
||||
}, GameID::Daytona3);
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user