feat(input): record the player's input and replay it frame for frame #1582
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
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1582
Loading…
Reference in a new issue
No description provided.
Delete branch "dyst/Longshot:feat/input-recording"
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
There was no way to give the game the same input twice. Every test run, A/B and bug repro depended on someone, or a script, steering the same way by hand, and nothing could tell when the game itself went another way. This PR lets the game record everything the player's input does to it, frame by frame, and give it back:
Each replay holds itself to two fingerprints of the original run, Link's position and the camera's state, and logs where the game first went its own way. In the game, a 65 s route in Link's house replays exactly, every update of Link's and the camera's identical. In Castle Town's market the input replays exactly, but the game drifts by its last bits from about 22 s (Measurements).
HOS_INPUT_RECORD=<file>records.HOS_INPUT_PLAY=<file>plays a recording back in place of the player's devices, the script and the bridge, and checks the run against it. With both set, the replay is recorded too, to another file; naming the played file is refused, so the recording is kept.HOS_INPUT_SNAP=1puts the camera and Link back where a replay leaves the recording.HOS_INPUT_FROM=bootstarts a recording at the game's first read instead of the frame after Link's first update.MX=/MY=inHOS_INPUT_SCRIPTmove the mouse, for the native camera's tests.Read first:
host/input_movie.h: the format and its logic, game-free.host/input_movie.c: the switches, the file, the start and the checks.npad_statesandGetSixAxisSensorStatesinhost/nn_hid.c;hos_mouse_camerainhost/mouse_native.c;hos_oot_menu_tickinhost/oot_menu.c;hos_oot_lift_playerinhost/hos_main.c.docs/dev/reference/input.md.Details:
hos_close_finish(host/hos_relaunch.c) ends the recording, sinceExitProcessruns no atexit handler.play/pilot/inputlog.py). Itspad,cam,gyro,motion,focus,itemkey,frames,viewandmarklines are ones that tool's converters pass over.See #1113
Testing
Tested: Windows 11, RTX 3080 (621.14), Ryzen 9 3900X, at
263874daonmain9dd41326, as a pack over the base. Each run went through the job queue:HOS_REALTIME_STEP=0),HOS_FIXED_TIME, no sound device, Skip title screen, the native mouse camera on.MX=/MY=.kokiri-start): one run recorded 3870 frames (7740 reads, 2680 camera updates), then:HOS_INPUT_SNAP=1: the same, nothing to put back.HOS_INPUT_RECORDnaming the played file: refused in the log, the recording's sha256 the same before and after, the playback carried on.market-entrance): one run recorded 3818 frames, then two replays. Pads, frames and camera inputs were identical; the game drifted (Measurements). A third replay, withHOS_INPUT_SNAP=1, put Link back at 2013 updates (the largest 0.087 m) and the camera at 144, through his character controller's own move. The game played the route through and the replay ended normally.python -I -B tests/run_all.pywith the Builder's llvm-mingw gives 719 passed, 70 failed, 126 skipped. The same 70 fail on cleanmain9dd41326, which has 3 more failures (load-related) and 715 passes; none is touched here. The checks that read the changed files pass:tests/test_input_movie.py: the format; recording and playback; the refusal by name, by another spelling and by a hard link; the cost with neither switch, 1 lock and 0 guest reads in 150 frames of hooks; one extra or missing update a frame.tests/test_oot_menu_mouse.py: a replay's menu choices checked against the screen.test_input_background,test_windows_stop,test_crash_record,test_oot_state_tapandtest_mouse_native, the last three among the checks that build the touched files with stubs.test_input_backgroundandtest_crash_recordfail identically onmain.Still to test:
HOS_INPUT_RECORD=run.jsonland play it withHOS_INPUT_PLAY=run.jsonl(the same save, the 60 cap,HOS_REALTIME_STEP=0). Expect the build to pass and the log'sinput: playback over at frame N of N, with the replay moving as recorded (@Beanstalk linux, build, then record and replay a walk)motionlines in the recording, andmenu choices givenmatching the recording's count with 0 not met (by hand)Measurements
Verdict: the input replays exactly. In Link's house the run does too, Link and the camera identical at every update. In the market the game drifts from update 1336 by its last bits, the determinism still open. With the switches unset the PR costs nothing measurable: 71.2 fps against
main's 70.6, withinmain's own spread from run to run (69.9 to 71.2).Setup: Windows 11, RTX 3080 (621.14), Ryzen 9 3900X, 32 GB. The cost with the switches unset was measured with
dev.py ab, this PR against its base, A1 B1 A2 B2:kokiri-startsave and the Debug tab's teleport.Each value below is the mean of the two runs, each run's in brackets. The tool refused to write the section itself, because each run's
HOS_CONTROLsocket name differs (a per-session random name).9dd41326263874daThe replays, from the same runtime: each replay's own checks are in its log, and the bridge's samples were lined up at Link's first update. The 60 cap, Per frame,
HOS_FIXED_TIME, no sound device, the native mouse camera on, the same frame-clocked script.263874da263874da263874da263874da263874daBoth market replays left the recording at the same update, at the same position, and stayed together for about 2000 updates. So the difference is most likely the game's own state at frame 0 rather than the input. The recording started at game clock 2183, both replays at 2037. In the PR's first measurements (Hyrule Field, before one pad a frame) 29 and 90 frames started at another read; now none does.
Switches
HOS_INPUT_RECORD=<file>HOS_INPUT_PLAY=<file>HOS_INPUT_SNAP=1HOS_INPUT_FROM=bootMX=/MY=inHOS_INPUT_SCRIPTRead, not added:
HOS_FIXED_TIME, which the header notes, andHOS_MOUSE_SENS, whichhos_mouse_sensitivitytakes before the first read has set the sensitivity up, asmouse_setupdoes.Risks
What could break: nothing with the switches unset. Each hook returns after one atomic load, and the callers read and copy nothing (measured above). The one player-path change besides is
hos_mouse_sensitivity(), which only reads: before the first controller read that sets the mouse up, it returnsHOS_MOUSE_SENSor the menu's value, clamped 0.1 to 5, wheremain's camera turned by 0. With the switches set, a recording from another build, save or set of settings replays the input but not the run, and the fingerprints say where.Turning it off: leave the switches unset.
After updating: nothing changes for a player: no new setting, file or cache.
Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
gpu/vk/switches.def.tests/that reads changed source is updated, not weakened.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
Tested in game: Windows 11, RTX 3080 (621.14), Ryzen 9 3900X: Hyrule Field from a save, 60 cap, Per frame, native mouse camera on. Recorded about 60 s (walks, rolls, swings, camera stick, mouse turns), replayed twice: every read given back (6929 of 6929), menu and camera lines given back; the replays' own checks find the game drifting on its own: the camera's pitch by 1e-6 degrees within 20 updates, Link by 0.00002 m after about 1200 updates. Investigating.
Verdict: Request changes. The recorder gives us useful evidence about repeatability. Playback can deliver a future frame’s input early, the default path still takes replay locks and reads the guest clock, and recording a replay can overwrite its source tape.
Reviewed head
ca473cafcc91against430eef4f2cc9. Read the tape format and parser, recorder and playback glue, changed host hooks, fixtures and switch/docs changes. Followed the input, camera, menu and shutdown paths using both exact-revision Graphify maps and source. Code review only. No changes pushed.Checked The feature captures the final pad word after live input processing, preserves the cheat axes, and reports camera and player-position drift separately. The explicit close hook addresses Windows exits that bypass
atexit. The reported Windows run is useful evidence of what the current branch can and cannot reproduce.Blocking
host/input_movie.c:255andtests/test_input_movie.py:583. Frame alignment is applied at the next frame’s first read, after an extra read may already have consumed the next frame’s input. The fixture explicitly accepts that outcome: the third read of frame 30 receives frame 31’s first pad, and frame 31 starts by delivering it again. A button edge can therefore happen a frame early. Use the recorded range for the current frame and report missing or surplus reads as input divergence. Test that a surplus read never consumes an event from a later frame, and that an omitted read is reported. Recheck the reported drift after input delivery is accounted for.host/input_movie.c:209. The switches-unset path still takes two exclusive locks per connected pad read, and begin reads the guest clock every time. The camera snapshots angles before its playback check, Link’s hook loads position before the off check, and live gyro history is copied before the recording hook returns off. Gate those operations on a cached mode so the ordinary path stays cheap, and verify the switches-unset behavior and cost.host/input_movie.c:191. If playback and recording name the same file, the tape loads first and the writer then opens that path withwb. The first playback read can truncate the original. This also applies to aliases of the same file. Reject an input/output collision or create a separate output safely. Test that the source bytes survive an attempted self-recording.host/oot_menu.c:830. Live hover passes a button taken from the current screen’s list. Replay passes a saved guest button address straight to the setter after checking only the screen address. Buttons can be rebuilt while a screen remains alive. Resolve the recorded choice against the current screen or validate membership before making the call. Count a missing button or failed setter as missed and exercise that case in the fixture.Suggestions Validate tape floats for finiteness, and use bounded yaw normalization in
hos_mouse_camera. The current camera parser accepts range-overflow results fromstrtof, and repeated subtraction can fail to make progress. Use UTF-8-aware file opens on Windows for the documented paths. For automation, report verified per-frame delivery separately from reaching the final read index. The reported 29 and 90 frame resyncs matter even when the last read index is 6,929.Testing The author reports one Windows RTX 3080 capture and two replays with input resyncs and state drift. Linux, physical gyro and menu-mouse playback remain open. Please run the record and replay sequence by hand on Linux or provide a supported farm route that preserves the tape between launches. The description check passed. The guide screenshot job is red on both this head and the base, so the status alone does not establish a new failure. List the failed checks that reproduce on main before marking ready.
The boot-save PR is related to repeatable starting state. No required merge order found.
@ -0,0 +206,4 @@/* ---- the controller (nn_hid.c npad_states) ---- */int hos_input_movie_begin(void) {AcquireSRWLockExclusive(&movie_lock);Both pad hooks take this exclusive lock even after mode is known to be off, and begin reads the guest clock. Use a cached off path before lock or guest reads, including the caller-side state copies.
@ -0,0 +252,4 @@ReleaseSRWLockExclusive(&movie_lock);return;}const uint32_t f = movie_reads++;Bound each pad lookup to the current recorded frame. An extra read currently consumes the next frame’s input early, then next-frame resync delivers it again. The fixture explicitly accepts that.
@ -0,0 +188,4 @@movie_mode == MOVIE_RECORD ? "replay of this recording" : "replay");const long long present = (long long)__atomic_load_n(&hos_present_count, __ATOMIC_RELAXED);if (movie_rec) {movie_file = fopen(movie_rec_path, "wb");The input tape was loaded earlier. If this path names that same file, wb truncates the original on playback start. Protect input/output identity, including aliases.
@ -820,0 +827,4 @@if (hos_input_movie_playing()) {MovieMenu m;while (hos_input_movie_menu_take(screen, &m)) {if (m.kind == 1) set_focus(c, screen, m.button);This address comes from a tape. Validate that the button belongs to the current screen, or resolve a stable logical ID, before calling the guest setter. Count a missing or rejected event as missed.
Pushed through
626fb0c8since this opened:376e4491). The game reads controller No.1 twice in most frames, from its job graphs, while Link updates on another worker; an input that changed between a frame's two reads reached Link or not as the race went, so replays left the recording at the first stick change (the same update in every pair of runs). Recording, a frame's first read takes the input and its later reads get the same pad; a replay gives every read of frame n frame n's pad.fcounts game frames (the game clock) in every line. In the game this took the pads and frames to identical in every pair of runs (3824 frames).ca473caf):HOS_INPUT_RECORDbesideHOS_INPUT_PLAYwrites the replay's own marks, views and frames, to set beside the recording's.1d345041,626fb0c8): view lines carry the camera's state block (14 words from+0x178), held to exactly.HOS_INPUT_SNAP=1(626fb0c8): where a replay leaves a fingerprint, the camera's block is written back and Link is moved to the mark's position through the game's own move of his character controller (OneShotPhysicsCctChangePosition, as Mark/Return do), each counted. Game-free check only so far: not run in the game yet.What is left is the game's own nondeterminism with identical input: the camera's pitch target (
+0x188) starts rising faster 3 frames apart between runs (camera dumps), most likely a background loader finishing at another frame. Under investigation; the description will follow once it is settled.mooki referenced this pull request2026-11-18 23:19:34 +00:00
Two things this needs before it can carry test and A/B routes:
1. Teleports and the Insert menu's other actions in the recording. A teleport, an age switch, an item or a Mark/Return from the Insert menu (or the bridge, or
HOS_INPUT_LIVE's!cheat) changes the game directly, not through the controller, soHOS_INPUT_RECORDdoesn't see it: the replay presses the same buttons where Link never went, and the marks call it drift from there on. The cheats' on/off state isn't in it either (only the flight and free camera cheats' sticks). A test route almost always starts with one ("teleport to X, walk to Y"), so:host/hos_main.c, the teleport throughoot_teleport_followup): anactionline with its frame, its number and its argument (destination, age, item), and acheatline when a toggle changes;2. Determinism, so a replay is the same run and not only the same input. The measurements show the input given back read for read, but the camera's pitch apart in its last bits within 20 updates and Link apart after ~20 s, growing. Until that's found the replay can't be a test ("Link reaches Y"), only a route. Places I'd look, from the numbers:
HOS_FIXED_TIME(the audio clock with no sound device,nn::osticks, the mouse camera's window clock if anything still reads it);A drift check would help hold it: record, replay twice, and report the first mark apart, so a fix shows as that update number moving out (and a regression as it moving in). Until then
HOS_INPUT_SNAPis a good stopgap for routes.Happy to help with either, the action lines especially.
Recommendation: Request changes. The design is right: it records input where it reaches the game, it gives each frame its own pad, and the drift checks are honest. But three of the earlier review's blockers are still in the code at this head: the off path takes the lock on every read, recording a replay to its own file wipes it, and replayed menu choices call the game with an unchecked pointer. It is also 196 commits behind
main, which has moveddocs/development.mdand changed every host file this touches. (Posted as a comment review at the maintainer's request.)For testers and anyone running an A/B: record a run once and play it back with the same input every frame, including the mouse camera, the gyro and the menu mouse. Each replay logs where the game first went its own way. It makes testing better and leaves the player path alone, apart from the small points below.
Does it help: not a perf change. As a test tool: partly, by the PR's own numbers (Windows, RTX 3080, 2 replays of a ~60 s recording). All 6929 reads were given back, but the camera was apart from update 9–11 and Link from update ~1192, and the gap grows. So it replays a route, not yet an exact run (see my comment on determinism and on teleports and Insert menu actions, which aren't recorded).
Other systems: every player runs the new hooks with the switches unset:
npad_states(2 exclusive locks and a guest clock read per pad read),hos_mouse_camera(now runslooks_like_cameraand a guest read at0x84c9ede0before checkingnative_on()), and Link's update (3 loads and a call). Each is cheap, but none is measured and none returns at once as the description says.hos_mouse_sensitivity()changes the mouse sensitivity path for players too (below). On Linux the build and run are not shown. The menu mouse is Windows-only, so its replay path there isn't reached.Switches:
HOS_INPUT_RECORD,HOS_INPUT_PLAY,HOS_INPUT_FROMandHOS_INPUT_SNAPare all diag switches, off unless set: the right defaults for test tools, and none is a player knob.HOS_INPUT_SNAPis missing from the description's Flags table.MX=/MY=script grammar has no default and needs none.Reviewed:
79014d29cd64against its base430eef4f2cc9. Read in full where they changed:host/input_movie.c,host/input_movie.h, thehost/nn_hid.c,host/mouse_native.c,host/oot_menu.c,host/hos_main.candhost/hos_relaunch.chunks, andgpu/vk/switches.def. Only skimmed:tests/test_input_movie.py(what it checks), the doc section and the stub-test edits. Nothing run (a code review). Compared against the earlier review atca473caf.Fixed in this review: nothing. The rebase isn't a basic conflict: 196 commits, a moved docs file and every touched host file changed on
main.Checked and fine:
376e4491. Every read of frame n now gets frame n's pad (hos_input_movie_begin275–283), and a different read count is counted, not consumed.word), so the merge and the recording can't disagree.GetSixAxisSensorStatesis bounded byHOS_MOTION_HISTORYon both sides.hos_input_movie_linktakesmovie_lockundercheats_lock, and nothing takes them the other way round.oot_put_linkmakes the sameOneShotPhysicsCctChangePositioncall Mark/Return make, with the vtable check, and restoresCtx.hos_close_finishplusatexit, once, under the lock.Blocking (to change before merge)
host/input_movie.c:237(earlier blocker 2, still open). With no switch set, every pad read still takesmovie_lockexclusively and reads the game clock, thenhos_input_movie_endtakes it again. The description's "every hook returns at once while neither switch is set" isn't true of this code. Fix: aftermovie_decide, keep an atomicmovie_mode == MOVIE_OFFfast path at the top ofbegin,endandlink.hos_mouse_cameracan likewise checknative_on()(or the movie mode) beforelooks_like_cameraand the guest read, as it did before.host/input_movie.c:214(earlier blocker 3, still open).HOS_INPUT_PLAY=run.jsonl HOS_INPUT_RECORD=run.jsonlloads the tape, then opens the same path withwbat the start, and the original recording is gone. That's an easy mistake now that "record a replay too" is a documented use. Refuse it when the two paths are the same file (compare paths, or betterGetFileInformationByHandle/statids for aliases), or write to<file>.replay.jsonl, and test that the source bytes survive.host/oot_menu.c:830(earlier blocker 4, still open). The replay passesm.button, a guest address read from the file, straight toset_focus. Only the screen address is checked. A recording from another build, or a screen whose buttons were rebuilt, makes the game call its setter on a wild pointer. Check that the button is in the current screen's list (asmouse_tickfinds it) or record a stable index, and count a miss inmovie_menu_missed.main.docs/development.mdno longer exists there (the switches docs are underdocs/dev/), andnn_hid.c,mouse_native.c,oot_menu.c,hos_main.c,hos_relaunch.c,switches.defand the four touched tests have all changed since430eef4f.pr statusalso lists 5 description items to fix beforepr ready(Summary, Still to test, commits in the Measurements columns, Ready for review).Suggestions (the author may take or leave)
host/nn_hid.c:241:hos_mouse_sensitivity()setshos_mouse_sensfrom the menu without the 0.1–5 clamp thatmouse_sens_keysapplies. If it runs before the firstmouse_sens_keys, it also overwrites the oldmouse_sens.txtvalue thatmouse_sens_keyswould have moved into the menu (it checkshos_mouse_sens != 1.0). That would lose a player's old sensitivity, and the file is renamed anyway. It is narrow (the camera update before any read with the native camera on), but it is on the player path. Clamp the value, and letmouse_setup()plusmouse_sens_keys()do the setup.host/input_movie.c:323: motion reads (c) and camera updates (n) are counted since the start, not keyed by frame. One extra or missing motion read or camera update in a replay (the same job race that moved 29/90 frames) shifts every later reading by one. Keying them by(frame, index in the frame), as the pads now are, would stop one race from shifting everything after it.host/input_movie.h:14,:23,:37,:50andmovie_tape_pad's comment still sayfis "controller reads". Since376e4491it is the game frame.strtofresults withoutisfinite(earlier suggestion). Ananin a mark makes every compare drift, and withHOS_INPUT_SNAPit writes NaN into Link's position.fopenon paths from the environment. On Windows that is the ANSI code page, not UTF-8; use the host's UTF-8 open if there is one, as otherHOS_*_FILEswitches do.read_input, so the script, the hold toggles and the live file advance once a frame instead of twice. That's intended, but worth a line in the docs: a recorded run isn't quite an unrecorded one.Questions
HOS_INPUT_SNAPbeen run in the game yet? dyst's last comment said game-free only.Testing: dyst recorded once and replayed twice on Windows 11, RTX 3080 (numbers above). The test file exercises the format and its logic and checks the wiring by reading the source. There is no Linux build or run (the PR's Must be tested), no gyro pad or menu mouse in the game, no long recording, and no in-game
HOS_INPUT_SNAPrun. Linux holds the merge, since host code must build there.Overlaps and merge order: the boot-save PR (a repeatable starting state) pairs with this; no order needed.
@ -0,0 +211,4 @@movie_mode == MOVIE_RECORD ? "replay of this recording" : "replay");const long long present = (long long)__atomic_load_n(&hos_present_count, __ATOMIC_RELAXED);if (movie_rec) {movie_file = fopen(movie_rec_path, "wb");Same path as HOS_INPUT_PLAY (or an alias): wb truncates the source recording here. Refuse it, or write beside it.
@ -0,0 +234,4 @@/* Before each read of controller No.1: 0 when the read is to be made (the merge runs, and recording, hos_input_movie_endtakes its pad as the frame's); 1 when *given is the read's pad: a replay's (the recording's for this frame), orrecording, the frame's pad taken at its first read. */int hos_input_movie_begin(MoviePad *given) {Off path: still two exclusive locks and a guest clock read per pad read with no switch set. An atomic MOVIE_OFF check after movie_decide would make it return at once, as the description says.
@ -0,0 +11,4 @@the game, where it points.Whichever device made it, a replay gives the game the same state at the same point.Points are counted from the recording's start, the first read of a game frame: `f` is controller reads since then (theStale since
376e4491: f is the game frame now, not controller reads (also :23, :37, :50, movie_tape_pad's comment).@ -232,0 +238,4 @@if (hos_mouse_sens <= 0) {mouse_setup();const char *e = getenv("HOS_MOUSE_SENS");if (!(e && atof(e) > 0)) hos_mouse_sens = rx_option(7, 100) / 100.0;No 0.1–5 clamp here, and this can run before mouse_sens_keys moves an old mouse_sens.txt into the menu, losing it.
@ -820,0 +827,4 @@if (hos_input_movie_playing()) {MovieMenu m;while (hos_input_movie_menu_take(screen, &m)) {if (m.kind == 1) set_focus(c, screen, m.button);m.button is a guest address from the file: check it is one of this screen's buttons before calling the game's setter; count a miss otherwise.
79014d29cd263874da30Rebased onto
main9dd41326and worked through both reviews: 3 commits now,393200253..263874da3.The rebase. The 11 review commits were squashed into one first (
39320025), somain's 196 commits were resolved once.docs/development.mdis gone onmain: the switches are rows ofdocs/dev/developing.md's Scripted input table, and the recordings have their own section, Input recordings.npad_statesmerged with Sprint and its toggle: a played read skips Sprint too, and the recorded word is still the one written to the game.The blockers (
88b38dd1):The off path returns at once (futondestroyer 2, HumanBean 1). The run's mode is decided once and read with one atomic load (
movie_mode_now). With neither switch set, no hook takes a lock or reads the game clock:npad_states' begin and end, the motion read, the camera and Link's update. The callers do nothing for it either (hos_input_movie_active):hos_mouse_camerachecksnative_on()beforelooks_like_cameraand the guest read again, as before the PR;The check counts it: 150 frames of every hook take 1 lock (the decision) and make 0 guest reads.
No recording over its own source (futondestroyer 3, HumanBean 2).
HOS_INPUT_RECORDnaming the fileHOS_INPUT_PLAYplays is refused before the start opens itwb. That covers the same name, another spelling of it, and a hard link: the volume serial and file index are compared on Windows,st_dev/st_inoelsewhere. The playback goes on unrecorded. The check plays a cut replay onto the file by all three names, and the recording's bytes survive each time. Without the refusal the bytes check fails.Replayed menu choices are checked (futondestroyer 4, HumanBean 3). A focus goes to the game's setter only when the file's button is one of the screen's buttons now (
each_entry, asmouse_tickfinds them). An item key goes only when it is one of Key Items'. Any other is counted innot met, and so is a choice with no setter (hos_input_movie_menu_done).test_oot_menu_mousenow plays five choices: a button of the screen, a stray address, another screen's button, an unknown key and a known one. Only the first and last reach the setters. The same case fails on the old code.Rebased (HumanBean 4). The description is in the current template now.
The suggestions:
nn_hid.c:241):hos_mouse_sensitivity()no longer setshos_mouse_sensup. It returns it once a read has set it up, and before thatHOS_MOUSE_SENSor the menu's value, clamped 0.1 to 5.mouse_sens_keysstill moves an oldmouse_sens.txtinto the menu at the first read.input_movie.c:323), in263874da. Camera updates, motion reads and Link's marks carry their frame (by the game clock, read on the hook's own thread) andi, their call within the frame. A replay looks up(frame, i): the last line at or before it for states, views and marks, and that exact call for a turn or a motion read. One more or one fewer in a frame leaves the rest alone. The glue check plays one extra of each in one frame and none in another, and every other frame is the recording's.input_movie.h:14): fixed.fis now the game frame in every line,frameslines too (their first read is"read").HOS_INPUT_SNAPwrites back.remainderf(target_yaw, 360)in one step, and no NaN is put back.getenvandfopentake UTF-8 paths as they are (nx2/win_manifest.py,tests/test_utf8_paths.py). A comment ininput_movie.csays so.HumanBean's question (has
HOS_INPUT_SNAPrun in the game?): yes, now. In Link's house a snapped replay had nothing to put back, the replay being exact. Replaying the market recording, it put Link back at 2013 updates (the largest 0.087 m, his velocity not being put back) and the camera at 144, through the game's own move of his character controller. The game played the whole route and the replay ended normally.HOS_INPUT_SNAPmakes a replay follow a route, as the docs say. It does not make the run the same.HumanBean's comment (teleports and Insert menu actions, determinism): both are follow-ups rather than part of this PR. Action lines need the tape to re-anchor its frames after each load, the way the start does after Link's first update. That's a design of its own, and I'd gladly take the offer to work on it together. On determinism, the frame keys above take one source of shifting out. The rest (job order, timers, RNG, per-thread float state) is the investigation the Measurements' drift numbers track.
Checks:
tests/test_input_movie.py,test_oot_menu_mouse,test_windows_stop,test_oot_state_tap,test_mouse_nativeand the other checks that read the touched files pass.test_input_background,test_crash_recordandtest_host_guest_writesfail identically on cleanmain9dd41326.In the game (Windows 11, RTX 3080, at
263874da, a pack over the base9dd41326; the 60 cap, Per frame,HOS_FIXED_TIME, no sound device, the native mouse camera on, the same frame-clocked script of walks, rolls, swings, the camera stick andMX=/MY=mouse turns):kokiri-start): recorded 3870 frames (7740 reads, 2680 camera updates), then two replays, each recorded too. Both were exact: 0 of 3869 updates of Link's and 0 of 2680 camera updates apart, no frame with another count of reads, and the bridge's samples identical at every common present. WithHOS_INPUT_SNAP=1the replay was the same and had nothing to put back. Replaying the market recording with it put Link back 2013 times and the camera 144 times; the game played on.market-entrance): the input replayed exactly (pads, frames, camera inputs), but the game drifted. Both replays left the recording at Link's update 1336, by 0.00002 m and at the same position as each other, and one replay's camera pitch differed in its last bits from update 10. The two replays then stayed together for about 2000 updates, which points at the game's state at frame 0 rather than the input: the recording started at game clock 2183, both replays at 2037. That's the first lead for the determinism follow-up.dev.py ab, this PR against its base, Hyrule Field, 2 runs a side): 71.2 fps (71.3, 71.1) againstmain's 70.6 (71.2, 69.9), the median frame time 13.82 ms against 13.92 ms, p99 21.48 ms against 22.20 ms. That is withinmain's own spread.Still open: a Linux build and run (Still to test names it for the Test Farm), and a gyroscope pad and the menu mouse in the game (game-free only so far). The PR stays WIP until Linux has built it.
Thanks, dyst: the three commits cover both reviews, and the exact Link's-house replays are great to see.
Taking you up on the offer: I'm building the follow-ups on top of
263874daand will push them to this branch as new commits after yours (yours untouched, no squash or reword). The plan:oot_update_player_cheatstakes (menu,HOS_INPUT_LIVE's!cheat, bridge): teleport, age, items, Mark/Return, the hour. Plus the cheat rows' values (flight, free camera, speed, heart protection, damage taken) at the start and on each change. A replay gives them back at their frame and ignores the live sources.HOS_INPUT_SYNC=<updates>(1 by default, 0 strict) puts Link and the camera back while they are off by less thanHOS_INPUT_SYNC_MAX(1 m). Beyond that the replay is reporteddivergedand stops correcting, so a test fails instead of being steered. This replacesHOS_INPUT_SNAP(it becomes a GONE row).record,play, with the recorder's state instatus).assets/routes/from a repository save, anddev.py ab --route.If you're mid-change in any of these files, say so and I'll rebase onto yours before pushing.
Pushed five commits on top of yours:
263874da→b8d2dd57, a fast-forward. Your three commits are untouched.ece8a879anchors, actions and rows, bounded correction, run-time start and stop (host/input_movie.c,.h,hos_main.c,rx_backend.c)oot_update_player_cheatstakes them. A replay takes none of the player's (a bridge teleport gets a refusal) and gives the recorded ones at their frame.rx_optionanswers them from the recording while it plays.HOS_INPUT_SYNCreplacesHOS_INPUT_SNAP, on by default: put back at every n-th update (0: never) while Link is withinHOS_INPUT_SYNC_MAX(1 m). Past that it'sdiverged, said once, and nothing is put back after it. A replay that is recorded too ends its file with aresultline.hos_input_record_start/_stop,hos_input_play_start/_stop,_status). The session state is one struct, cleared between recordings. A run-time playback refuses a recording from another map and puts Link at its start first.HOS_INPUT_ROUTE=1: no guest words or addresses (view angles only, no menu mouse lines).HOS_INPUT_SAVEgoes in the header.test_mouse_nativebuilds on Linux again (it skips on Windows, so it didn't show for you): stand-ins for the recording's hooks.082ed925Debug tab rows and bridge commandsdrift_correction, frozen) in the Debug tab's Developer section, in a module of their own. MkwVkHost goes to version 42 (input_record,input_play,input_status).recordandplaycommands, andstatus'srecorder.7321b829the host's own time-based choices by the game clock while recording or playing: the OCB hold and the texture compaction gap.b686531aroutes:assets/routes/(README, the exception noted in CONTRIBUTING and AGENTS),dev.py route record|check|list,tests/test_routes.py, anddev.py ab --route ROUTE [--sync N], which refuses a run whose replay diverged or missed a load.b8d2dd57docs:reference/input.mdrewritten around the above, plus the switch table and the user docs' rows.Checked here (Linux, game-free, through the job queue):
test_input_moviepasses with the new cases:test_routes,test_mouse_native,test_control,test_longshot_ctl,test_menu_ini_keys,test_menu_model,test_hos_ab,test_ocb_hold,test_tex_compact,test_switch_table, and thenn_vi.cpacing checks.dev.py packover base9dd41326builds the host and the renderer.263874dawithout these changes:test_input_background(stick-directions),test_menu_text_field(956, the Output resolution field) andtest_dev_ab(the Skip title screen row).Not run in the game yet. Next:
kokiri-startwith a teleport in it, and replay it withHOS_INPUT_SYNC=0and at 1;- A playback started from the menu or the bridge takes Link to the recording's age and map first: the Debug tab's age switch and its teleport to the destination whose map is the recording's (the header now writes the age too), each asked again after 12 s and given up after the third, then the start after his next update there, and Link put at the recording's start. Only a map no teleport goes to is refused. A recording made from the game's start (HOS_INPUT_FROM=boot) plays from the switches alone. - The Debug tab's Play recording opens a page of its own (TAB_RECORDINGS, back to Debug): Stop playback while one plays (where it is, the corrections), Last recording, then the recordings folder's newest first (16, named by their date and map), and No recordings yet when there is none. After a restart the last recording is the folder's newest. MkwVkHost version 42's input_play takes a path, and input_recording lists the folder. - The cold review's points: - a recording made above 60 fps writes its frames lines once a frame of its own, so it plays back (several of the game's frames to one); - the wait at a load gives up by the game clock's time (15 s), not after 900 of the game's frames; - a load the recording does not have is a divergence that uses up none of its anchors, and a rebase never goes back; - Link past HOS_INPUT_SYNC_MAX is a divergence with or without the correction, and a run-time playback puts Link at the start with Drift correction Off too; - a replay that is recorded too writes the recording's Debug tools rows; - the bridge's record stop says whether a file was written; - the three rows have their own place after Set up for a weak laptop; - the route checker refuses a key twice, NaN and infinities, and any text in the header but what the game writes there. Checked here, game-free, through the job queue: test_input_movie (another map's start, a map no teleport goes to, a recording made above 60 fps, an unmatched load, a recorded replay's rows), test_routes, test_menu_model, test_menu_ini_keys, test_hos_ab, test_control, test_longshot_ctl; dev.py pack builds. test_menu_keys, test_menu_module_slots and test_menu_text_field fail here as on263874dawithout these changes. Not run in the game yet. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017vw8e3aEPBsd7QfUkaatjPPushed three commits on top of
b8d2dd57(head now02b37487), @dyst for your eyes:c5f7061a, a playback starts from anywhere. One started from the menu or the bridge takes Link to the recording's age and map itself (the Debug tab's age switch and teleport, from the header'smapandage), then puts him at its start; only a map no teleport goes to is refused. The Debug tab's Play recording is now a page: Stop playback while one plays, Last recording, therecordings/folder newest first, and an empty state. MkwVkHost 42'sinput_playtakes a path andinput_recordinglists the folder. Plus the cold review's points: frames above 60 fps, the load wait by the game clock, unmatched loads, divergence without correction, a recorded replay's rows,record stop'swritten, and the route checker.bcaa7256, from a first try in the game. Stop now works: during playback the pads still reach the menu, not the game. A playback turns the menu into the compact bar. The rows have their own Input recording section on the Debug tab, and Play recording has its arrow. Link and the camera are held to the recording for its first 30 updates, because the game's move of Link lands an update late and replays were calling themselves diverged at frame 1. Those holds aren't counted as corrections.02b37487, docs. developing.md has a new Replay a recording section (the dev loop for tests and agents). There's also a row in AGENTS.md, the measure skill, and updates to the bridge and input references.Checked: game-free, on Linux: test_input_movie, test_routes, test_menu_model, test_menu_ini_keys, test_hos_ab, test_control, test_menu_tune, test_doc_anchors and test_switch_table; the pack builds.
Already failing: test_menu_keys, test_menu_module_slots and test_menu_text_field fail here exactly as they do on
263874da.Not yet tested in the game: the second and third commits.
Pushed
95acb020on top of02b37487: fixes from a cold self-review.MOVIE_ANCHOR_GAP) is moved back to it. Before, it counted as a load the recording doesn't have, and the playback ended early.agegoes to the age whose map it is;playor the menu; one made from the start plays withHOS_INPUT_PLAY.Checked: game-free, on Linux: test_input_movie (with a new check of the load re-base), test_menu_model, test_menu_ini_keys, test_hos_ab and test_menu_tune; the pack builds.
Not yet tested in the game.
Rebased onto main
c7bd8f80(37 commits ahead of where it was): the old head was95acb020, the new one isd2ebcbc9. dyst's three commits are kept, each rebased as it was. The only conflict was inscripts/devtools/ab.py, between main's--dynamicand phase timings and this branch's--route: both are kept. MkwVkHost stays at version 42 (main is still at 41).Checked: game-free, on Linux, on the rebased tree: test_input_movie, test_routes, test_menu_model, test_hos_ab, test_menu_tune, test_control, test_longshot_ctl, test_doc_anchors, test_switch_table, test_ocb_hold, test_tex_compact, test_mouse_native and test_dev_ab all pass.
Failing, but not from this branch:
grass_distance, a key from main (#1382) that isn't in FROZEN. It fails the same way on main.rx_nvn.hand the fixture.Not built: the pack, since there's no shared base at the new main on this PC yet.
95acb020dfd2ebcbc98aWIP: feat(input): record the player's input and replay it frame for frameto feat(input): record the player's input and replay it frame for frameBeanSeller referenced this pull request2026-11-22 02:52:18 +00:00