Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions crates/bevy_input/src/keyboard.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::Input;
use crate::{ElementState, Input};
use bevy_app::prelude::*;
use bevy_ecs::{Local, Res, ResMut};

Expand All @@ -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 {
Expand Down
13 changes: 13 additions & 0 deletions crates/bevy_input/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
3 changes: 1 addition & 2 deletions crates/bevy_input/src/mouse.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
5 changes: 4 additions & 1 deletion crates/bevy_input/src/system.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use crate::keyboard::{ElementState, KeyCode, KeyboardInput};
use crate::{
keyboard::{KeyCode, KeyboardInput},
ElementState,
};
use bevy_app::{
prelude::{EventReader, Events},
AppExit,
Expand Down
3 changes: 2 additions & 1 deletion crates/bevy_winit/src/converters.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use bevy_input::{
keyboard::{ElementState, KeyCode, KeyboardInput},
keyboard::{KeyCode, KeyboardInput},
mouse::MouseButton,
touch::{TouchInput, TouchPhase},
ElementState,
};
use bevy_math::Vec2;

Expand Down