fix(input): the mouse points at the ocarina song sheet's songs while ZL is held (#1253) #1640
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
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1640
Loading…
Reference in a new issue
No description provided.
Delete branch "cuecuemoar/Longshot:fix/songbook-mouse-hover"
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
The ocarina's song sheet opens only while ZL is held. With ZL on a controller or on the Z key, moving the mouse over the songs often did not select them: the game counted the held ZL as the player using the pad, which hides the mouse cursor again right after the mouse showed it. A button or key that stays held no longer hides the cursor; pressing one still does, and so do the sticks. To see the bug on main (Windows 10, RTX 4090, main
e090cc48): load an adult save with the ocarina (the Lost Woods), take the ocarina out, hold ZL on a pad button or the Z key (not on the right mouse button, whose own bug is #1130) and move the mouse over the songs: the selection often does not follow it. With this change each song under the mouse is selected.Read first:
read_inputinhost/nn_hid.c, which now keeps the buttons and keys that were down at the last read (down_was) and stamps the player's input only for one that was not, and theheld-inputcase intests/input_background_test.c.tests/test_pads_after_menu.py's cut ofread_inputgets the new mask it writes to (no assertion changed). The README sentence about the hidden cursor, which an earlier version of this change extended, left the README when the player docs moved todocs/user/(#1802), so the README is not changed; anddocs/tested/is gone from main (#1856), so the runs by hand are written down here, in Testing and Measurements, not in run files. Fixes #1253.Testing
Tested: By hand on my own PC (Windows 10, RTX 4090, Core i9-13900K):
rt-mainshows the song sheet's mouse hover failing with ZL held, and the runtime of this change (built at 4cf1c744: the same code, before two rebases) points at the songs (Windows 10 Pro 22H2, RTX 4090 with the driver recorded on 2026-11-16, 617.42, Core i9-13900K, 32 GB). I did not record which controller it was, nor whether ZL was on the pad or the Z key. Game-free: theheld-inputcase fails on main for the reason in Measurements and passes here, and it also fails when the fix's key line is made to stamp at every read again.test_input_background,test_pads_after_menu,test_keys_player_input,test_cursor_hidden_in_play,test_bound_keysandtest_game_menu_mouse_buttonspass atc07b0136.The whole suite (
tests/run_all.pyin WSL on Ubuntu 22.04, without--strict) at5eaa02e5and at its base, main6d25da8c: 795 passed, 69 failed, 18 skipped on the PR head; 794 passed, 70 failed, 18 skipped on main. No check fails only on the PR head: 68 check files fail on it and the same 68 fail on main, and main also failstest_longshot_ctl, which is flaky under load (it passes 3 of 3 alone on both). They are named in the comment posted with this description (2026-11-20). One check is skipped here because dav1d is not installed, and--strictwould fail it. The last rebase, onto one more main commit (2210931c,host/nn_os_sync.c, a switch row and its own test, nothingnn_hid.cincludes), ran the checks that readnn_hid.cagain, not the whole suite.Linux, at
c07b0136(on main2210931c) on Ubuntu 22.04 under WSL2, with the Linux build tools oftools.lock(clang 23.1.5 and its sysroot): the renderer builds (scripts/dev.py vk, 0 files failed, its exports checked).host/nn_hid.c, the only host file this PR changes, compiles to an object file with the build's flags (host/posix/windows.hstanding in for Windows'), against the headersrtgenwrites and an empty stand-in for the lifter'sa64_fpx.h. It gives the same 62-Wall -Wextrawarnings as on main, with the same messages and counts, so none is new. The 29 check files that readnn_hid.cran there: 27 pass, andtest_walk_keyandtest_host_guest_writesfail on main too. Not linked, and the game was not run on Linux: no game was built there, and WSL cannot run it.Still to test: None. (Not run: the game on Linux.)
Measurements
Verdict: nothing to measure in frame time: the change adds a mask compare to each read of the controls and no draw, wait or allocation. The behaviour is shown by the game-free case (fails on main, passes here) and by the run by hand.
Setup: Windows 10 Pro 22H2, RTX 4090, Core i9-13900K, 32 GB; the Lost Woods (adult), the ocarina's song sheet, ZL held. The game-free case is
python -I -B tests/test_input_background.py --case held-input; on main it is run with only this PR's test commit applied. By hand:rt-main(main) and adev_packs.pypack of this change.2210931cc07b0136held-input(stamps after one press and five more reads with Z held)FAIL:305 player_stamps == 1e090cc48)Risks
The player's-input stamp, which hides the game menus' cursor, is now made once when an input goes down: a held button no longer hides a cursor the mouse showed. A pad button that goes down and up between two reads (under one frame) is missed by the stamp, as it was by the buttons themselves. A revert is enough to turn it off. Nothing changes for players after updating: nothing is saved or written, and the options and the caches are untouched.
Checklist
Ready for review
main; the title is a Conventional Commit. (Rebased onto main2210931cwhen pushed.)mise run testpasses (any failure that also fails onmainis named). (tests/run_all.pywithout--strict: no check fails only on the PR head; the 68 files that fail on it also fail on main, named in the comment posted with this description; see Testing.)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.host/nn_hid.cbuilt on Ubuntu 22.04 under WSL2 atc07b0136, not linked or run: see Testing.)Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.Tested in game: RTX 4090, Windows 10 Pro 22H2, adult Link in the Lost Woods: ocarina out, ZL held, mouse over the song sheet's icons: the mouse points at the songs on this change (pack s1253 at 4cf1c744) and did not reliably on main (
e090cc48); run by hand, rows in docs/tested/Possibly related, for context:
The full suite, run before the last two rebases (WSL,
python -I -B tests/run_all.py): the same 43 checks fail on this branch and on main at876dc360(no clang, Vulkan headers or PIL here), so none comes from this change:test_check_third_partyandtest_crt_shadersfailed only in my/mnt/ccheckout and passed on main in a clean worktree; this PR changes nothing underthird_party/. The seven checks that read the changed files were rerun on the rebased branch and pass.@Beanstalk linux: please build the host code of this branch and check that host/nn_hid.c compiles without a new warning and the controls still read (the change is one mask compare in read_input). Any GPU is fine; no game run is needed beyond a start to the title screen.
@cuecuemoar only members of
BigBeanscan start the farm.One of them can approve this request by reacting 👍 to it or to this comment.This request was for708f985, and the PR has changed since (96aac50), so a 👍 no longer approves it. Comment@Beanstalkagain to ask for the new commit.The full suite on the rebased branch (
708f985eon main10010630, WSL): 615 passed, 54 failed, 132 skipped, in 51 distinct check files. 49 of them also fail on main at10010630: 42 of the 43 listed above (test_mirror_budgetpassed this time) and seven newer ones:test_capture_read_once,test_high_fps_fixes,test_host_guest_writes,test_mise_build,test_prepare_cache_save,test_song_note_cue,test_texture_tile_upload. The other two,test_check_third_partyandtest_crt_shaders, fail only in my/mnt/ccheckout and pass on main in a clean worktree; this PR changes nothing underthird_party/.708f985e1196aac501d1Rebased onto main
08994a9e(96 commits since the old base) and force-pushed,708f985e->96aac501(--force-with-leaseon708f985e).README.md. #1802 moved the player docs out of it, so the sentence this PR extended ("the cursor stays hidden while you play on a controller or the keyboard, until the mouse moves") no longer exists, and I kept main's README unchanged. The code and the test are the same as before; the PR no longer touches the README.96aac501on Ubuntu 22.04 under WSL2, with the Linux build tools oftools.lock(clang 23.1.5): the renderer builds (scripts/dev.py vk, 0 files failed) andhost/nn_hid.ccompiles to an object file, with the same 62-Wall -Wextrawarnings as main (none new). Not linked and not run. That is the Host code builds on both Windows and Linux box, now ticked, and "Must be tested" is now None, so the Test Farm request above is no longer needed.96aac501: the 29 check files that readnn_hid.c: 27 pass;test_walk_keyandtest_host_guest_writesfail on main08994a9ethe same way. The full suite is not re-run on this head, so that box is unticked until it is.Description moved to the new template, and the suite re-run, with the numbers below. This comment is the list the description points to.
Suite, 2026-11-19 (
tests/run_all.py, WSL on Ubuntu 22.04, not--strict, 32 at once): PR head96aac501and its base, main08994a9e, one after the other: 787 passed, 66 failed, 18 skipped on both. The same 65 check files fail on both (the runner counts 66 failures; its table lists these 65 files). This PR adds none and fixes none. One check is skipped here (dav1d is not installed), which--strictwould fail.The 65 files:
Where I looked at the causes (from the failure output, not every test), they are of two kinds, neither this change's: tests that cut code out of the source and no longer find it because main's source moved (for example
srccut: 'uint32_t memory_page_stamp(' is not in gpu/vk/vk_memory.cpp,undeclared identifier 'host_read_barrier',too many arguments to function 'scripted_input'), and checks that regenerate SPIR-V or validate it with glslang 11.8 and spirv-tools 2022.1, which Ubuntu 22.04 ships and the repository's pins are newer than (Invalid capability operand: 6022,*_spv.h is not made from ... as it is now).The only new thing this run changed in the description: One topic, on current
mainis unticked, because main has moved one commit since the rebase (3f2c9b3c, a test-only change to the NFC menu, no file in common with this PR). I will rebase right beforepr ready.96aac501d15eaa02e5ed5eaa02e5edc07b01368aRebased onto main
2210931cand force-pushed (--force-with-lease),96aac501->c07b0136; the description is current for that head. What changed since the last comment:docs(tested)commit is dropped. #1856 removeddocs/tested/from main ("no longer asks for" run files since #1802), so adding two run files back would re-create a folder main deleted. The by-hand runs are in Testing and Measurements now. The PR is two commits: the test and the fix.tests/run_all.py, WSL on Ubuntu 22.04, not--strict, 32 at once): PR head5eaa02e5: 795 passed, 69 failed, 18 skipped; its base, main6d25da8c: 794 passed, 70 failed, 18 skipped. No check fails only on the PR head. The same 68 check files fail on both; main also failedtest_longshot_ctlin that run, which is flaky under load (3 of 3 passes alone on both commits). One check is skipped here (dav1d is not installed), which--strictwould fail.2210931c,host/nn_os_sync.cplus a switch row and its test, nothingnn_hid.cincludes) atc07b0136: the renderer builds (scripts/dev.py vk, 0 files failed),host/nn_hid.ccompiles with the same 62-Wall -Wextrawarnings as main, the 29 check files that read it give 27 passes and the same two failures as main (test_walk_key,test_host_guest_writes), andheld-inputfails on main + the test commit (FAIL:305 player_stamps == 1) and passes here. Not the whole suite again.The 68 files that fail on both:
From the failure output (not every test): tests that cut code out of main's source and no longer find it, and checks that regenerate or validate SPIR-V with the glslang 11.8 and spirv-tools 2022.1 of Ubuntu 22.04, older than the repository's pins. Neither is this change's.
WIP: fix(input): the mouse points at the ocarina song sheet's songs while ZL is held (#1253)to fix(input): the mouse points at the ocarina song sheet's songs while ZL is held (#1253)Recommendation: Approve. It fixes the mouse's hover on the ocarina's song sheet while ZL is held on a pad or the Z key: the held button no longer re-hides the cursor at every read. It costs nothing, and the only thing that reads the stamp is the game menus' cursor. Recommend approval; not approved on the forge.
For a player: with the ocarina out and ZL held on a controller or the Z key, moving the mouse over the songs now selects them. The code gets better: one edge check (
down & ~down_was) in place of a stamp on every read, so a press still hides the cursor and a held button no longer does.Does it help: not a perf change. The fix is shown by the game-free
held-inputcase (fails on main + the test commit withFAIL:305 player_stamps == 1, passes here) and by the author's run by hand on Windows 10 / RTX 4090 (the build at 4cf1c744, the same code before two rebases).Other systems:
player_input_nshas one reader,host/display.cgm_cursor_shown(the free cursor in play and in the game's menus), so nothing else can change. A controller player whose mouse is bumped past the slack while they hold a button now keeps the cursor shown until the next press or stick tilt, where it used to hide again at once. That is the intended change and does no harm. The sticks (past 12000) and the movement and camera keys still stamp at every read. Mouse buttons never stamped and still don't. Scripted and bridge presses go into*buttonsabovepband never stamped. Linux and the Steam Deck run the same C on the same masks (pads_read'spb,bound_downthroughhost/posix/windows.h), so the platform can't make it behave differently. It is built on Linux and not run there.Switches: none.
Reviewed:
c07b01368aagainst main2210931cf2(its base; it is still mergeable on main3df5c13ed2). Read in full:read_inputinhost/nn_hid.c,player_usedandhos_player_input_ns,gm_cursor_shown/gm_mouse_usedinhost/display.c,tests/input_background_test.c's new case, and the changes totests/test_input_background.pyandtests/test_pads_after_menu.py. The suite numbers in the comments were only skimmed. Nothing was run, since this is a code review.Fixed in this review: nothing.
Checked and fine:
downholds the pads' buttons (pb) and the bound keys (bound_down(i, 0)) in the same HidNpadButton bit layout that*buttonsuses.pbis read whatever the menu state). Keys read as up there (key()).HOS_INPUT_EXCLUSIVE) leavedown_wasas it was. At worst a press made right after the game comes back to the front is not stamped, which leaves the cursor shown. That is harmless and never causes a hide.down_wasis one morestaticlikemenu_wasbeside it, read and written only on the input thread.read_inputwith the realplayer_usedcall sites. It counts stamps for a key and for a pad button going down, held for five reads, let go, pressed again, and a second button pressed while the first is held. Undo the key line (stamp at every read) and it fails.test_pads_after_menu.py's cut gets a localdownand asserts nothing new, so the check is not weakened.Suggestions (the author may take or leave)
host/display.clines 79-80 (outside this diff) give, as the wheel's reason for not showing the cursor, that "a button held (R, for the item choice) counts as the pad in use, and hid the cursor again at each notch". After this PR a held button no longer counts, so that reason is out of date. A word there (for example "counted", or the reason that holds now) would stop it misleading the next reader.player_input_ns(host/nn_hid.c~155) says "the last time the player's pads (a button, ...) or bound keys were used". "A button or bound key pressed" would match the new rule.Testing: By hand on Windows 10 Pro 22H2, RTX 4090, by the author, on the same code before two rebases. The game-free case fails on main and passes here. The checks that read
nn_hid.cpass, apart from two that fail the same way on main. On Linux it is built (renderer, plusnn_hid.ccompiled with no new warnings) and not run. The game can't plausibly behave differently on Linux, so the missing Linux run doesn't hold the merge. The forge's CI hasn't run on this head yet (it is waiting on its required conditions).Overlaps and merge order: #1257 is by the same author in
host/nn_hid.c: the right mouse button (ZL) held on the same song sheet stays pressed, fixing #1130. The two are independent, and neither needs the other:read_input, which doesn't stamp.nn_hid.c,input_background_test.cortest_input_background.py.docs/tested/(removed in #1856).Merge this one first. #1257 then rebases onto main with it.
@ -1089,0 +1092,4 @@ZL is for the ocarina's song sheet, it kept the game menus' cursor hidden, which the mouse shows by moving: Longshot#1253) */static uint64_t down_was;if (down & ~down_was) player_used();Checked: the edge stamp is right. Only display.c's gm_cursor_shown reads player_input_ns, a press still hides the cursor, the sticks and the movement keys still stamp at every read, and an early return that leaves down_was stale can only miss a stamp (cursor left shown), never add one.
Correction to my description and to my comment of 2026-11-20: I wrote that
docs/tested/is "gone from main" and that I dropped thedocs(tested)commit because main deleted the folder. That was too strong. #1802 stopped asking for run files and #1856 removed the one file left at that moment, but main has run files there again, added by PRs merged since. Dropping this PR's two run files was still allowed (they are no longer asked for), and the by-hand runs are in Testing and Measurements; the description now says that. The squashed commit message (83df631b) keeps my first wording; the code merged is the verifiedc07b0136.