Emscripten: Fixed sending button and motion events for not opened joysticks.
authorPhilipp Wiesemann <philipp.wiesemann@arcor.de>
Sun, 22 Feb 2015 21:00:35 +0100
changeset 9372a9bf04588f17
parent 9371 375799828431
child 9373 679eb3986e37
Emscripten: Fixed sending button and motion events for not opened joysticks.

SDL_SYS_JoystickUpdate() was implemented incorrectly. For every call to it all
attached joysticks were checked. But actually only the given SDL_Joystick should
be checked then. This allowed sending broken events for attached but not opened
joysticks. It also checked the opened joysticks more often than actually needed.
src/joystick/emscripten/SDL_sysjoystick.c
     1.1 --- a/src/joystick/emscripten/SDL_sysjoystick.c	Sat Feb 21 00:33:25 2015 -0500
     1.2 +++ b/src/joystick/emscripten/SDL_sysjoystick.c	Sun Feb 22 21:00:35 2015 +0100
     1.3 @@ -335,10 +335,10 @@
     1.4  SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
     1.5  {
     1.6      EmscriptenGamepadEvent gamepadState;
     1.7 -    SDL_joylist_item *item = SDL_joylist;
     1.8 +    SDL_joylist_item *item = (SDL_joylist_item *) joystick->hwdata;
     1.9      int i, result, buttonState;
    1.10  
    1.11 -    while (item != NULL) {
    1.12 +    if (item) {
    1.13          result = emscripten_get_gamepad_status(item->index, &gamepadState);
    1.14          if( result == EMSCRIPTEN_RESULT_SUCCESS) {
    1.15              if(gamepadState.timestamp == 0 || gamepadState.timestamp != item->timestamp) {
    1.16 @@ -368,7 +368,6 @@
    1.17                  }
    1.18              }
    1.19          }
    1.20 -        item = item->next;
    1.21      }
    1.22  }
    1.23