src/joystick/emscripten/SDL_sysjoystick.c
changeset 10226 cb13d22b7f09
parent 10224 d1c27f616999
child 10617 346c02ff71b6
     1.1 --- a/src/joystick/emscripten/SDL_sysjoystick.c	Fri Aug 26 11:16:44 2016 -0700
     1.2 +++ b/src/joystick/emscripten/SDL_sysjoystick.c	Fri Aug 26 12:18:08 2016 -0700
     1.3 @@ -27,10 +27,6 @@
     1.4  #include "SDL_error.h"
     1.5  #include "SDL_events.h"
     1.6  
     1.7 -#if !SDL_EVENTS_DISABLED
     1.8 -#include "../../events/SDL_events_c.h"
     1.9 -#endif
    1.10 -
    1.11  #include "SDL_joystick.h"
    1.12  #include "SDL_hints.h"
    1.13  #include "SDL_assert.h"
    1.14 @@ -57,10 +53,6 @@
    1.15        return 1;
    1.16      }
    1.17  
    1.18 -#if !SDL_EVENTS_DISABLED
    1.19 -    SDL_Event event;
    1.20 -#endif
    1.21 -
    1.22      item = (SDL_joylist_item *) SDL_malloc(sizeof (SDL_joylist_item));
    1.23      if (item == NULL) {
    1.24          return 1;
    1.25 @@ -105,20 +97,12 @@
    1.26      }
    1.27  
    1.28      ++numjoysticks;
    1.29 +
    1.30 +    SDL_PrivateJoystickAdded(numjoysticks - 1);
    1.31 +
    1.32  #ifdef DEBUG_JOYSTICK
    1.33      SDL_Log("Number of joysticks is %d", numjoysticks);
    1.34  #endif
    1.35 -#if !SDL_EVENTS_DISABLED
    1.36 -    event.type = SDL_JOYDEVICEADDED;
    1.37 -
    1.38 -    if (SDL_GetEventState(event.type) == SDL_ENABLE) {
    1.39 -        event.jdevice.which = numjoysticks - 1;
    1.40 -        if ( (SDL_EventOK == NULL) ||
    1.41 -             (*SDL_EventOK) (SDL_EventOKParam, &event) ) {
    1.42 -            SDL_PushEvent(&event);
    1.43 -        }
    1.44 -    }
    1.45 -#endif /* !SDL_EVENTS_DISABLED */
    1.46  
    1.47  #ifdef DEBUG_JOYSTICK
    1.48      SDL_Log("Added joystick with index %d", item->index);
    1.49 @@ -132,9 +116,6 @@
    1.50  {
    1.51      SDL_joylist_item *item = SDL_joylist;
    1.52      SDL_joylist_item *prev = NULL;
    1.53 -#if !SDL_EVENTS_DISABLED
    1.54 -    SDL_Event event;
    1.55 -#endif
    1.56  
    1.57      while (item != NULL) {
    1.58          if (item->index == gamepadEvent->index) {
    1.59 @@ -165,17 +146,7 @@
    1.60      /* Need to decrement the joystick count before we post the event */
    1.61      --numjoysticks;
    1.62  
    1.63 -#if !SDL_EVENTS_DISABLED
    1.64 -    event.type = SDL_JOYDEVICEREMOVED;
    1.65 -
    1.66 -    if (SDL_GetEventState(event.type) == SDL_ENABLE) {
    1.67 -        event.jdevice.which = item->device_instance;
    1.68 -        if ( (SDL_EventOK == NULL) ||
    1.69 -             (*SDL_EventOK) (SDL_EventOKParam, &event) ) {
    1.70 -            SDL_PushEvent(&event);
    1.71 -        }
    1.72 -    }
    1.73 -#endif /* !SDL_EVENTS_DISABLED */
    1.74 +	SDL_PrivateJoystickRemoved(item->device_instance);
    1.75  
    1.76  #ifdef DEBUG_JOYSTICK
    1.77      SDL_Log("Removed joystick with id %d", item->device_instance);