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.
This commit is contained in:
Jonathan Li 2016-02-27 11:50:55 +00:00
parent 490cb757bf
commit 834652922a
1 changed files with 10 additions and 6 deletions

View File

@ -16,6 +16,7 @@
*/ */
#include "Global.h" #include "Global.h"
#include <VersionHelpers.h>
#include <xinput.h> #include <xinput.h>
#include "VKey.h" #include "VKey.h"
#include "InputManager.h" #include "InputManager.h"
@ -248,18 +249,21 @@ public:
}; };
void EnumXInputDevices() { void EnumXInputDevices() {
int i;
wchar_t temp[30]; wchar_t temp[30];
if (!pXInputSetState) { if (!pXInputSetState) {
// Also used as flag to indicute XInput not installed, so // Also used as flag to indicute XInput not installed, so
// don't repeatedly try to load it. // don't repeatedly try to load it.
if (pXInputEnable) return; if (pXInputEnable) return;
HMODULE hMod = 0; const DWORD flags = LOAD_LIBRARY_SEARCH_APPLICATION_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32;
for (i=3; i>= 0; i--) {
wsprintfW(temp, L"xinput1_%i.dll", i); // Prefer XInput 1.3 since SCP only has an XInput 1.3 wrapper right now.
if (hMod = LoadLibraryW(temp)) break; // 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 (hMod) {
if ((pXInputEnable = (_XInputEnable) GetProcAddress(hMod, "XInputEnable")) && if ((pXInputEnable = (_XInputEnable) GetProcAddress(hMod, "XInputEnable")) &&
((pXInputGetStateEx = (_XInputGetStateEx) GetProcAddress(hMod, (LPCSTR)100)) || // Try Ex version first ((pXInputGetStateEx = (_XInputGetStateEx) GetProcAddress(hMod, (LPCSTR)100)) || // Try Ex version first
@ -274,7 +278,7 @@ void EnumXInputDevices() {
} }
} }
pXInputEnable(1); pXInputEnable(1);
for (i=0; i<4; i++) { for (int i = 0; i < 4; i++) {
wsprintfW(temp, L"XInput Pad %i", i); wsprintfW(temp, L"XInput Pad %i", i);
dm->AddDevice(new XInputDevice(i, temp)); dm->AddDevice(new XInputDevice(i, temp));
} }