Skip to content

Commit

Permalink
Fix an issue where control binds would be duplicated and quickly mult…
Browse files Browse the repository at this point in the history
…iply.
  • Loading branch information
EliteMasterEric committed May 9, 2024
1 parent 1e35903 commit 4d5c044
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion source/funkin/input/Controls.hx
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,14 @@ class Controls extends FlxActionSet
action.inputs[i].inputID = toAdd;
}
hasReplaced = true;
} else if (input.device == KEYBOARD && input.inputID == toAdd) {
// This key is already bound!
if (hasReplaced) {
// Remove the duplicate keybind, don't replace.
action.inputs.remove(input);
} else {
hasReplaced = true;
}
}
}

Expand Down Expand Up @@ -989,6 +997,7 @@ class Controls extends FlxActionSet
for (control in Control.createAll())
{
var inputs:Array<Int> = Reflect.field(data, control.getName());
inputs = inputs.unique();
if (inputs != null)
{
if (inputs.length == 0) {
Expand Down Expand Up @@ -1038,7 +1047,11 @@ class Controls extends FlxActionSet
var inputs = getInputsFor(control, device);
isEmpty = isEmpty && inputs.length == 0;

if (inputs.length == 0) inputs = [FlxKey.NONE];
if (inputs.length == 0) {
inputs = [FlxKey.NONE];
} else {
inputs = inputs.unique();
}

Reflect.setField(data, control.getName(), inputs);
}
Expand Down

0 comments on commit 4d5c044

Please sign in to comment.