From fc7ac73089e200612fccdc60b8b819eb9d06be46 Mon Sep 17 00:00:00 2001 From: Nathanial Lydick Date: Thu, 30 Nov 2023 10:47:53 -0500 Subject: [PATCH] Fix Joysticks on Web. The html Gamepad API does not support an event-based model, only a polling model for input (see [here](https://emscripten.org/docs/api_reference/html5.h.html#how-to-use-this-api)). While mouse and such work without the `SDL_PollEvent` and resulting `SDL_PumpEvents` call because SDL sets emscripten callbacks that handle the other events, joysticks will only be connected and updated once, and then not again. --- Source/Urho3D/Input/Input.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Urho3D/Input/Input.cpp b/Source/Urho3D/Input/Input.cpp index 084a639ae..7e24680ab 100644 --- a/Source/Urho3D/Input/Input.cpp +++ b/Source/Urho3D/Input/Input.cpp @@ -409,7 +409,6 @@ void Input::Update() URHO3D_PROFILE(UpdateInput); -#ifndef __EMSCRIPTEN__ bool mouseMoved = false; if (mouseMove_ != IntVector2::ZERO) mouseMoved = true; @@ -420,6 +419,7 @@ void Input::Update() while (SDL_PollEvent(&evt)) HandleSDLEvent(&evt); +#ifndef __EMSCRIPTEN__ if (suppressNextMouseMove_ && (mouseMove_ != IntVector2::ZERO || mouseMoved)) UnsuppressMouseMove(); #endif