Check the pathname first, as that's a faster check for XInput devices

main
Sam Lantinga 2021-09-07 15:50:21 -07:00
parent 21160cb815
commit 27a48b142b
1 changed files with 6 additions and 6 deletions

View File

@ -242,6 +242,12 @@ SDL_IsXInputDevice(Uint16 vendor_id, Uint16 product_id, const char* hidPath)
return SDL_FALSE;
}
/* If device path contains "IG_" then its an XInput device */
/* See: https://docs.microsoft.com/windows/win32/xinput/xinput-and-directinput */
if (SDL_strstr(hidPath, "IG_") != NULL) {
return SDL_TRUE;
}
type = SDL_GetJoystickGameControllerType("", vendor_id, product_id, -1, 0, 0, 0);
if (type == SDL_CONTROLLER_TYPE_XBOX360 ||
type == SDL_CONTROLLER_TYPE_XBOXONE ||
@ -249,12 +255,6 @@ SDL_IsXInputDevice(Uint16 vendor_id, Uint16 product_id, const char* hidPath)
return SDL_TRUE;
}
/* If device path contains "IG_" then its an XInput device */
/* See: https://docs.microsoft.com/windows/win32/xinput/xinput-and-directinput */
if (SDL_strstr(hidPath, "IG_") != NULL) {
return SDL_TRUE;
}
return SDL_FALSE;
}