add watch toggle setting (#526)

* add watch toggle setting

* previous commit broke monado workaround, this fixes it

* use active_state to toggle watch

* use the other monado workaround

* fix whitespace

* cargo fmt
This commit is contained in:
art0007i 2026-06-03 09:22:09 +02:00 committed by GitHub
parent 066f033a91
commit 9806027e19
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 37 additions and 4 deletions

View File

@ -100,6 +100,7 @@
"SCREEN_RENDER_DOWN_HELP": "Helps with aliasing on high-res screens", "SCREEN_RENDER_DOWN_HELP": "Helps with aliasing on high-res screens",
"SCROLL_SPEED": "Scroll speed", "SCROLL_SPEED": "Scroll speed",
"SELECT_VARIANT": "Select variant", "SELECT_VARIANT": "Select variant",
"ENABLE_WATCH": "Enable watch",
"SETS_ON_WATCH": "Sets on watch", "SETS_ON_WATCH": "Sets on watch",
"SKYBOX": "Skybox", "SKYBOX": "Skybox",
"SKYMAP_ALREADY_DOWNLOADED": "This skymap is already downloaded. Select desired action.", "SKYMAP_ALREADY_DOWNLOADED": "This skymap is already downloaded. Select desired action.",

View File

@ -44,6 +44,7 @@
"USE_SKYBOX_HELP": "Wyświetlaj niebo, jeśli nie ma aplikacji sceny lub passthrough", "USE_SKYBOX_HELP": "Wyświetlaj niebo, jeśli nie ma aplikacji sceny lub passthrough",
"USE_PASSTHROUGH_HELP": "Pozwól na passthrough, jeśli runtime XR to obsługuje", "USE_PASSTHROUGH_HELP": "Pozwól na passthrough, jeśli runtime XR to obsługuje",
"SCREEN_RENDER_DOWN_HELP": "Pomaga redukować aliasing na ekranach o wysokiej rozdzielczości", "SCREEN_RENDER_DOWN_HELP": "Pomaga redukować aliasing na ekranach o wysokiej rozdzielczości",
"ENABLE_WATCH": "Włącz zegarek",
"SETS_ON_WATCH": "Lista zestawów na zegarku", "SETS_ON_WATCH": "Lista zestawów na zegarku",
"TROUBLESHOOTING": "Rozwiązywanie problemów", "TROUBLESHOOTING": "Rozwiązywanie problemów",
"CLEAR_SAVED_STATE": "Wyczyść zapisany stan", "CLEAR_SAVED_STATE": "Wyczyść zapisany stan",

View File

@ -274,6 +274,7 @@ enum SettingType {
PointerLerpFactor, PointerLerpFactor,
ScreenRenderDown, ScreenRenderDown,
ScrollSpeed, ScrollSpeed,
EnableWatch,
SetsOnWatch, SetsOnWatch,
SpaceDragMultiplier, SpaceDragMultiplier,
SpaceDragUnlocked, SpaceDragUnlocked,
@ -309,6 +310,7 @@ impl SettingType {
Self::KeyboardSoundEnabled => &mut config.keyboard_sound_enabled, Self::KeyboardSoundEnabled => &mut config.keyboard_sound_enabled,
Self::UprightScreenFix => &mut config.upright_screen_fix, Self::UprightScreenFix => &mut config.upright_screen_fix,
Self::DoubleCursorFix => &mut config.double_cursor_fix, Self::DoubleCursorFix => &mut config.double_cursor_fix,
Self::EnableWatch => &mut config.enable_watch,
Self::SetsOnWatch => &mut config.sets_on_watch, Self::SetsOnWatch => &mut config.sets_on_watch,
Self::HideGrabHelp => &mut config.hide_grab_help, Self::HideGrabHelp => &mut config.hide_grab_help,
Self::AllowSliding => &mut config.allow_sliding, Self::AllowSliding => &mut config.allow_sliding,
@ -435,6 +437,7 @@ impl SettingType {
Self::PointerLerpFactor => Ok("APP_SETTINGS.POINTER_LERP_FACTOR"), Self::PointerLerpFactor => Ok("APP_SETTINGS.POINTER_LERP_FACTOR"),
Self::ScreenRenderDown => Ok("APP_SETTINGS.SCREEN_RENDER_DOWN"), Self::ScreenRenderDown => Ok("APP_SETTINGS.SCREEN_RENDER_DOWN"),
Self::ScrollSpeed => Ok("APP_SETTINGS.SCROLL_SPEED"), Self::ScrollSpeed => Ok("APP_SETTINGS.SCROLL_SPEED"),
Self::EnableWatch => Ok("APP_SETTINGS.ENABLE_WATCH"),
Self::SetsOnWatch => Ok("APP_SETTINGS.SETS_ON_WATCH"), Self::SetsOnWatch => Ok("APP_SETTINGS.SETS_ON_WATCH"),
Self::SpaceDragMultiplier => Ok("APP_SETTINGS.SPACE_DRAG_MULTIPLIER"), Self::SpaceDragMultiplier => Ok("APP_SETTINGS.SPACE_DRAG_MULTIPLIER"),
Self::SpaceDragUnlocked => Ok("APP_SETTINGS.SPACE_DRAG_UNLOCKED"), Self::SpaceDragUnlocked => Ok("APP_SETTINGS.SPACE_DRAG_UNLOCKED"),

View File

@ -1,6 +1,6 @@
use crate::tab::settings::{ use crate::tab::settings::{
macros::{options_category, options_checkbox, options_range_f32, options_slider_f32},
SettingType, SettingsMountParams, SettingsTab, SettingType, SettingsMountParams, SettingsTab,
macros::{options_category, options_checkbox, options_range_f32, options_slider_f32},
}; };
pub struct State {} pub struct State {}

View File

@ -22,6 +22,7 @@ impl State {
options_slider_f32(par.mp, c, SettingType::UiAnimationSpeed, 0.5, 5.0, 0.1)?; // min, max, step options_slider_f32(par.mp, c, SettingType::UiAnimationSpeed, 0.5, 5.0, 0.1)?; // min, max, step
options_slider_f32(par.mp, c, SettingType::UiGradientIntensity, 0.0, 1.0, 0.05)?; // min, max, step options_slider_f32(par.mp, c, SettingType::UiGradientIntensity, 0.0, 1.0, 0.05)?; // min, max, step
options_slider_f32(par.mp, c, SettingType::UiRoundMultiplier, 0.1, 5.0, 0.1)?; options_slider_f32(par.mp, c, SettingType::UiRoundMultiplier, 0.1, 5.0, 0.1)?;
options_checkbox(par.mp, c, SettingType::EnableWatch)?;
options_checkbox(par.mp, c, SettingType::SetsOnWatch)?; options_checkbox(par.mp, c, SettingType::SetsOnWatch)?;
options_checkbox(par.mp, c, SettingType::Clock12h)?; options_checkbox(par.mp, c, SettingType::Clock12h)?;
Ok(State {}) Ok(State {})

View File

@ -346,9 +346,12 @@ pub fn openxr_run(
app.hid_provider.inner.commit(); app.hid_provider.inner.commit();
let watch = overlays.mut_by_id(watch_id).unwrap(); // want panic let watch = overlays.mut_by_id(watch_id).unwrap(); // want panic
if watch.config.active_state.is_none() {
watch.config.activate(&mut app);
}
let watch_state = watch.config.active_state.as_mut().unwrap(); let watch_state = watch.config.active_state.as_mut().unwrap();
let watch_transform = watch_state.transform; let watch_transform = watch_state.transform;
if watch_state.alpha < 0.05 { if watch_state.alpha < 0.05 || !app.session.config.enable_watch {
//FIXME: Temporary workaround for Monado bug //FIXME: Temporary workaround for Monado bug
watch_state.transform = Affine3A::from_scale(Vec3 { watch_state.transform = Affine3A::from_scale(Vec3 {
x: 0.001, x: 0.001,
@ -510,7 +513,13 @@ pub fn openxr_run(
//FIXME: Temporary workaround for Monado bug //FIXME: Temporary workaround for Monado bug
let watch = overlays.mut_by_id(watch_id).unwrap(); // want panic let watch = overlays.mut_by_id(watch_id).unwrap(); // want panic
watch.config.active_state.as_mut().unwrap().transform = watch_transform;
if let Some(state) = watch.config.active_state.as_mut() {
state.transform = watch_transform
}
if !app.session.config.enable_watch {
watch.config.deactivate();
}
} // main_loop } // main_loop
if let (Some(blocker), Some(monado)) = (blocker, app.monado_state.as_mut()) { if let (Some(blocker), Some(monado)) = (blocker, app.monado_state.as_mut()) {

View File

@ -145,6 +145,7 @@ pub struct AutoSettings {
pub keyboard_sound_enabled: bool, pub keyboard_sound_enabled: bool,
pub upright_screen_fix: bool, pub upright_screen_fix: bool,
pub double_cursor_fix: bool, pub double_cursor_fix: bool,
pub enable_watch: bool,
pub sets_on_watch: bool, pub sets_on_watch: bool,
pub hide_grab_help: bool, pub hide_grab_help: bool,
pub xr_click_sensitivity: f32, pub xr_click_sensitivity: f32,
@ -200,6 +201,7 @@ pub fn save_settings(config: &GeneralConfig) -> anyhow::Result<()> {
keyboard_sound_enabled: config.keyboard_sound_enabled, keyboard_sound_enabled: config.keyboard_sound_enabled,
upright_screen_fix: config.upright_screen_fix, upright_screen_fix: config.upright_screen_fix,
double_cursor_fix: config.double_cursor_fix, double_cursor_fix: config.double_cursor_fix,
enable_watch: config.enable_watch,
sets_on_watch: config.sets_on_watch, sets_on_watch: config.sets_on_watch,
hide_grab_help: config.hide_grab_help, hide_grab_help: config.hide_grab_help,
xr_click_sensitivity: config.xr_click_sensitivity, xr_click_sensitivity: config.xr_click_sensitivity,

View File

@ -156,7 +156,7 @@ pub fn create_watch(app: &mut AppState) -> anyhow::Result<OverlayWindowConfig> {
angle_fade: true, angle_fade: true,
..OverlayWindowState::default() ..OverlayWindowState::default()
}, },
show_on_spawn: true, show_on_spawn: app.session.config.enable_watch,
global: true, global: true,
..OverlayWindowConfig::from_backend(Box::new(panel)) ..OverlayWindowConfig::from_backend(Box::new(panel))
}) })

View File

@ -85,6 +85,9 @@
# The settings are here for reference only. # The settings are here for reference only.
# Probably don't include them in your config file. # Probably don't include them in your config file.
## The watch will be enabled
#enable_watch: true
## The bottom of the watch will list sets instead of overlays. ## The bottom of the watch will list sets instead of overlays.
#sets_on_watch: false #sets_on_watch: false

View File

@ -288,6 +288,16 @@ where
self.sets_changed(app); self.sets_changed(app);
} }
OverlayTask::SettingsChanged => { OverlayTask::SettingsChanged => {
if let Some(watch) = self.mut_by_id(self.watch_id) {
if app.session.config.enable_watch != watch.config.active_state.is_some() {
if watch.config.active_state.is_some() {
watch.config.deactivate();
} else {
watch.config.activate(app);
}
}
}
for o in self.overlays.values_mut() { for o in self.overlays.values_mut() {
let _ = o let _ = o
.config .config

View File

@ -273,6 +273,9 @@ pub struct GeneralConfig {
#[serde(default = "def_false")] #[serde(default = "def_false")]
pub double_cursor_fix: bool, pub double_cursor_fix: bool,
#[serde(default = "def_true")]
pub enable_watch: bool,
#[serde(default = "def_false")] #[serde(default = "def_false")]
pub sets_on_watch: bool, pub sets_on_watch: bool,