fix swipe_type wayvr

This commit is contained in:
oneshinyboi 2026-08-15 21:14:53 -05:00
parent 13d63b00fd
commit 55c46ccfd2
No known key found for this signature in database
GPG Key ID: A494E206A095F0C0
5 changed files with 23 additions and 23 deletions

5
Cargo.lock generated
View File

@ -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",
]

View File

@ -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)?;

View File

@ -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"]

View File

@ -158,8 +158,8 @@ pub fn create_keyboard(app: &mut AppState, wayland: bool) -> anyhow::Result<Over
})
}
#[cfg(feature = "swipe-to-type")]
pub(self) fn init_swipe_type_manager(state: &mut KeyboardState, model_folder: std::path::PathBuf) {
match SwipeTypingManager::new(model_folder) {
pub(self) fn init_swipe_type_manager(state: &mut KeyboardState, model_path: std::path::PathBuf) {
match SwipeTypingManager::new(model_path) {
Ok((engine, receiver)) => {
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;

View File

@ -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<Option<Vec<String>>>)> {
pub fn new(model_path: PathBuf) -> anyhow::Result<(SwipeTypingManager, Receiver<Option<Vec<String>>>)> {
let (candidate_sender, candidate_receiver) = sync_channel(1);
let (task_sender, task_receiver) = channel::<PredictionTask>();
// 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<dyn ClipboardProvider>);
.map(|p| Box::new(p) as Box<dyn ClipboardProvider>)
}
#[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<MouseButtonIndex> {
pub const fn current_swipe_mouse_button_index(&self) -> Option<MouseButtonIndex> {
self.current_swipe_mouse_button_index
}
pub fn add_swipe(&mut self, within_key_pos_normalized: &Vec2, key_label: char, device: DeviceBitmask, index: Option<MouseButtonIndex>) {
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));
}
}
}