input_actions/
event.rs

1use crate::binding;
2
3/// An event created by a third-party to send input to [`System`](crate::System::send_event).
4#[derive(Debug, Clone)]
5pub struct Event {
6	pub(crate) source: binding::Source,
7	pub(crate) state: State,
8}
9
10impl Event {
11	pub fn new(source: binding::Source, state: State) -> Self {
12		Self { source, state }
13	}
14}
15
16/// The state of a [`gamepad`](crate::source::Button) or [`mouse`](crate::source::MouseButton) button.
17#[derive(Debug, Clone, Copy, PartialEq, Eq)]
18pub enum ButtonState {
19	Pressed,
20	Released,
21}
22
23/// What non-gamepad device caused the event.
24pub enum Source {
25	Mouse,
26	Keyboard,
27}
28
29/// The data for [`Event`].
30/// Can provide a mouse button/keyboard key state, mouse move, mouse scroll, or mouse button/keyboard key value.
31#[derive(Debug, Clone, Copy)]
32pub enum State {
33	ButtonState(ButtonState),
34	MouseMove(/*delta pixels x*/ f64, /*delta pixels y*/ f64),
35	MouseScroll(f32, f32),
36	ValueChanged(f32),
37}