diff --git a/Common/KeyMap.cpp b/Common/KeyMap.cpp index 092ca95144..2a05e4e434 100644 --- a/Common/KeyMap.cpp +++ b/Common/KeyMap.cpp @@ -44,6 +44,7 @@ struct DefMappingStruct { }; KeyMapping g_controllerMap; +int g_controllerMapGeneration = 0; std::set g_seenPads; bool g_swapped_keys = false; @@ -833,6 +834,7 @@ void SetKeyMapping(int btn, KeyDef key, bool replace) { } g_controllerMap[btn].push_back(key); } + g_controllerMapGeneration++; UpdateNativeMenuKeys(); } @@ -956,6 +958,7 @@ void AutoConfForPad(const std::string &name) { // Add a couple of convenient keyboard mappings by default, too. g_controllerMap[VIRTKEY_PAUSE].push_back(KeyDef(DEVICE_ID_KEYBOARD, NKCODE_ESCAPE)); g_controllerMap[VIRTKEY_UNTHROTTLE].push_back(KeyDef(DEVICE_ID_KEYBOARD, NKCODE_TAB)); + g_controllerMapGeneration++; #endif } diff --git a/Common/KeyMap.h b/Common/KeyMap.h index 9f408ed7f6..a6020fc076 100644 --- a/Common/KeyMap.h +++ b/Common/KeyMap.h @@ -85,6 +85,7 @@ class IniFile; namespace KeyMap { extern KeyMapping g_controllerMap; + extern int g_controllerMapGeneration; // Key & Button names struct KeyMap_IntStrPair { diff --git a/UI/ControlMappingScreen.cpp b/UI/ControlMappingScreen.cpp index 68448d059b..0612cad540 100644 --- a/UI/ControlMappingScreen.cpp +++ b/UI/ControlMappingScreen.cpp @@ -29,6 +29,7 @@ #include "ui/view.h" #include "ui/viewgroup.h" +#include "Core/Host.h" #include "Core/HLE/sceCtrl.h" #include "Core/System.h" #include "Common/KeyMap.h" @@ -79,6 +80,7 @@ void ControlMapper::Update() { if (refresh_) { refresh_ = false; Refresh(); + host->UpdateUI(); } } @@ -169,6 +171,7 @@ void ControlMapper::MappedCallback(KeyDef kdf) { break; case REPLACEONE: KeyMap::g_controllerMap[pspKey_][actionIndex_] = kdf; + KeyMap::g_controllerMapGeneration++; break; default: ; @@ -211,6 +214,7 @@ UI::EventReturn ControlMapper::OnAddMouse(UI::EventParams ¶ms) { UI::EventReturn ControlMapper::OnDelete(UI::EventParams ¶ms) { int index = atoi(params.v->Tag().c_str()); KeyMap::g_controllerMap[pspKey_].erase(KeyMap::g_controllerMap[pspKey_].begin() + index); + KeyMap::g_controllerMapGeneration++; refresh_ = true; return UI::EVENT_DONE; } diff --git a/Windows/MainWindowMenu.cpp b/Windows/MainWindowMenu.cpp index 2bb5f9be4b..b0a87829a7 100644 --- a/Windows/MainWindowMenu.cpp +++ b/Windows/MainWindowMenu.cpp @@ -50,6 +50,7 @@ namespace MainWindow { static std::unordered_map initialMenuKeys; static std::vector availableShaders; static std::string menuLanguageID = ""; + static int menuKeymapGeneration = -1; static bool menuShaderInfoLoaded = false; std::vector menuShaderInfo; @@ -209,6 +210,10 @@ namespace MainWindow { } void DoTranslateMenus(HWND hWnd, HMENU menu) { + auto useDefHotkey = [](int virtkey) { + return KeyMap::g_controllerMap[virtkey].empty(); + }; + TranslateMenuItem(menu, ID_FILE_MENU); TranslateMenuItem(menu, ID_EMULATION_MENU); TranslateMenuItem(menu, ID_DEBUG_MENU); @@ -220,9 +225,9 @@ namespace MainWindow { TranslateMenuItem(menu, ID_FILE_LOAD_DIR); TranslateMenuItem(menu, ID_FILE_LOAD_MEMSTICK); TranslateMenuItem(menu, ID_FILE_MEMSTICK); - TranslateMenuItem(menu, ID_FILE_SAVESTATE_SLOT_MENU, L"\tF3"); - TranslateMenuItem(menu, ID_FILE_QUICKLOADSTATE, L"\tF4"); - TranslateMenuItem(menu, ID_FILE_QUICKSAVESTATE, L"\tF2"); + TranslateMenuItem(menu, ID_FILE_SAVESTATE_SLOT_MENU, useDefHotkey(VIRTKEY_NEXT_SLOT) ? L"\tF3" : L""); + TranslateMenuItem(menu, ID_FILE_QUICKLOADSTATE, useDefHotkey(VIRTKEY_LOAD_STATE) ? L"\tF4" : L""); + TranslateMenuItem(menu, ID_FILE_QUICKSAVESTATE, useDefHotkey(VIRTKEY_SAVE_STATE) ? L"\tF2" : L""); TranslateMenuItem(menu, ID_FILE_LOADSTATEFILE); TranslateMenuItem(menu, ID_FILE_SAVESTATEFILE); TranslateMenuItem(menu, ID_FILE_RECORD_MENU); @@ -326,7 +331,7 @@ namespace MainWindow { bool changed = false; const std::string curLanguageID = i18nrepo.LanguageID(); - if (curLanguageID != menuLanguageID) { + if (curLanguageID != menuLanguageID || menuKeymapGeneration != KeyMap::g_controllerMapGeneration) { DoTranslateMenus(hWnd, menu); menuLanguageID = curLanguageID; changed = true;