fix: multiply bindings handling on single key
This commit is contained in:
+9
-4
@@ -46,11 +46,11 @@ impl<
|
||||
fn save_input(
|
||||
keyboard_input: Res<Input<KeyCode>>,
|
||||
mouse_input: Res<Input<MouseButton>>,
|
||||
mut lobby: ResMut<Ic>,
|
||||
mut inputs_container: ResMut<Ic>,
|
||||
controls: Res<Controls<A, Gs>>,
|
||||
game_state: Res<State<Gs>>,
|
||||
) {
|
||||
if let Some(inputs) = lobby.me_mut() {
|
||||
if let Some(inputs) = inputs_container.me_mut() {
|
||||
for (action, config) in controls.iter() {
|
||||
'bindings_loop: for binding in config.bindings.iter() {
|
||||
for condition in &binding.conditions {
|
||||
@@ -63,14 +63,18 @@ impl<
|
||||
}
|
||||
}
|
||||
|
||||
log::trace!("action {:?} in condition", action);
|
||||
log::trace!("action binding {:?} {:?} in condition", action, binding);
|
||||
|
||||
match &binding.input {
|
||||
ButtonCombination::Single(button) => match button {
|
||||
InputType::Keyboard(key) => {
|
||||
log::trace!("presed?: {:?}", keyboard_input.pressed(*key));
|
||||
log::trace!("active");
|
||||
inputs.forced_set(*action, keyboard_input.pressed(*key));
|
||||
if keyboard_input.pressed(*key) {
|
||||
inputs.forced_set(*action, true);
|
||||
break; // when on binding trigered no sence check another
|
||||
}
|
||||
inputs.forced_set(*action, false); // FIXME: this is happening on every pass so too frequently
|
||||
}
|
||||
InputType::Mouse(input) => {
|
||||
match input {
|
||||
@@ -124,6 +128,7 @@ impl<
|
||||
log::trace!("active");
|
||||
// TODO: should be [`Chord`](ButtonCombination::Chord) only [`Boolean`](InputValue::Boolean) type
|
||||
inputs.forced_set(*action, true);
|
||||
break; // when on binding trigered no sence check another
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user