diff --git a/src/Game.c b/src/Game.c index 266a00804..0ee240857 100644 --- a/src/Game.c +++ b/src/Game.c @@ -762,8 +762,7 @@ static CC_INLINE void Game_RenderFrame(void) { Gfx_BindIb(Gfx.DefaultIb); Game.Time += deltaD; Game_Vertices = 0; - - if (Input.Sources & INPUT_SOURCE_GAMEPAD) Gamepad_Tick(delta); + Gamepad_Tick(delta); #ifdef CC_BUILD_SPLITSCREEN /* TODO: find a better solution */ diff --git a/src/Input.c b/src/Input.c index f096ae629..6238ef7d8 100644 --- a/src/Input.c +++ b/src/Input.c @@ -539,6 +539,7 @@ static void Gamepad_Apply(int port, int btn, cc_bool was, int pressed) { static void Gamepad_Update(int port, float delta) { struct GamepadDevice* pad = &Gamepad_Devices[port]; int btn; + if (!pad->deviceID) return; for (btn = 0; btn < GAMEPAD_BTN_COUNT; btn++) { diff --git a/src/Window_Web.c b/src/Window_Web.c index ed8036cdc..19198253f 100644 --- a/src/Window_Web.c +++ b/src/Window_Web.c @@ -572,12 +572,7 @@ static void Cursor_DoSetVisible(cc_bool visible) { *-------------------------------------------------------Gamepads----------------------------------------------------------* *#########################################################################################################################*/ void Gamepads_Init(void) { - /* TODO find a better solution */ - int count; - if (emscripten_sample_gamepad_data() != 0) return; - count = emscripten_get_num_gamepads(); - - if (count) Input.Sources |= INPUT_SOURCE_GAMEPAD; + /* Devices can't be detected until first time a button is pressed */ } /* https://www.w3.org/TR/gamepad/#dfn-standard-gamepad */