File tree 1 file changed +17
-0
lines changed 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 82
82
}
83
83
}
84
84
85
+ /// Registers a release for all currently pressed inputs.
86
+ pub fn release_all ( & mut self ) {
87
+ // Move all items from pressed into just_released
88
+ self . just_released . extend ( self . pressed . drain ( ) ) ;
89
+ }
90
+
85
91
/// Returns `true` if the `input` has just been pressed.
86
92
pub fn just_pressed ( & self , input : T ) -> bool {
87
93
self . just_pressed . contains ( & input)
@@ -197,6 +203,17 @@ mod test {
197
203
assert ! ( input. just_released. contains( & DummyInput :: Input1 ) ) ;
198
204
}
199
205
206
+ #[ test]
207
+ fn test_release_all ( ) {
208
+ let mut input = Input :: default ( ) ;
209
+ input. press ( DummyInput :: Input1 ) ;
210
+ input. press ( DummyInput :: Input2 ) ;
211
+ input. release_all ( ) ;
212
+ assert ! ( input. pressed. is_empty( ) ) ;
213
+ assert ! ( input. just_released. contains( & DummyInput :: Input1 ) ) ;
214
+ assert ! ( input. just_released. contains( & DummyInput :: Input2 ) ) ;
215
+ }
216
+
200
217
#[ test]
201
218
fn test_just_pressed ( ) {
202
219
let mut input = Input :: default ( ) ;
You can’t perform that action at this time.
0 commit comments