From 27a48b142bb53def7e1e6fafcdb5433d3b6a5865 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 7 Sep 2021 15:50:21 -0700 Subject: [PATCH] Check the pathname first, as that's a faster check for XInput devices --- src/joystick/windows/SDL_dinputjoystick.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/joystick/windows/SDL_dinputjoystick.c b/src/joystick/windows/SDL_dinputjoystick.c index 4854df325..f334c00b2 100644 --- a/src/joystick/windows/SDL_dinputjoystick.c +++ b/src/joystick/windows/SDL_dinputjoystick.c @@ -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; }