add ::SendKey

This commit is contained in:
galister
2025-12-14 02:42:50 +09:00
parent f2bd169c22
commit f3f775c06b
2 changed files with 27 additions and 25 deletions

View File

@@ -2,6 +2,7 @@ use std::{
cell::RefCell,
process::{Command, Stdio},
rc::Rc,
str::FromStr,
sync::{Arc, atomic::Ordering},
time::{Duration, Instant},
};
@@ -23,6 +24,7 @@ use crate::{
gui::panel::helper::PipeReaderThread,
overlays::toast::Toast,
state::AppState,
subsystem::hid::VirtualKey,
windowing::OverlaySelector,
};
@@ -140,6 +142,24 @@ pub(super) fn setup_custom_button<S: 'static>(
RUNNING.store(false, Ordering::Relaxed);
Ok(EventResult::Consumed)
}),
"::SendKey" => {
let Some(key) = args.next().and_then(|s| VirtualKey::from_str(s).ok()) else {
log::error!("{command} has bad/missing arguments");
return;
};
let Some(down) = args.next().and_then(|s| match s.to_lowercase().as_str() {
"down" => Some(true),
"up" => Some(false),
_ => None,
}) else {
log::error!("{command} has bad/missing arguments");
return;
};
Box::new(move |_common, _data, app, _| {
app.hid_provider.send_key_routed(key, down);
Ok(EventResult::Consumed)
})
}
"::ShellExec" => {
let state = Rc::new(ShellButtonState {
button: button.clone(),