hide watch, switch hands, store actions.json on disk
This commit is contained in:
@@ -12,7 +12,7 @@ use crate::{
|
||||
keyboard::create_keyboard,
|
||||
screen::{get_screens_wayland, get_screens_x11},
|
||||
toast::Toast,
|
||||
watch::create_watch,
|
||||
watch::{create_watch, WATCH_NAME, WATCH_SCALE},
|
||||
},
|
||||
state::AppState,
|
||||
};
|
||||
@@ -111,6 +111,10 @@ where
|
||||
o.state.reset(app, false);
|
||||
}
|
||||
}
|
||||
// toggle watch back on if it was hidden
|
||||
if !any_shown && *o.state.name == *WATCH_NAME {
|
||||
o.state.spawn_scale = WATCH_SCALE * app.session.config.watch_scale;
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use std::{array, io::Write, path::Path, time::Duration};
|
||||
use std::{array, fs::File, io::Write, time::Duration};
|
||||
|
||||
use anyhow::bail;
|
||||
use ovr_overlay::{
|
||||
input::{ActionHandle, ActionSetHandle, ActiveActionSet, InputManager, InputValueHandle},
|
||||
sys::{
|
||||
@@ -12,6 +13,7 @@ use ovr_overlay::{
|
||||
|
||||
use crate::{
|
||||
backend::input::{Haptics, TrackedDevice, TrackedDeviceRole},
|
||||
config_io::CONFIG_ROOT_PATH,
|
||||
state::AppState,
|
||||
};
|
||||
|
||||
@@ -282,29 +284,42 @@ fn get_tracked_device(
|
||||
})
|
||||
}
|
||||
|
||||
pub fn action_manifest_path() -> &'static Path {
|
||||
let action_path = "/tmp/wlxoverlay-s/actions.json";
|
||||
std::fs::create_dir_all("/tmp/wlxoverlay-s").unwrap();
|
||||
pub fn set_action_manifest(input: &mut InputManager) -> anyhow::Result<()> {
|
||||
let action_path = CONFIG_ROOT_PATH.join("actions.json");
|
||||
|
||||
std::fs::File::create(action_path)
|
||||
.unwrap()
|
||||
.write_all(include_bytes!("../../res/actions.json"))
|
||||
.unwrap();
|
||||
if !action_path.is_file() {
|
||||
File::create(&action_path)
|
||||
.unwrap()
|
||||
.write_all(include_bytes!("../../res/actions.json"))
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
std::fs::File::create("/tmp/wlxoverlay-s/actions_binding_knuckles.json")
|
||||
.unwrap()
|
||||
.write_all(include_bytes!("../../res/actions_binding_knuckles.json"))
|
||||
.unwrap();
|
||||
let binding_path = CONFIG_ROOT_PATH.join("actions_binding_knuckles.json");
|
||||
if !binding_path.is_file() {
|
||||
File::create(&binding_path)
|
||||
.unwrap()
|
||||
.write_all(include_bytes!("../../res/actions_binding_knuckles.json"))
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
std::fs::File::create("/tmp/wlxoverlay-s/actions_binding_vive.json")
|
||||
.unwrap()
|
||||
.write_all(include_bytes!("../../res/actions_binding_vive.json"))
|
||||
.unwrap();
|
||||
let binding_path = CONFIG_ROOT_PATH.join("actions_binding_vive.json");
|
||||
if !binding_path.is_file() {
|
||||
File::create(&binding_path)
|
||||
.unwrap()
|
||||
.write_all(include_bytes!("../../res/actions_binding_vive.json"))
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
std::fs::File::create("/tmp/wlxoverlay-s/actions_binding_oculus.json")
|
||||
.unwrap()
|
||||
.write_all(include_bytes!("../../res/actions_binding_oculus.json"))
|
||||
.unwrap();
|
||||
let binding_path = CONFIG_ROOT_PATH.join("actions_binding_oculus.json");
|
||||
if !binding_path.is_file() {
|
||||
File::create(&binding_path)
|
||||
.unwrap()
|
||||
.write_all(include_bytes!("../../res/actions_binding_oculus.json"))
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
Path::new(action_path)
|
||||
if let Err(e) = input.set_action_manifest(action_path.as_path()) {
|
||||
bail!("Failed to set action manifest: {}", e.description());
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -20,7 +20,12 @@ use vulkano::{
|
||||
use crate::{
|
||||
backend::{
|
||||
input::interact,
|
||||
openvr::{input::OpenVrInputSource, lines::LinePool, manifest::install_manifest},
|
||||
openvr::{
|
||||
input::{set_action_manifest, OpenVrInputSource},
|
||||
lines::LinePool,
|
||||
manifest::{install_manifest, uninstall_manifest},
|
||||
overlay::OpenVrOverlayData,
|
||||
},
|
||||
osc::OscSender,
|
||||
},
|
||||
graphics::WlxGraphics,
|
||||
@@ -28,8 +33,6 @@ use crate::{
|
||||
state::AppState,
|
||||
};
|
||||
|
||||
use self::{input::action_manifest_path, manifest::uninstall_manifest, overlay::OpenVrOverlayData};
|
||||
|
||||
use super::common::{BackendError, OverlayContainer, TaskType};
|
||||
|
||||
pub mod helpers;
|
||||
@@ -94,8 +97,8 @@ pub fn openvr_run(running: Arc<AtomicBool>) -> Result<(), BackendError> {
|
||||
|
||||
state.hid_provider.set_desktop_extent(overlays.extent);
|
||||
|
||||
if let Err(e) = input_mngr.set_action_manifest(action_manifest_path()) {
|
||||
log::error!("Failed to set action manifest: {}", e.description());
|
||||
if let Err(e) = set_action_manifest(&mut input_mngr) {
|
||||
log::error!("{}", e.to_string());
|
||||
return Err(BackendError::Fatal);
|
||||
};
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@ impl OverlayData<OpenVrOverlayData> {
|
||||
|
||||
self.upload_width(overlay);
|
||||
self.upload_color(overlay);
|
||||
self.upload_alpha(overlay);
|
||||
self.upload_curvature(overlay);
|
||||
self.upload_sort_order(overlay);
|
||||
|
||||
@@ -77,6 +78,7 @@ impl OverlayData<OpenVrOverlayData> {
|
||||
if self.data.visible {
|
||||
if self.state.dirty {
|
||||
self.upload_transform(overlay);
|
||||
self.upload_alpha(overlay);
|
||||
self.state.dirty = false;
|
||||
}
|
||||
self.upload_texture(overlay, graphics);
|
||||
@@ -108,14 +110,21 @@ impl OverlayData<OpenVrOverlayData> {
|
||||
self.backend.pause(app);
|
||||
}
|
||||
|
||||
pub(super) fn upload_alpha(&self, overlay: &mut OverlayManager) {
|
||||
let Some(handle) = self.data.handle else {
|
||||
log::debug!("{}: No overlay handle", self.state.name);
|
||||
return;
|
||||
};
|
||||
if let Err(e) = overlay.set_opacity(handle, self.state.alpha) {
|
||||
panic!("Failed to set overlay alpha: {}", e);
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn upload_color(&self, overlay: &mut OverlayManager) {
|
||||
let Some(handle) = self.data.handle else {
|
||||
log::debug!("{}: No overlay handle", self.state.name);
|
||||
return;
|
||||
};
|
||||
if let Err(e) = overlay.set_opacity(handle, self.data.color.w) {
|
||||
panic!("Failed to set overlay opacity: {}", e);
|
||||
}
|
||||
if let Err(e) = overlay.set_tint(
|
||||
handle,
|
||||
ovr_overlay::ColorTint {
|
||||
|
||||
@@ -27,6 +27,7 @@ pub struct OverlayState {
|
||||
pub interactable: bool,
|
||||
pub recenter: bool,
|
||||
pub dirty: bool,
|
||||
pub alpha: f32,
|
||||
pub transform: Affine3A,
|
||||
pub saved_point: Option<Vec3A>,
|
||||
pub spawn_scale: f32, // aka width
|
||||
@@ -49,6 +50,7 @@ impl Default for OverlayState {
|
||||
recenter: false,
|
||||
interactable: false,
|
||||
dirty: true,
|
||||
alpha: 1.0,
|
||||
relative_to: RelativeTo::None,
|
||||
saved_point: None,
|
||||
spawn_scale: 1.0,
|
||||
|
||||
Reference in New Issue
Block a user