shithub: choc

Download patch

ref: d0de770d9980f24c4b17cfd21e6d392e03e62082
parent: 1fdb037589d76f2e7f7d464e0a92daecc7c1f241
author: Simon Howard <[email protected]>
date: Sun Jun 5 10:30:16 EDT 2016

setup: Avoid use of SDL_JoystickFromInstanceID().

This function was only added in SDL2 v2.0.4. So refactor to avoid
using it, since it's not strictly necessary. This should also fix
failing build on Travis, which is using an older version of SDL2.

--- a/src/setup/joystick.c
+++ b/src/setup/joystick.c
@@ -672,24 +672,16 @@
 // joystick_guid and joystick_index config variables.
 static boolean SetJoystickGUID(SDL_JoystickID joy_id)
 {
-    SDL_Joystick *joystick;
     SDL_JoystickGUID guid;
     int i;
 
-    joystick = SDL_JoystickFromInstanceID(joy_id);
-    if (joystick == NULL)
-    {
-        return false;
-    }
-
-    guid = SDL_JoystickGetGUID(joystick);
-    joystick_guid = malloc(33);
-    SDL_JoystickGetGUIDString(guid, joystick_guid, 33);
-
     for (i = 0; i < all_joysticks_len; ++i)
     {
-        if (all_joysticks[i] == joystick)
+        if (SDL_JoystickInstanceID(all_joysticks[i]) == joy_id)
         {
+            guid = SDL_JoystickGetGUID(all_joysticks[i]);
+            joystick_guid = malloc(33);
+            SDL_JoystickGetGUIDString(guid, joystick_guid, 33);
             joystick_index = i;
             return true;
         }