use super::AxisId;
use super::ButtonId;
use super::DeviceId;
use super::ElementState;
use super::KeyboardInput;
use super::MouseScrollDelta;
#[derive(Debug, Clone)]
pub enum DeviceEvent {
Added(DeviceAddedEvent),
Removed(DeviceRemovedEvent),
MouseMotion(DeviceMouseMotionEvent),
MouseWheel(DeviceMouseWheelEvent),
Motion(DeviceMotionEvent),
Button(DeviceButtonEvent),
KeyboardInput(DeviceKeyboardInputEvent),
TextInput(DeviceTextInputEvent),
}
#[derive(Debug, Clone)]
pub struct DeviceAddedEvent {
pub device_id: DeviceId,
}
#[derive(Debug, Clone)]
pub struct DeviceRemovedEvent {
pub device_id: DeviceId,
}
#[derive(Debug, Clone)]
pub struct DeviceMouseMotionEvent {
pub device_id: DeviceId,
pub delta: glam::Vec2,
}
#[derive(Debug, Clone)]
pub struct DeviceMouseWheelEvent {
pub device_id: DeviceId,
pub delta: MouseScrollDelta,
}
#[derive(Debug, Clone)]
pub struct DeviceMotionEvent {
pub device_id: DeviceId,
pub axis: AxisId,
pub value: f64,
}
#[derive(Debug, Clone)]
pub struct DeviceButtonEvent {
pub device_id: DeviceId,
pub button: ButtonId,
pub state: ElementState,
}
#[derive(Debug, Clone)]
pub struct DeviceKeyboardInputEvent {
pub device_id: DeviceId,
pub input: KeyboardInput,
}
#[derive(Debug, Clone)]
pub struct DeviceTextInputEvent {
pub device_id: DeviceId,
pub codepoint: char,
}
impl_from_variant!(DeviceEvent::Added(DeviceAddedEvent));
impl_from_variant!(DeviceEvent::Removed(DeviceRemovedEvent));
impl_from_variant!(DeviceEvent::MouseMotion(DeviceMouseMotionEvent));
impl_from_variant!(DeviceEvent::MouseWheel(DeviceMouseWheelEvent));
impl_from_variant!(DeviceEvent::Motion(DeviceMotionEvent));
impl_from_variant!(DeviceEvent::Button(DeviceButtonEvent));
impl_from_variant!(DeviceEvent::KeyboardInput(DeviceKeyboardInputEvent));
impl_from_variant!(DeviceEvent::TextInput(DeviceTextInputEvent));