add alt_click
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
use std::f32::consts::PI;
|
||||
use std::process::{Child, Command};
|
||||
use std::{collections::VecDeque, time::Instant};
|
||||
|
||||
use glam::{Affine3A, Vec2, Vec3, Vec3A, Vec3Swizzles};
|
||||
@@ -8,7 +9,7 @@ use smallvec::{smallvec, SmallVec};
|
||||
use crate::backend::common::{snap_upright, OverlaySelector};
|
||||
use crate::config::{AStrMapExt, GeneralConfig};
|
||||
use crate::overlays::anchor::ANCHOR_NAME;
|
||||
use crate::state::{AppState, KeyboardFocus};
|
||||
use crate::state::{AppSession, AppState, KeyboardFocus};
|
||||
|
||||
use super::overlay::{OverlayID, OverlayState};
|
||||
use super::task::{TaskContainer, TaskType};
|
||||
@@ -35,6 +36,7 @@ pub struct InputState {
|
||||
pub ipd: f32,
|
||||
pub pointers: [Pointer; 2],
|
||||
pub devices: Vec<TrackedDevice>,
|
||||
processes: Vec<Child>,
|
||||
}
|
||||
|
||||
impl InputState {
|
||||
@@ -44,6 +46,7 @@ impl InputState {
|
||||
ipd: 0.0,
|
||||
pointers: [Pointer::new(0), Pointer::new(1)],
|
||||
devices: Vec::new(),
|
||||
processes: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +55,7 @@ impl InputState {
|
||||
self.pointers[1].before = self.pointers[1].now;
|
||||
}
|
||||
|
||||
pub fn post_update(&mut self) {
|
||||
pub fn post_update(&mut self, session: &AppSession) {
|
||||
for hand in &mut self.pointers {
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
@@ -134,6 +137,24 @@ impl InputState {
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
|
||||
if hand.now.alt_click != hand.before.alt_click {
|
||||
// Reap previous processes
|
||||
self.processes
|
||||
.retain_mut(|child| !matches!(child.try_wait(), Ok(Some(_))));
|
||||
|
||||
let mut args = if hand.now.alt_click {
|
||||
session.config.alt_click_down.iter()
|
||||
} else {
|
||||
session.config.alt_click_up.iter()
|
||||
};
|
||||
|
||||
if let Some(program) = args.next() {
|
||||
if let Ok(child) = Command::new(program).args(args).spawn() {
|
||||
self.processes.push(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -281,7 +281,7 @@ pub fn openvr_run(running: Arc<AtomicBool>, show_by_default: bool) -> Result<(),
|
||||
&mut system_mgr,
|
||||
&mut state,
|
||||
);
|
||||
state.input_state.post_update();
|
||||
state.input_state.post_update(&state.session);
|
||||
|
||||
if state
|
||||
.input_state
|
||||
|
||||
@@ -268,7 +268,7 @@ pub fn openxr_run(running: Arc<AtomicBool>, show_by_default: bool) -> Result<(),
|
||||
|
||||
app_state.input_state.pre_update();
|
||||
input_source.update(&xr_state, &mut app_state)?;
|
||||
app_state.input_state.post_update();
|
||||
app_state.input_state.post_update(&app_state.session);
|
||||
|
||||
if app_state
|
||||
.input_state
|
||||
|
||||
@@ -129,6 +129,10 @@ fn def_osc_port() -> u16 {
|
||||
9000
|
||||
}
|
||||
|
||||
fn def_empty_vec_string() -> Vec<String> {
|
||||
Vec::new()
|
||||
}
|
||||
|
||||
fn def_screens() -> AStrSet {
|
||||
AStrSet::new()
|
||||
}
|
||||
@@ -273,6 +277,12 @@ pub struct GeneralConfig {
|
||||
|
||||
#[serde(default = "def_false")]
|
||||
pub space_rotate_unlocked: bool,
|
||||
|
||||
#[serde(default = "def_empty_vec_string")]
|
||||
pub alt_click_down: Vec<String>,
|
||||
|
||||
#[serde(default = "def_empty_vec_string")]
|
||||
pub alt_click_up: Vec<String>,
|
||||
}
|
||||
|
||||
impl GeneralConfig {
|
||||
|
||||
Reference in New Issue
Block a user