From 6dda14c0d85800e16af47f49e7451136a3395f7d Mon Sep 17 00:00:00 2001 From: Philipp Wiesemann Date: Wed, 18 Feb 2015 21:34:07 +0100 Subject: [PATCH] Emscripten: Fixed receiving joystick events after failed init or subsystem 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. --- src/joystick/emscripten/SDL_sysjoystick.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/joystick/emscripten/SDL_sysjoystick.c b/src/joystick/emscripten/SDL_sysjoystick.c index 8f44cf092..cc5a6f668 100644 --- a/src/joystick/emscripten/SDL_sysjoystick.c +++ b/src/joystick/emscripten/SDL_sysjoystick.c @@ -220,6 +220,7 @@ SDL_SYS_JoystickInit(void) Emscripten_JoyStickConnected); if(retval != EMSCRIPTEN_RESULT_SUCCESS) { + SDL_SYS_JoystickQuit(); return -1; } @@ -227,6 +228,7 @@ SDL_SYS_JoystickInit(void) 0, Emscripten_JoyStickDisconnected); if(retval != EMSCRIPTEN_RESULT_SUCCESS) { + SDL_SYS_JoystickQuit(); return -1; } @@ -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)