Fixes
Some checks failed
Build legacy Nix package on Ubuntu / build (push) Has been cancelled

This commit is contained in:
Florian RICHER 2025-05-28 13:41:13 +02:00
parent 09bfe6fb48
commit fbb1493b45
Signed by: florian.richer
GPG key ID: C73D37CBED7BFC77
5 changed files with 68 additions and 76 deletions

View file

@ -3,7 +3,7 @@ use std::collections::HashMap;
use cache::{CachedElementState, CachedMovement};
use virtual_input::VirtualInput;
use winit::{
event::{MouseButton, MouseScrollDelta, WindowEvent},
event::{DeviceEvent, MouseButton, MouseScrollDelta, WindowEvent},
keyboard::PhysicalKey,
};
@ -39,6 +39,15 @@ impl InputManager {
input_manager
}
pub fn process_device_event(&mut self, event: &DeviceEvent) {
match event {
DeviceEvent::MouseMotion { delta, .. } => {
self.mouse_position_delta += glam::Vec2::new(delta.0 as f32, delta.1 as f32);
}
_ => {}
}
}
pub fn process_window_event(&mut self, event: &WindowEvent) {
match event {
WindowEvent::AxisMotion { axis, value, .. } => {
@ -53,10 +62,6 @@ impl InputManager {
.update_key_binding(event.physical_key, new_key_state);
}
}
WindowEvent::CursorMoved { position, .. } => {
self.mouse_position_delta
.set_value(glam::Vec2::new(position.x as f32, position.y as f32));
}
WindowEvent::MouseInput { button, state, .. } => {
let new_mouse_button_state =
self.mouse_buttons_state.set_key_state(*button, *state);