bugfix(input): Fix touchpad upward scrolling in UI list boxes#2586
bugfix(input): Fix touchpad upward scrolling in UI list boxes#2586afc-afc0 wants to merge 3 commits intoTheSuperHackers:mainfrom
Conversation
Preserve wheel delta sign when normalizing for touchpad scroll direction detection. Touchpad devices send small continuous deltas that were truncated to 0 by integer division with MOUSE_WHEEL_DELTA, causing upward scroll to be misidentified as downward scroll. Clamp the normalized value to at least 1 or -1 based on the original sign.
|
| Filename | Overview |
|---|---|
| Core/GameEngine/Source/GameClient/Input/Mouse.cpp | Core fix: changes appendIntegerArgument(wheelPos / MOUSE_WHEEL_DELTA) to appendRealArgument(wheelPos / (Real)MOUSE_WHEEL_DELTA), preserving sign for small touchpad deltas that integer-divide to 0. |
| Generals/Code/GameEngine/Include/Common/MessageStream.h | Comment on MSG_RAW_MOUSE_WHEEL updated from integer to Real spin to match the new argument type — documentation-only change. |
| GeneralsMD/Code/GameEngine/Include/Common/MessageStream.h | Same documentation-only comment update as the Generals variant — MSG_RAW_MOUSE_WHEEL now correctly documents Real spin argument. |
| Generals/Code/GameEngine/Source/GameClient/MessageStream/WindowXlat.cpp | Updated two read sites from .integer to .real for MSG_RAW_MOUSE_WHEEL argument 1: direction check in rawMouseToWindowMessage and the wheelPos variable in the main handler — both correctly aligned with the new Real storage type. |
| GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/WindowXlat.cpp | Identical consumer update to the Generals variant — .integer to .real for MSG_RAW_MOUSE_WHEEL argument 1 in both read sites. |
| Generals/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp | Updated MSG_RAW_MOUSE_WHEEL handler to read spin as .real instead of .integer; zoom calculation -spin * ZoomHeightPerSecond is unchanged and now benefits from proportional touchpad zoom values. |
| GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp | Identical update to Generals variant — spin now read as .real, enabling proportional touchpad zoom via the same -spin * ZoomHeightPerSecond expression. |
Sequence Diagram
sequenceDiagram
participant TP as Touchpad (Δ=+30)
participant MC as Mouse::createStreamMessages()
participant MS as MessageStream
participant WX as WindowXlat / LookAtXlat
participant WM as WindowManager / TacticalView
Note over MC: OLD (integer division)
TP->>MC: wheelPos = +30
MC->>MS: appendIntegerArgument(30/120 = 0)
MS->>WX: MSG_RAW_MOUSE_WHEEL arg[1].integer = 0
WX->>WM: 0 > 0 is false → GWM_WHEEL_DOWN ❌
Note over MC: NEW (float division)
TP->>MC: wheelPos = +30
MC->>MS: appendRealArgument(30.0f/120.0f = 0.25f)
MS->>WX: MSG_RAW_MOUSE_WHEEL arg[1].real = 0.25f
WX->>WM: 0.25f > 0 is true → GWM_WHEEL_UP ✅
Reviews (3): Last reviewed commit: "Apply float based fix" | Re-trigger Greptile
|
Good catch, closes #2584 |
Summary
Root Cause
In
Mouse::createStreamMessages(), the wheel delta was divided byMOUSE_WHEEL_DELTA(120) before being sent as a message argument.Touchpad devices send small deltas (e.g. +30) that truncate to 0 on integer division. In
WindowXlat.cpp, the direction checkif (argument > 0)maps 0 toGWM_WHEEL_DOWN, causing upward touchpad scroll to be treated as downward.Fix
Clamp the normalized wheel delta to at least
1or-1based on the original sign ofwheelPos, ensuring the scroll direction isalways preserved. Only
Mouse.cppis changed — no consumers need modification.Test plan