Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/SDL2' into dreamcastSDL2
Browse files Browse the repository at this point in the history
  • Loading branch information
GPF committed Oct 24, 2024
2 parents 5e2068d + 00f15dd commit e0ae87a
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 e0ae87a

Please sign in to comment.