Move ElementState to top-level of bevy_input. Resolves #687. (#769)

This commit is contained in:
Nathan Stocks 2020-11-02 19:16:13 -07:00 committed by GitHub
parent d4dc115bd7
commit 2f87ff6618
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 18 deletions

View file

@ -1,4 +1,4 @@
use crate::Input;
use crate::{ElementState, Input};
use bevy_app::prelude::*;
use bevy_ecs::{Local, Res, ResMut};
@ -10,19 +10,6 @@ pub struct KeyboardInput {
pub state: ElementState,
}
/// The current "press" state of an element
#[derive(Debug, Clone, Eq, PartialEq)]
pub enum ElementState {
Pressed,
Released,
}
impl ElementState {
pub fn is_pressed(&self) -> bool {
matches!(self, ElementState::Pressed)
}
}
/// State used by the keyboard input system
#[derive(Default)]
pub struct KeyboardInputState {

View file

@ -60,3 +60,16 @@ impl Plugin for InputPlugin {
.add_system_to_stage(bevy_app::stage::EVENT, touch_screen_input_system.system());
}
}
/// The current "press" state of an element
#[derive(Debug, Clone, Eq, PartialEq)]
pub enum ElementState {
Pressed,
Released,
}
impl ElementState {
pub fn is_pressed(&self) -> bool {
matches!(self, ElementState::Pressed)
}
}

View file

@ -1,5 +1,4 @@
use super::keyboard::ElementState;
use crate::Input;
use crate::{ElementState, Input};
use bevy_app::prelude::{EventReader, Events};
use bevy_ecs::{Local, Res, ResMut};
use bevy_math::Vec2;

View file

@ -1,4 +1,7 @@
use crate::keyboard::{ElementState, KeyCode, KeyboardInput};
use crate::{
keyboard::{KeyCode, KeyboardInput},
ElementState,
};
use bevy_app::{
prelude::{EventReader, Events},
AppExit,

View file

@ -1,7 +1,8 @@
use bevy_input::{
keyboard::{ElementState, KeyCode, KeyboardInput},
keyboard::{KeyCode, KeyboardInput},
mouse::MouseButton,
touch::{TouchInput, TouchPhase},
ElementState,
};
use bevy_math::Vec2;