Skip to content

Commit

Permalink
Emscripten: Fixed sending SDL_JOYDEVICEADDED events with an index out…
Browse files Browse the repository at this point in the history
… of range.

SDL_JOYDEVICEADDED events must contain the device index which is a value between
0 and the number of connected joysticks. The old implementation included a value
based on the instance id instead. It worked in some cases because the values are
similar initially. But after disconnecting joysticks this is no more the case
and the always increasing instance id becomes larger than number of joysticks.
  • Loading branch information
philippwiesemann committed Feb 14, 2015
1 parent 3941848 commit 2ef8b1a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/joystick/emscripten/SDL_sysjoystick.c
Expand Up @@ -112,7 +112,7 @@ Emscripten_JoyStickConnected(int eventType, const EmscriptenGamepadEvent *gamepa
event.type = SDL_JOYDEVICEADDED;

if (SDL_GetEventState(event.type) == SDL_ENABLE) {
event.jdevice.which = item->device_instance - 1;
event.jdevice.which = item->index;
if ( (SDL_EventOK == NULL) ||
(*SDL_EventOK) (SDL_EventOKParam, &event) ) {
SDL_PushEvent(&event);
Expand Down

0 comments on commit 2ef8b1a

Please sign in to comment.