Skip to content

Commit

Permalink
masonry: add pressure sensitivity to the pen's touch on the screen (#453
Browse files Browse the repository at this point in the history
)

device test
* huion kamvas 13 tablet windows 10 platform
  • Loading branch information
werickdasilva authored Jul 29, 2024
1 parent 727d696 commit 67afe67
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion masonry/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::WidgetId;

use std::{collections::HashSet, path::PathBuf};

use winit::event::{Ime, KeyEvent, Modifiers};
use winit::event::{Force, Ime, KeyEvent, Modifiers};
use winit::keyboard::ModifiersState;

// TODO - Occluded(bool) event
Expand Down Expand Up @@ -95,6 +95,7 @@ pub struct PointerState {
pub mods: Modifiers,
pub count: u8,
pub focus: bool,
pub force: Option<Force>,
}

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -351,6 +352,7 @@ impl PointerState {
mods: Default::default(),
count: 0,
focus: false,
force: None,
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion masonry/src/event_loop_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,12 +497,16 @@ impl MasonryState<'_> {
));
}
WinitWindowEvent::Touch(winit::event::Touch {
location, phase, ..
location,
phase,
force,
..
}) => {
// FIXME: This is naïve and should be refined for actual use.
// It will also interact with gesture discrimination.
self.pointer_state.physical_position = location;
self.pointer_state.position = location.to_logical(window.scale_factor());
self.pointer_state.force = force;
match phase {
winit::event::TouchPhase::Started => {
self.render_root
Expand Down

0 comments on commit 67afe67

Please sign in to comment.