feat(input): add hold-to-fast-forward trigger and speed options (#2800) #3031
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!3031
Loading…
Reference in a new issue
No description provided.
Delete branch "cfw34683/Longshot:feat/2800-trigger-fast-forward"
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?
Closes #2800
Adds configurable fast-forward trigger and speed settings to Gameplay:
Tests run
07860d6b713f3a829d1aPlease move this atop the
mod-apibranch which is merging soon!9d5e51534eb18fc993f3@HumanBean Ported atop
origin/mod-api(b18fc993) and retargeted this PR's base branch tomod-api:fast_forward_trigger(legacyId = 57) andfast_forward_speed(legacyId = 67) togame/mods/gameplay/mod.tomland regeneratedsettings_abiviaschema-gen.hos_fast_forward_held/hos_fast_forward_percent(host/nn_hid.c,host/nn_vi.c) throughgame_set_fast_forward(game/game.h,longshot-game) intogame_core::video::Realtime(game/crates/game-core/src/video.rs).game-core video::tests(25 passed),tests/test_settings_link.py(PASS), andclangcompilation ofhost/nn_hid.c&host/nn_vi.c.b18fc993f3b832f1c477b832f1c47791052832029105283202eeac62a59c@review
Recommendation: Request changes. The host calls a function that no longer exists, so the game cannot link. The new input read also races with the input thread and can respond to input while the game is in the background.
Adds configurable hold-to-fast-forward controls and scales the game’s frame step while held. The feature is useful, but the current host integration is broken and its input and timing paths need further verification.
Blocking (4): must change before merging.
host/nn_hid.c:1020: This calls the removed rx_option interface, for which the host has no definition. (more on the line) Do: Use hos_input_held() to check whether the menu or a mod holds input.host/nn_hid.c:1023: The present thread reads pad_after_menu under a lock that its writer does not take. (more on the line) Do: Protect both reads and writes with the same lock, or publish the mask atomically and load it atomically here.host/nn_hid.c:1021: The fast-forward input bypasses the foreground gate used for gameplay input. (more on the line) Do: Apply the same foreground and controller-in-background policy as read_input, and clear or ignore stale pad state when pads do not count.game/mods/gameplay/mod.toml:36: The two new saved settings are absent from the frozen options-key table. (more on the line) Do: Add both keys with their gameplay owner to tests/test_menu_ini_keys.py and update the menu-order check for the new rows.Should fix (2): not blocking, but worth doing before merging.
game/mods/gameplay/mod.toml:36: The new Gameplay rows are missing from the user settings table. (more on the line) Do: Add both rows in menu order with their choices and defaults.Nits (1): optional.
Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
game/crates/game-core/src/video.rs:1268: The port changes the game’s timing path, but the reported in-game test predates this implementation. (more on the line) Do: Run the current head in game with keyboard and controller triggers, release and menu capture, and representative frame caps on Windows and Linux, including Tier 1 hardware. Compare frame times with the feature Off against the base.@fixcan do L1, L2, L3, L4, L5, L6 and L7.Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Unproven on this head. The reported Windows F2 run describes the earlier implementation; the port comment reports unit and compile checks but no in-game run of
eeac62a59c. No before-and-after frame-time measurements are supplied for the feature’s cost while off.Other systems: The change affects controller and keyboard input, menu input capture, game timing at all frame caps, Windows and Linux, and input recordings. The reported run covers only F2 on Windows on the earlier implementation; it does not establish controller, Linux, timing-mode, or current-head behavior.
Switches: No environment switches added, changed, or removed. The player settings default to trigger Off and speed 200%; Off is an appropriate opt-in default, but the current implementation has not been verified on the head.
Reviewed:
eeac62a59cagainst267b4e4fee: Read the repository rules, standards, PR template, diff, commit, changed timing and input sections, their callers, settings declarations and relevant checks. Skimmed the large generated settings files and unchanged portions of the large host and game headers; the combined full-file output was truncated. Tooling’s adjacent AGENTS.md and docs/review-checklist.md were absent.; nothing run (a code review).Checked and fine:
Testing: Read-only review; no builds, scripts, or tests were run. The supplied CI checks are still running.
Overlaps and merge order: PR #3029 concerns skipping cutscenes outright; the supplied context does not show it overlapping this implementation. The author says this was ported atop mod-api, which the maintainer asked to merge first.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -1262,3 +1266,3 @@let sum: f64 = self.samples[..self.count].iter().sum();let mean = sum / self.count as f64;let timed = p.cap != CAP_CONSOLE && sw.fps_step && p.step_object.is_some();let timed = (p.cap != CAP_CONSOLE || ff_active) && sw.fps_step && p.step_object.is_some();L8 (should fix): The port changes the game’s timing path, but the reported in-game test predates this implementation.
When: The current head’s trigger, release, and scaled game step have not been shown working together in gameplay; the unit test exercises only a synthetic 60 FPS timed step.
Do: Run the current head in game with keyboard and controller triggers, release and menu capture, and representative frame caps on Windows and Linux, including Tier 1 hardware. Compare frame times with the feature Off against the base.
@ -33,2 +33,4 @@place = { tab = "gameplay", before = "bug_report", order = 300 }[[settings]]id = "fast_forward_trigger"L4 (blocking): The two new saved settings are absent from the frozen options-key table.
When: test_menu_ini_keys.py collects both store = options declarations and rejects them as new keys because neither appears in FROZEN.
Do: Add both keys with their gameplay owner to tests/test_menu_ini_keys.py and update the menu-order check for the new rows.
L5 (should fix): The new Gameplay rows are missing from the user settings table.
When: A player looking up Gameplay settings in docs/user/graphics-and-controls.md cannot find either the trigger choices or the speed range and defaults.
Do: Add both rows in menu order with their choices and defaults.
@ -1014,0 +1017,4 @@int hos_fast_forward_held(void) {int rx_option(int id, int otherwise);const int mode = HOS_SETTING(fast_forward_trigger, 0);if (mode <= 0 || rx_option(1, 0)) return 0;L1 (blocking): This calls the removed rx_option interface, for which the host has no definition.
When: Whenever the host is linked, hos_fast_forward_held references rx_option; the only remaining host interface is rx_option_set, so the link fails even when fast-forward is Off.
Do: Use hos_input_held() to check whether the menu or a mod holds input.
@ -1014,0 +1018,4 @@int rx_option(int id, int otherwise);const int mode = HOS_SETTING(fast_forward_trigger, 0);if (mode <= 0 || rx_option(1, 0)) return 0;if (mode == 4) return key(0x71);L3 (blocking): The fast-forward input bypasses the foreground gate used for gameplay input.
When: With F2 selected, pressing F2 in another foreground application is read by GetAsyncKeyState and speeds up the background game. With a controller selected, leaving the window while a trigger is held can leave pad_raw_now stale because background pad polling is disabled by default, keeping fast-forward active.
Do: Apply the same foreground and controller-in-background policy as read_input, and clear or ignore stale pad state when pads do not count.
@ -1014,0 +1020,4 @@if (mode <= 0 || rx_option(1, 0)) return 0;if (mode == 4) return key(0x71);AcquireSRWLockShared(&pad_bind_lock);const uint64_t raw = (uint64_t)(uint32_t)pad_raw_now & ~(pad_after_menu | hud_pad_mask());L2 (blocking): The present thread reads pad_after_menu under a lock that its writer does not take.
When: A game input read updates pad_after_menu while a present evaluates a controller trigger. Those unsynchronized accesses form a data race, so the trigger can see an invalid or stale mask.
Do: Protect both reads and writes with the same lock, or publish the mask atomically and load it atomically here.
Rebased onto
main(267b4e4f) and force-pushed to your branch:eeac62a5, was91052832. If you have local work on it, take the new head first.Conflicts were in the generated settings files;
game/settings_abi.h,host-sys/src/settings_abi.rsandgame/game.hwere regenerated withschema-genandffi-gen.The final head was pushed without checks and not run in the game.
(Posted by Claude Code.)
eeac62a59c6ca7383c0c6ca7383c0c2b77772714BeanBot's review on
eeac62a5flags items that are already fixed on the current head (2b777727, rebased ontomain1a86a938):host/nn_hid.c): Replaced removedrx_option(1, 0)withhos_input_held().host/nn_hid.c): Synchronizedpad_after_menuacrossread_input()and readers (hos_fast_forward_held(),pad_sprint_down(), ocarina notes) using__atomic_load_n/__atomic_store_n.host/nn_hid.c): Addedgame_in_front()andpads_in_background(getenv("HOS_INPUT_BACKGROUND"), PADS_IN_BACKGROUND_SETTING)gating tohos_fast_forward_held()so keyboard/controller triggers respect window focus andController in background.tests/test_menu_ini_keys.py,game/mods/menu/test/menu.test.ts): Addedfast_forward_triggerandfast_forward_speed(game:GAMEPLAY) toFROZENand updated the gameplay menu order list.docs/user/graphics-and-controls.md): Documented both new Gameplay rows in menu order with their choices and defaults.Assisted-by:): Head commit2b777727includesAssisted-by: Antigravity.fast_forward_trigger,fast_forward_speed,mod.toml, and the actual checks run (tests/test_menu_ini_keys.py,tests/test_settings_link.py,cargo test -p game-core video::tests, andclang -fsyntax-onlyonhost/nn_hid.candhost/nn_vi.c).f995b827312712a9ea7dRebased onto
main(0a68a1de) and pushed2712a9ea. The rebase had conflicts, and a local run of the game-free checks found problems CI never reported, because CI hasn't run on this PR yet (every job shows blocked or cancelled). The fixes are in their own commit,2712a9ea, so they're easy to review apart from the feature.Rebase conflicts
host/nn_hid.c: #3108 removedpad_bind_lock, and this branch still took it inpad_sprint_down()andoc_notes(). I kept main's lock-free code there.menu.test.tsanddocs/user/graphics-and-controls.md: I kept main's new Gameplay order (# interfacesection) and put Fast-forward trigger and speed right after Game speed, which matches theirplaceinmod.toml.The data race BeanBot raised (L2), done more narrowly
pad_after_menuis now atomic only where two threads share it.read_input()publishes it with an atomic store, andhos_fast_forward_held()loads it atomically on the game thread.pad_sprint_down()andoc_notes()are called only fromread_input(), on the thread that writes it, so they keep main's plain reads (this also keepstest_sprint's pinned source).Fixes for checks that would have failed in CI
test_walk_key: the fast-forward functions sat behind a forward declaration ofpads_in_background(), and the test's source extraction took that declaration for the definition. They now sit below the definition, and the forward declaration is gone.test_parity_gates: the Per frame 60 cap gate and the timed-step condition invideo.rskeep main's exact lines. Fast-forward is an extra branch: while held, it takes the timed step scaled by the multiplier. Not held (100%), every path is the same as before, so parity runs, which never hold it, still get Per frame's exact 60th.test_option_ids: I removed the twolegacyIds (57, 67). The LEGACY table says a new setting takes none.test_settings_area_keys: FROZEN now gives the new keys as an area mod's setting (&opts.fast_forward_*) rather than a system mod's (game:GAMEPLAY).test_i18n_complete: the four new texts are translated into all 13 languages, and "ZL + ZR" is on NAMES, as ZL and ZR are. Native speakers, please correct any wording.test_pacing_policy: stubs forhos_fast_forward_percent()andgame_set_fast_forward().missing-docswarning:game_set_fast_forward()had been inserted betweengame_presented's doc comment andgame_presented, sogame_presentedlost its docs.game_set_fast_forward()now has its own doc comment, and the comment innn_vi.cis fixed the same way.Checked locally (Windows, tools.lock's llvm-mingw)
tests/run_all.py --changed origin/main: 74 passed and 5 failed. The 5 (test_alt_enter,test_hle_guest_ranges,test_fps_stats,test_input_background,test_gfx_world) fail the same way on cleanmainon this PC, so they're unrelated to this PR.cargo test -p game-core video: 25 passed, includingfast_forward_scales_timed_step.cargo clippy -p game-core -p longshot-game --all-targets: no warnings in the files this PR touches.schema-gen --check: the generated files match.Still needed: an in-game retest of hold-to-fast-forward (ZL, ZR, ZL + ZR, F2) at 60 and above 60 FPS, in both Per frame and Real time. I'll post the results here.
@review
Recommendation: Approve. The current head commit still lacks the AI-assistance trailer requested in L6. The integrated fast-forward behavior also awaits an in-game retest. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge.
Adds a configurable hold-to-fast-forward trigger and speed. It extends the existing input and timing paths, with the trigger off by default; the integrated behavior has not yet been demonstrated on this implementation.
Should fix (1): not blocking, but worth doing before merging.
Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
game/crates/game-core/src/video.rs:1268: The port changes the game’s timing path, but the reported in-game test predates this implementation. When: The current head’s trigger, release, and scaled game step have not been shown working together in gameplay; the unit test exercises only a synthetic 60 FPS timed step. Do: Run the current head in game with keyboard and controller triggers, release and menu capture, and representative frame caps on Windows and Linux, including Tier 1 hardware. Compare frame times with the feature Off against the base.@fixcan do L6.Since the last review (on
eeac62a59c)Resolved: L1 (This calls the removed rx_option interface, for which the host has no definition.); L2 (The present thread reads pad_after_menu under a lock that its writer does not take.); L3 (The fast-forward input bypasses the foreground gate used for gameplay input.); L4 (The two new saved settings are absent from the frozen options-key table.); L5 (The new Gameplay rows are missing from the user settings table.); L7 (The description and test claims still describe the previous implementation.)
Still open: L6 (The description claims an AI-assistance trailer is recorded, but the head commit has none.); L8 (The port changes the game’s timing path, but the reported in-game test predates this imple…)
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 25 game-core video tests include a scaled-step test, but no in-game run of the current implementation is reported.
Other systems: The change affects keyboard and controller input, focus and background input, and game timing at 60 FPS and other caps. The reported game-free checks cover part of the wiring; in-game behavior on Windows and Linux remains unreported.
Switches: Adds Gameplay settings Fast-forward trigger, default Off, and Fast-forward speed, default 200%. Off avoids changing existing play until enabled; the speed choices need the pending in-game check.
Reviewed:
2712a9ea7dagainst0a68a1dea8: Read AGENTS.md and CONTRIBUTING.md, the commit messages, and the relevant timing, input, setting and frozen-key diff and surrounding code. Skimmed the recorded checks and review context; did not read every changed code file in full. Tooling's neighboring AGENTS.md and docs/review-checklist.md were not present.; nothing run (a code review).Checked and fine:
Testing: No commands that execute project code or tests were run. The author reports 25 game-core video tests passed and game-free checks with five failures also present on clean main; CI is still running.
Overlaps and merge order: None identified from the supplied context.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
llun referenced this pull request2026-12-04 00:23:27 +00:00