From 82a800e26687447febced9bbbddbd3ef5aa0ec8d Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 7 Sep 2025 10:01:44 -0400 Subject: [PATCH] emscripten: Let joystick dpad-to-hat conversion allow impossible combinations. This matches what other backends do. --- src/joystick/emscripten/SDL_sysjoystick.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/joystick/emscripten/SDL_sysjoystick.c b/src/joystick/emscripten/SDL_sysjoystick.c index 6c51f8eaf6..31a1de6140 100644 --- a/src/joystick/emscripten/SDL_sysjoystick.c +++ b/src/joystick/emscripten/SDL_sysjoystick.c @@ -100,12 +100,14 @@ static EM_BOOL Emscripten_JoyStickConnected(int eventType, const EmscriptenGamep // this currently expects the first button to be up, then down, then left, then right. if (gamepadEvent->digitalButton[first_hat_button + 0]) { value |= SDL_HAT_UP; - } else if (gamepadEvent->digitalButton[first_hat_button + 1]) { + } + if (gamepadEvent->digitalButton[first_hat_button + 1]) { value |= SDL_HAT_DOWN; } if (gamepadEvent->digitalButton[first_hat_button + 2]) { value |= SDL_HAT_LEFT; - } else if (gamepadEvent->digitalButton[first_hat_button + 3]) { + } + if (gamepadEvent->digitalButton[first_hat_button + 3]) { value |= SDL_HAT_RIGHT; } item->hat = value;