use px_backend::winit;
#[derive(Debug, Clone, Copy)]
pub struct Input {
pub pressed: bool,
pub held: bool,
pub released: bool,
}
impl Input {
#[must_use]
pub const fn new(pressed: bool, held: bool, released: bool) -> Self {
Input {
pressed,
held,
released,
}
}
#[must_use]
pub const fn default() -> Self {
Input {
pressed: false,
held: false,
released: false,
}
}
#[must_use]
pub fn any(self) -> bool {
self.pressed || self.held || self.released
}
}
#[derive(Debug, Clone, Copy)]
pub(crate) struct Mouse {
pub(crate) buttons: [Input; 3],
pub(crate) pos: (u32, u32),
pub(crate) wheel: MouseWheel,
}
impl Mouse {
pub const fn new() -> Self {
Mouse {
buttons: [Input::default(), Input::default(), Input::default()],
pos: (0, 0),
wheel: MouseWheel::None,
}
}
}
#[derive(Debug, Clone, Copy)]
pub enum MouseBtn {
Left,
Right,
Middle,
}
#[derive(Debug, Clone, Copy)]
pub enum MouseWheel {
None,
Up,
Down,
Right,
Left,
}
pub use winit::event::VirtualKeyCode as Keycodes;
#[derive(Eq, PartialEq, Debug, Hash, Clone, Copy)]
pub struct Key {
pub key: Keycodes,
}
impl From<winit::event::KeyboardInput> for Key {
fn from(key: winit::event::KeyboardInput) -> Self {
Self {
key: key.virtual_keycode.unwrap(),
}
}
}