Emscripten: Fixed receiving joystick events after failed init or subsystem quit.
authorPhilipp Wiesemann <philipp.wiesemann@arcor.de>
Wed, 18 Feb 2015 21:34:07 +0100
changeset 9357620c3c2fb9b9
parent 9356 e87d6e1e812a
child 9358 d7301b277d13
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
     1.1 --- a/src/joystick/emscripten/SDL_sysjoystick.c	Wed Feb 18 21:31:21 2015 +0100
     1.2 +++ b/src/joystick/emscripten/SDL_sysjoystick.c	Wed Feb 18 21:34:07 2015 +0100
     1.3 @@ -220,6 +220,7 @@
     1.4                                                        Emscripten_JoyStickConnected);
     1.5  
     1.6      if(retval != EMSCRIPTEN_RESULT_SUCCESS) {
     1.7 +        SDL_SYS_JoystickQuit();
     1.8          return -1;
     1.9      }
    1.10  
    1.11 @@ -227,6 +228,7 @@
    1.12                                                           0,
    1.13                                                           Emscripten_JoyStickDisconnected);
    1.14      if(retval != EMSCRIPTEN_RESULT_SUCCESS) {
    1.15 +        SDL_SYS_JoystickQuit();
    1.16          return -1;
    1.17      }
    1.18  
    1.19 @@ -399,6 +401,9 @@
    1.20  
    1.21      numjoysticks = 0;
    1.22      instance_counter = 0;
    1.23 +
    1.24 +    emscripten_set_gamepadconnected_callback(NULL, 0, NULL);
    1.25 +    emscripten_set_gamepaddisconnected_callback(NULL, 0, NULL);
    1.26  }
    1.27  
    1.28  SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID(int index)