emscripten: scale mousewheel X coordinates correctly, not just Y coordinates.

Fixes #10454.

(cherry picked from commit 4ea26a7771)
This commit is contained in:
Ryan C. Gordon 2024-10-23 23:35:02 -04:00
parent 52714d5063
commit 00f15dd215
No known key found for this signature in database
GPG Key ID: FA148B892AB48044
1 changed files with 5 additions and 1 deletions

View File

@ -714,20 +714,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:
deltaY /= 100; /* 100 pixels make up a step */
deltaX /= 100; /* 100 pixels make up a step */
break;
case DOM_DELTA_LINE:
deltaY /= 3; /* 3 lines make up a step */
deltaX /= 3; /* 3 lines make up a step */
break;
case DOM_DELTA_PAGE:
deltaY *= 80; /* A page makes up 80 steps */
deltaX *= 80; /* A page makes up 80 steps */
break;
}
SDL_SendMouseWheel(window_data->window, 0, (float)wheelEvent->deltaX, -deltaY, SDL_MOUSEWHEEL_NORMAL);
SDL_SendMouseWheel(window_data->window, 0, deltaX, -deltaY, SDL_MOUSEWHEEL_NORMAL);
return SDL_GetEventState(SDL_MOUSEWHEEL) == SDL_ENABLE;
}