TeamREPENTOGON / TeamREPENTOGON/REPENTOGON

(Bug) Input.GetMouseWheel() loses wheel delta when mouse moves during scrolling

Open
#902 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
345
Forks
51
Avg merge
11h 2m
Merged PRs (30d)
4

Description

Input.GetMouseWheel() loses wheel delta when mouse moves during scrolling

Description

Input.GetMouseWheel() returns an incorrect zero value when mouse movement and mouse wheel scrolling happen in the same frame.

Scrolling while the cursor is stationary works correctly. However, moving the cursor while scrolling causes the wheel delta to be cleared before it can be read.

This reproduces through the Input API directly and does not involve ImGui.

Steps to reproduce

  1. Run the minimal reproduction code below.
  2. Scroll the mouse wheel without moving the mouse.
  3. Observe that Input.GetMouseWheel() returns a non-zero Y value.
  4. Continuously move the mouse cursor while scrolling.
  5. Observe that Input.GetMouseWheel() returns Vector(0, 0) for wheel events that occurred during mouse movement.

Expected behavior

Input.GetMouseWheel() should return the wheel delta generated during the current render frame, regardless of whether the mouse position also changes.

Actual behavior

Moving the mouse while scrolling causes the wheel delta to be cleared before it can be read.

The same wheel movement is detected correctly if the mouse cursor remains stationary.

Example:

Scrolling only:
Wheel X: 0
Wheel Y: 1

Moving + scrolling:
Wheel X: 0
Wheel Y: 0

The reproduction reads the wheel before calling Input.GetMousePosition(), so the issue is not caused by the Lua script reading the mouse position first.

Minimal reproduction

The following can be injected directly through the debug console:

if not _G.MouseWheelTestMod then
    _G.MouseWheelTestMod = RegisterMod("Mouse Wheel Test", 1)
    _G.MouseWheelTestCount = 0

    _G.MouseWheelTestMod:AddCallback(
        ModCallbacks.MC_POST_RENDER,
        function()
            -- Read wheel first to exclude GetMousePosition() as the cause.
            local w = Input.GetMouseWheel()
            local p = Isaac.WorldToScreen(Input.GetMousePosition(true))

            if w.X ~= 0 or w.Y ~= 0 then
                _G.MouseWheelTestCount = _G.MouseWheelTestCount + 1
            end

            Isaac.RenderText(
                string.format(
                    "Mouse X: %.1f Y: %.1f",
                    p.X,
                    p.Y
                ),
                20,
                35,
                1, 1, 1, 1
            )

            Isaac.RenderText(
                string.format(
                    "Wheel X: %.3f Y: %.3f",
                    w.X,
                    w.Y
                ),
                20,
                50,
                1, 1, 1, 1
            )

            Isaac.RenderText(
                "Detected: " .. tostring(_G.MouseWheelTestCount),
                20,
                65,
                w.Y ~= 0 and 0 or 1,
                1,
                w.Y ~= 0 and 0 or 1,
                1
            )
        end
    )
end

Environment

  • Tested with:
    • REPENTOGON 1.1.2e
    • Repentance+ 1.9.7.17
  • Steam build ID: 22878971
  • OS: Windows 11 Home, 64-bit, build 22621
  • Mouse: Logitech wireless mouse (VID_046D, PID_C53F)

Additional notes

The issue appears to be related to the lifetime or update order of the internal mouse input state.

The wheel delta may be overwritten or cleared when mouse movement is processed before the value is consumed.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Input.GetMouseWheel API and trace the mouse movement and wheel update or clearing order around MC_POST_RENDER. Run the provided Lua reproduction through the debug console, testing stationary scrolling and simultaneous movement. Done means wheel delta remains non-zero for wheel events in the current render frame even when the cursor moves.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, lua
Domain
api, game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.