Skip to content

Commit 2f87ff6

Browse files
authored
Move ElementState to top-level of bevy_input. Resolves #687. (#769)
1 parent d4dc115 commit 2f87ff6

File tree

5 files changed

+21
-18
lines changed

5 files changed

+21
-18
lines changed

crates/bevy_input/src/keyboard.rs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::Input;
1+
use crate::{ElementState, Input};
22
use bevy_app::prelude::*;
33
use bevy_ecs::{Local, Res, ResMut};
44

@@ -10,19 +10,6 @@ pub struct KeyboardInput {
1010
pub state: ElementState,
1111
}
1212

13-
/// The current "press" state of an element
14-
#[derive(Debug, Clone, Eq, PartialEq)]
15-
pub enum ElementState {
16-
Pressed,
17-
Released,
18-
}
19-
20-
impl ElementState {
21-
pub fn is_pressed(&self) -> bool {
22-
matches!(self, ElementState::Pressed)
23-
}
24-
}
25-
2613
/// State used by the keyboard input system
2714
#[derive(Default)]
2815
pub struct KeyboardInputState {

crates/bevy_input/src/lib.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,16 @@ impl Plugin for InputPlugin {
6060
.add_system_to_stage(bevy_app::stage::EVENT, touch_screen_input_system.system());
6161
}
6262
}
63+
64+
/// The current "press" state of an element
65+
#[derive(Debug, Clone, Eq, PartialEq)]
66+
pub enum ElementState {
67+
Pressed,
68+
Released,
69+
}
70+
71+
impl ElementState {
72+
pub fn is_pressed(&self) -> bool {
73+
matches!(self, ElementState::Pressed)
74+
}
75+
}

crates/bevy_input/src/mouse.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
use super::keyboard::ElementState;
2-
use crate::Input;
1+
use crate::{ElementState, Input};
32
use bevy_app::prelude::{EventReader, Events};
43
use bevy_ecs::{Local, Res, ResMut};
54
use bevy_math::Vec2;

crates/bevy_input/src/system.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
use crate::keyboard::{ElementState, KeyCode, KeyboardInput};
1+
use crate::{
2+
keyboard::{KeyCode, KeyboardInput},
3+
ElementState,
4+
};
25
use bevy_app::{
36
prelude::{EventReader, Events},
47
AppExit,

crates/bevy_winit/src/converters.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
use bevy_input::{
2-
keyboard::{ElementState, KeyCode, KeyboardInput},
2+
keyboard::{KeyCode, KeyboardInput},
33
mouse::MouseButton,
44
touch::{TouchInput, TouchPhase},
5+
ElementState,
56
};
67
use bevy_math::Vec2;
78

0 commit comments

Comments
 (0)