Skip to content

fix(sdl): only forward whole wheel notches to the LWJGL 2 input path - #708

Merged
Rongmario merged 1 commit into
CleanroomMC:mainfrom
TheRedJa:fix/legacy-wheel-whole-notches
Oct 21, 2026
Merged

Rongmario merged 1 commit into
CleanroomMC:mainfrom
TheRedJa:fix/legacy-wheel-whole-notches

Conversation

@TheRedJa

Copy link
Copy Markdown
Contributor

Problem

With a high-resolution mouse wheel, one physical notch scrolls several hotbar slots or JEI/HEI pages at once (one click jumped from page 1 to page 17). Reproduced on KDE Plasma 6.8 Wayland and on X11 (XWayland, SDL_VIDEO_DRIVER=x11) with a Logitech G502 X PLUS in hi-res scroll mode. Related to #548, but not the same issue.

Cause

SDL reports one notch as several wheel events with fractional y (about 0.125 each). Window.wheel forwards every one of them to LegacyInputQueues.wheel, which appends one LWJGL 2 mouse event per SDL event. LWJGL 2 consumers (vanilla changeCurrentItem, JEI page flipping, most mod GUIs) treat every non-zero Mouse.getEventDWheel() as one step. LWJGLY already scales the magnitude correctly (wheel * 120 with carry), so the number of events is what's wrong, not their size.

Fix

The legacy path now uses SDL_MouseWheelEvent.integer_y, which SDL only makes non-zero once a whole notch has accumulated, and skips the event when it is 0. The modern MouseEvent.Wheel post is unchanged and keeps the smooth float amount. integer_y needs SDL 3.2.12 or newer; the bundled LWJGL 3.4.3 natives ship SDL 3.4.14.

Testing

  • ./gradlew compileJava passes on main.
  • Built the same change on top of 0.7.11-alpha and played a large 1.12.2 modpack with it (KDE Wayland, G502 X PLUS hi-res wheel). One ratchet click now moves the hotbar one slot and JEI/HEI one page. Free-spin scrolling still works.

🤖 Generated with Claude Code

High-resolution mouse wheels report a single notch as several SDL wheel
events with fractional deltas. LWJGL 2 consumers (hotbar scrolling, JEI
page flipping, most mod GUIs) treat every non-zero Mouse.getEventDWheel()
as one step, so one notch scrolled several slots or pages.

Feed the legacy queue SDL's accumulated integer_y instead, which is only
non-zero once a whole notch completes. The modern MouseEvent.Wheel keeps
the smooth fractional amount.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@Rongmario
Rongmario merged commit 1619809 into CleanroomMC:main Oct 21, 2026
@TheRedJa
TheRedJa deleted the fix/legacy-wheel-whole-notches branch October 21, 2026 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants