UI: Keyboard shortcuts overrides via PCSX2_keys.ini

Keys combination can be:
"alt-" and/or "ctrl-" and/or "shift-" and ( F1-F12 or KP_0-KP_9 or SPECIAL1-SPECIAL20 )

Where:
Fn is function key n
KP_n is numpad number n
SPECIALn is hardware button n (whatever that means...)

Examples:
FullscreenToggle=alt-ctrl-f12
GSwindow_CycleAspectRatio=KP_0

See full configurable strings at the first comment.


git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4917 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
avihal 2011-09-11 22:13:02 +00:00
parent 45ae2cb4e8
commit 8b2aa64d7e
5 changed files with 45 additions and 3 deletions

View File

@ -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 );

View File

@ -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 )
{

View File

@ -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

View File

@ -63,6 +63,8 @@ extern wxDirName ThemesFolder;
extern wxDirName GetSettingsFolder();
extern wxString GetVmSettingsFilename();
extern wxString GetUiSettingsFilename();
extern wxString GetUiKeysFilename();
extern wxDirName GetLogFolder();
enum InstallationModeType

View File

@ -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 );