Skip to content

Commit cf831d5

Browse files
committed
input clear should not clear pressed (#4418)
# Objective - Revert #4410 - `Input<T>.clear()` is the method call at the end of each frame for inputs. Clearing `pressed` in it mean that checking if a key is pressed will always return false
1 parent 8e864fd commit cf831d5

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

crates/bevy_input/src/input.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,10 @@ where
116116
self.just_released.remove(&input);
117117
}
118118

119-
/// Clear pressed, just pressed and just released information.
119+
/// Clear just pressed and just released information.
120120
pub fn clear(&mut self) {
121121
self.just_pressed.clear();
122122
self.just_released.clear();
123-
self.pressed.clear();
124123
}
125124

126125
/// List all inputs that are pressed.
@@ -167,23 +166,20 @@ mod test {
167166
assert!(input.pressed(DummyInput::Input1));
168167
assert!(input.pressed(DummyInput::Input2));
169168

170-
// Clear the `input`, removing pressed, just pressed and just released
169+
// Clear the `input`, removing just pressed and just released
171170
input.clear();
172171

172+
// After calling clear, inputs should still be pressed but not be just_pressed
173+
173174
// Check if they're marked "just pressed"
174175
assert!(!input.just_pressed(DummyInput::Input1));
175176
assert!(!input.just_pressed(DummyInput::Input2));
176177

177178
// Check if they're marked as pressed
178-
assert!(!input.pressed(DummyInput::Input1));
179-
assert!(!input.pressed(DummyInput::Input2));
180-
181-
// Test pressing
182-
input.press(DummyInput::Input1);
183-
input.press(DummyInput::Input2);
179+
assert!(input.pressed(DummyInput::Input1));
180+
assert!(input.pressed(DummyInput::Input2));
184181

185182
// Release the inputs and check state
186-
187183
input.release(DummyInput::Input1);
188184
input.release(DummyInput::Input2);
189185

0 commit comments

Comments
 (0)