From bbe3cc1f4757c9afe041f8d84dd6f53c2c566d6f Mon Sep 17 00:00:00 2001 From: ergo720 <45463469+ergo720@users.noreply.github.com> Date: Thu, 18 Jun 2020 14:57:14 +0200 Subject: [PATCH] Load the most appropriate xinput dll based on the Windows version --- src/common/input/XInputPad.cpp | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/src/common/input/XInputPad.cpp b/src/common/input/XInputPad.cpp index 8162e342e..8b50ab537 100644 --- a/src/common/input/XInputPad.cpp +++ b/src/common/input/XInputPad.cpp @@ -38,11 +38,6 @@ #include "core\kernel\support\Emu.h" #include "InputManager.h" -// For MinGW -#ifndef XINPUT_DLL -#define XINPUT_DLL "xinput1_3.dll" -#endif - #ifndef XINPUT_GAMEPAD_GUIDE #define XINPUT_GAMEPAD_GUIDE 0x0400 #endif @@ -106,19 +101,19 @@ namespace XInput { std::unique_lock lck(Mtx); - // Because we use _WIN32_WINNT=0x0601, this will load the XInput 9.1.0 library - // The 9.1.0 (Win7) doesn't provide support for the guide button, but the legacy 1.3 does. Unfortunately, it requires - // that the user has installed the June 2010 release of the DirectX SDK to be available. If they didn't, we will default - // to the 9.1.0 instead of failing the initialization - if (std::string(XINPUT_DLL).compare(TEXT("xinput9_1_0.dll")) == 0) { - hXInput = ::LoadLibrary(TEXT("xinput1_3.dll")); - } + // will only work on Win8/10; provides guide button info + hXInput = ::LoadLibrary(TEXT("xinput1_4.dll")); if (!hXInput) { - hXInput = ::LoadLibrary(XINPUT_DLL); + // will only work if the user has installed the June 2010 release of the DirectX SDK; provides guide button info + hXInput = ::LoadLibrary(TEXT("xinput1_3.dll")); if (!hXInput) { - EmuLog(LOG_LEVEL::ERROR2, "Failed to initialize XInput subsystem!"); - XInputInitStatus = XINPUT_INIT_ERROR; - return; + // will work on Win7; does NOT provide guide button info + hXInput = ::LoadLibrary(TEXT("xinput9_1_0.dll")); + if (!hXInput) { + EmuLog(LOG_LEVEL::ERROR2, "Failed to initialize XInput subsystem!"); + XInputInitStatus = XINPUT_INIT_ERROR; + return; + } } }