mirror of
https://github.com/bevyengine/bevy
synced 2024-11-26 14:40:19 +00:00
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
This commit is contained in:
parent
8e864fdd18
commit
cf831d5185
1 changed files with 6 additions and 10 deletions
|
@ -116,11 +116,10 @@ where
|
|||
self.just_released.remove(&input);
|
||||
}
|
||||
|
||||
/// Clear pressed, just pressed and just released information.
|
||||
/// Clear just pressed and just released information.
|
||||
pub fn clear(&mut self) {
|
||||
self.just_pressed.clear();
|
||||
self.just_released.clear();
|
||||
self.pressed.clear();
|
||||
}
|
||||
|
||||
/// List all inputs that are pressed.
|
||||
|
@ -167,23 +166,20 @@ mod test {
|
|||
assert!(input.pressed(DummyInput::Input1));
|
||||
assert!(input.pressed(DummyInput::Input2));
|
||||
|
||||
// Clear the `input`, removing pressed, just pressed and just released
|
||||
// Clear the `input`, removing just pressed and just released
|
||||
input.clear();
|
||||
|
||||
// After calling clear, inputs should still be pressed but not be just_pressed
|
||||
|
||||
// Check if they're marked "just pressed"
|
||||
assert!(!input.just_pressed(DummyInput::Input1));
|
||||
assert!(!input.just_pressed(DummyInput::Input2));
|
||||
|
||||
// Check if they're marked as pressed
|
||||
assert!(!input.pressed(DummyInput::Input1));
|
||||
assert!(!input.pressed(DummyInput::Input2));
|
||||
|
||||
// Test pressing
|
||||
input.press(DummyInput::Input1);
|
||||
input.press(DummyInput::Input2);
|
||||
assert!(input.pressed(DummyInput::Input1));
|
||||
assert!(input.pressed(DummyInput::Input2));
|
||||
|
||||
// Release the inputs and check state
|
||||
|
||||
input.release(DummyInput::Input1);
|
||||
input.release(DummyInput::Input2);
|
||||
|
||||
|
|
Loading…
Reference in a new issue