sdl: don't add a joystick if its name can't be retrieved
Otherwise it crashes later on during SDL_JoystickClose Fixes MINIDUMP-9K, MINIDUMP-B4
This commit is contained in:
parent
26815d042a
commit
b86df7217c
|
@ -66,8 +66,11 @@ static void sdl_open_joystick(int index)
|
|||
INFO_LOG(INPUT, "SDL: Cannot open joystick %d", index + 1);
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<SDLGamepad> gamepad = std::make_shared<SDLGamepad>(index < MAPLE_PORTS ? index : -1, index, pJoystick);
|
||||
SDLGamepad::AddSDLGamepad(gamepad);
|
||||
try {
|
||||
std::shared_ptr<SDLGamepad> gamepad = std::make_shared<SDLGamepad>(index < MAPLE_PORTS ? index : -1, index, pJoystick);
|
||||
SDLGamepad::AddSDLGamepad(gamepad);
|
||||
} catch (const FlycastException& e) {
|
||||
}
|
||||
}
|
||||
|
||||
static void sdl_close_joystick(SDL_JoystickID instance)
|
||||
|
|
|
@ -170,12 +170,9 @@ public:
|
|||
if (joyName == nullptr)
|
||||
{
|
||||
WARN_LOG(INPUT, "Can't get joystick %d name: %s", joystick_idx, SDL_GetError());
|
||||
_name = "Joystick " + std::to_string(joystick_idx);
|
||||
}
|
||||
else
|
||||
{
|
||||
_name = joyName;
|
||||
throw FlycastException("joystick failure");
|
||||
}
|
||||
_name = joyName;
|
||||
sdl_joystick_instance = SDL_JoystickInstanceID(sdl_joystick);
|
||||
_unique_id = "sdl_joystick_" + std::to_string(sdl_joystick_instance);
|
||||
INFO_LOG(INPUT, "SDL: Opened joystick %d on port %d: '%s' unique_id=%s", sdl_joystick_instance, maple_port, _name.c_str(), _unique_id.c_str());
|
||||
|
|
Loading…
Reference in New Issue