From 3115a291e07cd23ddf4bb91f6c7fd9cf1ef5e7c1 Mon Sep 17 00:00:00 2001 From: = <=> Date: Tue, 1 Dec 2026 19:01:39 +0100 Subject: [PATCH] VICTORY_KEYS_UNTIL=: the scripted keys end once the file is there VICTORY_KEYS presses keys at set seconds, focus or not, but a script that wants Enter pressed until the world draws cannot know those seconds: the start screen takes Enter after a time that depends on the cache and the disk, and a press that comes late lands in the world. With this a script has Enter pressed every few seconds and makes the file when it sees the world draw (the window's title has the draws a frame); from then on no scripted key is pressed. The file is looked for only while a key of the script is due. Under Proton on a Wayland desktop this is what lets a measuring run start with nobody at the keyboard: a key sent from outside reaches the title only while its window has the focus. Co-Authored-By: Claude Fable 5.2 --- crates/victory-hle/src/modules/gameinput.rs | 24 +++++++++++++++++---- docs/README-fxceless.md | 1 + 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/crates/victory-hle/src/modules/gameinput.rs b/crates/victory-hle/src/modules/gameinput.rs index 4ee03c7..8298e72 100644 --- a/crates/victory-hle/src/modules/gameinput.rs +++ b/crates/victory-hle/src/modules/gameinput.rs @@ -1264,6 +1264,11 @@ mod host { /// time), with or without focus. A key is a /// letter, a digit, or `Enter`, `Esc`, `Tab`, `Back`, `Up`, `Down`, /// `Left`, `Right` (the stand-in pad's table maps them to buttons). + /// + /// `VICTORY_KEYS_UNTIL=`: no scripted key is pressed once that file + /// is there (a script that presses Enter until the world draws makes it + /// then, and the run needs nobody at the keyboard). Looked for only + /// while a key of the script is due. fn scripted() -> Vec { static SCRIPT: LazyLock<(Instant, Vec<(Duration, Duration, u8)>)> = LazyLock::new(|| { let list = std::env::var("VICTORY_KEYS").unwrap_or_default(); @@ -1292,12 +1297,23 @@ mod host { }); (Instant::now(), keys.collect()) }); + static UNTIL: LazyLock> = + LazyLock::new(|| std::env::var_os("VICTORY_KEYS_UNTIL").filter(|v| !v.is_empty()).map(Into::into)); + static OVER: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false); + use std::sync::atomic::Ordering::Relaxed; let (start, keys) = &*SCRIPT; + if keys.is_empty() || OVER.load(Relaxed) { + return Vec::new(); + } let now = start.elapsed(); - keys.iter() - .filter(|&&(from, to, _)| (from..to).contains(&now)) - .map(|&(_, _, vk)| vk) - .collect() + let down: Vec = + keys.iter().filter(|&&(from, to, _)| (from..to).contains(&now)).map(|&(_, _, vk)| vk).collect(); + if !down.is_empty() && UNTIL.as_ref().is_some_and(|file| file.exists()) { + OVER.store(true, Relaxed); + tracing::info!("VICTORY_KEYS: the file of VICTORY_KEYS_UNTIL is there, no more scripted keys"); + return Vec::new(); + } + down } /// The keyboard's keys held, from the keyboard's raw input diff --git a/docs/README-fxceless.md b/docs/README-fxceless.md index ff4ecb1..0b444ab 100644 --- a/docs/README-fxceless.md +++ b/docs/README-fxceless.md @@ -314,6 +314,7 @@ The on/off switches below (`...=1`) are off when unset or set to `0`. | `VICTORY_WATCH=,...` | logs a title u32 when it changes | | `VICTORY_POKE=[@]:,...` | writes a title byte twice a second (a hang watchdog's tick, say); in every build, not only `diagnostics`. With `@` only into the build whose image hash (`victory-image-.dll`) starts with it. The launchers set `b99f876b74d4a77f@71b6330:1`: that build's 30 s watchdog (its write to 0 at +0x23cf683) starts over while the bit is set. `off`: nothing | | `VICTORY_KEYS=30:Enter,35:X` | presses keys at those seconds, focus or not | +| `VICTORY_KEYS_UNTIL=` | no more of those keys once the file is there (a script makes it when the world draws: a run with nobody at the keyboard) | | `VICTORY_CRASH_SAVE=:,...` | saves title memory to the cache folder on a crash | | `VICTORY_CAPTURE=` | saves presented frames (powers of two, or `VICTORY_CAPTURE_FRAMES=`) | | `VICTORY_DUMP_TARGETS=1` | with the two above, saves every render target of those frames |