Skip to content

Commit

Permalink
Manually hook OnRenderStart
Browse files Browse the repository at this point in the history
  • Loading branch information
ASpoonPlaysGames committed Aug 27, 2024
1 parent 5aae421 commit 98bc47d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions primedev/client/latencyflex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ ConVar* Cvar_r_latencyflex;

void (*m_winelfx_WaitAndBeginFrame)();

// clang-format off
AUTOHOOK(OnRenderStart, client.dll + 0x1952C0,
void, __fastcall, ())
// clang-format on
void(__fastcall* o_pOnRenderStart)() = nullptr;
void __fastcall h_OnRenderStart()
{
if (Cvar_r_latencyflex->GetBool() && m_winelfx_WaitAndBeginFrame)
m_winelfx_WaitAndBeginFrame();

OnRenderStart();
o_pOnRenderStart();
}

ON_DLL_LOAD_CLIENT_RELIESON("client.dll", LatencyFlex, ConVar, (CModule module))
Expand All @@ -37,6 +35,8 @@ ON_DLL_LOAD_CLIENT_RELIESON("client.dll", LatencyFlex, ConVar, (CModule module))
}

AUTOHOOK_DISPATCH()
o_pOnRenderStart = module.Offset(0x1952C0).RCast<decltype(o_pOnRenderStart)>();
HookAttach(&(PVOID&)o_pOnRenderStart, (PVOID)h_OnRenderStart);

spdlog::info("LatencyFleX initialized.");
Cvar_r_latencyflex = new ConVar("r_latencyflex", "1", FCVAR_ARCHIVE, "Whether or not to use LatencyFleX input latency reduction.");
Expand Down

0 comments on commit 98bc47d

Please sign in to comment.