VICTORY_KEYS_UNTIL=<file>: 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 <noreply@anthropic.com>
This commit is contained in:
=
2026-12-01 19:01:39 +01:00
parent 75b1568280
commit 3115a291e0
2 changed files with 21 additions and 4 deletions

View File

@ -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=<file>`: 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<u8> {
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<Option<std::path::PathBuf>> =
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<u8> =
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

View File

@ -314,6 +314,7 @@ The on/off switches below (`...=1`) are off when unset or set to `0`.
| `VICTORY_WATCH=<rva>,...` | logs a title u32 when it changes |
| `VICTORY_POKE=[<hash>@]<rva>:<byte>,...` | writes a title byte twice a second (a hang watchdog's tick, say); in every build, not only `diagnostics`. With `<hash>@` only into the build whose image hash (`victory-image-<hash>.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=<file>` | 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=<rva>:<len>,...` | saves title memory to the cache folder on a crash |
| `VICTORY_CAPTURE=<dir>` | saves presented frames (powers of two, or `VICTORY_CAPTURE_FRAMES=<list>`) |
| `VICTORY_DUMP_TARGETS=1` | with the two above, saves every render target of those frames |