diff --git a/plugins/GSnull/GS.cpp b/plugins/GSnull/GS.cpp index 2b34af2d38..7d55d5f0c6 100644 --- a/plugins/GSnull/GS.cpp +++ b/plugins/GSnull/GS.cpp @@ -100,6 +100,10 @@ void SysPrintf(const char *fmt, ...) } // basic funcs +EXPORT_C_(void) GSsetSettingsDir(const char* dir) +{ + s_strIniPath = (dir == NULL) ? "inis/" : dir; +} EXPORT_C_(s32) GSinit() { diff --git a/plugins/GSnull/GS.h b/plugins/GSnull/GS.h index 7161cb477c..42816bc4de 100644 --- a/plugins/GSnull/GS.h +++ b/plugins/GSnull/GS.h @@ -32,6 +32,7 @@ typedef struct _keyEvent keyEvent; #define GSdefs #include "PS2Edefs.h" +#include "PS2Eext.h" #include "Registers.h" #include "null/GSnull.h" diff --git a/plugins/GSnull/Linux/Config.cpp b/plugins/GSnull/Linux/Config.cpp index 4834dcf13f..66291484d7 100644 --- a/plugins/GSnull/Linux/Config.cpp +++ b/plugins/GSnull/Linux/Config.cpp @@ -44,6 +44,7 @@ extern "C" GtkWidget *MsgDlg, *About, *Conf; extern string s_strIniPath; +PluginConf Ini; void OnMsg_Ok() { @@ -121,12 +122,9 @@ void OnConf_Cancel(GtkButton *button, gpointer user_data) void CFGconfigure() { - Conf = create_Config(); - LoadConfig(); - - gtk_widget_show_all(Conf); - gtk_main(); + PluginNullConfigure("Since this is a null plugin, all that is really configurable is logging.", conf.Log); + SaveConfig(); } long CFGmessage(char *msg) { @@ -137,35 +135,29 @@ long CFGmessage(char *msg) { void LoadConfig() { - FILE *f; - char cfg[255]; + const std::string iniFile(s_strIniPath + "/GSNull.ini"); - strcpy(cfg, s_strIniPath.c_str()); - f = fopen(cfg, "r"); - if (f == NULL) + if (!Ini.Open(iniFile, READ_FILE)) { - printf("failed to open %s\n", s_strIniPath.c_str()); + printf("failed to open %s\n", iniFile.c_str()); SaveConfig();//save and return return; } - //fscanf(f, "options = %hhx\n", &confOptions); - fclose(f); + + conf.Log = Ini.ReadInt("logging", 0); + Ini.Close(); } void SaveConfig() { - FILE *f; - char cfg[255]; + const std::string iniFile(s_strIniPath + "/GSNull.ini"); - strcpy(cfg, s_strIniPath.c_str()); - f = fopen(cfg,"w"); - if (f == NULL) + if (!Ini.Open(iniFile, WRITE_FILE)) { - printf("failed to open %s\n", s_strIniPath.c_str()); + printf("failed to open %s\n", iniFile.c_str()); return; } - //fprintf(f, "options = %hhx\n", confOptions); - fclose(f); + Ini.WriteInt("logging", conf.Log); + Ini.Close(); } - diff --git a/plugins/PadNull/Linux/Config.cpp b/plugins/PadNull/Linux/Config.cpp index b2a4aaa105..1fbeaec185 100644 --- a/plugins/PadNull/Linux/Config.cpp +++ b/plugins/PadNull/Linux/Config.cpp @@ -44,6 +44,7 @@ extern "C" GtkWidget *MsgDlg, *About, *Conf; extern string s_strIniPath; +PluginConf Ini; void OnMsg_Ok() { @@ -124,45 +125,36 @@ void OnConf_Cancel(GtkButton *button, gpointer user_data) EXPORT_C_(void) PADconfigure() { LoadConfig(); - Conf = create_Config(); - - set_checked(Conf, "check_logging", conf.Log); - gtk_widget_show_all(Conf); - gtk_main(); + PluginNullConfigure("Since this is a null plugin, all that is really configurable is logging.", conf.Log); + SaveConfig(); } void LoadConfig() { - FILE *f; - char cfg[255]; + const std::string iniFile(s_strIniPath + "/Padnull.ini"); - strcpy(cfg, s_strIniPath.c_str()); - f = fopen(cfg, "r"); - if (f == NULL) + if (!Ini.Open(iniFile, READ_FILE)) { - printf("failed to open %s\n", s_strIniPath.c_str()); + printf("failed to open %s\n", iniFile.c_str()); SaveConfig();//save and return return; } - fscanf(f, "logging = %hhx\n", &conf.Log); - //fscanf(f, "options = %hhx\n", &confOptions); - fclose(f); + + conf.Log = Ini.ReadInt("logging", 0); + Ini.Close(); } void SaveConfig() { - FILE *f; - char cfg[255]; + const std::string iniFile(s_strIniPath + "/Padnull.ini"); - strcpy(cfg, s_strIniPath.c_str()); - f = fopen(cfg,"w"); - if (f == NULL) + if (!Ini.Open(iniFile, WRITE_FILE)) { - printf("failed to open '%s'\n", s_strIniPath.c_str()); + printf("failed to open %s\n", iniFile.c_str()); return; } - fprintf(f, "logging = %hhx\n", conf.Log); - //fprintf(f, "options = %hhx\n", confOptions); - fclose(f); + + Ini.WriteInt("logging", conf.Log); + Ini.Close(); } diff --git a/plugins/PadNull/Pad.cpp b/plugins/PadNull/Pad.cpp index 7b567ec1f0..3d1273973f 100644 --- a/plugins/PadNull/Pad.cpp +++ b/plugins/PadNull/Pad.cpp @@ -26,7 +26,7 @@ const u8 revision = 0; const u8 build = 1; // increase that with each version static char *libraryName = "Padnull Driver"; -string s_strIniPath="inis/Padnull.ini"; +string s_strIniPath="inis/"; FILE *padLog; Config conf; @@ -71,6 +71,11 @@ void __LogToConsole(const char *fmt, ...) va_end(list); } +EXPORT_C_(void) PADsetSettingsDir(const char* dir) +{ + s_strIniPath = (dir == NULL) ? "inis/" : dir; +} + EXPORT_C_(s32) PADinit(u32 flags) { LoadConfig(); diff --git a/plugins/PadNull/Pad.h b/plugins/PadNull/Pad.h index 5a74613cae..455fadc371 100644 --- a/plugins/PadNull/Pad.h +++ b/plugins/PadNull/Pad.h @@ -20,6 +20,7 @@ #define PADdefs #include "PS2Edefs.h" +#include "PS2Eext.h" #ifdef _WIN32 #include "PadWin.h" diff --git a/plugins/SPU2null/Linux/Config.cpp b/plugins/SPU2null/Linux/Config.cpp index 1272577f5b..04b78a51e0 100644 --- a/plugins/SPU2null/Linux/Config.cpp +++ b/plugins/SPU2null/Linux/Config.cpp @@ -35,6 +35,8 @@ extern "C" using namespace std; GtkWidget *MsgDlg, *About, *Conf; +extern string s_strIniPath; +PluginConf Ini; void OnMsg_Ok() { @@ -107,15 +109,9 @@ void OnConf_Cancel(GtkButton *button, gpointer user_data) EXPORT_C_(void) SPU2configure() { - //SysMessage("Nothing to Configure"); - - Conf = create_Config(); - - LoadConfig(); - - set_checked(Conf, "check_logging", conf.Log); - gtk_widget_show_all(Conf); - gtk_main(); + LoadConfig(); + PluginNullConfigure("Since this is a null plugin, all that is really configurable is logging.", conf.Log); + SaveConfig(); } EXPORT_C_(void) SPU2about() @@ -129,36 +125,29 @@ EXPORT_C_(void) SPU2about() void LoadConfig() { - FILE *f; - char cfg[255]; + const std::string iniFile(s_strIniPath + "/Spu2null.ini"); - strcpy(cfg, s_strIniPath.c_str()); - f = fopen(cfg, "r"); - if (f == NULL) + if (!Ini.Open(iniFile, READ_FILE)) { - printf("failed to open %s\n", s_strIniPath.c_str()); + printf("failed to open %s\n", iniFile.c_str()); SaveConfig();//save and return return; } - fscanf(f, "logging = %hhx\n", &conf.Log); - //fscanf(f, "options = %hhx\n", &confOptions); - fclose(f); + + conf.Log = Ini.ReadInt("logging", 0); + Ini.Close(); } void SaveConfig() { - FILE *f; - char cfg[255]; + const std::string iniFile(s_strIniPath + "/Spu2null.ini"); - strcpy(cfg, s_strIniPath.c_str()); - f = fopen(cfg,"w"); - if (f == NULL) + if (!Ini.Open(iniFile, WRITE_FILE)) { - printf("failed to open %s\n", s_strIniPath.c_str()); + printf("failed to open %s\n", iniFile.c_str()); return; } - fprintf(f, "logging = %hhx\n", conf.Log); - //fprintf(f, "options = %hhx\n", confOptions); - fclose(f); + Ini.WriteInt("logging", conf.Log); + Ini.Close(); } diff --git a/plugins/SPU2null/SPU2.cpp b/plugins/SPU2null/SPU2.cpp index 87e9a95225..a83723c602 100644 --- a/plugins/SPU2null/SPU2.cpp +++ b/plugins/SPU2null/SPU2.cpp @@ -40,7 +40,7 @@ char *libraryName = "SPU2null (Debug)"; #else char *libraryName = "SPU2null "; #endif -string s_strIniPath="inis/SPU2null.ini"; +string s_strIniPath="inis/"; FILE *spu2Log; Config conf; @@ -109,6 +109,11 @@ void __Log(char *fmt, ...) va_end(list); } +EXPORT_C_(void) SPU2setSettingsDir(const char* dir) +{ + s_strIniPath = (dir == NULL) ? "inis/" : dir; +} + EXPORT_C_(s32) SPU2init() { #ifdef SPU2_LOG diff --git a/plugins/SPU2null/SPU2.h b/plugins/SPU2null/SPU2.h index 22d55434e8..9b00613f61 100644 --- a/plugins/SPU2null/SPU2.h +++ b/plugins/SPU2null/SPU2.h @@ -29,6 +29,7 @@ extern "C" #define SPU2defs #include "PS2Edefs.h" } +#include "PS2Eext.h" #ifdef __LINUX__ #include