InputCommon: Fix slow startup on some Windows systems

Rewrite GetXInputGUIDS to use SetupAPI instead of WMI Queries. When
using a language pack where the system language and user/program
language differ, Windows starts taking a VERY long time (10+ seconds)
to complete Queries for Win32_PNPEntity objects (it's probably
translating every single string since it transfers every single one
from the WMI server into memory in the program).

Fixes Issue 9744.
This commit is contained in:
EmptyChaos
2016-08-10 23:30:36 +00:00
parent 8552ff5789
commit 17e4bd9575
4 changed files with 64 additions and 124 deletions

View File

@ -23,14 +23,11 @@ void InitJoystick(IDirectInput8* const idi8, HWND hwnd)
idi8->EnumDevices(DI8DEVCLASS_GAMECTRL, DIEnumDevicesCallback, (LPVOID)&joysticks,
DIEDFL_ATTACHEDONLY);
std::vector<DWORD> xinput_guids;
GetXInputGUIDS(&xinput_guids);
std::unordered_set<DWORD> xinput_guids = GetXInputGUIDS();
for (DIDEVICEINSTANCE& joystick : joysticks)
{
// skip XInput Devices
if (std::find(xinput_guids.begin(), xinput_guids.end(), joystick.guidProduct.Data1) !=
xinput_guids.end())
if (xinput_guids.count(joystick.guidProduct.Data1))
{
continue;
}