lazer pointer wao

feat: handle touch

ptr.pet 6ce9c1fa 688909cf

verified
Changed files
+15 -1
src
+15 -1
src/main.rs
···
use tokio::sync::{OnceCell, mpsc};
use winit::{
application::ApplicationHandler,
-
event::{ElementState, MouseButton, WindowEvent},
+
event::{ElementState, MouseButton, TouchPhase, WindowEvent},
event_loop::{ActiveEventLoop, ControlFlow, EventLoop},
window::{Window, WindowAttributes, WindowId},
};
···
WindowEvent::CloseRequested => {
event_loop.exit();
return;
+
}
+
WindowEvent::Touch(touch) => {
+
let pos = (touch.location.x as f32, touch.location.y as f32);
+
match touch.phase {
+
TouchPhase::Started => {
+
self.handle_mouse_press(pos);
+
}
+
TouchPhase::Moved => {
+
self.handle_mouse_move(pos);
+
}
+
TouchPhase::Ended | TouchPhase::Cancelled => {
+
self.handle_mouse_release();
+
}
+
}
}
WindowEvent::MouseInput { state, button, .. } => {
if button == MouseButton::Left {