diff options
Diffstat (limited to 'winit/src/conversion.rs')
-rw-r--r-- | winit/src/conversion.rs | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/winit/src/conversion.rs b/winit/src/conversion.rs index b6a0b64b..2fc76c9d 100644 --- a/winit/src/conversion.rs +++ b/winit/src/conversion.rs @@ -5,7 +5,7 @@ use crate::{ input::{ keyboard::{self, KeyCode, ModifiersState}, - mouse, ButtonState, + mouse, touch, ButtonState, }, window, Event, Mode, MouseCursor, }; @@ -84,6 +84,9 @@ pub fn window_event( WindowEvent::HoveredFileCancelled => { Some(Event::Window(window::Event::FilesHoveredLeft)) } + WindowEvent::Touch(touch) => { + Some(Event::Touch(touch_event(touch))) + } _ => None, } } @@ -342,3 +345,24 @@ pub(crate) fn is_private_use_character(c: char) -> bool { _ => false, } } +pub(crate) fn touch_event(touch: winit::event::Touch) -> touch::Touch { + let location = touch.location; + match touch.phase { + winit::event::TouchPhase::Started => touch::Touch::Started { + x: location.x as f32, + y: location.y as f32, + }, + winit::event::TouchPhase::Ended => touch::Touch::Ended { + x: location.x as f32, + y: location.y as f32, + }, + winit::event::TouchPhase::Moved => touch::Touch::Moved { + x: location.x as f32, + y: location.y as f32, + }, + winit::event::TouchPhase::Cancelled => touch::Touch::Cancelled { + x: location.x as f32, + y: location.y as f32, + }, + } +} |