summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2014-01-22 18:28:08 -0500
committerLioncash <mathew1800@gmail.com>2014-01-22 18:28:59 -0500
commit391d26d3bf65b7768dfa0b866cdc8a651c14c2b8 (patch)
tree9225435cbb148a8b62c2385d96018585c4cc337a /Source
parenteb29177c5a6ddca49f757ac99f23c39e451571b8 (diff)
[DolphinWX] Prevent hotkeys from being assigned to more than one button/function.
Prior to this commit it was possible to assign the same keycode to more than one button. ie. Say I assigned Open with the hotkey Ctrl+O; well, it was possible to also add it to another function as well, which leads to hotkey clashing. Now, say I assign Open with Ctrl+O, but then assign that same hotkey to Refresh List; it will unbind the hotkey from Open and then assign it to refresh list.
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/DolphinWX/HotkeyDlg.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/Source/Core/DolphinWX/HotkeyDlg.cpp b/Source/Core/DolphinWX/HotkeyDlg.cpp
index 03b40dd286..5fe375c04f 100644
--- a/Source/Core/DolphinWX/HotkeyDlg.cpp
+++ b/Source/Core/DolphinWX/HotkeyDlg.cpp
@@ -72,6 +72,26 @@ void HotkeyConfigDialog::OnKeyDown(wxKeyEvent& event)
}
else
{
+ // Check if the hotkey combination was already applied to another button
+ // and unapply it if necessary.
+ for (wxButton* btn : m_Button_Hotkeys)
+ {
+ // We compare against this to see if we have a duplicate bind attempt.
+ wxString existingHotkey = btn->GetLabel();
+
+ wxString tentativeModKey = InputCommon::WXKeymodToString(g_Modkey);
+ wxString tentativePressedKey = InputCommon::WXKeyToString(g_Pressed);
+ wxString tentativeHotkey(tentativeModKey + tentativePressedKey);
+
+ // Found a button that already has this binding. Unbind it.
+ if (tentativeHotkey == existingHotkey)
+ {
+ SaveButtonMapping(btn->GetId(), -1, 0);
+ SetButtonText(btn->GetId(), wxString());
+ }
+ }
+
+ // Proceed to apply the binding to the selected button.
SetButtonText(ClickedButton->GetId(),
InputCommon::WXKeyToString(g_Pressed),
InputCommon::WXKeymodToString(g_Modkey));