mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-05-30 05:52:02 +02:00
Port InputPluginCommon to use the original IniFile code, get rid of Billiard's.
a few minor warning/compile fixes. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5604 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
05c418ebe2
commit
12a4c25e9f
@ -95,7 +95,7 @@ void ReadGC(std::string FileName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if we should play this file
|
// Check if we should play this file
|
||||||
void CheckFile(std::string File, int Size)
|
void CheckFile(std::string File, u64 Size)
|
||||||
{
|
{
|
||||||
// Don't do anything if the log is unselected
|
// Don't do anything if the log is unselected
|
||||||
if (!LogManager::GetInstance()->isEnable(LogTypes::FILEMON)) return;
|
if (!LogManager::GetInstance()->isEnable(LogTypes::FILEMON)) return;
|
||||||
|
@ -26,8 +26,8 @@ namespace FileMon
|
|||||||
|
|
||||||
void ShowSound(std::string File);
|
void ShowSound(std::string File);
|
||||||
void ReadGC(std::string File);
|
void ReadGC(std::string File);
|
||||||
void CheckFile(std::string File, int Size);
|
void CheckFile(std::string File, u64 Size);
|
||||||
void FindFilename(u64 Offset);
|
void FindFilename(u64 Offset);
|
||||||
void Close();
|
void Close();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -113,37 +113,37 @@ void VideoConfig::GameIniLoad(const char *ini_file)
|
|||||||
iniFile.Load(ini_file);
|
iniFile.Load(ini_file);
|
||||||
|
|
||||||
if (iniFile.Exists("Video", "ForceFiltering"))
|
if (iniFile.Exists("Video", "ForceFiltering"))
|
||||||
iniFile.Get("Video", "ForceFiltering", &bForceFiltering, 0);
|
iniFile.Get("Video", "ForceFiltering", &bForceFiltering);
|
||||||
if (iniFile.Exists("Video", "MaxAnisotropy"))
|
if (iniFile.Exists("Video", "MaxAnisotropy"))
|
||||||
iniFile.Get("Video", "MaxAnisotropy", &iMaxAnisotropy, 3); // NOTE - this is x in (1 << x)
|
iniFile.Get("Video", "MaxAnisotropy", &iMaxAnisotropy); // NOTE - this is x in (1 << x)
|
||||||
if (iniFile.Exists("Video", "EFBCopyDisable"))
|
if (iniFile.Exists("Video", "EFBCopyDisable"))
|
||||||
iniFile.Get("Video", "EFBCopyDisable", &bEFBCopyDisable, 0);
|
iniFile.Get("Video", "EFBCopyDisable", &bEFBCopyDisable);
|
||||||
if (iniFile.Exists("Video", "EFBCopyDisableHotKey"))
|
if (iniFile.Exists("Video", "EFBCopyDisableHotKey"))
|
||||||
iniFile.Get("Video", "EFBCopyDisableHotKey", &bOSDHotKey, 0);
|
iniFile.Get("Video", "EFBCopyDisableHotKey", &bOSDHotKey);
|
||||||
if (iniFile.Exists("Video", "EFBToTextureEnable"))
|
if (iniFile.Exists("Video", "EFBToTextureEnable"))
|
||||||
iniFile.Get("Video", "EFBToTextureEnable", &bCopyEFBToTexture, 0);
|
iniFile.Get("Video", "EFBToTextureEnable", &bCopyEFBToTexture);
|
||||||
if (iniFile.Exists("Video", "EFBScaledCopy"))
|
if (iniFile.Exists("Video", "EFBScaledCopy"))
|
||||||
iniFile.Get("Video", "EFBScaledCopy", &bCopyEFBScaled, 0);
|
iniFile.Get("Video", "EFBScaledCopy", &bCopyEFBScaled);
|
||||||
if (iniFile.Exists("Video", "SafeTextureCache"))
|
if (iniFile.Exists("Video", "SafeTextureCache"))
|
||||||
iniFile.Get("Video", "SafeTextureCache", &bSafeTextureCache, false);
|
iniFile.Get("Video", "SafeTextureCache", &bSafeTextureCache);
|
||||||
//Safe texture cache params
|
//Safe texture cache params
|
||||||
if (iniFile.Exists("Video", "SafeTextureCacheColorSamples"))
|
if (iniFile.Exists("Video", "SafeTextureCacheColorSamples"))
|
||||||
iniFile.Get("Video", "SafeTextureCacheColorSamples", &iSafeTextureCache_ColorSamples,512);
|
iniFile.Get("Video", "SafeTextureCacheColorSamples", &iSafeTextureCache_ColorSamples);
|
||||||
|
|
||||||
if (iniFile.Exists("Video", "MSAA"))
|
if (iniFile.Exists("Video", "MSAA"))
|
||||||
iniFile.Get("Video", "MSAA", &iMultisampleMode, 0);
|
iniFile.Get("Video", "MSAA", &iMultisampleMode);
|
||||||
if (iniFile.Exists("Video", "DstAlphaPass"))
|
if (iniFile.Exists("Video", "DstAlphaPass"))
|
||||||
iniFile.Get("Video", "DstAlphaPass", &bDstAlphaPass, false);
|
iniFile.Get("Video", "DstAlphaPass", &bDstAlphaPass);
|
||||||
if (iniFile.Exists("Video", "UseXFB"))
|
if (iniFile.Exists("Video", "UseXFB"))
|
||||||
iniFile.Get("Video", "UseXFB", &bUseXFB, 0);
|
iniFile.Get("Video", "UseXFB", &bUseXFB);
|
||||||
if (iniFile.Exists("Video", "UseRealXFB"))
|
if (iniFile.Exists("Video", "UseRealXFB"))
|
||||||
iniFile.Get("Video", "UseRealXFB", &bUseRealXFB, 0);
|
iniFile.Get("Video", "UseRealXFB", &bUseRealXFB);
|
||||||
if (iniFile.Exists("Video", "FIFOBPHack"))
|
if (iniFile.Exists("Video", "FIFOBPHack"))
|
||||||
iniFile.Get("Video", "FIFOBPHack", &bFIFOBPhack, false);
|
iniFile.Get("Video", "FIFOBPHack", &bFIFOBPhack);
|
||||||
if (iniFile.Exists("Video", "ProjectionHack"))
|
if (iniFile.Exists("Video", "ProjectionHack"))
|
||||||
iniFile.Get("Video", "ProjectionHack", &iPhackvalue, 0);
|
iniFile.Get("Video", "ProjectionHack", &iPhackvalue);
|
||||||
if (iniFile.Exists("Video", "UseNativeMips"))
|
if (iniFile.Exists("Video", "UseNativeMips"))
|
||||||
iniFile.Get("Video", "UseNativeMips", &bUseNativeMips, true);
|
iniFile.Get("Video", "UseNativeMips", &bUseNativeMips);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoConfig::Save(const char *ini_file)
|
void VideoConfig::Save(const char *ini_file)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
<VisualStudioProject
|
<VisualStudioProject
|
||||||
ProjectType="Visual C++"
|
ProjectType="Visual C++"
|
||||||
Version="9.00"
|
Version="9,00"
|
||||||
Name="InputPluginCommon"
|
Name="InputPluginCommon"
|
||||||
ProjectGUID="{660BB3F7-ED8F-4027-A460-8E4EDA8189BE}"
|
ProjectGUID="{660BB3F7-ED8F-4027-A460-8E4EDA8189BE}"
|
||||||
RootNamespace="VideoCommon"
|
RootNamespace="VideoCommon"
|
||||||
@ -436,14 +436,6 @@
|
|||||||
RelativePath=".\Src\ControllerEmu.h"
|
RelativePath=".\Src\ControllerEmu.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\Src\IniFile.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\Src\IniFile.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
</Files>
|
</Files>
|
||||||
<Globals>
|
<Globals>
|
||||||
</Globals>
|
</Globals>
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
|
|
||||||
Plugin::Plugin( const char* const _ini_name, const char* const _gui_name, const char* const _profile_name )
|
Plugin::Plugin( const char* const _ini_name, const char* const _gui_name, const char* const _profile_name )
|
||||||
: ini_name(_ini_name)
|
: ini_name(_ini_name)
|
||||||
, gui_name(_gui_name)
|
, gui_name(_gui_name)
|
||||||
@ -26,32 +27,26 @@ Plugin::~Plugin()
|
|||||||
void Plugin::LoadConfig()
|
void Plugin::LoadConfig()
|
||||||
{
|
{
|
||||||
IniFile inifile;
|
IniFile inifile;
|
||||||
|
inifile.Load(std::string(File::GetUserPath(D_CONFIG_IDX)) + ini_name + ".ini");
|
||||||
std::ifstream file;
|
|
||||||
file.open( (std::string(File::GetUserPath(D_CONFIG_IDX)) + ini_name + ".ini" ).c_str() );
|
|
||||||
inifile.Load( file );
|
|
||||||
file.close();
|
|
||||||
|
|
||||||
std::vector< ControllerEmu* >::const_iterator i = controllers.begin(),
|
std::vector< ControllerEmu* >::const_iterator i = controllers.begin(),
|
||||||
e = controllers.end();
|
e = controllers.end();
|
||||||
for ( ; i!=e; ++i )
|
for ( ; i!=e; ++i ) {
|
||||||
(*i)->LoadConfig( inifile[ (*i)->GetName() ] );
|
(*i)->LoadConfig(inifile.GetOrCreateSection((*i)->GetName().c_str()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Plugin::SaveConfig()
|
void Plugin::SaveConfig()
|
||||||
{
|
{
|
||||||
|
std::string ini_filename = (std::string(File::GetUserPath(D_CONFIG_IDX)) + ini_name + ".ini" );
|
||||||
|
|
||||||
IniFile inifile;
|
IniFile inifile;
|
||||||
|
inifile.Load(ini_filename);
|
||||||
|
|
||||||
std::vector< ControllerEmu* >::const_iterator i = controllers.begin(),
|
std::vector< ControllerEmu* >::const_iterator i = controllers.begin(),
|
||||||
e = controllers.end();
|
e = controllers.end();
|
||||||
for ( ; i!=e; ++i )
|
for ( ; i!=e; ++i )
|
||||||
(*i)->SaveConfig( inifile[ (*i)->GetName() ] );
|
(*i)->SaveConfig(inifile.GetOrCreateSection((*i)->GetName().c_str()));
|
||||||
|
|
||||||
// dont need to save empty values
|
inifile.Save(ini_filename);
|
||||||
//inifile.Clean();
|
|
||||||
|
|
||||||
std::ofstream file;
|
|
||||||
file.open( (std::string(File::GetUserPath(D_CONFIG_IDX)) + ini_name + ".ini" ).c_str() );
|
|
||||||
inifile.Save( file );
|
|
||||||
file.close();
|
|
||||||
}
|
}
|
||||||
|
@ -283,12 +283,12 @@ void GamepadPage::ClearAll( wxCommandEvent& event )
|
|||||||
g_plugin->controls_crit.Enter(); // enter
|
g_plugin->controls_crit.Enter(); // enter
|
||||||
|
|
||||||
// just load an empty ini section to clear everything :P
|
// just load an empty ini section to clear everything :P
|
||||||
IniSection section;
|
IniFile::Section section;
|
||||||
controller->LoadConfig( section );
|
controller->LoadConfig(§ion);
|
||||||
|
|
||||||
// no point in using the real ControllerInterface i guess
|
// no point in using the real ControllerInterface i guess
|
||||||
ControllerInterface face;
|
ControllerInterface face;
|
||||||
controller->UpdateReferences( face );
|
controller->UpdateReferences(face);
|
||||||
|
|
||||||
UpdateGUI();
|
UpdateGUI();
|
||||||
|
|
||||||
@ -524,7 +524,6 @@ void GamepadPage::LoadProfile( wxCommandEvent& event )
|
|||||||
|
|
||||||
g_plugin->controls_crit.Enter();
|
g_plugin->controls_crit.Enter();
|
||||||
|
|
||||||
std::ifstream file;
|
|
||||||
std::string fname( File::GetUserPath(D_CONFIG_IDX) );
|
std::string fname( File::GetUserPath(D_CONFIG_IDX) );
|
||||||
fname += PROFILES_PATH; fname += g_plugin->profile_name; fname += '/';
|
fname += PROFILES_PATH; fname += g_plugin->profile_name; fname += '/';
|
||||||
fname += profile_cbox->GetValue().ToAscii(); fname += ".ini";
|
fname += profile_cbox->GetValue().ToAscii(); fname += ".ini";
|
||||||
@ -532,16 +531,12 @@ void GamepadPage::LoadProfile( wxCommandEvent& event )
|
|||||||
if ( false == File::Exists( fname.c_str() ) )
|
if ( false == File::Exists( fname.c_str() ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
file.open( fname.c_str() );
|
|
||||||
IniFile inifile;
|
IniFile inifile;
|
||||||
inifile.Load( file );
|
inifile.Load(fname);
|
||||||
controller->LoadConfig( inifile["Profile"] );
|
controller->LoadConfig( inifile.GetOrCreateSection("Profile"));
|
||||||
file.close();
|
|
||||||
|
|
||||||
controller->UpdateReferences( g_plugin->controller_interface );
|
controller->UpdateReferences( g_plugin->controller_interface );
|
||||||
|
|
||||||
g_plugin->controls_crit.Leave();
|
g_plugin->controls_crit.Leave();
|
||||||
|
|
||||||
UpdateGUI();
|
UpdateGUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -551,21 +546,17 @@ void GamepadPage::SaveProfile( wxCommandEvent& event )
|
|||||||
if ( profile_cbox->GetValue().empty() )
|
if ( profile_cbox->GetValue().empty() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// don't need lock
|
|
||||||
IniFile inifile;
|
|
||||||
controller->SaveConfig( inifile["Profile"] );
|
|
||||||
std::ofstream file;
|
|
||||||
std::string fname( File::GetUserPath(D_CONFIG_IDX) );
|
std::string fname( File::GetUserPath(D_CONFIG_IDX) );
|
||||||
fname += PROFILES_PATH; fname += g_plugin->profile_name; fname += '/';
|
fname += PROFILES_PATH; fname += g_plugin->profile_name; fname += '/';
|
||||||
|
|
||||||
if ( false == File::Exists( fname.c_str() ) )
|
if ( false == File::Exists( fname.c_str() ) )
|
||||||
File::CreateFullPath( fname.c_str() );
|
File::CreateFullPath( fname.c_str() );
|
||||||
|
|
||||||
fname += profile_cbox->GetValue().ToAscii(); fname += ".ini";
|
fname += profile_cbox->GetValue().ToAscii(); fname += ".ini";
|
||||||
|
|
||||||
file.open( fname.c_str() );
|
// don't need lock
|
||||||
inifile.Save( file );
|
IniFile inifile;
|
||||||
file.close();
|
inifile.Load(fname);
|
||||||
|
controller->SaveConfig( inifile.GetOrCreateSection("Profile") );
|
||||||
|
inifile.Save(fname);
|
||||||
|
|
||||||
m_config_dialog->UpdateProfileComboBox();
|
m_config_dialog->UpdateProfileComboBox();
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ void ControllerEmu::UpdateDefaultDevice()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControllerEmu::ControlGroup::LoadConfig( IniFile::Section& sec, const std::string& defdev, const std::string& base )
|
void ControllerEmu::ControlGroup::LoadConfig(IniFile::Section *sec, const std::string& defdev, const std::string& base )
|
||||||
{
|
{
|
||||||
std::string group( base + name ); group += "/";
|
std::string group( base + name ); group += "/";
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ void ControllerEmu::ControlGroup::LoadConfig( IniFile::Section& sec, const std::
|
|||||||
si = settings.begin(),
|
si = settings.begin(),
|
||||||
se = settings.end();
|
se = settings.end();
|
||||||
for ( ; si!=se; ++si )
|
for ( ; si!=se; ++si )
|
||||||
(*si)->value = sec.Get(group+(*si)->name, (*si)->default_value*100) / 100;
|
(*si)->value = sec->Get((group+(*si)->name).c_str(), (*si)->default_value*100) / 100;
|
||||||
|
|
||||||
// controls
|
// controls
|
||||||
std::vector<ControlGroup::Control*>::const_iterator
|
std::vector<ControlGroup::Control*>::const_iterator
|
||||||
@ -116,16 +116,17 @@ void ControllerEmu::ControlGroup::LoadConfig( IniFile::Section& sec, const std::
|
|||||||
for ( ; ci!=ce; ++ci )
|
for ( ; ci!=ce; ++ci )
|
||||||
{
|
{
|
||||||
// control and dev qualifier
|
// control and dev qualifier
|
||||||
(*ci)->control_ref->control_qualifier.name = sec[group + (*ci)->name];
|
(*ci)->control_ref->control_qualifier.name = sec->Get((group + (*ci)->name).c_str(), "");
|
||||||
(*ci)->control_ref->device_qualifier.FromString( sec.Get( group+(*ci)->name+"/Device", defdev ) );
|
(*ci)->control_ref->device_qualifier.FromString(
|
||||||
|
sec->Get((group+(*ci)->name+"/Device").c_str(), defdev.c_str() ) );
|
||||||
|
|
||||||
// range
|
// range
|
||||||
(*ci)->control_ref->range = sec.Get( group+(*ci)->name+"/Range", 100.0f ) / 100;
|
(*ci)->control_ref->range = sec->Get( (group+(*ci)->name+"/Range").c_str(), 100.0f ) / 100;
|
||||||
|
|
||||||
// input mode
|
// input mode
|
||||||
if ( (*ci)->control_ref->is_input )
|
if ( (*ci)->control_ref->is_input )
|
||||||
((ControllerInterface::InputReference*)((*ci)->control_ref))->mode
|
((ControllerInterface::InputReference*)((*ci)->control_ref))->mode
|
||||||
= sec.Get( group+(*ci)->name+"/Mode", 0 );
|
= sec->Get( (group+(*ci)->name+"/Mode").c_str(), 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
// extensions
|
// extensions
|
||||||
@ -135,7 +136,7 @@ void ControllerEmu::ControlGroup::LoadConfig( IniFile::Section& sec, const std::
|
|||||||
|
|
||||||
ex->switch_extension = 0;
|
ex->switch_extension = 0;
|
||||||
unsigned int n = 0;
|
unsigned int n = 0;
|
||||||
const std::string extname = sec[ base + name ];
|
const std::string extname = sec->Get((base + name).c_str(), "");
|
||||||
|
|
||||||
std::vector<ControllerEmu*>::const_iterator
|
std::vector<ControllerEmu*>::const_iterator
|
||||||
ai = ((Extension*)this)->attachments.begin(),
|
ai = ((Extension*)this)->attachments.begin(),
|
||||||
@ -151,22 +152,21 @@ void ControllerEmu::ControlGroup::LoadConfig( IniFile::Section& sec, const std::
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControllerEmu::LoadConfig( IniFile::Section& sec, const std::string& base )
|
void ControllerEmu::LoadConfig( IniFile::Section *sec, const std::string& base )
|
||||||
{
|
{
|
||||||
std::string defdev = default_device.ToString();
|
std::string defdev = default_device.ToString();
|
||||||
if ( base.empty() )
|
if (base.empty())
|
||||||
{
|
{
|
||||||
defdev = sec[ base + "Device" ];
|
defdev = sec->Get((base + "Device").c_str(), "");
|
||||||
default_device.FromString( defdev );
|
default_device.FromString(defdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<ControlGroup*>::const_iterator i = groups.begin(),
|
std::vector<ControlGroup*>::const_iterator i = groups.begin(),
|
||||||
e = groups.end();
|
e = groups.end();
|
||||||
for ( ; i!=e; ++i )
|
for ( ; i!=e; ++i )
|
||||||
(*i)->LoadConfig( sec, defdev, base );
|
(*i)->LoadConfig(sec, defdev, base);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControllerEmu::ControlGroup::SaveConfig( IniFile::Section& sec, const std::string& defdev, const std::string& base )
|
void ControllerEmu::ControlGroup::SaveConfig( IniFile::Section *sec, const std::string& defdev, const std::string& base )
|
||||||
{
|
{
|
||||||
std::string group( base + name ); group += "/";
|
std::string group( base + name ); group += "/";
|
||||||
|
|
||||||
@ -175,7 +175,7 @@ void ControllerEmu::ControlGroup::SaveConfig( IniFile::Section& sec, const std::
|
|||||||
si = settings.begin(),
|
si = settings.begin(),
|
||||||
se = settings.end();
|
se = settings.end();
|
||||||
for ( ; si!=se; ++si )
|
for ( ; si!=se; ++si )
|
||||||
sec.Set( group+(*si)->name, (*si)->value*100, (*si)->default_value*100 );
|
sec->Set( (group+(*si)->name).c_str(), (*si)->value*100.0f);
|
||||||
|
|
||||||
// controls
|
// controls
|
||||||
std::vector<ControlGroup::Control*>::const_iterator
|
std::vector<ControlGroup::Control*>::const_iterator
|
||||||
@ -184,23 +184,23 @@ void ControllerEmu::ControlGroup::SaveConfig( IniFile::Section& sec, const std::
|
|||||||
for ( ; ci!=ce; ++ci )
|
for ( ; ci!=ce; ++ci )
|
||||||
{
|
{
|
||||||
// control and dev qualifier
|
// control and dev qualifier
|
||||||
sec.Set( group+(*ci)->name, (*ci)->control_ref->control_qualifier.name );
|
sec->Set( (group+(*ci)->name).c_str(), (*ci)->control_ref->control_qualifier.name );
|
||||||
sec.Set( group+(*ci)->name+"/Device", (*ci)->control_ref->device_qualifier.ToString(), defdev );
|
sec->Set( (group+(*ci)->name+"/Device").c_str(), (*ci)->control_ref->device_qualifier.ToString());
|
||||||
|
|
||||||
// range
|
// range
|
||||||
sec.Set( group+(*ci)->name+"/Range", (*ci)->control_ref->range*100, 100 );
|
sec->Set( (group+(*ci)->name+"/Range").c_str(), (*ci)->control_ref->range*100.0f);
|
||||||
|
|
||||||
// input mode
|
// input mode
|
||||||
if ( (*ci)->control_ref->is_input )
|
if ( (*ci)->control_ref->is_input )
|
||||||
sec.Set( group+(*ci)->name+"/Mode",
|
sec->Set( (group+(*ci)->name+"/Mode").c_str(),
|
||||||
((ControllerInterface::InputReference*)((*ci)->control_ref))->mode, (unsigned int)0 );
|
((ControllerInterface::InputReference*)((*ci)->control_ref))->mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
// extensions
|
// extensions
|
||||||
if ( GROUP_TYPE_EXTENSION == type )
|
if ( GROUP_TYPE_EXTENSION == type )
|
||||||
{
|
{
|
||||||
Extension* const ext = ((Extension*)this);
|
Extension* const ext = ((Extension*)this);
|
||||||
sec.Set( base + name, ext->attachments[ext->switch_extension]->GetName(), std::string("None") );
|
sec->Set((base + name).c_str(), ext->attachments[ext->switch_extension]->GetName());
|
||||||
|
|
||||||
std::vector<ControllerEmu*>::const_iterator
|
std::vector<ControllerEmu*>::const_iterator
|
||||||
ai = ((Extension*)this)->attachments.begin(),
|
ai = ((Extension*)this)->attachments.begin(),
|
||||||
@ -210,11 +210,11 @@ void ControllerEmu::ControlGroup::SaveConfig( IniFile::Section& sec, const std::
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControllerEmu::SaveConfig( IniFile::Section& sec, const std::string& base )
|
void ControllerEmu::SaveConfig( IniFile::Section *sec, const std::string& base )
|
||||||
{
|
{
|
||||||
const std::string defdev = default_device.ToString();
|
const std::string defdev = default_device.ToString();
|
||||||
if ( base.empty() )
|
if ( base.empty() )
|
||||||
sec.Set( std::string(" ") + base + "Device", defdev );
|
sec->Set( std::string(" ") + base + "Device", defdev );
|
||||||
|
|
||||||
std::vector<ControlGroup*>::const_iterator i = groups.begin(),
|
std::vector<ControlGroup*>::const_iterator i = groups.begin(),
|
||||||
e = groups.end();
|
e = groups.end();
|
||||||
|
@ -101,8 +101,8 @@ public:
|
|||||||
ControlGroup( const char* const _name, const unsigned int _type = GROUP_TYPE_OTHER ) : name(_name), type(_type) {}
|
ControlGroup( const char* const _name, const unsigned int _type = GROUP_TYPE_OTHER ) : name(_name), type(_type) {}
|
||||||
virtual ~ControlGroup();
|
virtual ~ControlGroup();
|
||||||
|
|
||||||
void LoadConfig( IniFile::Section& sec, const std::string& defdev = "", const std::string& base = "" );
|
void LoadConfig(IniFile::Section *sec, const std::string& defdev = "", const std::string& base = "" );
|
||||||
void SaveConfig( IniFile::Section& sec, const std::string& defdev = "", const std::string& base = "" );
|
void SaveConfig(IniFile::Section *sec, const std::string& defdev = "", const std::string& base = "" );
|
||||||
|
|
||||||
const char* const name;
|
const char* const name;
|
||||||
const unsigned int type;
|
const unsigned int type;
|
||||||
@ -382,8 +382,8 @@ public:
|
|||||||
|
|
||||||
virtual std::string GetName() const = 0;
|
virtual std::string GetName() const = 0;
|
||||||
|
|
||||||
void LoadConfig( IniFile::Section& sec, const std::string& base = "" );
|
void LoadConfig(IniFile::Section *sec, const std::string& base = "");
|
||||||
void SaveConfig( IniFile::Section& sec, const std::string& base = "" );
|
void SaveConfig(IniFile::Section *sec, const std::string& base = "");
|
||||||
void UpdateDefaultDevice();
|
void UpdateDefaultDevice();
|
||||||
|
|
||||||
void UpdateReferences( ControllerInterface& devi );
|
void UpdateReferences( ControllerInterface& devi );
|
||||||
|
@ -1,156 +0,0 @@
|
|||||||
|
|
||||||
#include "IniFile.h"
|
|
||||||
|
|
||||||
//
|
|
||||||
// TrimChars
|
|
||||||
//
|
|
||||||
// trim whitespace, or any, chars from both ends
|
|
||||||
//
|
|
||||||
template <typename S>
|
|
||||||
std::string TrimChars( const std::string& str, const S space )
|
|
||||||
{
|
|
||||||
const size_t start = str.find_first_not_of( space );
|
|
||||||
|
|
||||||
if ( str.npos == start )
|
|
||||||
return "";
|
|
||||||
|
|
||||||
return str.substr( start, str.find_last_not_of( space ) - start + 1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// IniSection :: Set
|
|
||||||
//
|
|
||||||
// set key's value if it doesn't match the default
|
|
||||||
// otherwise remove the key from the section if it exists
|
|
||||||
//
|
|
||||||
void IniSection::Set( const std::string& key, const std::string& val, const std::string& def )
|
|
||||||
{
|
|
||||||
if ( val != def )
|
|
||||||
operator[](key) = val;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
iterator f = find(key);
|
|
||||||
if ( f != end() )
|
|
||||||
erase( f );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// IniSection :: Get
|
|
||||||
//
|
|
||||||
// return a key's value if it exists
|
|
||||||
// otherwise return the default
|
|
||||||
//
|
|
||||||
std::string IniSection::Get( const std::string& key, const std::string& def )
|
|
||||||
{
|
|
||||||
const const_iterator f = find(key);
|
|
||||||
if ( f != end() )
|
|
||||||
if ( false == f->second.empty() )
|
|
||||||
return f->second;
|
|
||||||
return def;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// IniFile :: Save
|
|
||||||
//
|
|
||||||
// save a file
|
|
||||||
//
|
|
||||||
void IniFile::Save( std::ostream& file )
|
|
||||||
{
|
|
||||||
const_iterator i = begin(),
|
|
||||||
e = end();
|
|
||||||
for ( ; i != e; ++i )
|
|
||||||
{
|
|
||||||
// skip a line at new sections
|
|
||||||
file << "\n[" << i->first << "]\n";
|
|
||||||
Section::const_iterator si = i->second.begin(),
|
|
||||||
se = i->second.end();
|
|
||||||
for ( ; si != se; ++si )
|
|
||||||
{
|
|
||||||
file << si->first << " = ";
|
|
||||||
// if value has quotes or whitespace, surround it with quotes
|
|
||||||
if (si->second.find_first_of("\"\t ") != std::string::npos)
|
|
||||||
file << '"' << si->second << '"';
|
|
||||||
else
|
|
||||||
file << si->second;
|
|
||||||
file << '\n';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// IniFile :: Load
|
|
||||||
//
|
|
||||||
// load a file
|
|
||||||
//
|
|
||||||
void IniFile::Load( std::istream& file )
|
|
||||||
{
|
|
||||||
const char* const space = "\t\r ";
|
|
||||||
std::string line;
|
|
||||||
// start off with an empty section
|
|
||||||
Section* section = &(*this)[""];
|
|
||||||
while ( std::getline( file, line ).good() ) // read a line
|
|
||||||
{
|
|
||||||
line = TrimChars(line,space);
|
|
||||||
if ( line.size() )
|
|
||||||
{
|
|
||||||
switch ( line[0] )
|
|
||||||
{
|
|
||||||
// comment
|
|
||||||
case '#' :
|
|
||||||
case ';' :
|
|
||||||
break;
|
|
||||||
// section
|
|
||||||
case '[' :
|
|
||||||
// kinda odd trimming
|
|
||||||
section = &(*this)[ TrimChars(line,"][\t\r ") ];
|
|
||||||
break;
|
|
||||||
// key/value
|
|
||||||
default :
|
|
||||||
{
|
|
||||||
std::istringstream ss(line);
|
|
||||||
std::string key; std::getline( ss, key, '=' );
|
|
||||||
std::string val; std::getline( ss, val );
|
|
||||||
val = TrimChars(val,space);
|
|
||||||
// handle quote surrounded values
|
|
||||||
if (val.length() > 1)
|
|
||||||
if ('"' == val[0])
|
|
||||||
val = val.substr(1, val.length()-2);
|
|
||||||
|
|
||||||
(*section)[ TrimChars(key,space) ] = val;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Clean();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// IniFile :: Clean
|
|
||||||
//
|
|
||||||
// remove empty key/values and sections
|
|
||||||
// after trying to access ini sections/values, they are automatically allocated
|
|
||||||
// this deletes the empty stuff
|
|
||||||
//
|
|
||||||
void IniFile::Clean()
|
|
||||||
{
|
|
||||||
iterator i = begin(),
|
|
||||||
e = end();
|
|
||||||
for ( ; i != e; )
|
|
||||||
{
|
|
||||||
Section::iterator si = i->second.begin(),
|
|
||||||
se = i->second.end();
|
|
||||||
for ( ; si != se; )
|
|
||||||
{
|
|
||||||
if ( si->second.empty() )
|
|
||||||
i->second.erase( si++ );
|
|
||||||
else
|
|
||||||
++si;
|
|
||||||
}
|
|
||||||
if ( i->second.empty() )
|
|
||||||
erase( i++ );
|
|
||||||
else
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,61 +0,0 @@
|
|||||||
#ifndef _INIFILE_H_
|
|
||||||
#define _INIFILE_H_
|
|
||||||
|
|
||||||
#include <fstream>
|
|
||||||
#include <map>
|
|
||||||
#include <string>
|
|
||||||
#include <sstream>
|
|
||||||
|
|
||||||
//
|
|
||||||
// IniFile
|
|
||||||
//
|
|
||||||
class IniSection : public std::map< std::string, std::string >
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
void Set( const std::string& key, const std::string& val, const std::string& def = "" );
|
|
||||||
std::string Get( const std::string& key, const std::string& def = "" );
|
|
||||||
|
|
||||||
template <typename V, typename D>
|
|
||||||
void Set( const std::string& key, const V& val, const D& def = 0 )
|
|
||||||
{
|
|
||||||
if ( val != def )
|
|
||||||
{
|
|
||||||
std::ostringstream ss;
|
|
||||||
ss << long(val);
|
|
||||||
operator[](key) = ss.str();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
iterator f = find(key);
|
|
||||||
if ( f != end() )
|
|
||||||
erase( f );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
template <typename V>
|
|
||||||
V Get( const std::string& key, const V& def = 0 )
|
|
||||||
{
|
|
||||||
const const_iterator f = find(key);
|
|
||||||
if ( f != end() )
|
|
||||||
if ( false == f->second.empty() )
|
|
||||||
{
|
|
||||||
std::istringstream ss(f->second);
|
|
||||||
int val;
|
|
||||||
ss >> val;
|
|
||||||
return V(val);
|
|
||||||
}
|
|
||||||
return def;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class IniFile : public std::map< std::string, IniSection >
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef IniSection Section;
|
|
||||||
|
|
||||||
void Clean();
|
|
||||||
void Save( std::ostream& file );
|
|
||||||
void Load( std::istream& file );
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
@ -418,7 +418,7 @@ bool OpenGL_MakeCurrent()
|
|||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
cocoaGLMakeCurrent(GLWin.cocoaCtx,GLWin.cocoaWin);
|
cocoaGLMakeCurrent(GLWin.cocoaCtx,GLWin.cocoaWin);
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
return wglMakeCurrent(hDC,hRC);
|
return wglMakeCurrent(hDC,hRC) ? true : false;
|
||||||
#elif defined(HAVE_X11) && HAVE_X11
|
#elif defined(HAVE_X11) && HAVE_X11
|
||||||
g_VideoInitialize.pRequestWindowSize(GLWin.x, GLWin.y, (int&)GLWin.width, (int&)GLWin.height);
|
g_VideoInitialize.pRequestWindowSize(GLWin.x, GLWin.y, (int&)GLWin.width, (int&)GLWin.height);
|
||||||
XMoveResizeWindow(GLWin.dpy, GLWin.win, GLWin.x, GLWin.y, GLWin.width, GLWin.height);
|
XMoveResizeWindow(GLWin.dpy, GLWin.win, GLWin.x, GLWin.y, GLWin.width, GLWin.height);
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
#include "Common.h" // Common
|
#include "Common.h" // Common
|
||||||
#include "FileUtil.h"
|
#include "FileUtil.h"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user