mirror of https://github.com/wayvr-org/wayvr.git
successful debug implementation
This commit is contained in:
parent
13248411a8
commit
5db05a7802
|
|
@ -26,7 +26,7 @@ use wgui::{
|
|||
taffy::{self, prelude::length},
|
||||
widget::{EventResult, div::WidgetDiv, rectangle::WidgetRectangle},
|
||||
};
|
||||
|
||||
use crate::overlays::keyboard::layout::KeyData;
|
||||
use super::{
|
||||
KeyButtonData, KeyState, KeyboardState, handle_press, handle_release,
|
||||
layout::{self, KeyCapType},
|
||||
|
|
@ -109,7 +109,6 @@ pub(super) fn create_keyboard_panel(
|
|||
KeyButtonData::Modifier { modifier, .. } => Some(modifier),
|
||||
_ => None,
|
||||
};
|
||||
let key_label: Rc<Vec<String>> = Rc::from(key.label.clone());
|
||||
|
||||
// todo: make this easier to maintain somehow
|
||||
let mut params: HashMap<Rc<str>, Rc<str>> = HashMap::new();
|
||||
|
|
@ -173,6 +172,9 @@ pub(super) fn create_keyboard_panel(
|
|||
})
|
||||
};
|
||||
|
||||
let key_cap_type: Rc<KeyCapType> = Rc::from(key.cap_type);
|
||||
let key_label: Rc<Vec<String>> = Rc::from(key.label);
|
||||
|
||||
let width_mul = 1. / my_size_f32;
|
||||
|
||||
panel.add_event_listener(
|
||||
|
|
@ -180,7 +182,9 @@ pub(super) fn create_keyboard_panel(
|
|||
EventListenerKind::MouseEnter,
|
||||
Box::new({
|
||||
let k = key_state.clone();
|
||||
move |common, data, _app, _state| {
|
||||
let k_label = key_label.clone();
|
||||
let k_cap_type = key_cap_type.clone();
|
||||
move |common, data, _app, state| {
|
||||
common.alterables.trigger_haptics();
|
||||
on_enter_anim(
|
||||
k.clone(),
|
||||
|
|
@ -190,6 +194,16 @@ pub(super) fn create_keyboard_panel(
|
|||
anim_mult,
|
||||
width_mul,
|
||||
);
|
||||
|
||||
if !&state.current_swipe_input.is_empty() {
|
||||
match k_cap_type.as_ref() {
|
||||
KeyCapType::Letter => {
|
||||
state.current_swipe_input.push_str(&*k_label.iter().next().unwrap().to_ascii_lowercase())
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
}
|
||||
Ok(EventResult::Pass)
|
||||
}
|
||||
}),
|
||||
|
|
@ -209,6 +223,7 @@ pub(super) fn create_keyboard_panel(
|
|||
anim_mult,
|
||||
width_mul,
|
||||
);
|
||||
|
||||
Ok(EventResult::Pass)
|
||||
}
|
||||
}),
|
||||
|
|
@ -219,19 +234,20 @@ pub(super) fn create_keyboard_panel(
|
|||
Box::new({
|
||||
let k = key_state.clone();
|
||||
let k_label = key_label.clone();
|
||||
let k_cap_type = key_cap_type.clone();
|
||||
move |common, data, app, state| {
|
||||
let CallbackMetadata::MouseButton(button) = data.metadata else {
|
||||
panic!("CallbackMetadata should contain MouseButton!");
|
||||
};
|
||||
|
||||
println!("pressed {:?}", &k_label);
|
||||
// match key.cap_type {
|
||||
// KeyCapType::Letter => {
|
||||
// let cloned_label = &key.label.clone();
|
||||
// state.current_swipe_input.push_str(cloned_label.iter().next().unwrap())
|
||||
// }
|
||||
// _ => {}
|
||||
// }
|
||||
match k_cap_type.as_ref() {
|
||||
KeyCapType::Letter => {
|
||||
state.current_swipe_input.clear();
|
||||
state.current_swipe_input.push_str(&*k_label.iter().next().unwrap().to_ascii_lowercase())
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
handle_press(app, &k, state, button);
|
||||
on_press_anim(k.clone(), common, data);
|
||||
|
|
@ -245,10 +261,17 @@ pub(super) fn create_keyboard_panel(
|
|||
Box::new({
|
||||
let k = key_state.clone();
|
||||
let k_label = key_label.clone();
|
||||
let k_cap_type = key_cap_type.clone();
|
||||
move |common, data, app, state| {
|
||||
if handle_release(app, &k, state) {
|
||||
on_release_anim(k.clone(), common, data);
|
||||
}
|
||||
|
||||
if let Some(engine) = &state.swipe_engine {
|
||||
let prediction = engine.predict(&state.current_swipe_input, None, 5);
|
||||
println!("swipe path: {}", &state.current_swipe_input);
|
||||
println!("{:?}", prediction);
|
||||
}
|
||||
println!("released {:?}", &k_label);
|
||||
Ok(EventResult::Pass)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -159,11 +159,10 @@ impl KeyboardBackend {
|
|||
let mut state = self.default_state.take();
|
||||
let layout_name = keymap.and_then(|k| k.get_name()).unwrap_or("us");
|
||||
|
||||
if layout_name == "us" {
|
||||
let point_map = build_key_to_char_point_map(keymap, &self.wlx_layout);
|
||||
state.swipe_engine = SwipeEngine::new(LanguageCode::En, Some(point_map)).and_then(|s| Ok(Some(s))).unwrap_or(None);
|
||||
}
|
||||
let point_map = build_key_to_char_point_map(keymap, &self.wlx_layout);
|
||||
state.swipe_engine = SwipeEngine::new(LanguageCode::En, Some(point_map)).and_then(|s| Ok(Some(s))).unwrap_or(None);
|
||||
|
||||
log::info!("swipe engine created");
|
||||
let panel =
|
||||
create_keyboard_panel(app, keymap, state, &self.wlx_layout)?;
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,9 @@ pub fn build_key_to_char_point_map(keymap: Option<&XkbKeymap>, layout: &layout::
|
|||
match label.cap_type {
|
||||
KeyCapType::Letter => {
|
||||
if let Some(char) = label.label.iter().next() {
|
||||
map.insert(char.to_ascii_lowercase().chars().next().unwrap(), Point {x: pos_x as f64, y: pos_y as f64});
|
||||
let point = Point {x: pos_x as f64, y: pos_y as f64};
|
||||
println!("char: {} \n point: {:?}\n",char, point);
|
||||
map.insert(char.to_ascii_lowercase().chars().next().unwrap(), point);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
|
|
@ -29,7 +31,7 @@ pub fn build_key_to_char_point_map(keymap: Option<&XkbKeymap>, layout: &layout::
|
|||
}
|
||||
pos_x += layout.key_sizes[row_idx][col_idx];
|
||||
}
|
||||
pos_y += layout.row_size;
|
||||
pos_y += 1.0;
|
||||
pos_x = 0.0;
|
||||
}
|
||||
map
|
||||
|
|
|
|||
Loading…
Reference in New Issue