XInput: Try to use XInput 1.3 if 1.4 is not present

This simple change enables the use of Guide button
for Windows 7 users, provided they have DirectX End-User
Runtimes installed. XInput 9.1.0 does not have the hidden
XInputGetStateEx export, so it was not possible to poll for
Guide button.
This commit is contained in:
Silent 2020-08-22 22:52:54 +02:00
parent 1c4bbc8cde
commit 8def7420c4
No known key found for this signature in database
GPG key ID: AE53149BB0C45AF1

View file

@ -23,16 +23,20 @@ ControllerInterface::Backend XInputControllerInterface::GetBackend() const
bool XInputControllerInterface::Initialize(CommonHostInterface* host_interface) bool XInputControllerInterface::Initialize(CommonHostInterface* host_interface)
{ {
m_xinput_module = LoadLibraryA("xinput1_4.dll"); m_xinput_module = LoadLibraryW(L"xinput1_4");
if (!m_xinput_module) if (!m_xinput_module)
{ {
m_xinput_module = LoadLibraryA("xinput9_1_0.dll"); m_xinput_module = LoadLibraryW(L"xinput1_3");
}
if (!m_xinput_module)
{
m_xinput_module = LoadLibraryW(L"xinput9_1_0");
}
if (!m_xinput_module) if (!m_xinput_module)
{ {
Log_ErrorPrintf("Failed to load XInput module."); Log_ErrorPrintf("Failed to load XInput module.");
return false; return false;
} }
}
// Try the hidden version of XInputGetState(), which lets us query the guide button. // Try the hidden version of XInputGetState(), which lets us query the guide button.
m_xinput_get_state = m_xinput_get_state =