From 834652922a0953a17cbd8fa5063539cf0321dc1b Mon Sep 17 00:00:00 2001 From: Jonathan Li Date: Sat, 27 Feb 2016 11:50:55 +0000 Subject: [PATCH] lilypad:windows:xinput: Only support 1.3 and 1.4 1.3 is used on Vista and 7, so we don't need earlier versions. --- plugins/LilyPad/XInputEnum.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/plugins/LilyPad/XInputEnum.cpp b/plugins/LilyPad/XInputEnum.cpp index 5e039b46e2..3f72441f0a 100644 --- a/plugins/LilyPad/XInputEnum.cpp +++ b/plugins/LilyPad/XInputEnum.cpp @@ -16,6 +16,7 @@ */ #include "Global.h" +#include #include #include "VKey.h" #include "InputManager.h" @@ -248,18 +249,21 @@ public: }; void EnumXInputDevices() { - int i; wchar_t temp[30]; if (!pXInputSetState) { // Also used as flag to indicute XInput not installed, so // don't repeatedly try to load it. if (pXInputEnable) return; - HMODULE hMod = 0; - for (i=3; i>= 0; i--) { - wsprintfW(temp, L"xinput1_%i.dll", i); - if (hMod = LoadLibraryW(temp)) break; + const DWORD flags = LOAD_LIBRARY_SEARCH_APPLICATION_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32; + + // Prefer XInput 1.3 since SCP only has an XInput 1.3 wrapper right now. + // FIXME: Missing FreeLibrary call. + HMODULE hMod = LoadLibraryEx(L"xinput1_3.dll", nullptr, flags); + if (hMod == nullptr && IsWindows8OrGreater()) { + hMod = LoadLibraryEx(L"XInput1_4.dll", nullptr, flags); } + if (hMod) { if ((pXInputEnable = (_XInputEnable) GetProcAddress(hMod, "XInputEnable")) && ((pXInputGetStateEx = (_XInputGetStateEx) GetProcAddress(hMod, (LPCSTR)100)) || // Try Ex version first @@ -274,7 +278,7 @@ void EnumXInputDevices() { } } pXInputEnable(1); - for (i=0; i<4; i++) { + for (int i = 0; i < 4; i++) { wsprintfW(temp, L"XInput Pad %i", i); dm->AddDevice(new XInputDevice(i, temp)); }