dead reckoning for mouse shadow because OS draws it before we get the event

This commit is contained in:
lifning 2021-10-19 03:17:45 -07:00
parent 52f7414dfe
commit 8471ec85fa
1 changed files with 7 additions and 3 deletions

View File

@ -30,6 +30,7 @@ use ferretro_components::provided::{
use sdl2::mouse::{Cursor, MouseUtil};
use sdl2::rect::Rect;
use itertools::Itertools;
use sdl2::event::WindowEvent;
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
@ -231,10 +232,13 @@ impl Zretro {
self.emu.libretro_core().unload_game();
self.emu.load_game(filename)?;
}
Event::MouseMotion { x, y, .. } => {
self.mouse_shadow_pos.set_x(x + 5);
self.mouse_shadow_pos.set_y(y + 7);
Event::MouseMotion { x, y, xrel, yrel, .. } => {
self.mouse_shadow_pos.set_x(x + xrel + 5);
self.mouse_shadow_pos.set_y(y + yrel + 7);
},
Event::Window { win_event: WindowEvent::Leave, .. } => {
self.mouse_shadow_pos.set_x(-(self.mouse_shadow_surf.width() as i32));
}
_ => {}
}
}