From 2acfdfb380e2a657d812cc1ee6a68aa0a44f9c20 Mon Sep 17 00:00:00 2001 From: local Date: Wed, 25 Nov 2026 07:19:34 -0600 Subject: [PATCH] Scripted keys can be held from one time to another Co-Authored-By: Claude Opus 5.5 --- crates/victory-hle/src/modules/gameinput.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/crates/victory-hle/src/modules/gameinput.rs b/crates/victory-hle/src/modules/gameinput.rs index bb5f26a..d0b0bf9 100644 --- a/crates/victory-hle/src/modules/gameinput.rs +++ b/crates/victory-hle/src/modules/gameinput.rs @@ -1246,12 +1246,13 @@ mod host { } /// Debugging aid: `VICTORY_KEYS=:,...` holds each key for - /// 0.2 s that long after input starts, with or without focus. A key is a + /// 0.2 s that long after input starts (`-:`: all that + /// 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). #[cfg(feature = "diagnostics")] fn scripted() -> Vec { - static SCRIPT: LazyLock<(Instant, Vec<(Duration, u8)>)> = LazyLock::new(|| { + static SCRIPT: LazyLock<(Instant, Vec<(Duration, Duration, u8)>)> = LazyLock::new(|| { let list = std::env::var("VICTORY_KEYS").unwrap_or_default(); let keys = list.split(',').filter_map(|entry| { let (at, key) = entry.split_once(':')?; @@ -1269,18 +1270,20 @@ mod host { } _ => return None, }; - Some(( - Duration::try_from_secs_f64(at.trim().parse().ok()?).ok()?, - vk, - )) + let time = |t: &str| Duration::try_from_secs_f64(t.trim().parse().ok()?).ok(); + let (from, to) = match at.split_once('-') { + Some((from, to)) => (time(from)?, time(to)?), + None => (time(at)?, time(at)? + Duration::from_millis(200)), + }; + Some((from, to, vk)) }); (Instant::now(), keys.collect()) }); let (start, keys) = &*SCRIPT; let now = start.elapsed(); keys.iter() - .filter(|&&(at, _)| (at..at + Duration::from_millis(200)).contains(&now)) - .map(|&(_, vk)| vk) + .filter(|&&(from, to, _)| (from..to).contains(&now)) + .map(|&(_, _, vk)| vk) .collect() }