From 55c46ccfd21c6740ce58dad132c8d4bb1feecf5c Mon Sep 17 00:00:00 2001 From: oneshinyboi Date: Sat, 15 Aug 2026 21:14:53 -0500 Subject: [PATCH] fix swipe_type wayvr --- Cargo.lock | 5 ++-- .../src/tab/settings/tab_features.rs | 2 +- wayvr/Cargo.toml | 4 +-- wayvr/src/overlays/keyboard/mod.rs | 8 +++--- wayvr/src/overlays/keyboard/swipe_type.rs | 27 +++++++++---------- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 840c5c44..9d4f557b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6079,9 +6079,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "super-swipe-type" -version = "0.3.2" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2514d173cdebfac064577dd38387f71244daa7aa4d769076a5806fd4f7cf73e" +checksum = "d39d2eca9f0ac1a82ec03e8de1b7672a9a145f5bcdeae941efd943d9b9575b5c" dependencies = [ "anyhow", "cached-path", @@ -6090,6 +6090,7 @@ dependencies = [ "regex", "regex-automata 0.1.10", "rten", + "tar", "vector2", ] diff --git a/dash-frontend/src/tab/settings/tab_features.rs b/dash-frontend/src/tab/settings/tab_features.rs index d58a1aff..f6a7d5f7 100644 --- a/dash-frontend/src/tab/settings/tab_features.rs +++ b/dash-frontend/src/tab/settings/tab_features.rs @@ -211,8 +211,8 @@ impl State { if par.feats.swipe_to_type { swipe_type_models_button(par.mp, c)?; + swipe_type_enabled_checkbox(par.mp, c)?; } - swipe_type_enabled_checkbox(par.mp, c)?; options_checkbox(par.mp, c, SettingType::NotificationsEnabled)?; options_checkbox(par.mp, c, SettingType::NotificationsSoundEnabled)?; options_checkbox(par.mp, c, SettingType::KeyboardSoundEnabled)?; diff --git a/wayvr/Cargo.toml b/wayvr/Cargo.toml index 0d5e93b1..2cff870f 100644 --- a/wayvr/Cargo.toml +++ b/wayvr/Cargo.toml @@ -127,13 +127,13 @@ xkbcommon = { calloop = { version = "0.14.4", optional = true } calloop-wayland-source = { version = "0.4.1", optional = true } evdev = "0.13.2" -super-swipe-type = { version = "0.3.2", optional = true } +super-swipe-type = { version = "0.4.2", optional = true } [build-dependencies] regex.workspace = true [features] -default = ["openvr", "openxr", "osc", "wayland", "whisper", "x11"] +default = ["openvr", "openxr", "osc", "wayland", "whisper", "x11", "swipe-to-type"] as-raw-xcb-connection = [] feat-monado-metrics = [] openvr = ["dep:json", "dep:ovr_overlay"] diff --git a/wayvr/src/overlays/keyboard/mod.rs b/wayvr/src/overlays/keyboard/mod.rs index e1c7aecd..b87fb7f4 100644 --- a/wayvr/src/overlays/keyboard/mod.rs +++ b/wayvr/src/overlays/keyboard/mod.rs @@ -158,8 +158,8 @@ pub fn create_keyboard(app: &mut AppState, wayland: bool) -> anyhow::Result { state.swipe_typing_manager = Some(engine); state.swipe_candidate_receiver = Some(receiver); @@ -216,7 +216,7 @@ impl KeyboardBackend { if app.session.config.keyboard_swipe_to_type_enabled { #[cfg(feature = "swipe-to-type")] - init_swipe_type_manager(&mut state, data_dir::get_path("swipe_type")); + init_swipe_type_manager(&mut state, data_dir::get_path("swipe_type").join("en.tar")); log::info!("swipe engine created"); } @@ -273,7 +273,7 @@ impl KeyboardBackend { if app.session.config.keyboard_swipe_to_type_enabled { #[cfg(feature = "swipe-to-type")] - init_swipe_type_manager(&mut state_from, data_dir::get_path("swipe_type")); + init_swipe_type_manager(&mut state_from, data_dir::get_path("swipe_type").join("en.tar")); } self.active_layout = new_key; diff --git a/wayvr/src/overlays/keyboard/swipe_type.rs b/wayvr/src/overlays/keyboard/swipe_type.rs index a943d358..0500887f 100644 --- a/wayvr/src/overlays/keyboard/swipe_type.rs +++ b/wayvr/src/overlays/keyboard/swipe_type.rs @@ -53,7 +53,7 @@ impl SwipeTypingManager { match app.hid_provider.get_input_focus() { InputFocus::PhysicalScreen => { if let Some(clipboard) = self.clipboard.as_mut() { - clipboard.set_clipboard_utf8(&*text_to_paste); + clipboard.set_clipboard_utf8(&text_to_paste); Self::paste(app, original_keyboard_mods); } }, @@ -88,17 +88,17 @@ impl SwipeTypingManager { app.hid_provider .set_modifiers_routed(app.wvr_server.as_mut(), original_keyboard_mods); } - pub fn new(model_folder: PathBuf) -> anyhow::Result<(SwipeTypingManager, Receiver>>)> { + pub fn new(model_path: PathBuf) -> anyhow::Result<(SwipeTypingManager, Receiver>>)> { let (candidate_sender, candidate_receiver) = sync_channel(1); let (task_sender, task_receiver) = channel::(); // Spawn persistent worker thread let worker_candidate_sender = candidate_sender.clone(); let worker_thread = thread::spawn(move || { - let mut swipe_engine = match SwipeOrchestrator::new_with_paths(&model_folder) { + let mut swipe_engine = match SwipeOrchestrator::new_from_path(&model_path) { Ok(engine) => engine, Err(e) => { - log::error!("Failed to initialize SwipeOrchestrator: {}", e); + log::error!("Failed to initialize SwipeOrchestrator: {e}"); return; } }; @@ -117,7 +117,7 @@ impl SwipeTypingManager { let _ = worker_candidate_sender.send(Some(words)); } Err(e) => { - log::error!("Prediction failed: {}", e); + log::error!("Prediction failed: {e}"); } } } @@ -131,7 +131,7 @@ impl SwipeTypingManager { clipboard::wl::Provider::new() .log_err("Could not create Wayland clipboard provider") .ok() - .map(|p| Box::new(p) as Box); + .map(|p| Box::new(p) as Box) } #[cfg(feature = "x11")] { @@ -207,26 +207,25 @@ impl SwipeTypingManager { now } - pub fn did_swipe_leave_first_key(&self) -> bool { + pub const fn did_swipe_leave_first_key(&self) -> bool { self.swipe_left_first_key } - pub fn is_current_swipe_empty(&self) -> bool { + pub const fn is_current_swipe_empty(&self) -> bool { self.current_swipe.is_empty() } - pub fn current_swipe_mouse_button_index(&self) -> Option { + pub const fn current_swipe_mouse_button_index(&self) -> Option { self.current_swipe_mouse_button_index } pub fn add_swipe(&mut self, within_key_pos_normalized: &Vec2, key_label: char, device: DeviceBitmask, index: Option) { if let Some(pos) = self.keyboard_gird.key_positions.get(&key_label.to_ascii_lowercase()) { - if let Some(current_device) = self.current_swipe_device { - if current_device != device { - return; - } + if let Some(current_device) = self.current_swipe_device && current_device != device { + return; } + if self.first_swipe_char != char::default() && self.first_swipe_char != key_label.to_ascii_lowercase() { @@ -255,7 +254,7 @@ impl SwipeTypingManager { let point = within_key_pos_from_center * key_dimensions + key_pos; let duration = Instant::now().duration_since(start_time).mul_f32(0.8); // multiply by .8 because library is trained on mobile swipes which happen on a smaller keyboard and are faster self.current_swipe - .push(SwipePoint::new(point.x.into(), point.y.into(), duration)) + .push(SwipePoint::new(point.x.into(), point.y.into(), duration)); } } }