SDL_MouseWheelEvent units

What units is event.wheel.y supposed to be using? Rotating the mouse wheel by one ‘notch’ is returning a much larger value when running in Emscripten than when running natively in Windows, Linux or MacOS. This is confusing my application which scrolls much further than it should when running in a browser.

I posted about this issue earlier in the year and got no answer. I don’t understand how this isn’t a common issue.

Nor me. The documentation refers to event.wheel.y as being “the amount scrolled vertically” but there’s no indication of the units. It seems that in the absence of a specification different platforms return different units, so it’s probably too late to fix this.

I would recommend not relying on the absolute values in this struct.

Count the mouse wheel event occurrences instead - scrolling two notches will also generate two events!

Do not rely on the units of the values in wheel! They will be what ever the underlying implementation provides. And they might even be flipped (SDL_MOUSEWHEEL_FLIPPED).

Different platforms deliver different scroll events, and this is what it ends up as, i suppsoe.

1 Like

But SDL is supposed to be an ‘abstraction layer’; it should resolve these inconsistencies and deliver values that can be relied upon!

That may be OK if the events are from a conventional mouse wheel, but what if they are from a touchpad?

I’ve got a patch up that roughly addresses the emscripten case in SDL2, in case looking at that is useful to read: https://github.com/emscripten-ports/SDL2/pull/154