Skip to content

Commit

Permalink
Emscripten: Fixed receiving joystick events after failed init or subs…
Browse files Browse the repository at this point in the history
…ystem quit.

The callbacks used to receive the HTML events were not removed if the joystick
subsystem initialization failed or if the joystick subsystem was quit. Also, the
already connected joysticks were not deleted if the initialization failed later.
  • Loading branch information
philippwiesemann committed Feb 18, 2015
1 parent f9adb45 commit 6dda14c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/joystick/emscripten/SDL_sysjoystick.c
Expand Up @@ -220,13 +220,15 @@ SDL_SYS_JoystickInit(void)
Emscripten_JoyStickConnected);

if(retval != EMSCRIPTEN_RESULT_SUCCESS) {
SDL_SYS_JoystickQuit();
return -1;
}

retval = emscripten_set_gamepaddisconnected_callback(NULL,
0,
Emscripten_JoyStickDisconnected);
if(retval != EMSCRIPTEN_RESULT_SUCCESS) {
SDL_SYS_JoystickQuit();
return -1;
}

Expand Down Expand Up @@ -399,6 +401,9 @@ SDL_SYS_JoystickQuit(void)

numjoysticks = 0;
instance_counter = 0;

emscripten_set_gamepadconnected_callback(NULL, 0, NULL);
emscripten_set_gamepaddisconnected_callback(NULL, 0, NULL);
}

SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID(int index)
Expand Down

0 comments on commit 6dda14c

Please sign in to comment.