XInput: Do not use XINPUT_CAPS_FFB_SUPPORTED

There are several reasons for this:
1. XINPUT_CAPS_FFB_SUPPORTED flag was introduced in Windows 8,
   and therefore only supported by XInput 1.4
2. Despite the name, this flag does NOT indicate whether normal rumble
   is supported. This flag is reserved for more complex force feedback,
   and according to MSDN it may have went unused on Windows.

This fixes a future (the method is not used yet) bug where
XInputControllerInterface::GetControllerRumbleMotorCount would
erroreously report no rumble support.
This commit is contained in:
Silent
2020-08-22 22:46:12 +02:00
parent 136a9d60e9
commit 1c4bbc8cde
2 changed files with 2 additions and 19 deletions

View File

@ -39,11 +39,9 @@ bool XInputControllerInterface::Initialize(CommonHostInterface* host_interface)
reinterpret_cast<decltype(m_xinput_get_state)>(GetProcAddress(m_xinput_module, reinterpret_cast<LPCSTR>(100)));
if (!m_xinput_get_state)
reinterpret_cast<decltype(m_xinput_get_state)>(GetProcAddress(m_xinput_module, "XInputGetState"));
m_xinput_get_capabilities =
reinterpret_cast<decltype(m_xinput_get_capabilities)>(GetProcAddress(m_xinput_module, "XInputGetCapabilities"));
m_xinput_set_state =
reinterpret_cast<decltype(m_xinput_set_state)>(GetProcAddress(m_xinput_module, "XInputSetState"));
if (!m_xinput_get_state || !m_xinput_get_capabilities || !m_xinput_set_state)
if (!m_xinput_get_state || !m_xinput_set_state)
{
Log_ErrorPrintf("Failed to get XInput function pointers.");
return false;
@ -72,7 +70,6 @@ void XInputControllerInterface::PollEvents()
if (!cd.connected)
{
cd.connected = true;
UpdateCapabilities(i);
OnControllerConnected(static_cast<int>(i));
}
@ -155,17 +152,6 @@ void XInputControllerInterface::CheckForStateChanges(u32 index, const XINPUT_STA
}
}
void XInputControllerInterface::UpdateCapabilities(u32 index)
{
ControllerData& cd = m_controllers[index];
XINPUT_CAPABILITIES caps = {};
m_xinput_get_capabilities(index, 0, &caps);
cd.supports_rumble = (caps.Flags & 0x0001 /* XINPUT_CAPS_FFB_SUPPORTED */);
Log_InfoPrintf("Controller %u: Rumble is %s", index, cd.supports_rumble ? "supported" : "not supported");
}
void XInputControllerInterface::ClearBindings()
{
for (auto& it : m_controllers)
@ -277,7 +263,7 @@ u32 XInputControllerInterface::GetControllerRumbleMotorCount(int controller_inde
if (static_cast<u32>(controller_index) >= XUSER_MAX_COUNT || !m_controllers[controller_index].connected)
return 0;
return m_controllers[controller_index].supports_rumble ? NUM_RUMBLE_MOTORS : 0;
return NUM_RUMBLE_MOTORS;
}
void XInputControllerInterface::SetControllerRumbleStrength(int controller_index, const float* strengths,