mirror of
https://github.com/DoubleGhosty/cool_fox.git
synced 2026-12-06 08:58:35 +00:00
Merge PR #202: VICTORY_KEYS_UNTIL=<file>: the scripted keys end once the file is there
This commit is contained in:
@ -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
|
||||
|
||||
@ -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 |
|
||||
|
||||
Reference in New Issue
Block a user