aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDLL/client/latencyflex.cpp
diff options
context:
space:
mode:
authorEmma Miler <emma.pi@protonmail.com>2022-12-19 19:32:16 +0100
committerGeckoEidechse <gecko.eidechse+git@pm.me>2023-01-04 14:45:48 +0100
commit27afb0ba38dcf0e74a4d09ba43e73261542b8e96 (patch)
tree28c737bdecc761fc8ca5257adfafaf2b325e1918 /NorthstarDLL/client/latencyflex.cpp
parentaf64117f09ba9b70d27c6b6da885d0474180849b (diff)
downloadNorthstarLauncher-27afb0ba38dcf0e74a4d09ba43e73261542b8e96.tar.gz
NorthstarLauncher-27afb0ba38dcf0e74a4d09ba43e73261542b8e96.zip
Restructuring (#365)
* Remove launcher proxy * Restructuring * More restructuring * Fix include dirs * Fix merge * Remove clang thing * Filters * Oops
Diffstat (limited to 'NorthstarDLL/client/latencyflex.cpp')
-rw-r--r--NorthstarDLL/client/latencyflex.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/NorthstarDLL/client/latencyflex.cpp b/NorthstarDLL/client/latencyflex.cpp
new file mode 100644
index 00000000..a1ef72ca
--- /dev/null
+++ b/NorthstarDLL/client/latencyflex.cpp
@@ -0,0 +1,44 @@
+#include "pch.h"
+#include "core/convar/convar.h"
+
+AUTOHOOK_INIT()
+
+ConVar* Cvar_r_latencyflex;
+
+void (*m_winelfx_WaitAndBeginFrame)();
+
+// clang-format off
+AUTOHOOK(OnRenderStart, client.dll + 0x1952C0,
+void, __fastcall, ())
+// clang-format on
+{
+ if (Cvar_r_latencyflex->GetBool() && m_winelfx_WaitAndBeginFrame)
+ m_winelfx_WaitAndBeginFrame();
+
+ OnRenderStart();
+}
+
+ON_DLL_LOAD_CLIENT_RELIESON("client.dll", LatencyFlex, ConVar, (CModule module))
+{
+ // Connect to the LatencyFleX service
+ // LatencyFleX is an open source vendor agnostic replacement for Nvidia Reflex input latency reduction technology.
+ // https://ishitatsuyuki.github.io/post/latencyflex/
+ HMODULE pLfxModule;
+
+ if (pLfxModule = LoadLibraryA("latencyflex_layer.dll"))
+ m_winelfx_WaitAndBeginFrame =
+ reinterpret_cast<void (*)()>(reinterpret_cast<void*>(GetProcAddress(pLfxModule, "lfx_WaitAndBeginFrame")));
+ else if (pLfxModule = LoadLibraryA("latencyflex_wine.dll"))
+ m_winelfx_WaitAndBeginFrame =
+ reinterpret_cast<void (*)()>(reinterpret_cast<void*>(GetProcAddress(pLfxModule, "winelfx_WaitAndBeginFrame")));
+ else
+ {
+ spdlog::info("Unable to load LatencyFleX library, LatencyFleX disabled.");
+ return;
+ }
+
+ AUTOHOOK_DISPATCH()
+
+ spdlog::info("LatencyFleX initialized.");
+ Cvar_r_latencyflex = new ConVar("r_latencyflex", "1", FCVAR_ARCHIVE, "Whether or not to use LatencyFleX input latency reduction.");
+}