emscripten: Decrease vertical scroll speed by using deltaMode

Reference issue #4623.
This commit is contained in:
Thomas Ballinger 2021-11-07 20:49:32 -05:00 committed by Ryan C. Gordon
parent 6657cbce8d
commit 94c1276a5f
No known key found for this signature in database
GPG key ID: FA148B892AB48044

View file

@ -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;
}