Scripted keys can be held from one time to another
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
b77262b5ae
commit
9e30a46122
1 file changed
+11
-8
@@ -1246,12 +1246,13 @@ mod host {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Debugging aid: `VICTORY_KEYS=<seconds>:<key>,...` holds each key for
|
/// Debugging aid: `VICTORY_KEYS=<seconds>:<key>,...` 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 (`<from>-<to>:<key>`: all that
|
||||||
|
/// time), with or without focus. A key is a
|
||||||
/// letter, a digit, or `Enter`, `Esc`, `Tab`, `Back`, `Up`, `Down`,
|
/// letter, a digit, or `Enter`, `Esc`, `Tab`, `Back`, `Up`, `Down`,
|
||||||
/// `Left`, `Right` (the stand-in pad's table maps them to buttons).
|
/// `Left`, `Right` (the stand-in pad's table maps them to buttons).
|
||||||
#[cfg(feature = "diagnostics")]
|
#[cfg(feature = "diagnostics")]
|
||||||
fn scripted() -> Vec<u8> {
|
fn scripted() -> Vec<u8> {
|
||||||
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 list = std::env::var("VICTORY_KEYS").unwrap_or_default();
|
||||||
let keys = list.split(',').filter_map(|entry| {
|
let keys = list.split(',').filter_map(|entry| {
|
||||||
let (at, key) = entry.split_once(':')?;
|
let (at, key) = entry.split_once(':')?;
|
||||||
@@ -1269,18 +1270,20 @@ mod host {
|
|||||||
}
|
}
|
||||||
_ => return None,
|
_ => return None,
|
||||||
};
|
};
|
||||||
Some((
|
let time = |t: &str| Duration::try_from_secs_f64(t.trim().parse().ok()?).ok();
|
||||||
Duration::try_from_secs_f64(at.trim().parse().ok()?).ok()?,
|
let (from, to) = match at.split_once('-') {
|
||||||
vk,
|
Some((from, to)) => (time(from)?, time(to)?),
|
||||||
))
|
None => (time(at)?, time(at)? + Duration::from_millis(200)),
|
||||||
|
};
|
||||||
|
Some((from, to, vk))
|
||||||
});
|
});
|
||||||
(Instant::now(), keys.collect())
|
(Instant::now(), keys.collect())
|
||||||
});
|
});
|
||||||
let (start, keys) = &*SCRIPT;
|
let (start, keys) = &*SCRIPT;
|
||||||
let now = start.elapsed();
|
let now = start.elapsed();
|
||||||
keys.iter()
|
keys.iter()
|
||||||
.filter(|&&(at, _)| (at..at + Duration::from_millis(200)).contains(&now))
|
.filter(|&&(from, to, _)| (from..to).contains(&now))
|
||||||
.map(|&(_, vk)| vk)
|
.map(|&(_, _, vk)| vk)
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user