From 35cf05d4cb6bd7f8d9ab80a83df41dc02ce88192 Mon Sep 17 00:00:00 2001 From: Hennadii Chernyshchyk Date: Tue, 12 Dec 2023 21:56:04 +0200 Subject: [PATCH] Add `InputMap::clear` --- RELEASES.md | 4 ++++ src/input_map.rs | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/RELEASES.md b/RELEASES.md index 129dcaea..117d1f4d 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,5 +1,9 @@ # Release Notes +## Unreleased + +- Added `InputMap::Clear`. + ## Version 0.11.2 - fixed [a bug](https://github.com/Leafwing-Studios/leafwing-input-manager/issues/285) with mouse motion and mouse wheel events being improperly counted diff --git a/src/input_map.rs b/src/input_map.rs index 49ee94c8..b5ffdf18 100644 --- a/src/input_map.rs +++ b/src/input_map.rs @@ -431,6 +431,13 @@ impl InputMap { pub fn is_empty(&self) -> bool { self.len() == 0 } + + /// Clears the map, removing all action-inputs pairs. + /// + /// Keeps the allocated memory for reuse. + pub fn clear(&mut self) { + self.map.clear(); + } } // Removing