From 4d5c0444c834ad16637d1912f096b733a76152e5 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Thu, 9 May 2024 00:46:21 -0400 Subject: [PATCH] Fix an issue where control binds would be duplicated and quickly multiply. --- source/funkin/input/Controls.hx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/source/funkin/input/Controls.hx b/source/funkin/input/Controls.hx index 1983d413b..548e4edfa 100644 --- a/source/funkin/input/Controls.hx +++ b/source/funkin/input/Controls.hx @@ -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; + } } } @@ -989,6 +997,7 @@ class Controls extends FlxActionSet for (control in Control.createAll()) { var inputs:Array = Reflect.field(data, control.getName()); + inputs = inputs.unique(); if (inputs != null) { if (inputs.length == 0) { @@ -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); }