From 38480942c6f1bf845bec5f2081657a71a115b61c Mon Sep 17 00:00:00 2001 From: Redline <> Date: Fri, 3 Oct 2025 23:14:09 +0200 Subject: [PATCH 1/2] Adjustable controller deadzone --- mc2hook/mc2hook/age/input/input.cpp | 19 ++++++++++++++- mc2hook/mc2hook/age/input/input.h | 4 +++- mc2hook/mc2hook/handlers/DeadZoneHandler.cpp | 25 ++++++++++++++++++++ mc2hook/mc2hook/handlers/DeadZoneHandler.h | 9 +++++++ mc2hook/mc2hook/handlers/handlers.h | 2 ++ mc2hook/mc2hook/mc2hook.vcxproj | 2 ++ 6 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 mc2hook/mc2hook/handlers/DeadZoneHandler.cpp create mode 100644 mc2hook/mc2hook/handlers/DeadZoneHandler.h diff --git a/mc2hook/mc2hook/age/input/input.cpp b/mc2hook/mc2hook/age/input/input.cpp index c4b44b8..65d45bf 100644 --- a/mc2hook/mc2hook/age/input/input.cpp +++ b/mc2hook/mc2hook/age/input/input.cpp @@ -1,4 +1,21 @@ #include "input.h" declfield(ioInput::bUseJoystick)(0x679674); -declfield(ioInput::bUseKeyboard)(0x679675); \ No newline at end of file +declfield(ioInput::bUseKeyboard)(0x679675); + +float ioInput::ioAddDeadZone(float originalValue, float deadZone) +{ + float val; + + if (originalValue > deadZone) { + val = (originalValue - deadZone) / (1.0f - deadZone); + } + else if (originalValue < -deadZone) { + val = (originalValue + deadZone) / (1.0f - deadZone); + } + else { + val = 0.0f; + } + + return val; +} diff --git a/mc2hook/mc2hook/age/input/input.h b/mc2hook/mc2hook/age/input/input.h index b79d43d..074a22f 100644 --- a/mc2hook/mc2hook/age/input/input.h +++ b/mc2hook/mc2hook/age/input/input.h @@ -6,4 +6,6 @@ class ioInput public: static hook::Type bUseKeyboard; static hook::Type bUseJoystick; -}; \ No newline at end of file + + static float ioAddDeadZone(float originalValue, float deadZone); +}; diff --git a/mc2hook/mc2hook/handlers/DeadZoneHandler.cpp b/mc2hook/mc2hook/handlers/DeadZoneHandler.cpp new file mode 100644 index 0000000..be5d587 --- /dev/null +++ b/mc2hook/mc2hook/handlers/DeadZoneHandler.cpp @@ -0,0 +1,25 @@ +#include "DeadZoneHandler.h" +#include + +float deadZoneMultiplier; + +float DeadZoneHandler::ioAddDeadZone(float originalValue, float deadZone) +{ + originalValue *= deadZoneMultiplier; + return ioInput::ioAddDeadZone(originalValue, deadZone); +} + +void DeadZoneHandler::Install() +{ + deadZoneMultiplier = HookConfig::GetFloat("Input", "DeadZoneMultiplier", 1.0f); + + InstallCallback("Deadzone Handler", "ioAddDeadZone", + &ioAddDeadZone, { + cb::call(0x426603), + cb::call(0x46752D), + cb::call(0x561D77), + cb::call(0x561D95), + cb::call(0x5689E0), + cb::call(0x60492A), + }); +} diff --git a/mc2hook/mc2hook/handlers/DeadZoneHandler.h b/mc2hook/mc2hook/handlers/DeadZoneHandler.h new file mode 100644 index 0000000..2e1a5aa --- /dev/null +++ b/mc2hook/mc2hook/handlers/DeadZoneHandler.h @@ -0,0 +1,9 @@ +#pragma once +#include + +class DeadZoneHandler +{ +public: + static float ioAddDeadZone(float originalValue, float deadZone); + static void Install(); +}; diff --git a/mc2hook/mc2hook/handlers/handlers.h b/mc2hook/mc2hook/handlers/handlers.h index ea7a661..37c8ecc 100644 --- a/mc2hook/mc2hook/handlers/handlers.h +++ b/mc2hook/mc2hook/handlers/handlers.h @@ -17,6 +17,7 @@ #include #include #include +#include #include @@ -50,6 +51,7 @@ static void InstallMainHandlers() InstallHandler("Chat Handler"); InstallHandler("Game Init Handler"); InstallHandler("Reflection Fidelity Handller"); + InstallHandler("Dead Zone Handler"); InstallHandler("SRH"); } \ No newline at end of file diff --git a/mc2hook/mc2hook/mc2hook.vcxproj b/mc2hook/mc2hook/mc2hook.vcxproj index 056702b..8be2d49 100644 --- a/mc2hook/mc2hook/mc2hook.vcxproj +++ b/mc2hook/mc2hook/mc2hook.vcxproj @@ -191,6 +191,7 @@ + @@ -244,6 +245,7 @@ + From 36f6ca349f287a272094772133b27c84fc749e2d Mon Sep 17 00:00:00 2001 From: Redline <> Date: Sat, 4 Oct 2025 18:03:26 +0200 Subject: [PATCH 2/2] Controller steer speed variable --- mc2hook/mc2hook/handlers/SteeringSmootherHandler.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mc2hook/mc2hook/handlers/SteeringSmootherHandler.cpp b/mc2hook/mc2hook/handlers/SteeringSmootherHandler.cpp index bbf3174..1a6129f 100644 --- a/mc2hook/mc2hook/handlers/SteeringSmootherHandler.cpp +++ b/mc2hook/mc2hook/handlers/SteeringSmootherHandler.cpp @@ -9,6 +9,8 @@ static float steerValue = 0.0f; static float steerSpeed = 4.0f; static float steerSpeedOut = 6.0f; +float controllerSteerSpeed; + void SteeringSmootherHandler::Update() { hook::Thunk<0x46B330>::Call(this); // call original @@ -43,4 +45,8 @@ void SteeringSmootherHandler::Install() if (datArgParser::Get("smoothsteer")) { InstallVTableHook("Input Update", &Update, { 0x63D0C4 }); } + + // Exposing controller speed value + controllerSteerSpeed = HookConfig::GetFloat("Input", "ControllerSteerSpeed", 10.0f); + mem::write(0x46B28E + 3, static_cast(controllerSteerSpeed)); }