commit d0de770d9980f24c4b17cfd21e6d392e03e62082
Author: Simon Howard <fraggle@soulsphere.org>
AuthorDate: Sun Jun 5 14:30:16 2016 -0400
Commit: Simon Howard <fraggle@soulsphere.org>
CommitDate: Sun Jun 5 14:30:16 2016 -0400
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.
---
src/setup/joystick.c | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)
diff --git a/src/setup/joystick.c b/src/setup/joystick.c
index e6db788c..cd1529ad 100644
--- a/src/setup/joystick.c
+++ b/src/setup/joystick.c
@@ -672,24 +672,16 @@ static void CalibrateXAxis(void)
// 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;
}