Skip to content

Commit

Permalink
Emscripten: Fixed sending button and motion events for not opened joy…
Browse files Browse the repository at this point in the history
…sticks.

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.
  • Loading branch information
philippwiesemann committed Feb 22, 2015
1 parent e4be934 commit 5c43207
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/joystick/emscripten/SDL_sysjoystick.c
Expand Up @@ -335,10 +335,10 @@ void
SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
{
EmscriptenGamepadEvent gamepadState;
SDL_joylist_item *item = SDL_joylist;
SDL_joylist_item *item = (SDL_joylist_item *) joystick->hwdata;
int i, result, buttonState;

while (item != NULL) {
if (item) {
result = emscripten_get_gamepad_status(item->index, &gamepadState);
if( result == EMSCRIPTEN_RESULT_SUCCESS) {
if(gamepadState.timestamp == 0 || gamepadState.timestamp != item->timestamp) {
Expand Down Expand Up @@ -368,7 +368,6 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
}
}
}
item = item->next;
}
}

Expand Down

0 comments on commit 5c43207

Please sign in to comment.