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/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)); } 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 @@ +