Skip to content
This repository has been archived by the owner on Feb 17, 2022. It is now read-only.

Commit

Permalink
Decrease vertical scroll speed by using deltaMode (#154)
Browse files Browse the repository at this point in the history
Resolves #149
  • Loading branch information
thomasballinger authored Oct 26, 2021
1 parent f9a06a3 commit c180eca
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/video/emscripten/SDL_emscriptenevents.c
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,22 @@ static EM_BOOL
Emscripten_HandleWheel(int eventType, const EmscriptenWheelEvent *wheelEvent, void *userData)
{
SDL_WindowData *window_data = userData;
SDL_SendMouseWheel(window_data->window, 0, (float)wheelEvent->deltaX, (float)-wheelEvent->deltaY, SDL_MOUSEWHEEL_NORMAL);

float deltaY = wheelEvent->deltaY;

switch (wheelEvent->deltaMode) {
case DOM_DELTA_PIXEL:
deltaY /= 100; /* 100 pixels make up a step */
break;
case DOM_DELTA_LINE:
deltaY /= 3; /* 3 lines make up a step */
break;
case DOM_DELTA_PAGE:
deltaY *= 80; /* A page makes up 80 steps */
break;
}

SDL_SendMouseWheel(window_data->window, 0, (float)wheelEvent->deltaX, -deltaY, SDL_MOUSEWHEEL_NORMAL);
return SDL_GetEventState(SDL_MOUSEWHEEL) == SDL_ENABLE;
}

Expand Down

0 comments on commit c180eca

Please sign in to comment.