Skip to content

Commit

Permalink
Release the pressed clashed ActionData
Browse files Browse the repository at this point in the history
  • Loading branch information
Shute052 committed Feb 19, 2024
1 parent 19b66ed commit d636245
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/clashing_inputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,19 @@ impl<A: Actionlike> InputMap<A> {
clash_strategy: ClashStrategy,
) {
for clash in self.get_clashes(action_data, input_streams) {
// Reset the action in the pair that was overruled, if any
if let Some(culled_action) = resolve_clash(&clash, clash_strategy, input_streams) {
action_data.insert(culled_action, ActionData::default());
let culled_action_data = action_data
.raw_entry_mut()
.from_key(&culled_action)
.or_insert_with(|| (culled_action.clone(), ActionData::default()))
.1;
if culled_action_data.state.pressed() {
// Reset the pressed action in the pair that was overruled, if any
culled_action_data.state.release();
} else {
// Remove the released action in the pair that was overruled, if any
action_data.remove(&culled_action);
}
}
}
}
Expand Down

0 comments on commit d636245

Please sign in to comment.