Fix cursor delta movement on desktop
@@ -81,7 +81,6 @@ impl Window
let mut accumulated_time = 0.0;
let mut events = Vec::new();
let mut cursor_pos = None;
- let mut last_cursor_pos: Option<(f64, f64)> = None;
let mut modifiers = Modifiers::default();
self.event_loop.run(move |event, _, control_flow| {
*control_flow = ControlFlow::Poll;
@@ -180,11 +179,10 @@ impl Window
},
WindowEvent::CursorMoved {position, ..} => {
let p = position.to_logical(windowed_context.window().scale_factor());
- let delta = if let Some(last_pos) = last_cursor_pos {
+ let delta = if let Some(last_pos) = cursor_pos {
(p.x - last_pos.0, p.y - last_pos.1)
} else {(0.0, 0.0)};
events.push(frame_input::Event::MouseMotion { delta, position: (p.x, p.y) });
- last_cursor_pos = cursor_pos;
cursor_pos = Some((p.x, p.y));
},
_ => (),
