1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
use crate::device::{
    Key, MouseButton, {ControllerButton, Which},
};
use serde::Deserialize;

/// Rappresent an Axis
#[derive(Debug, Deserialize, Eq, PartialEq, Clone)]
pub enum Axis {
    /// X axis
    X,
    /// Y axis
    Y,
}

/// Rappresent an Input from the User
#[derive(Debug, Deserialize, Eq, PartialEq, Clone)]
pub enum Input {
    /// Triggered when the user press a keyboard key
    Keyboard {
        /// indicates which keyboard key has been pressed
        key: Key,
    },
    /// Triggered when the user moves the mouse
    MouseMotion {
        /// indicates the event motion axis
        axis: Axis,
    },
    /// Triggered when the user uses the mouse wheel
    MouseWheel {
        /// indicates the event wheel axis
        axis: Axis,
    },
    /// Triggered when the user press a mouse button
    MouseButton {
        /// indicate which button has been pressed
        button: MouseButton,
    },
    // Triggered when the user uses a gamepad stick
    ControllerStick {
        /// gamepad device id
        device_id: usize,
        /// indicates which stick as been used
        which: Which,
        /// indicates the event motion axis
        axis: Axis,
    },
    /// Triggered when the user uses a gamepad trigger
    ControllerTrigger {
        /// gamepad device id
        device_id: usize,
        /// indicates which trigger as been used
        which: Which,
    },
    /// Triggered when the user uses a gamepad button
    ControllerButton {
        /// gamepad device id
        device_id: usize,
        /// indicate which gamepad button has been pressed
        button: ControllerButton,
    },
    /// Triggered then the user touch the screen (only on supported platform)
    Touch {
        /// indixate the axis of the touch event
        axis: Axis,
    },
}

/// Rappresent an input event composed by the input type and its value
#[derive(Debug)]
pub struct InputEvent {
    pub input: Input,
    pub value: f32,
}