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
74
75
76
77
78
79
80
81
82
83
use bevy::prelude::*;

#[derive(Resource, Default, Debug)]
pub struct ActiveGamepad(pub Option<Gamepad>);

/// This system signals whether the debug camera should be active. You can selectively pick which
/// input types are active at a given time. You can
#[derive(Resource, Debug, Clone)]
pub struct DebugCameraActive {
    /// If set to true, our keyboard + mouse bindings will be active for any cameras marked as
    /// [`crate::DebugCamera`].
    pub keymouse: bool,
    /// If set to true, our gamepad bindings will be active for any cameras marked as
    /// [`crate::DebugCamera`].
    pub gamepad: bool,
}

impl Default for DebugCameraActive {
    fn default() -> DebugCameraActive {
        DebugCameraActive {
            keymouse: true,
            gamepad: true,
        }
    }
}

/// Configurable bindings for keyboard input. Field defaults can be found in the crate root
/// documentation.
#[derive(Resource, Debug, Clone)]
pub struct KeyboardBindings {
    pub fwd: KeyCode,
    pub bwd: KeyCode,
    pub up: KeyCode,
    pub down: KeyCode,
    pub left: KeyCode,
    pub right: KeyCode,
    pub roll_left: KeyCode,
    pub roll_right: KeyCode,
}

impl Default for KeyboardBindings {
    fn default() -> KeyboardBindings {
        KeyboardBindings {
            fwd: KeyCode::W,
            bwd: KeyCode::S,
            up: KeyCode::Space,
            down: KeyCode::LShift,
            left: KeyCode::A,
            right: KeyCode::D,
            roll_left: KeyCode::Q,
            roll_right: KeyCode::E,
        }
    }
}

/// Configurable bindings for gamepad input. Field defaults can be found in the crate root
/// documentation.
#[derive(Resource, Debug, Clone)]
pub struct GamepadBindings {
    pub fwd_bwd: GamepadAxisType,
    pub up: GamepadButtonType,
    pub down: GamepadButtonType,
    pub left_right: GamepadAxisType,
    pub roll_left: GamepadButtonType,
    pub roll_right: GamepadButtonType,
    pub yaw: GamepadAxisType,
    pub pitch: GamepadAxisType,
}

impl Default for GamepadBindings {
    fn default() -> GamepadBindings {
        GamepadBindings {
            fwd_bwd: GamepadAxisType::LeftStickY,
            up: GamepadButtonType::RightTrigger2,
            down: GamepadButtonType::LeftTrigger2,
            left_right: GamepadAxisType::LeftStickX,
            roll_left: GamepadButtonType::LeftTrigger,
            roll_right: GamepadButtonType::RightTrigger,
            yaw: GamepadAxisType::RightStickX,
            pitch: GamepadAxisType::RightStickY,
        }
    }
}