2020-09-18 21:43:47 +00:00
|
|
|
mod axis;
|
|
|
|
pub mod gamepad;
|
2020-06-05 05:48:53 +00:00
|
|
|
mod input;
|
2020-04-04 21:59:49 +00:00
|
|
|
pub mod keyboard;
|
2020-04-05 06:42:39 +00:00
|
|
|
pub mod mouse;
|
2020-04-19 19:13:04 +00:00
|
|
|
pub mod system;
|
2020-04-04 21:59:49 +00:00
|
|
|
|
2020-09-18 21:43:47 +00:00
|
|
|
pub use axis::*;
|
2020-06-05 05:48:53 +00:00
|
|
|
pub use input::*;
|
|
|
|
|
2020-07-17 02:27:19 +00:00
|
|
|
pub mod prelude {
|
2020-09-18 21:43:47 +00:00
|
|
|
pub use crate::{
|
|
|
|
gamepad::{
|
|
|
|
Gamepad, GamepadAxis, GamepadAxisType, GamepadButton, GamepadButtonType, GamepadEvent,
|
|
|
|
GamepadEventType,
|
|
|
|
},
|
|
|
|
keyboard::KeyCode,
|
|
|
|
mouse::MouseButton,
|
|
|
|
Axis, Input,
|
|
|
|
};
|
2020-07-17 02:27:19 +00:00
|
|
|
}
|
|
|
|
|
2020-07-17 01:47:51 +00:00
|
|
|
use bevy_app::prelude::*;
|
2020-08-09 23:13:04 +00:00
|
|
|
use keyboard::{keyboard_input_system, KeyCode, KeyboardInput};
|
2020-08-21 00:04:01 +00:00
|
|
|
use mouse::{mouse_button_input_system, MouseButton, MouseButtonInput, MouseMotion, MouseWheel};
|
2020-04-04 21:59:49 +00:00
|
|
|
|
2020-07-10 04:18:35 +00:00
|
|
|
use bevy_ecs::IntoQuerySystem;
|
2020-09-18 21:43:47 +00:00
|
|
|
use gamepad::{GamepadAxis, GamepadButton, GamepadEvent};
|
2020-07-10 04:18:35 +00:00
|
|
|
|
2020-08-09 23:13:04 +00:00
|
|
|
/// Adds keyboard and mouse input to an App
|
2020-04-04 21:59:49 +00:00
|
|
|
#[derive(Default)]
|
|
|
|
pub struct InputPlugin;
|
|
|
|
|
2020-08-08 03:22:17 +00:00
|
|
|
impl Plugin for InputPlugin {
|
2020-04-06 03:19:02 +00:00
|
|
|
fn build(&self, app: &mut AppBuilder) {
|
2020-04-04 21:59:49 +00:00
|
|
|
app.add_event::<KeyboardInput>()
|
2020-04-05 07:32:53 +00:00
|
|
|
.add_event::<MouseButtonInput>()
|
2020-06-05 06:34:21 +00:00
|
|
|
.add_event::<MouseMotion>()
|
2020-08-21 00:04:01 +00:00
|
|
|
.add_event::<MouseWheel>()
|
2020-06-05 06:34:21 +00:00
|
|
|
.init_resource::<Input<KeyCode>>()
|
|
|
|
.add_system_to_stage(
|
|
|
|
bevy_app::stage::EVENT_UPDATE,
|
|
|
|
keyboard_input_system.system(),
|
|
|
|
)
|
|
|
|
.init_resource::<Input<MouseButton>>()
|
|
|
|
.add_system_to_stage(
|
|
|
|
bevy_app::stage::EVENT_UPDATE,
|
|
|
|
mouse_button_input_system.system(),
|
2020-09-18 21:43:47 +00:00
|
|
|
)
|
|
|
|
.add_event::<GamepadEvent>()
|
|
|
|
.init_resource::<Input<GamepadButton>>()
|
|
|
|
.init_resource::<Axis<GamepadAxis>>();
|
2020-04-04 21:59:49 +00:00
|
|
|
}
|
|
|
|
}
|