Skip to content

Commit

Permalink
add mouse logging
Browse files Browse the repository at this point in the history
  • Loading branch information
TornaxO7 committed Dec 22, 2024
1 parent e47a4c8 commit 75c1df7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion shady-lib/src/uniforms/mouse.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use tracing::{debug, instrument};

use super::Uniform;

#[derive(Default, Debug, Clone, Copy)]
Expand All @@ -6,7 +8,7 @@ struct Coord {
pub y: f32,
}

#[derive(Debug, PartialEq, Eq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum MouseState {
Pressed,
Released,
Expand All @@ -24,16 +26,21 @@ pub struct Mouse {
}

impl Mouse {
#[instrument(skip(self), level = "trace")]
pub fn cursor_moved(&mut self, x: f32, y: f32) {
self.pos = Coord { x, y };
}

#[instrument(skip(self), level = "trace")]
pub fn mouse_input(&mut self, state: MouseState) {
self.prev_state = state;
if state == MouseState::Pressed {
self.curr_pos = self.pos;
debug!("Mouse curr pos: {:?}", self.curr_pos);

if self.prev_state == MouseState::Released {
self.prev_pos = self.pos;
debug!("Mouse prev pos: {:?}", self.prev_pos);
}
} else {
self.prev_pos = Coord::default();
Expand Down

0 comments on commit 75c1df7

Please sign in to comment.