Emscripten: call emscripten_sample_gamepad_data
authorCharlie Birks <charlie@daftgames.net>
Tue, 29 Jan 2019 12:19:00 +0000
changeset 1257562f907f026bb
parent 12574 109c919d61f6
child 12576 8d61748ac590
Emscripten: call emscripten_sample_gamepad_data
src/joystick/emscripten/SDL_sysjoystick.c
     1.1 --- a/src/joystick/emscripten/SDL_sysjoystick.c	Tue Jan 29 12:18:56 2019 +0000
     1.2 +++ b/src/joystick/emscripten/SDL_sysjoystick.c	Tue Jan 29 12:19:00 2019 +0000
     1.3 @@ -189,13 +189,16 @@
     1.4      EmscriptenGamepadEvent gamepadState;
     1.5  
     1.6      numjoysticks = 0;
     1.7 -    numjs = emscripten_get_num_gamepads();
     1.8 +
     1.9 +    retval = emscripten_sample_gamepad_data();
    1.10  
    1.11      /* Check if gamepad is supported by browser */
    1.12 -    if (numjs == EMSCRIPTEN_RESULT_NOT_SUPPORTED) {
    1.13 +    if (retval == EMSCRIPTEN_RESULT_NOT_SUPPORTED) {
    1.14          return SDL_SetError("Gamepads not supported");
    1.15      }
    1.16  
    1.17 +    numjs = emscripten_get_num_gamepads();
    1.18 +
    1.19      /* handle already connected gamepads */
    1.20      if (numjs > 0) {
    1.21          for(i = 0; i < numjs; i++) {
    1.22 @@ -335,6 +338,8 @@
    1.23      SDL_joylist_item *item = (SDL_joylist_item *) joystick->hwdata;
    1.24      int i, result, buttonState;
    1.25  
    1.26 +    emscripten_sample_gamepad_data();
    1.27 +
    1.28      if (item) {
    1.29          result = emscripten_get_gamepad_status(item->index, &gamepadState);
    1.30          if( result == EMSCRIPTEN_RESULT_SUCCESS) {