WIP: fix(input): the mouse's side buttons stay their controls' in the game's menus #1329
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
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
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1329
Loading…
Reference in a new issue
No description provided.
Delete branch "cuecuemoar/Longshot:fix/side-buttons-in-game-menus"
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?
Type: fix · Risk: low · Tested on: Windows 10, RTX 4090 · Needs: none
Why
With A bound to a mouse side button (Mouse 4), ordinary dialogue advances but a choice in the text box, such as Navi's "Sleep until morning" at a bed, can't be confirmed: the button does nothing there. A keyboard key on A works. Fixes #1306.
How to reproduce
Seen on: Windows 10 22H2, RTX 4090, NVIDIA 617.42 (the report: Windows 11, RTX 4090, v3.0.0-rc.5)
Settings and switches: A on Mouse 4 (Insert menu, Controls;
key_a=69,5), Mouse camera on (As the stick or Native)Steps: with the mouse captured, open a choice of the text box (the report: any bed, Navi's sleep choice) and press Mouse 4
Expected: the focused choice is confirmed, as with the key on A
Actual: on main nothing happens
What changed
On Windows each of the game's own menus takes the mouse from the camera (
host/oot_menu.c,host/display.c): the capture ends and the cursor is that menu's. The left, right and middle buttons are its clicks there. A bound mouse button counted as its control only while the mouse was captured (host/nn_hid.c), so in a menu the two side buttons reached neither the menu nor their controls. Now they stay their controls' while one of the game's menus has the mouse, as a key does.host/display.c):menus_mouse, the one place the two menus' states change, records whether a game menu has the mouse with the Insert menu closed;hos_mouse_in_game_menugives it to the game's thread (avolatile LONG, as the capture's own flag).host/nn_hid.c):mouse_buttons_arm(captured, menu)arms the side buttons also while a game menu has the mouse;read_inputasks the window, not with Mouse camera Off, and reads the bound mouse buttons then too. The arming rule is the same as for a capture: a side button held as the menu opens with the mouse free counts only after it was let go; one held from play into the menu, or back, stays one press.host/posix/display_sdl.c): its window does not hand the mouse to the game's menus, so the capture and the buttons stay the game's there;hos_mouse_in_game_menureturns 0 and nothing changes. (#1172 is the side buttons being readable on Linux at all.)menu-side-buttonscase intests/test_input_background.py, through the realread_input, and the newtests/test_game_menu_mouse_buttons.py, which runsmenus_mouse(both in their own commit before the fix);tests/test_bound_keys.pychecks the arming with the new argument;tests/display_pointer_test.cpp, which compilesmenus_mouse, gets the new flag and two checks of it.docs/tested/2026-11-16-side-buttons-menus-cuecuemoar-run01.mdandrun02.This touches the same lines of
host/nn_hid.cas #1257 (a mouse button held when a menu takes the mouse); whichever lands second needs a small rebase, and the two rules compose.Measurements
Verdict: fixed: Mouse 4 on A confirms the choice with this change and does not on main (by hand, a real mouse); the game-free check fails on main and passes here. Nothing to measure for speed: one flag read and a few integer operations per input read.
Hardware: Windows 10 Pro 22H2 (19045), RTX 4090 24 GB, NVIDIA 617.42, Core i9-13900K, 32 GB
Scene: a copied save, a choice of the text box
Method: by hand with a mouse that has side buttons, A on E and Mouse 4 in both builds (the control bridge's presses do not go through the mouse's buttons)
How to reproduce: as in How to reproduce
e090cc48b81f4cfa, which adds only a test fixture's lines)tests/test_input_background.py --case menu-side-buttons(main @6d72ca93with the test commit9caabea7; this PR @b81f4cfa)tests/test_game_menu_mouse_buttons.py(the same commits)Baseline: main
e090cc48is thedev_packs.pybase on this PC; the fix's build is main6d72ca93plus this change, as a pack over it.mouse_buttons_arm,bound_downandmenus_mouseare the same one090cc48and6d72ca93.Flags and settings
None.
Testing
Tested:
read_inputnot reading the buttons in a menu.host/nn_hid.c,host/display.c,host/posix/display_sdl.cor the README: they pass but for the ones that fail on main too (below).tests/test_display_pointer.pycompilesmenus_mouseand failed on the first version of the fix for want of the new flag: its fixture is updated in the fix commit.host/nn_hid.candhost/display.ccompiled whole for Windows in the pack's build (llvm-mingw, nowarning:in its log).python -I -B tests/run_all.pyon Linux (WSL, Ubuntu 22.04), main @6d72ca93and this branch at the same commit, run side by side: main 563 passed, 49 failed, 108 skipped; the branch before the fixture update 563 passed, 50 failed, 108 skipped, the one more beingtests/test_display_pointer.py, which passes since. The 49 are the same checks on both (this WSL machine has no clang, Vulkan headers or some Python modules); among them, of the checks that read the changed files:test_crash_record,test_display_startup_failure,test_hud_layout_row,test_longshot_saves,test_tested_configurations(another PR's file with two rows),test_walk_key.Not tested:
host/); the change there is one function that returns 0, andhost/nn_hid.c's changed functions are compiled with gcc on Linux by the checks.Must be tested:
Risks
What could break: a control bound to a side button now acts in the game's menus where it did nothing before: with B or Plus on one, it backs out of or closes the menu there, as its key would.
Turning it off: revert the commit.
Compatibility: Nothing changes: no save, option, cache or interface is touched (
gpu/vk/vk_api.his not).Issues
Fixes #1306
Checklist
Everyone
type(scope): description) of the status line's type.main.python -I -B tests/run_all.pypasses (any failure that also fails onmainis named).third_party/untouched (a new folder with aPROVENANCE.mdinstead).When it applies
Assisted-by:/Co-Authored-By:trailers.docs/tested/for each new measured run (format indocs/tested-configurations.md).mainand passing here.tests/that reads changed source updated in this PR, not weakened.🤖 Generated with Claude Code
https://claude.ai/code/session_01VxeaZkuxWxPjY31qDxgN1k
Tested in game: RTX 4090, NVIDIA 617.42, Windows 10 22H2, by hand with a mouse that has side buttons (cuecuemoar): A on Mouse 4, a choice of the text box. main @
e090cc48does not confirm it; this change's build (b59bcab3, a pack over that base) confirms it.@Beanstalk please build this branch on Linux (any GPU) and start the game to the title screen and into a save: the Linux build was not made on my PC. On Linux the change is one new function in host/posix/display_sdl.c that returns 0 and its call in host/nn_hid.c, so the run only has to show that it builds, links and plays as main does.
🤖 Posted by an agent for cuecuemoar.
@cuecuemoar only members of
BigBeanscan start the farm. One of them can approve this request by reacting 👍 to it or to this comment.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.