input/sdl_gamepad: move controller null check to front
No need to call SDL_GameControllerGetJoystick if controller is NULL.
This commit is contained in:
1 parent
a24227d7ad
commit
6a5e514509
1 file changed
+3
-1
+3
-1
@@ -187,10 +187,12 @@ static void remove_gamepad(struct mp_input_src *src, int id)
|
||||
{
|
||||
struct gamepad_priv *p = src->priv;
|
||||
SDL_GameController *controller = p->controller;
|
||||
if (!controller)
|
||||
return;
|
||||
SDL_Joystick* j = SDL_GameControllerGetJoystick(controller);
|
||||
SDL_JoystickID jid = SDL_JoystickInstanceID(j);
|
||||
|
||||
if (controller && jid == id) {
|
||||
if (jid == id) {
|
||||
const char *name = SDL_GameControllerName(controller);
|
||||
MP_INFO(src, "removed controller: %s\n", name);
|
||||
SDL_GameControllerClose(controller);
|
||||
|
||||
Reference in new issue
Block a user