From f4268d7befe7365acaf58d73a0244191af688c93 Mon Sep 17 00:00:00 2001 From: yukkop Date: Fri, 4 Sep 2026 18:14:21 +0000 Subject: [PATCH] fix: bindings manipulations --- crate/bevy_controls/src/resource.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/crate/bevy_controls/src/resource.rs b/crate/bevy_controls/src/resource.rs index 5c5c233..ca0e98f 100755 --- a/crate/bevy_controls/src/resource.rs +++ b/crate/bevy_controls/src/resource.rs @@ -501,6 +501,16 @@ impl Bindings { } } + pub fn customizable(mut self) -> Self { + self.options = OptionsMode::Customizable; + self + } + + pub fn immutable(mut self) -> Self { + self.options = OptionsMode::Immutable; + self + } + pub fn with_option_mode(mut self, options: OptionsMode) -> Self { self.options = options; self @@ -672,7 +682,7 @@ impl Controls { } /// Push new binding for action - pub fn push(&mut self, action: A, binding: Binding) { + pub fn push_binding(&mut self, action: A, binding: Binding) { // TODO: warning if config is not exist yet // TODO: interface for [`ActivationOptions`] self @@ -684,7 +694,7 @@ impl Controls { } /// Remove all bindings for action - pub fn remove(&mut self, action: A) { + pub fn clear_bindings(&mut self, action: A) { // TODO: warning if config is not exist yet self .0 @@ -694,9 +704,10 @@ impl Controls { .clear(); } + /// Remove binding for action pub fn remove_binding(&mut self, action: A, binding: Binding) { if let Some(config) = self.0.get_mut(&action) { - config.bindings.retain(|b| *b == binding); + config.bindings.retain(|b| *b != binding); } }