bevy_debug_camera/
resources.rs

1use bevy::prelude::*;
2
3#[derive(Resource, Default, Debug)]
4pub struct ActiveGamepad(pub Option<Gamepad>);
5
6/// This system signals whether the debug camera should be active. You can selectively pick which
7/// input types are active at a given time. You can
8#[derive(Resource, Debug, Clone)]
9pub struct DebugCameraActive {
10    /// If set to true, our keyboard + mouse bindings will be active for any cameras marked as
11    /// [`crate::DebugCamera`].
12    pub keymouse: bool,
13    /// If set to true, our gamepad bindings will be active for any cameras marked as
14    /// [`crate::DebugCamera`].
15    pub gamepad: bool,
16}
17
18impl Default for DebugCameraActive {
19    fn default() -> DebugCameraActive {
20        DebugCameraActive {
21            keymouse: true,
22            gamepad: true,
23        }
24    }
25}
26
27/// Configurable bindings for keyboard input. Field defaults can be found in the crate root
28/// documentation.
29#[derive(Resource, Debug, Clone)]
30pub struct KeyboardBindings {
31    pub fwd: KeyCode,
32    pub bwd: KeyCode,
33    pub up: KeyCode,
34    pub down: KeyCode,
35    pub left: KeyCode,
36    pub right: KeyCode,
37    pub roll_left: KeyCode,
38    pub roll_right: KeyCode,
39}
40
41impl Default for KeyboardBindings {
42    fn default() -> KeyboardBindings {
43        KeyboardBindings {
44            fwd: KeyCode::W,
45            bwd: KeyCode::S,
46            up: KeyCode::Space,
47            down: KeyCode::ShiftLeft,
48            left: KeyCode::A,
49            right: KeyCode::D,
50            roll_left: KeyCode::Q,
51            roll_right: KeyCode::E,
52        }
53    }
54}
55
56/// Configurable bindings for gamepad input. Field defaults can be found in the crate root
57/// documentation.
58#[derive(Resource, Debug, Clone)]
59pub struct GamepadBindings {
60    pub fwd_bwd: GamepadAxisType,
61    pub up: GamepadButtonType,
62    pub down: GamepadButtonType,
63    pub left_right: GamepadAxisType,
64    pub roll_left: GamepadButtonType,
65    pub roll_right: GamepadButtonType,
66    pub yaw: GamepadAxisType,
67    pub pitch: GamepadAxisType,
68}
69
70impl Default for GamepadBindings {
71    fn default() -> GamepadBindings {
72        GamepadBindings {
73            fwd_bwd: GamepadAxisType::LeftStickY,
74            up: GamepadButtonType::RightTrigger2,
75            down: GamepadButtonType::LeftTrigger2,
76            left_right: GamepadAxisType::LeftStickX,
77            roll_left: GamepadButtonType::LeftTrigger,
78            roll_right: GamepadButtonType::RightTrigger,
79            yaw: GamepadAxisType::RightStickX,
80            pitch: GamepadAxisType::RightStickY,
81        }
82    }
83}