diff --git a/pcsx2/PathDefs.h b/pcsx2/PathDefs.h index e249d834c1..35fe2c8eb0 100644 --- a/pcsx2/PathDefs.h +++ b/pcsx2/PathDefs.h @@ -80,6 +80,7 @@ namespace PathDefs namespace FilenameDefs { extern wxFileName GetUiConfig(); + extern wxFileName GetUiKeysConfig(); extern wxFileName GetVmConfig(); extern wxFileName GetUsermodeConfig(); extern const wxFileName& Memcard( uint port, uint slot ); diff --git a/pcsx2/gui/AppAccelerators.h b/pcsx2/gui/AppAccelerators.h index 479fa2122e..673fef7bc1 100644 --- a/pcsx2/gui/AppAccelerators.h +++ b/pcsx2/gui/AppAccelerators.h @@ -39,6 +39,16 @@ struct KeyAcceleratorCode KeyAcceleratorCode() : val32( 0 ) {} KeyAcceleratorCode( const wxKeyEvent& evt ); + + //grab event attributes only + KeyAcceleratorCode( const wxAcceleratorEntry& right) + { + val32 = 0; + keycode = right.GetKeyCode(); + if( right.GetFlags() & wxACCEL_ALT ) Alt(); + if( right.GetFlags() & wxACCEL_CMD ) Cmd(); + if( right.GetFlags() & wxACCEL_SHIFT ) Shift(); + } KeyAcceleratorCode( wxKeyCode code ) { diff --git a/pcsx2/gui/AppConfig.cpp b/pcsx2/gui/AppConfig.cpp index 14f08bc5d5..8878a21777 100644 --- a/pcsx2/gui/AppConfig.cpp +++ b/pcsx2/gui/AppConfig.cpp @@ -336,6 +336,11 @@ namespace FilenameDefs return pxGetAppName() + L"_ui.ini"; } + wxFileName GetUiKeysConfig() + { + return pxGetAppName() + L"_keys.ini"; + } + wxFileName GetVmConfig() { return pxGetAppName() + L"_vm.ini"; @@ -412,6 +417,12 @@ wxString GetUiSettingsFilename() return GetSettingsFolder().Combine( fname ).GetFullPath(); } +wxString GetUiKeysFilename() +{ + wxFileName fname( FilenameDefs::GetUiKeysConfig() ); + return GetSettingsFolder().Combine( fname ).GetFullPath(); +} + wxString AppConfig::FullpathToBios() const { return Path::Combine( Folders.Bios, BaseFilenames.Bios ); } wxString AppConfig::FullpathToMcd( uint slot ) const diff --git a/pcsx2/gui/AppConfig.h b/pcsx2/gui/AppConfig.h index d66d9763e7..d14484ddcc 100644 --- a/pcsx2/gui/AppConfig.h +++ b/pcsx2/gui/AppConfig.h @@ -63,6 +63,8 @@ extern wxDirName ThemesFolder; extern wxDirName GetSettingsFolder(); extern wxString GetVmSettingsFilename(); extern wxString GetUiSettingsFilename(); +extern wxString GetUiKeysFilename(); + extern wxDirName GetLogFolder(); enum InstallationModeType diff --git a/pcsx2/gui/GlobalCommands.cpp b/pcsx2/gui/GlobalCommands.cpp index f99e20d92c..a72f942642 100644 --- a/pcsx2/gui/GlobalCommands.cpp +++ b/pcsx2/gui/GlobalCommands.cpp @@ -55,8 +55,8 @@ wxString KeyAcceleratorCode::ToString() const return wxAcceleratorEntry( (cmd ? wxACCEL_CMD : 0) | - (shift ? wxACCEL_CMD : 0) | - (alt ? wxACCEL_CMD : 0), + (shift ? wxACCEL_SHIFT : 0) | + (alt ? wxACCEL_ALT : 0), keycode ).ToString(); } @@ -530,8 +530,26 @@ AcceleratorDictionary::AcceleratorDictionary() AcceleratorDictionary::~AcceleratorDictionary() throw() {} -void AcceleratorDictionary::Map( const KeyAcceleratorCode& acode, const char *searchfor ) +void AcceleratorDictionary::Map( const KeyAcceleratorCode& _acode, const char *searchfor ) { + // Search override mapping at ini file + KeyAcceleratorCode acode = _acode; + wxString overrideStr; + wxAcceleratorEntry codeParser; //Provides string parsing capabilities + wxFileConfig cfg(L"", L"", L"" , GetUiKeysFilename(), wxCONFIG_USE_GLOBAL_FILE ); + if( cfg.Read( wxString::FromUTF8(searchfor), &overrideStr) ) + { + overrideStr = wxString(L"\t") + overrideStr; + if( codeParser.FromString( overrideStr ) ) // needs a '\t' prefix (originally used for wxMenu accelerators parsing)... + { + //ini file contains alternative parsable key combination for current 'searchfor'. + acode = codeParser; + Console.WriteLn(Color_StrongGreen, L"Overriding '%s': assigning %s (instead of %s)", + fromUTF8( searchfor ).c_str(), acode.ToString().c_str(), _acode.ToString().c_str()); + } + } + // End of overrides section + const GlobalCommandDescriptor* result = NULL; TryGetValue( acode.val32, result );