From 0407bb2e8671b5a7a4160a413faba197eb199ff4 Mon Sep 17 00:00:00 2001 From: "andres.delikat" Date: Sat, 9 Jul 2011 18:24:53 +0000 Subject: [PATCH] Input widget - Check for duplicates in binding array before committing a mapping --- BizHawk.MultiClient/config/InputWidget.cs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/BizHawk.MultiClient/config/InputWidget.cs b/BizHawk.MultiClient/config/InputWidget.cs index 1b23ab4165..e99a8d2998 100644 --- a/BizHawk.MultiClient/config/InputWidget.cs +++ b/BizHawk.MultiClient/config/InputWidget.cs @@ -78,13 +78,27 @@ namespace BizHawk.MultiClient if (TempBindingStr == "Alt+F4") return; - Bindings[pos] = TempBindingStr; - wasPressed = TempBindingStr; - UpdateLabel(); - Increment(); + if (!IsDuplicate(TempBindingStr)) + { + Bindings[pos] = TempBindingStr; + wasPressed = TempBindingStr; + UpdateLabel(); + Increment(); + } } } + public bool IsDuplicate(string binding) + { + for (int x = 0; x < MaxBind; x++) + { + if (Bindings[x] == binding) + return true; + } + + return false; + } + protected override void OnKeyUp(KeyEventArgs e) { if (e.KeyCode == Keys.F4 && e.Modifiers == Keys.Alt)