From 4ea26a777104fcd59ddb49d77f4a91a66dee13c9 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 23 Oct 2024 23:35:02 -0400 Subject: [PATCH] emscripten: scale mousewheel X coordinates correctly, not just Y coordinates. Fixes #10454. --- src/video/emscripten/SDL_emscriptenevents.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/video/emscripten/SDL_emscriptenevents.c b/src/video/emscripten/SDL_emscriptenevents.c index b578128dc455f..18d9117fc3da3 100644 --- a/src/video/emscripten/SDL_emscriptenevents.c +++ b/src/video/emscripten/SDL_emscriptenevents.c @@ -360,20 +360,24 @@ static EM_BOOL Emscripten_HandleWheel(int eventType, const EmscriptenWheelEvent SDL_WindowData *window_data = userData; float deltaY = wheelEvent->deltaY; + float deltaX = wheelEvent->deltaX; switch (wheelEvent->deltaMode) { case DOM_DELTA_PIXEL: + deltaX /= 100; // 100 pixels make up a step deltaY /= 100; // 100 pixels make up a step break; case DOM_DELTA_LINE: + deltaX /= 3; // 3 lines make up a step deltaY /= 3; // 3 lines make up a step break; case DOM_DELTA_PAGE: + deltaX *= 80; // A page makes up 80 steps deltaY *= 80; // A page makes up 80 steps break; } - SDL_SendMouseWheel(0, window_data->window, SDL_DEFAULT_MOUSE_ID, (float)wheelEvent->deltaX, -deltaY, SDL_MOUSEWHEEL_NORMAL); + SDL_SendMouseWheel(0, window_data->window, SDL_DEFAULT_MOUSE_ID, deltaX, -deltaY, SDL_MOUSEWHEEL_NORMAL); return SDL_EventEnabled(SDL_EVENT_MOUSE_WHEEL); }