fix(input): Mouse 4 and Mouse 5 can be bound in Controls (#3226) #3257
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!3257
Loading…
Reference in a new issue
No description provided.
Delete branch "cuecuemoar/Longshot:fix/mouse-side-button-bind"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
In the Controls page (F1), a control's key slot that is listening takes a mouse button pressed then, but only the left, right and middle ones: Mouse 4 and Mouse 5, the side buttons, did nothing, so they could not be bound (#3226). This came with the Controls page's move to the Rust UI (#2822). The names
Mouse4andMouse5were already there, and play already reads both buttons (host/nn_hid.c, since #1329), but nothing passed a side button on to the menu:host/display.cnever handledWM_XBUTTONDOWN/WM_XBUTTONUPand counted only three buttons as held;gpu/vk/vk_ui.cppmasked the pointer's buttons with& 7ubefore the UI saw them;key_names::MOUSE, the table a listening Keybind looks a pressed button up in, stopped at the middle button.Now the side buttons are the menu's buttons X1 (8) and X2 (16), from Windows'
WM_XBUTTON*(button_bit, shared with the pop-out windows) and from SDL's buttons 4 and 5 on Linux. They reach the UI throughMKW_UI_BUTTONS, and a listening Keybind takes them asMouse4andMouse5. Nothing else in the UI reads them: only the left button clicks. With the Insert menu closed, in play or in a game menu, they go on as before: their controls' (nn_hid.c), and on WindowsDefWindowProcstill gets their messages.gpu/vk/vk_api.hgets two values of theHOS_MOUSE_*enum, nothing ofMkwVkHostorMkwVkRenderer, soMKWVK_API_VERSIONstays.Read first:
host/display.cbutton_bitand theWM_XBUTTONDOWNcase;game/crates/key-names/src/lib.rsMOUSE.Linux's half for play, binding a side button and it acting in the game, is #1172 (TrashPanda, WIP:
VK_XBUTTON1/2from SDL's X1/X2 inkeys_update). This PR uses the same buttons 4 and 5 for the menu and does not touch that path.Fixes #3226
Testing
Tested: Windows 10, RTX 4090, driver 617.42, a 5-button mouse; a copy of my own save. Runtime
v3.2.0-335-g7e106835a(this head's code: since then only tests changed). In Controls:key_a = "5,0"andkey_y = "6,0".Checks:
game-uia_listening_keybind_takes_the_mouse_side_buttons(new): a listening Keybind takes X1 and X2 asMouse4andMouse5, and while not listening they neither start it nor change it. It fails onmain(assertion failed: Mouse4, left: [], right: [(Change, Text("Mouse4"))]) and passes here.tests/test_display_pointer.py: the window procedure's button messages are compiled in too, asbutton_event. The new cases:WM_XBUTTONDOWNwith the Insert menu open is a press of X1 or X2 at its point, andVK_XBUTTON1/2down count as held.vk_ui.cpppasses the pointer's buttons on masked byMKW_UI_BUTTONS, not& 7.It fails on
main(FAIL: gpu/vk/vk_ui.cpp passes the pointer's buttons on without the side buttons; with that mask alone mended,FAIL line 580: ... out.pressed==HOS_MOUSE_X1) and passes here with g++ and clang. Undoing each part of the fix in turn fails it: the held buttons, the press, the Insert menu's gate (it then becomes a game-menu press), eitherMK_XBUTTONin the capture's release, SDL's 4 and 5, the mask.tests/screensaver_test.ccompiles the whole window procedure: its fixture got the side buttons' constants and a stand-in forbutton_bit.button_bitis written withifs, sotests/test_menu_hit.pyand the button cut still find the window procedure's owncase WM_LBUTTONDOWN:/case WM_RBUTTONDOWN:. Every check that reads a changed file passes (run_all.py --changed), apart from five that fail onmaintoo in this WSL.scripts/check_host_compile.py: Linux 83 host units, Windows (llvm-mingw) 81, 0 failed, on 7e106835a as onmain7bc53f841.The whole suite
--strict, 7e106835a againstmain7bc53f841: 845 passed, 53 failed, 13 skipped on both, the same 53 files failing (they fail onmainin this WSL). Since then onlytests/display_pointer_test.cppandtests/test_display_pointer.pychanged, and they pass on this head.cargo test -p game-ui -p key-names: 194 and 2 passed.A cold review by a second agent (the diff and the tests) found nothing blocking. The fix's mutations it found untested, the mask and the capture's release, are now caught by the checks above.
Still to test:
Measurements
Nothing on the frame path: the mask is a constant, and the two extra
GetAsyncKeyStatecalls run only when a mouse message is published.Risks
Low. A side button pressed with the Insert menu open is now the menu's, so a listening slot takes it. Out of a listening slot nothing reads it. Out of the Insert menu nothing changes. A revert is enough.
Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.tests/that reads changed source is updated, not weakened.docs/modding/settings.mdalready listsMouse4andMouse5.)Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
https://claude.ai/code/session_01VxeaZi9Np8FcHAzJs2LM9d
Tested in game: Windows 10, RTX 4090, driver 617.42, a 5-button mouse, a copy of my own save; runtime v3.2.0-335-g7e106835a (this head's code). F1 > Controls: A's slot listening took Mouse 4, Y's took Mouse 5 (settings file: key_a = "5,0", key_y = "6,0"); the side buttons do nothing over the menu while no slot listens; in play (mouse captured) Mouse 4 and Mouse 5 act as A and Y; on the pause screen Mouse 4 confirms as A, as before.
WIP: fix(input): Mouse 4 and Mouse 5 can be bound in Controls (#3226)to fix(input): Mouse 4 and Mouse 5 can be bound in Controls (#3226)@rebase
I rebased this pull request onto
main(6b888fa3d2): the new head is077f987f38.Conflicts resolved
Nothing was built or run: read the resolution before merging.
Automated rebase by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
c40c980845077f987f38Recommendation: Approve. The code is ready: only testing is left. The reported Windows run shows the binding fix working, but the Linux input path has not yet been tested with a real side-button mouse. Recommend approval; not approved on the forge.
The change passes side-button presses through the host and UI so a listening Controls keybind can name them Mouse4 and Mouse5. It also changes pointer handling in pop-out windows; Linux gameplay support remains a separate, existing limitation.
Nits (1): optional.
Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
host/posix/display_sdl.c:129: The Linux side-button binding path needs the real-mouse run already identified in Still to test. (more on the line) Do: On Linux with a five-button mouse, bind each side button in Controls and verify the displayed and saved bindings.@fixcan do L2.Checks: Still running:
PR description / Title and description (pull_request_target).More: does it help, other systems, switches, what was read
Does it help: Yes on the reported Windows run: both buttons were bound and then used in play. The game-free tests reportedly fail on the base and pass on this head; the Linux binding path still needs an in-game run.
Other systems: Windows and Linux have separate event paths, and both also feed pop-out windows. The reported in-game run covers Windows; the Linux fixture covers the button mapping but does not exercise SDL with a real mouse. GPU vendor differences are not apparent in this input wiring. Linux gameplay support for these bindings is explicitly outside this change.
Switches: None added, changed or removed.
Reviewed:
077f987f38against6b888fa3d2: Read AGENTS.md, CONTRIBUTING.md, the pull request template, relevant standards, the diff and commit messages. Read the changed key-name and input definitions and the pointer test harness; inspected the changed host and renderer paths and their callers. The large changed source files and UI test file were skimmed outside the changed areas, rather than read in full. No review checklist was present at docs/review-checklist.md. Comments and supplied CI results were read; overlapping pull requests cannot be checked on the closed network beyond the one named in the description.; nothing run (a code review).Checked and fine:
Testing: No code or tests were run during review. The author reports a successful Windows in-game run and game-free checks; the supplied CI status has no head-only failures and one check still running.
Overlaps and merge order: The description identifies #1172 as the separate Linux gameplay support change; its merge order cannot be verified from the checkout.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its rebase. Nothing was run; a maintainer decides.
@ -127,3 +127,3 @@pointer_publish_at(x, y, pressed, wheel);}static uint32_t sdl_button_bit(int b) { return b == 1 ? HOS_MOUSE_LEFT : b == 3 ? HOS_MOUSE_RIGHT : b == 2 ? HOS_MOUSE_MIDDLE : 0; }static uint32_t sdl_button_bit(int b) { /* (SDL's 4 and 5 are the side buttons, Mouse 4 and 5: #3226) */L1 (should fix): The Linux side-button binding path needs the real-mouse run already identified in Still to test.
When: The fixture supplies SDL button numbers directly, so it cannot show that a real Linux SDL event reaches a listening Controls slot and is saved as the intended binding.
Do: On Linux with a five-button mouse, bind each side button in Controls and verify the displayed and saved bindings.