mirror of
https://github.com/Ryujinx/SDL.git
synced 2025-03-23 21:55:12 +00:00
Fix crash on controller hotplug on linux.
CR: Sam
This commit is contained in:
parent
e015140af3
commit
c2f0394831
|
@ -465,7 +465,7 @@ SDL_SYS_HapticOpen(SDL_Haptic * haptic)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set the fname. */
|
/* Set the fname. */
|
||||||
haptic->hwdata->fname = item->fname;
|
haptic->hwdata->fname = SDL_strdup( item->fname );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -542,11 +542,12 @@ SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
|
||||||
/* Find the joystick in the haptic list. */
|
/* Find the joystick in the haptic list. */
|
||||||
for (item = SDL_hapticlist; item; item = item->next) {
|
for (item = SDL_hapticlist; item; item = item->next) {
|
||||||
if (SDL_strcmp(item->fname, joystick->hwdata->fname) == 0) {
|
if (SDL_strcmp(item->fname, joystick->hwdata->fname) == 0) {
|
||||||
haptic->index = device_index;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
++device_index;
|
++device_index;
|
||||||
}
|
}
|
||||||
|
haptic->index = device_index;
|
||||||
|
|
||||||
if (device_index >= MAX_HAPTICS) {
|
if (device_index >= MAX_HAPTICS) {
|
||||||
return SDL_SetError("Haptic: Joystick doesn't have Haptic capabilities");
|
return SDL_SetError("Haptic: Joystick doesn't have Haptic capabilities");
|
||||||
}
|
}
|
||||||
|
@ -561,7 +562,8 @@ SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
haptic->hwdata->fname = item->fname;
|
haptic->hwdata->fname = SDL_strdup( joystick->hwdata->fname );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -583,6 +585,7 @@ SDL_SYS_HapticClose(SDL_Haptic * haptic)
|
||||||
close(haptic->hwdata->fd);
|
close(haptic->hwdata->fd);
|
||||||
|
|
||||||
/* Free */
|
/* Free */
|
||||||
|
SDL_free(haptic->hwdata->fname);
|
||||||
SDL_free(haptic->hwdata);
|
SDL_free(haptic->hwdata);
|
||||||
haptic->hwdata = NULL;
|
haptic->hwdata = NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue