mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-12-17 03:45:30 +00:00
Fixed crash when the joystick can't be opened
This commit is contained in:
@@ -295,16 +295,25 @@ static int StandardizeAxisValue(int nValue)
|
|||||||
|
|
||||||
static void RefreshControllerName(void)
|
static void RefreshControllerName(void)
|
||||||
{
|
{
|
||||||
|
const char *name = NULL;
|
||||||
|
|
||||||
SDL_free(controller_name);
|
SDL_free(controller_name);
|
||||||
controller_name = NULL;
|
controller_name = NULL;
|
||||||
|
|
||||||
if (controller) {
|
if (controller) {
|
||||||
if (controller->gamepad) {
|
if (controller->gamepad) {
|
||||||
controller_name = SDL_strdup(SDL_GetGamepadName(controller->gamepad));
|
name = SDL_GetGamepadName(controller->gamepad);
|
||||||
} else {
|
} else {
|
||||||
controller_name = SDL_strdup(SDL_GetJoystickName(controller->joystick));
|
name = SDL_GetJoystickName(controller->joystick);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDL_free(controller_name);
|
||||||
|
if (name) {
|
||||||
|
controller_name = SDL_strdup(name);
|
||||||
|
} else {
|
||||||
|
controller_name = SDL_strdup("");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetAndFreeGamepadMapping(char *mapping)
|
static void SetAndFreeGamepadMapping(char *mapping)
|
||||||
|
|||||||
Reference in New Issue
Block a user