Skip to content

Commit

Permalink
Fix Joysticks on Web.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
SirNate0 committed Nov 30, 2023
1 parent 4655979 commit fc7ac73
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Source/Urho3D/Input/Input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,6 @@ void Input::Update()

URHO3D_PROFILE(UpdateInput);

#ifndef __EMSCRIPTEN__
bool mouseMoved = false;
if (mouseMove_ != IntVector2::ZERO)
mouseMoved = true;
Expand All @@ -420,6 +419,7 @@ void Input::Update()
while (SDL_PollEvent(&evt))
HandleSDLEvent(&evt);

#ifndef __EMSCRIPTEN__
if (suppressNextMouseMove_ && (mouseMove_ != IntVector2::ZERO || mouseMoved))
UnsuppressMouseMove();
#endif
Expand Down

0 comments on commit fc7ac73

Please sign in to comment.