mirror of https://github.com/wayvr-org/wayvr.git
preserve pointer mods while swiping
This commit is contained in:
parent
db0e6ab080
commit
b62a4fde28
|
|
@ -481,7 +481,7 @@ fn handle_mouse_motion(
|
|||
if pos.x >= 0.0 && pos.x <= 1.0 && pos.y >= 0.0 && pos.y <= 1.0 {
|
||||
|
||||
if let Some(label) = key_label.first() {
|
||||
swipe_manager.add_swipe(pos, label.chars().next().unwrap_or_default(), device);
|
||||
swipe_manager.add_swipe(pos, label.chars().next().unwrap_or_default(), device, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -509,7 +509,7 @@ fn handle_press(
|
|||
{
|
||||
if let Some(pos) = within_key_pos {
|
||||
if let Some(label) = key_label.first() {
|
||||
swipe_manager.add_swipe(pos, label.chars().next().unwrap_or_default(), device);
|
||||
swipe_manager.add_swipe(pos, label.chars().next().unwrap_or_default(), device, Some(button.index));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -570,6 +570,11 @@ fn handle_release(app: &mut AppState, key: &KeyState, k_cap_type: &KeyCapType, k
|
|||
}
|
||||
}
|
||||
else { // pointer must have been released on the same key it was pressed on
|
||||
keyboard.modifiers |= match swipe_manager.current_swipe_mouse_button_index() {
|
||||
Some(MouseButtonIndex::Right) => SHIFT,
|
||||
Some(MouseButtonIndex::Middle) => keyboard.alt_modifier,
|
||||
_ => 0,
|
||||
};
|
||||
swipe_manager.reset(); // drop swipe tracking that was started on press
|
||||
|
||||
app.hid_provider
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use std::time::Instant;
|
|||
use super_swipe_type::keyboard_manager::QwertyKeyboardGrid;
|
||||
use super_swipe_type::swipe_orchestrator::SwipeOrchestrator;
|
||||
use super_swipe_type::{SwipePoint};
|
||||
use wgui::event::DeviceBitmask;
|
||||
use wgui::event::{DeviceBitmask, MouseButtonIndex};
|
||||
use crate::subsystem::input::InputFocus;
|
||||
|
||||
const PREDICTION_SUGGESTION_COUNT: usize = 5;
|
||||
|
|
@ -34,6 +34,7 @@ pub struct SwipeTypingManager {
|
|||
swipe_left_first_key: bool,
|
||||
first_swipe_char: char,
|
||||
current_swipe_device: Option<DeviceBitmask>,
|
||||
current_swipe_mouse_button_index: Option<MouseButtonIndex>,
|
||||
last_swiped_word: Option<String>,
|
||||
}
|
||||
|
||||
|
|
@ -134,6 +135,7 @@ impl SwipeTypingManager {
|
|||
swipe_left_first_key: false,
|
||||
first_swipe_char: char::default(),
|
||||
current_swipe_device: None,
|
||||
current_swipe_mouse_button_index: None,
|
||||
last_swiped_word: None,
|
||||
},
|
||||
candidate_receiver,
|
||||
|
|
@ -170,13 +172,15 @@ impl SwipeTypingManager {
|
|||
self.first_swipe_char = char::default();
|
||||
self.swipe_left_first_key = false;
|
||||
self.current_swipe_device = None;
|
||||
self.current_swipe_mouse_button_index = None;
|
||||
}
|
||||
|
||||
fn start_swipe(&mut self, key_label: char, device: DeviceBitmask) -> Instant {
|
||||
fn start_swipe(&mut self, key_label: char, device: DeviceBitmask, index: Option<MouseButtonIndex>) -> Instant {
|
||||
let now = Instant::now();
|
||||
self.swipe_start_time = Some(now);
|
||||
self.first_swipe_char = key_label.to_ascii_lowercase();
|
||||
self.current_swipe_device = Some(device);
|
||||
self.current_swipe_mouse_button_index = index;
|
||||
now
|
||||
}
|
||||
|
||||
|
|
@ -187,8 +191,12 @@ impl SwipeTypingManager {
|
|||
pub fn is_current_swipe_empty(&self) -> bool {
|
||||
self.current_swipe.is_empty()
|
||||
}
|
||||
|
||||
pub 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) {
|
||||
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 {
|
||||
|
|
@ -209,7 +217,7 @@ impl SwipeTypingManager {
|
|||
|
||||
let start_time = match self.swipe_start_time {
|
||||
Some(time) => time,
|
||||
None => self.start_swipe(key_label, device),
|
||||
None => self.start_swipe(key_label, device, index),
|
||||
};
|
||||
|
||||
let within_key_pos_from_center = Vec2 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue