Spu2-x: Hack in some ini file support for Linux.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2630 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
arcum42 2010-02-23 13:45:36 +00:00
parent f8e9c20664
commit f86876f9fe
5 changed files with 145 additions and 17 deletions

View File

@ -16,15 +16,91 @@
*/
#include "Dialogs.h"
#include <wx/fileconf.h>
wxConfigBase *oldConfig;
wxString path;
wxFileConfig *setIni(const wchar_t* Section)
{
wxConfig *tempConfig;
oldConfig = wxConfigBase::Get(false);
tempConfig = new wxFileConfig(L"", L"", path, L"", wxCONFIG_USE_LOCAL_FILE);
wxConfigBase::Set(tempConfig);
tempConfig->SetPath(L"/");
tempConfig->SetPath(Section);
return tempConfig;
}
void writeIni(wxFileConfig *tempConfig)
{
tempConfig->Flush();
if (oldConfig != NULL) wxConfigBase::Set(oldConfig);
delete tempConfig;
}
void CfgSetSettingsDir(const char* dir)
{
path = wxString::FromAscii(dir) + L"spu2-x.ini";
}
void CfgWriteBool(const wchar_t* Section, const wchar_t* Name, bool Value)
{
wxConfig *config = setIni(Section);
config->Write(Name, Value);
writeIni(config);
}
void CfgWriteInt(const wchar_t* Section, const wchar_t* Name, int Value)
{
wxConfig *config = setIni(Section);
config->Write(Name, Value);
writeIni(config);
}
void CfgWriteStr(const wchar_t* Section, const wchar_t* Name, const wstring& Data)
{
wxConfig *config = setIni(Section);
config->Write(Name, Data);
writeIni(config);
}
bool CfgReadBool(const wchar_t *Section,const wchar_t* Name, bool Default)
{
bool ret;
wxConfig *config = setIni(Section);
config->Read(Name, &ret, Default);
writeIni(config);
return ret;
}
int CfgReadInt(const wchar_t* Section, const wchar_t* Name,int Default)
{
int ret;
wxConfig *config = setIni(Section);
config->Read(Name, &ret, Default);
writeIni(config);
return ret;
}
void CfgReadStr(const wchar_t* Section, const wchar_t* Name, wxString& Data, int DataSize, const wchar_t* Default)
{
wxConfig *config = setIni(Section);
Data = config->Read(Name, Default);
writeIni(config);
}
void CfgReadStr(const wchar_t* Section, const wchar_t* Name, wstring& Data, int DataSize, const wchar_t* Default)
{
wxString temp;
CfgReadStr(Section, Name, temp, DataSize, Default);
Data = temp.c_str();
}

View File

@ -87,19 +87,67 @@ bool StereoExpansionEnabled = false;
/*****************************************************************************/
void ReadSettings()
{
{
Interpolation = CfgReadInt( L"MIXING",L"Interpolation", 1 );
ReverbBoost = CfgReadInt( L"MIXING",L"Reverb_Boost", 0 );
timeStretchDisabled = CfgReadBool( L"OUTPUT", L"Disable_Timestretch", false );
EffectsDisabled = CfgReadBool( L"MIXING", L"Disable_Effects", false );
StereoExpansionEnabled = CfgReadBool( L"OUTPUT", L"Enable_StereoExpansion", false );
SndOutLatencyMS = CfgReadInt(L"OUTPUT",L"Latency", 150);
wchar_t omodid[128];
//CfgReadStr( L"OUTPUT", L"Output_Module", omodid, 127, PortaudioOut->GetIdent() );
// find the driver index of this module:
//OutputModule = FindOutputModuleById( omodid );
// Read DSOUNDOUT and WAVEOUT configs:
CfgReadStr( L"WAVEOUT", L"Device", Config_WaveOut.Device, 254, L"default" );
Config_WaveOut.NumBuffers = CfgReadInt( L"WAVEOUT", L"Buffer_Count", 4 );
PortaudioOut->ReadSettings();
SoundtouchCfg::ReadSettings();
//DebugConfig::ReadSettings();
// Sanity Checks
// -------------
Clampify( SndOutLatencyMS, LATENCY_MIN, LATENCY_MAX );
WriteSettings();
}
/*****************************************************************************/
void WriteSettings()
{
{
CfgWriteInt(L"MIXING",L"Interpolation",Interpolation);
CfgWriteInt(L"MIXING",L"Reverb_Boost",ReverbBoost);
CfgWriteBool(L"MIXING",L"Disable_Effects",EffectsDisabled);
CfgWriteStr(L"OUTPUT",L"Output_Module", mods[OutputModule]->GetIdent() );
CfgWriteInt(L"OUTPUT",L"Latency", SndOutLatencyMS);
CfgWriteBool(L"OUTPUT",L"Disable_Timestretch", timeStretchDisabled);
CfgWriteBool(L"OUTPUT",L"Enable_StereoExpansion", StereoExpansionEnabled);
if( Config_WaveOut.Device.empty() ) Config_WaveOut.Device = L"default";
CfgWriteStr(L"WAVEOUT",L"Device",Config_WaveOut.Device);
CfgWriteInt(L"WAVEOUT",L"Buffer_Count",Config_WaveOut.NumBuffers);
PortaudioOut->WriteSettings();
SoundtouchCfg::WriteSettings();
//DebugConfig::WriteSettings();
}
void configure()
{
ReadSettings();
ReadSettings();
WriteSettings();
}
void MessageBox(char const*, ...)

View File

@ -96,9 +96,10 @@ namespace SoundtouchCfg
static int SeekWindowMS = 16;
static int OverlapMS = 7;
static void ReadSettings();
static void WriteSettings();
static void OpenDialog( uptr hWnd );
/*static*/ void ReadSettings();
/*static*/ void WriteSettings();
/*static*/ void OpenDialog( uptr hWnd );
static void ClampValues();
};

View File

@ -42,18 +42,19 @@ void ApplySettings( soundtouch::SoundTouch& sndtouch )
void ReadSettings()
{
//SequenceLenMS = CfgReadInt( L"SOUNDTOUCH", L"SequenceLengthMS", 63 );
//SeekWindowMS = CfgReadInt( L"SOUNDTOUCH", L"SeekWindowMS", 16 );
//OverlapMS = CfgReadInt( L"SOUNDTOUCH", L"OverlapMS", 7 );
SequenceLenMS = CfgReadInt( L"SOUNDTOUCH", L"SequenceLengthMS", 63 );
SeekWindowMS = CfgReadInt( L"SOUNDTOUCH", L"SeekWindowMS", 16 );
OverlapMS = CfgReadInt( L"SOUNDTOUCH", L"OverlapMS", 7 );
ClampValues();
ClampValues();
WriteSettings();
}
void WriteSettings()
{
//CfgWriteInt( L"SOUNDTOUCH", L"SequenceLengthMS", SequenceLenMS );
//CfgWriteInt( L"SOUNDTOUCH", L"SeekWindowMS", SeekWindowMS );
//CfgWriteInt( L"SOUNDTOUCH", L"OverlapMS", OverlapMS );
CfgWriteInt( L"SOUNDTOUCH", L"SequenceLengthMS", SequenceLenMS );
CfgWriteInt( L"SOUNDTOUCH", L"SeekWindowMS", SeekWindowMS );
CfgWriteInt( L"SOUNDTOUCH", L"OverlapMS", OverlapMS );
}
/*bool CALLBACK SoundtouchCfg::DialogProc(uptr hWnd,u32 uMsg,uptr wParam,uptr lParam)
@ -62,5 +63,7 @@ void WriteSettings()
void OpenDialog( uptr hWnd )
{
ReadSettings();
WriteSettings();
}
}

View File

@ -23,13 +23,13 @@
extern void CfgSetSettingsDir(const char* dir);
//extern void CfgWriteBool(const wchar_t* Section, const wchar_t* Name, bool Value);
//extern void CfgWriteInt(const wchar_t* Section, const wchar_t* Name, int Value);
extern void CfgWriteBool(const wchar_t* Section, const wchar_t* Name, bool Value);
extern void CfgWriteInt(const wchar_t* Section, const wchar_t* Name, int Value);
extern void CfgWriteStr(const wchar_t* Section, const wchar_t* Name, const wstring& Data);
//extern bool CfgReadBool(const wchar_t *Section,const wchar_t* Name, bool Default);
extern bool CfgReadBool(const wchar_t *Section,const wchar_t* Name, bool Default);
extern void CfgReadStr(const wchar_t* Section, const wchar_t* Name, wstring& Data, int DataSize, const wchar_t* Default);
//extern void CfgReadStr(const wchar_t* Section, const wchar_t* Name, wchar_t* Data, int DataSize, const wchar_t* Default);
//extern int CfgReadInt(const wchar_t* Section, const wchar_t* Name,int Default);
extern int CfgReadInt(const wchar_t* Section, const wchar_t* Name,int Default);
#endif