diff --git a/wlx-overlay-s/src/gui/README.md b/wlx-overlay-s/src/gui/README.md index 5f9717a..d50955a 100644 --- a/wlx-overlay-s/src/gui/README.md +++ b/wlx-overlay-s/src/gui/README.md @@ -1,28 +1,4 @@ -# WayVR GUI Customization - -When customizing the watch, keyboard, dashboard, etc; place custom XML files under ~/.config/wlxoverlay/theme/gui - -## Custom timezones, 12 vs 24-hour clock - -These are not done via the GUI system, but via the regular config. - -Create `~/.config/wlxoverlay/conf.d/clock.yaml` as such: - -```yaml -timezones: -- "Europe/Oslo" -- "America/New_York" - -clock_12h: false -``` - -Once this file is created, the various settings in custom UI that accept the `_timezone` property will use these custom alternate timezones (instead of the default set, which are selected as major ones on different continents from your current actual timezone). - -The first timezone is selected with `_timezone="0"`, the second with `_timezone="1"`, and so on. - -There is usually no need to specify your own local timezone in here; omitting `_timezone` from a `_source="clock"` Label will display local time. - -## Custom UI Elements +# Custom UI Elements ### Labels @@ -149,6 +125,12 @@ Available argument value types (case insensitive): Gracefully shuts down WlxOverlay-S. Useful when using an auto-restart script. +##### `::SendKey ` + +Sends a key using the virtual keyboard. If WayVR is focused, the key is sent to the WayVR app. + +Supported VirtualKey values are listed [here](https://github.com/galister/wlx-overlay-s/blob/f2bd169c2217d51cd2de862a6429444bf326f471/wlx-overlay-s/src/subsystem/hid/mod.rs#L336). + ##### `::PlayspaceReset` Resets the STAGE space to (0,0,0) with identity rotation. diff --git a/wlx-overlay-s/src/gui/panel/button.rs b/wlx-overlay-s/src/gui/panel/button.rs index 834dcda..f02a17e 100644 --- a/wlx-overlay-s/src/gui/panel/button.rs +++ b/wlx-overlay-s/src/gui/panel/button.rs @@ -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( 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(),