Procházet zdrojové kódy

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

Sam Lantinga před 3 roky
rodič
revize
27a48b142b
1 změnil soubory, kde provedl 6 přidání a 6 odebrání
  1. 6 6
      src/joystick/windows/SDL_dinputjoystick.c

+ 6 - 6
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;
 }