From 0e9093a74b86e58dc4c0e193906a1cc481c47f88 Mon Sep 17 00:00:00 2001 From: bicarus <202771338+bicarus-dev@users.noreply.github.com> Date: Sat, 11 Jul 2026 03:04:49 -0700 Subject: [PATCH] xinput: allow for newer xinput DLL (#794) Fixes #792 --- src/spice2x/rawinput/xinput.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/spice2x/rawinput/xinput.cpp b/src/spice2x/rawinput/xinput.cpp index 351abc3..dfe45d5 100644 --- a/src/spice2x/rawinput/xinput.cpp +++ b/src/spice2x/rawinput/xinput.cpp @@ -179,11 +179,27 @@ XInputSetState( XInputManager::XInputManager() { log_info("xinput", "initialize..."); - this->xinput_lib = LoadLibraryA("xinput1_3.dll"); + + // many systems ship only a newer XInput runtime, so try the known + // DLL names in order of preference until one loads + static const char *xinput_dll_names[] = { + "xinput1_4.dll", + "xinput1_3.dll", + "xinput9_1_0.dll", + }; + const char *loaded_name = nullptr; + for (const char *name : xinput_dll_names) { + this->xinput_lib = LoadLibraryA(name); + if (this->xinput_lib) { + loaded_name = name; + break; + } + } if (!this->xinput_lib) { - log_warning("xinput", "failed to load xinput1_3.dll"); + log_warning("xinput", "failed to load any XInput DLL"); return; } + log_info("xinput", "loaded {}", loaded_name); XInputGetState_addr = reinterpret_cast( GetProcAddress(this->xinput_lib, "XInputGetState")); if (!XInputGetState_addr) {