fix(input): a mouse button held when one of the game's menus takes the mouse stays pressed #1257
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!1257
Loading…
Reference in a new issue
No description provided.
Delete branch "cuecuemoar/Longshot:fix/songbook-rmb"
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
Playing the ocarina with a mouse, the song sheet ("Check songbook") can't be read: holding the right mouse button, which is ZL by default (shield and lock-on, beside the Z key), opens the sheet and closes it again at once. The Z key works. Fixes #1130.
How to reproduce
Seen on: Windows 10 22H2, RTX 4090, NVIDIA 617.42 (the report: Windows 11, RTX 4080, v3.0.0-rc.5)
Settings and switches: defaults: ZL on Z and the right mouse button, Mouse camera on
Steps: with the mouse captured, take out the ocarina and hold the right mouse button
Expected: the song sheet stays open while the button is held, as with Z
Actual: on main it opens and closes at once
What changed
The song sheet shows only while ZL is held, and it is one of the game's own menus, which take the mouse from the camera (
host/oot_menu.c). A mouse button counted as its control only while the mouse was captured, so the moment the sheet opened the held button stopped counting: the game saw ZL let go and closed the sheet. Now a press made while the mouse is captured stays its control's until the button is let go, as a key's does.host/nn_hid.c):mouse_buttons_armkeeps, beside which buttons are armed, which count (mouse_counts): down, from a press the game got. While the mouse is captured that is an armed button held, as before; when the capture ends it stays so until the button is let go, and a capture that comes back with it still held keeps the same press.bound_downreads that, andread_inputreads the mouse's buttons (and the keys-only controls a mouse button can be bound to) whether or not the mouse is captured.host/display.c), never the game's; with the Insert menu open nothing counts (key()); Mouse camera Off never captures, so its buttons never count.tests/test_bound_keys.py(its own commit before the fix) checks the press kept after the capture ends and when it comes back, dropped when let go, a press made while free not counted, the right button as ZL, and thatread_input's loop is no longer underif (captured).tests/test_input_background.pycuts the buttons' declaration by its text: updated to the new line.docs/tested/2026-11-16-songbook-rmb-cuecuemoar-run01.mdtorun03.Measurements
Verdict: fixed: with the right mouse button held, the song sheet stays open (by hand, a real mouse); the game-free check fails on main and passes here. Nothing to measure for speed: 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: adult Link in the Lost Woods (a copied save), the ocarina out
Method: headless through the control bridge with
HOS_MENU_TRACE=1for the cause on main and a regression run of the fix (ZL pressed by the bridge: 300 frames held, and a 6-frame tap on main); the mouse itself by hand in the fix's build, since the bridge's presses do not go through the mouse's buttonsHow to reproduce: as in How to reproduce
e090cc48480d7df8, which adds only a comment's and the README's wording)the mouse is for screen ...tests/test_bound_keys.py(main @177d6b22with the test commit7a4014bc; this PR @480d7df8)Baseline: main
e090cc48is thedev_packs.pybase on this PC; the fix's build is main31f8d8beplus this change, as a pack over it. The mouse's buttons' code (mouse_buttons_arm,bound_down) is the same one090cc48,31f8d8beand177d6b22.Flags and settings
None.
Testing
Tested:
tests/test_bound_keys.pyagainst broken fixes, each failing: no carry after the capture ends, the press not kept when the capture comes back, presses made while the mouse is free counted, andread_input's loop underif (captured)again.host/nn_hid.c: 22 pass;test_walk_key.pyfails as on main (its stand-ins no longer matchscripted_inputandbound_pad_buttons, three compile errors, the same on main).host/nn_hid.ccompiled whole for Windows in the pack's build (llvm-mingw, nowarning:in its log). Linux builds the same file throughhost/posix/windows.h(itsGetAsyncKeyState): no full Linux build was made here, but the change is plain C onkey()alone, and the two checks compilemouse_buttons_arm,bound_downand the whole ofread_inputwith gcc on Linux.python -I -B tests/run_all.pyon Linux (WSL, Ubuntu 22.04): 564 passed, 33 failed (32 checks), 102 skipped on this branch overa413bf1c, before the comment's and the README's wording were added to the fix commit (the checks that read the README, the two changed checks and the tested-runs check were run again after: they pass, but for main's failures). Every one of the 32 fails on main too, the WSL machine lacking clang, the Vulkan headers and some Python modules for most: 25 failed on main @ac778751(the full suite there), and the seven others, the menu's checks, fail on main @a413bf1crun alone:nx2/test_nup_zstd_heads,test_bug_report_defaults,test_check_third_party,test_cpp_preflight,test_crash_record,test_crt_options,test_crt_shaders,test_damage_debug_menu,test_dlss_feature_size,test_failed_compile_keeps_objects,test_framegen_preset,test_guest_imported,test_hud_layout_row,test_lift_lookups,test_link_skip,test_linux_update,test_longshot_saves,test_make_game_cache,test_menu_i18n,test_missing_nup,test_mods_size_table,test_pending_guest_import,test_prof_clock,test_prompt_skip,test_rumble_menu,test_run_all_changed,test_scene_tonemap_pass,test_upscaler_round_trip,test_upscaler_rows,test_vk_occlusion_queries,test_walk,test_walk_key.Not tested:
WM_RBUTTONDOWNwhile a menu has the mouse); other controls bound to mouse buttons while a menu opens (the same rule: held until let go).Must be tested:
Risks
What could break: a mouse button held while one of the game's menus opens now stays pressed until it is let go, as a key already does: the left button (Y, attack) held into a text box, say. Before, it was let go for the game as the menu took the mouse.
Turning it off: revert the commit.
Compatibility: Nothing changes: no save, option, cache or interface is touched.
Issues
Fixes #1130
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_01VxeaZib8ryJL5zYJuGgxcr
Tested in game: Windows 10 22H2, RTX 4090, NVIDIA 617.42. By hand with a mouse, the fix's build: the ocarina out in the Lost Woods, the right mouse button (ZL) held: the song sheet stays open; the cursor shows while it is open, as in any of the game's menus. Headless through the control bridge: the sheet open for a 300-frame ZL hold and closed after it; on main the menu trace shows the sheet takes the mouse and shows only while ZL is held.
Description corrected: host/nn_hid.c is built on Linux too (through host/posix/windows.h), so the fix applies there; it was not run on Linux by hand. The Host code box added; the README's line named.
WIP: fix(input): a mouse button held when one of the game's menus takes the mouse stays pressedto fix(input): a mouse button held when one of the game's menus takes the mouse stays pressedHolding the right mouse button keeps the ocarina's song sheet open. I read head
9c29fece. Approved.A mouse button counted only while the mouse was captured. The song sheet is one of the game's menus, and opening it takes the mouse, so the held right button stopped counting as ZL and the sheet closed.
mouse_countsstays set from a press made while the mouse was captured until that button comes up, including after the capture ends, and a capture that returns with it still held keeps the same press. A press that starts while the mouse is free does not count, and the click that begins a capture still does not. The Z key already reached the game from the earlierbound_downloop, which does not look at the mouse, so that key was never dropped.The check compiles
bound_downand runs the hold, the release, a press made while the mouse is free, and the right button as ZL. The hand play was on Windows 10 with an RTX 4090: the sheet stayed open and the cursor showed. Linux was not played. The measured base is older than the current main;mouse_buttons_armis the same function on both. #11309c29fecea1b9a472efb0New commits pushed, approval review dismissed automatically according to repository settings
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.