Skip to content

Commit

Permalink
emscripten: scale mousewheel X coordinates correctly, not just Y coor…
Browse files Browse the repository at this point in the history
…dinates.

Fixes #10454.

(cherry picked from commit 4ea26a7)
  • Loading branch information
icculus committed Oct 24, 2024
1 parent 52714d5 commit 00f15dd
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/video/emscripten/SDL_emscriptenevents.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 00f15dd

Please sign in to comment.