@@ -129,7 +129,18 @@ where
129
129
self . just_released . remove ( & input) ;
130
130
}
131
131
132
+ /// Clears the `pressed`, `just_pressed`, and `just_released` data for every input.
133
+ ///
134
+ /// See also [`Input::clear`] for simulating elapsed time steps.
135
+ pub fn reset_all ( & mut self ) {
136
+ self . pressed . clear ( ) ;
137
+ self . just_pressed . clear ( ) ;
138
+ self . just_released . clear ( ) ;
139
+ }
140
+
132
141
/// Clears the `just pressed` and `just released` data for every input.
142
+ ///
143
+ /// See also [`Input::reset_all`] for a full reset.
133
144
pub fn clear ( & mut self ) {
134
145
self . just_pressed . clear ( ) ;
135
146
self . just_released . clear ( ) ;
@@ -301,6 +312,22 @@ mod test {
301
312
assert ! ( !input. just_released( DummyInput :: Input1 ) ) ;
302
313
}
303
314
315
+ #[ test]
316
+ fn test_reset_all ( ) {
317
+ let mut input = Input :: default ( ) ;
318
+
319
+ input. press ( DummyInput :: Input1 ) ;
320
+ input. press ( DummyInput :: Input2 ) ;
321
+ input. release ( DummyInput :: Input2 ) ;
322
+ assert ! ( input. pressed. contains( & DummyInput :: Input1 ) ) ;
323
+ assert ! ( input. just_pressed. contains( & DummyInput :: Input1 ) ) ;
324
+ assert ! ( input. just_released. contains( & DummyInput :: Input2 ) ) ;
325
+ input. reset_all ( ) ;
326
+ assert ! ( input. pressed. is_empty( ) ) ;
327
+ assert ! ( input. just_pressed. is_empty( ) ) ;
328
+ assert ! ( input. just_released. is_empty( ) ) ;
329
+ }
330
+
304
331
#[ test]
305
332
fn test_clear ( ) {
306
333
let mut input = Input :: default ( ) ;
0 commit comments