From 2f87ff661824284990856575d8979923da9ee20d Mon Sep 17 00:00:00 2001 From: Nathan Stocks Date: Mon, 2 Nov 2020 19:16:13 -0700 Subject: [PATCH] Move ElementState to top-level of bevy_input. Resolves #687. (#769) --- crates/bevy_input/src/keyboard.rs | 15 +-------------- crates/bevy_input/src/lib.rs | 13 +++++++++++++ crates/bevy_input/src/mouse.rs | 3 +-- crates/bevy_input/src/system.rs | 5 ++++- crates/bevy_winit/src/converters.rs | 3 ++- 5 files changed, 21 insertions(+), 18 deletions(-) diff --git a/crates/bevy_input/src/keyboard.rs b/crates/bevy_input/src/keyboard.rs index 7ffc8c07d9..c5b2f202a3 100644 --- a/crates/bevy_input/src/keyboard.rs +++ b/crates/bevy_input/src/keyboard.rs @@ -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 { diff --git a/crates/bevy_input/src/lib.rs b/crates/bevy_input/src/lib.rs index ec8ec84498..c2aa2ddc0c 100644 --- a/crates/bevy_input/src/lib.rs +++ b/crates/bevy_input/src/lib.rs @@ -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) + } +} diff --git a/crates/bevy_input/src/mouse.rs b/crates/bevy_input/src/mouse.rs index 4a0662960c..3123785fb0 100644 --- a/crates/bevy_input/src/mouse.rs +++ b/crates/bevy_input/src/mouse.rs @@ -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; diff --git a/crates/bevy_input/src/system.rs b/crates/bevy_input/src/system.rs index e02276ed20..526c23e67c 100644 --- a/crates/bevy_input/src/system.rs +++ b/crates/bevy_input/src/system.rs @@ -1,4 +1,7 @@ -use crate::keyboard::{ElementState, KeyCode, KeyboardInput}; +use crate::{ + keyboard::{KeyCode, KeyboardInput}, + ElementState, +}; use bevy_app::{ prelude::{EventReader, Events}, AppExit, diff --git a/crates/bevy_winit/src/converters.rs b/crates/bevy_winit/src/converters.rs index 8bc04e20b5..295801647c 100644 --- a/crates/bevy_winit/src/converters.rs +++ b/crates/bevy_winit/src/converters.rs @@ -1,7 +1,8 @@ use bevy_input::{ - keyboard::{ElementState, KeyCode, KeyboardInput}, + keyboard::{KeyCode, KeyboardInput}, mouse::MouseButton, touch::{TouchInput, TouchPhase}, + ElementState, }; use bevy_math::Vec2;