Added pressed state to input clear so it clears everything (#4410)
# Objective Adds `pressed` state to Input::clear(). Fixes #3383
This commit is contained in:
parent
39d89fe0df
commit
d9d2fb6409
@ -116,10 +116,11 @@ where
|
|||||||
self.just_released.remove(&input);
|
self.just_released.remove(&input);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Clear just pressed and just released information.
|
/// Clear pressed, just pressed and just released information.
|
||||||
pub fn clear(&mut self) {
|
pub fn clear(&mut self) {
|
||||||
self.just_pressed.clear();
|
self.just_pressed.clear();
|
||||||
self.just_released.clear();
|
self.just_released.clear();
|
||||||
|
self.pressed.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// List all inputs that are pressed.
|
/// List all inputs that are pressed.
|
||||||
@ -166,7 +167,7 @@ mod test {
|
|||||||
assert!(input.pressed(DummyInput::Input1));
|
assert!(input.pressed(DummyInput::Input1));
|
||||||
assert!(input.pressed(DummyInput::Input2));
|
assert!(input.pressed(DummyInput::Input2));
|
||||||
|
|
||||||
// Clear the `input`, removing just pressed and just released
|
// Clear the `input`, removing pressed, just pressed and just released
|
||||||
input.clear();
|
input.clear();
|
||||||
|
|
||||||
// Check if they're marked "just pressed"
|
// Check if they're marked "just pressed"
|
||||||
@ -174,8 +175,12 @@ mod test {
|
|||||||
assert!(!input.just_pressed(DummyInput::Input2));
|
assert!(!input.just_pressed(DummyInput::Input2));
|
||||||
|
|
||||||
// Check if they're marked as pressed
|
// Check if they're marked as pressed
|
||||||
assert!(input.pressed(DummyInput::Input1));
|
assert!(!input.pressed(DummyInput::Input1));
|
||||||
assert!(input.pressed(DummyInput::Input2));
|
assert!(!input.pressed(DummyInput::Input2));
|
||||||
|
|
||||||
|
// Test pressing
|
||||||
|
input.press(DummyInput::Input1);
|
||||||
|
input.press(DummyInput::Input2);
|
||||||
|
|
||||||
// Release the inputs and check state
|
// Release the inputs and check state
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user