fix(input): Sprint keeps its buttons after a restart; the controls' bindings move to Rust #3108
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
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!3108
Loading…
Reference in a new issue
No description provided.
Delete branch "HumanBean/Longshot:push-xlrluxqvxtpy"
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 bug (since #2822): turn Sprint on, restart the game: the Sprint row still reads On, but L3 and Shift no longer sprint until you turn it off and on again. Turning Sprint on moved Shift and the left stick's press onto Sprint in the host, but only the "off" path told the game to read the bindings back (
binds_moved()), so the "on" move was never saved.What this changes
game/crates/binds: the table, the rebind rules, Sprint's layout, the Layout presets and Reset.longshot-gamekeeps it beside the settings and saves every change where it is made.host/nn_hid.c) only copies the table whengame_binds_generationmoves; a read of the controllers keeps the copy it began with.gpu/vk/menu/sprint.cppandbindings.cppare gone, withMkwVkHost.bindandbinds_serial.Read first:
game/crates/binds/src/lib.rs(ported from the C and C++), thenedit_binds,change_bindsandrules_afteringame/crates/longshot-game/src/settings_now.rs, thenbinds_loadinhost/nn_hid.c.Conflicts to expect with other open PRs on the same code: #2753, #1709, #3031, #3044.
Testing
Not tested in the game. The person this was done for asked to skip the game test. Nothing here has run with a controller or keyboard.
Tested (Linux, RTX 3090; no one has played it yet):
159d3ca0, rebased ontomain6318f405(one conflict: #3105 also tookMKWVK_API_VERSION90, so this is now 91):cargo checkof the touched crates,ffi-gen --checkandtest_sprint,test_bound_keys,test_input_background,test_prompt_current_bindspass. The runs below are from before the rebase.54613068(basemain76092c5e): a Linux runtime builds, anddev.py smokepasses (headless: in play fromkokiri-start, 900 frames, the Insert menu opened). It does not touch Sprint or any binding.binds,host-sysandlongshot-gamepass.tests/sprint_saved.rscopied onto plainmainfails there for the bug's reason: the file hassprint = trueand nopad_sprint.0aeb6858);mise run testwith 10 failures, 8 also on plainmainand since fixed there, 2 this branch's and fixed (313178e5); the host's C compiled for Windows (llvm-mingw, compile only) (313178e5).api's andmodtool's tests, clippy, the Windows compile (CI runs them).Still to test:
settings.tomlfrom a nightly that has the bug (Sprint on, no button), turn Sprint off and on, restart, and check it still works.Measurements
Not measured. The input read's change: an atomic load per read to see whether the bindings moved, a copy of the 128-byte table only when they did, and two reader locks gone.
Risks
pad_,key_andsprint_auto_bindlines keep their names and values; the reader is now Rust. A porting slip would show as controls lost or changed after updating. 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). (Not rerun on this head, see Testing.)main, or Measurements says why there is nothing to measure. (Not measured.)third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here. (game/crates/longshot-game/tests/sprint_saved.rs)tests/that reads changed source is updated, not weakened. (test_pad_layout,test_plus_bindingandtest_ocarina_note_bindingstested the removed C: their table rules are nowgame/crates/binds' tests.test_bound_keysandtest_sprintkeep their host checks.)MKWVK_API_VERSIONbumped (MkwVkHostorMkwVkRendereringpu/vk/vk_api.hchanged).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
Possibly related, for context:
WIP: fix(input): Sprint keeps its buttons after a restart; the controls' bindings move to Rustto fix(input): Sprint keeps its buttons after a restart; the controls' bindings move to Rust@review
Recommendation: Request changes. The migration can mix binding versions within one input report and can save stale bindings after concurrent edits. Startup repair also overwrites deliberately empty Sprint bindings, and the fix has not been exercised in the game.
The change moves binding ownership into the game and saves Sprint's automatically assigned inputs. It also replaces the host's locked input snapshot with per-thread copies and repairs unbound Sprint settings at startup; those paths need correction before merge.
Blocking (2): must change before merging.
game/crates/longshot-game/src/settings_now.rs:598: The repair cannot distinguish the broken saved layout from a player deliberately clearing both Sprint inputs. (more on the line) Do: Use a migration marker or another reliable indication that the saved bindings came from the broken automatic move; preserve explicitly cleared inputs.game/crates/longshot-game/src/settings_now.rs:1249: The fix lacks the repository-required game-free regression test that can demonstrate the failure on the base. (more on the line) Do: Add a game-free regression harness that exercises the old and new observable save-and-restart behavior and fails on the base while passing here.Should fix (3): not blocking, but worth doing before merging.
host/nn_hid.c:1199: An input read can replace its bindings after it has started, despite marking the snapshot active. (more on the line) Do: Load once at the start of the report and make every later load respect input_snapshot_active; publish Sprint's setting and its bindings as one coherent input snapshot too.game/crates/longshot-game/src/settings_now.rs:637: Binding edits and their serialization are not ordered as one operation. (more on the line) Do: Serialize each table mutation and its complete document update with a shared transaction lock, including binding rules and resets.game/crates/binds/src/lib.rs:226: The numeric parser saturates multiplication but can still overflow when it adds the next digit. (more on the line) Do: Use saturating_add as well, or parse with checked arithmetic and reject out-of-range values.Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
@fixcan do L1, L2, L3, L4 and L5.Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Unproven. The added Rust tests cover save and reload behavior, but the PR reports no keyboard or controller game run and no before-and-after measurements.
Other systems: The binding table feeds keyboard, mouse, gamepad, HUD shortcut, ocarina notes and prompts on Windows and Linux. Concurrent changes can affect a controller report in progress; neither platform has a reported game run on this head.
Switches: No switches added, changed or removed.
Reviewed:
e0ce70df5fagainst76092c5e5a: Read the available AGENTS.md, CONTRIBUTING.md and PR template; docs/review-checklist.md and ../Tooling/AGENTS.md were absent. Read the commit and portions of the diff, including the binding table, startup and persistence code, host input snapshot and API wiring. The full set of changed files, surrounding callers, tests, documentation and generated files was not read in full; this review cannot establish that all problems were found.; nothing run (a code review).Checked and fine:
Testing: Read-only review; no tests, builds or project scripts were run. The PR reports cargo check on the head's base, earlier checks on other bases, and no game test.
Overlaps and merge order: The PR identifies #2753, #1709, #3031 and #3044 as conflicting work; their current state and merge order were not available in the checkout.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -0,0 +223,4 @@Some(t) => (-1, t),None => (1, t.strip_prefix('+').unwrap_or(t)),};sign * t.bytes().take_while(u8::is_ascii_digit).fold(0i64, |n, d| n.saturating_mul(10) + i64::from(d - b'0'))L4 (should fix): The numeric parser saturates multiplication but can still overflow when it adds the next digit.
When: A sufficiently long numeric pad or key value in settings.toml reaches i64::MAX during parsing; adding a nonzero digit overflows, potentially panicking during startup or producing a wrapped value.
Do: Use saturating_add as well, or parse with checked arithmetic and reject out-of-range values.
@ -593,0 +595,4 @@*lock(&self.binds) = table;// (the file's own value: a run's switch writes no bindings)let saved_on = self.file_line("sprint").is_some_and(|t| options_store::atoi(&t) != 0);if saved_on && self.with_binds(binds::Table::sprint_unbound) {L3 (blocking): The repair cannot distinguish the broken saved layout from a player deliberately clearing both Sprint inputs.
When: A player who leaves Sprint enabled but clears its key and pad slots gets Shift and L3 assigned again at every start; the repair can also move B and LS away from their chosen bindings and saves those changes.
Do: Use a migration marker or another reliable indication that the saved bindings came from the broken automatic move; preserve explicitly cleared inputs.
@ -604,2 +636,2 @@pub fn controls_changed(&self) {if self.put_controls() {/// The bindings changed by `f` and written: a change the menu or the control bridge makes.pub(crate) fn change_binds<R>(&self, f: impl FnOnce(&mut binds::Table) -> R) -> R {L2 (should fix): Binding edits and their serialization are not ordered as one operation.
When: One thread can change the table and copy its lines in put_binds, then pause while a second thread changes and writes a newer table. When the first resumes, it can overwrite the document with its older lines, so the live bindings look correct but a restart restores stale or mixed bindings.
Do: Serialize each table mutation and its complete document update with a shared transaction lock, including binding rules and resets.
@ -1178,0 +1246,4 @@use binds::{Set, control};d.with_binds(|t| {[t.binding(Set::Pad, control::SPRINT, 0),L5 (blocking): The fix lacks the repository-required game-free regression test that can demonstrate the failure on the base.
When: The new restart tests depend on the new binding table and do not build on main, as the PR notes, so they cannot demonstrate the reported old host-to-settings failure on the base.
Do: Add a game-free regression harness that exercises the old and new observable save-and-restart behavior and fails on the base while passing here.
@ -1549,3 +1197,3 @@player_used();}binds_load(); /* (the keys: key_default's, or longshot_options.ini's; the mouse's buttons once its capture is known) */binds_load(); /* (the keys; the mouse's buttons once its capture is known) */L1 (should fix): An input read can replace its bindings after it has started, despite marking the snapshot active.
When: If a binding changes after pad or ocarina inputs have been sampled, the unconditional binds_load here, or the calls in bound_pad_buttons and oc_notes, can load the new table before the rest of the report is built. One report can therefore combine old and new assignments, including consuming an ocarina input under one layout and mapping it under another.
Do: Load once at the start of the report and make every later load respect input_snapshot_active; publish Sprint's setting and its bindings as one coherent input snapshot too.
@review
Recommendation: Request changes. The repair still cannot distinguish every deliberately cleared legacy Sprint layout from the broken layout, so it can overwrite a player's controls. The migrated input path also needs an in-game run.
The change moves binding ownership and persistence into the game so enabling Sprint saves its buttons across restarts. It also centralizes binding rules, at the cost of a substantial input-path migration and an ambiguous repair of older settings.
Blocking (1): must change before merging.
game/crates/longshot-game/src/settings_now.rs:598: The repair cannot distinguish the broken saved layout from a player deliberately clearing both Sprint inputs. When: A player who leaves Sprint enabled but clears its key and pad slots gets Shift and L3 assigned again at every start; the repair can also move B and LS away from their chosen bindings and saves those changes. Do: Use a migration marker or another reliable indication that the saved bindings came from the broken automatic move; preserve explicitly cleared inputs.Testing before merging (1) (the change behaves the same on every system: one run of the change itself is enough; it doesn't hold the recommendation)
@fixcan do L3.Since the last review (on
e0ce70df5f)Resolved: L1 (An input read can replace its bindings after it has started, despite marking the snapshot…); L2 (Binding edits and their serialization are not ordered as one operation.); L4 (The numeric parser saturates multiplication but can still overflow when it adds the next d…); L5 (The fix lacks the repository-required game-free regression test that can demonstrate the f…)
Still open: L3 (The repair cannot distinguish the broken saved layout from a player deliberately clearing…); L6 (The migrated input path has not been exercised in the game.)
Checks: Still running: 11 checks.
Also noticed (1; not asked for, not blocking)
More: does it help, other systems, switches, what was read
Does it help: Unproven: the new game-free test exercises the saved bindings, but the change has not been tested in the game. No performance gain is claimed or measured.
Other systems: The migration affects keyboard and controller input, prompts, ocarina controls, presets and saved settings on Windows and Linux. The description reports earlier builds, but no controller or keyboard play test and no Windows game start on this head.
Switches: No switches added, changed or removed.
Reviewed:
d6d8301a2cagainst76092c5e5a: Read the fix diff, binding publication code, Sprint regression test, relevant host input and binding rules, and the repository contribution rules and PR template. The full PR diff and all changed files were not read in full; other affected code and tests were skimmed.; nothing run (a code review).Checked and fine:
Testing: No commands that build or run the project were executed. The PR reports no in-game test; its head CI checks are still running.
Overlaps and merge order: The description identifies overlapping pull requests #2753, #1709, #3031 and #3044; merge order is not established.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
Pushed
54613068, answering both reviews.tests/sprint_saved.rsreads the saved file through functionsmainhas. Its run onmainis still to be done.@review
Recommendation: Approve. The code is ready: only testing is left (a run of the change itself). The startup repair no longer changes deliberately cleared bindings, but the migrated input path has not yet been exercised in the game. The head's CI checks are also still running. Recommend approval; not approved on the forge.
Sprint binding changes are saved where they are made, and the host reads a consistent copy of the bindings. Removing startup repair preserves deliberate layouts; players with an already broken Sprint layout must turn Sprint off and on once.
Testing before merging (1) (the change behaves the same on every system: one run of the change itself is enough; it doesn't hold the recommendation)
Since the last review (on
d6d8301a2c)Resolved: L3 (The repair cannot distinguish the broken saved layout from a player deliberately clearing…)
Still open: L6 (The migrated input path has not been exercised in the game.)
Checks: Still running: 11 checks.
Also noticed (1; not asked for, not blocking)
More: does it help, other systems, switches, what was read
Does it help: Unproven: the reported Rust tests pass on this head, but no keyboard or controller game run has confirmed the fix. The input-read performance change has not been measured.
Other systems: The migration affects keyboard and controller bindings, presets, prompts and input reads on Windows and Linux. No in-game run is reported, and the Windows compile and other CI checks are still running.
Switches: None added, changed or removed.
Reviewed:
546130688eagainst76092c5e5a: Read the fix diff, the affected startup loading and binding-write code, the Sprint persistence test, and repository rules. Skimmed the full pull request diff and input documentation; the remaining changed files were not read in full.; nothing run (a code review).Checked and fine:
Testing: No commands that build or run tests were executed. The author reports passing binds, host-sys and longshot-game tests on this head; in-game testing and CI results remain outstanding.
Overlaps and merge order: The description identifies potential conflicts with #2753, #1709, #3031 and #3044; their current status and merge order were not checked.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
On
54613068: the Linux runtime builds and the headless smoke run passes (start, play, menu); tests/sprint_saved.rs fails on plain main for the bug's reason. Sprint and rebinding have still not been tried by a player.Rebased onto main
6318f405, now159d3ca0. One conflict, in gpu/vk/vk_api.h: #3105 also took MKWVK_API_VERSION 90, so this change is 91. Nothing else changed by hand.546130688e159d3ca0e8llun referenced this pull request2026-12-03 23:38:52 +00:00