Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion mc2hook/mc2hook/age/input/input.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
#include "input.h"

declfield(ioInput::bUseJoystick)(0x679674);
declfield(ioInput::bUseKeyboard)(0x679675);
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;
}
4 changes: 3 additions & 1 deletion mc2hook/mc2hook/age/input/input.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ class ioInput
public:
static hook::Type<bool> bUseKeyboard;
static hook::Type<bool> bUseJoystick;
};

static float ioAddDeadZone(float originalValue, float deadZone);
};
25 changes: 25 additions & 0 deletions mc2hook/mc2hook/handlers/DeadZoneHandler.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "DeadZoneHandler.h"
#include <age/input/input.h>

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),
});
}
9 changes: 9 additions & 0 deletions mc2hook/mc2hook/handlers/DeadZoneHandler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once
#include <mc2hook\mc2hook.h>

class DeadZoneHandler
{
public:
static float ioAddDeadZone(float originalValue, float deadZone);
static void Install();
};
6 changes: 6 additions & 0 deletions mc2hook/mc2hook/handlers/SteeringSmootherHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>(this); // call original
Expand Down Expand Up @@ -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<float>(controllerSteerSpeed));
}
2 changes: 2 additions & 0 deletions mc2hook/mc2hook/handlers/handlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <handlers\InputHandler.h>
#include <handlers\BorderlessHandler.h>
#include <handlers\ReflectionFidelityHandler.h>
#include <handlers/DeadZoneHandler.h>

#include <handlers\StateResearchHook.h>

Expand Down Expand Up @@ -50,6 +51,7 @@ static void InstallMainHandlers()
InstallHandler<ChatHandler>("Chat Handler");
InstallHandler<InitHandler>("Game Init Handler");
InstallHandler<ReflectionFidelityHandler>("Reflection Fidelity Handller");
InstallHandler<DeadZoneHandler>("Dead Zone Handler");

InstallHandler<StateResearchHook>("SRH");
}
2 changes: 2 additions & 0 deletions mc2hook/mc2hook/mc2hook.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
<ClInclude Include="handlers\ChatHandler.h" />
<ClInclude Include="handlers\CustomExceptionHandler.h" />
<ClInclude Include="handlers\CustomVehicleHandler.h" />
<ClInclude Include="handlers\DeadZoneHandler.h" />
<ClInclude Include="handlers\FontCrashFixHandler.h" />
<ClInclude Include="handlers\handlers.h" />
<ClInclude Include="handlers\HybridFileMethodsHandler.h" />
Expand Down Expand Up @@ -244,6 +245,7 @@
<ClCompile Include="handlers\ChatHandler.cpp" />
<ClCompile Include="handlers\CustomExceptionHandler.cpp" />
<ClCompile Include="handlers\CustomVehicleHandler.cpp" />
<ClCompile Include="handlers\DeadZoneHandler.cpp" />
<ClCompile Include="handlers\FontCrashFixHandler.cpp" />
<ClCompile Include="handlers\HybridFileMethodsHandler.cpp" />
<ClCompile Include="handlers\InputHandler.cpp" />
Expand Down