From f67299ad834ef540e74edca7f0f7392165ab0546 Mon Sep 17 00:00:00 2001 From: arcum42 Date: Sat, 22 May 2010 02:52:47 +0000 Subject: [PATCH] onepad: apply a patch to the ini settings. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3054 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/onepad/Linux/gui.cpp | 1 - plugins/onepad/Linux/ini.cpp | 15 ++++++++------- plugins/onepad/Linux/linux.cpp | 5 ----- plugins/onepad/Linux/linux.h | 1 - plugins/onepad/onepad.cpp | 16 ++++++++-------- 5 files changed, 16 insertions(+), 22 deletions(-) diff --git a/plugins/onepad/Linux/gui.cpp b/plugins/onepad/Linux/gui.cpp index c37b81ee86..167b95744c 100644 --- a/plugins/onepad/Linux/gui.cpp +++ b/plugins/onepad/Linux/gui.cpp @@ -35,7 +35,6 @@ extern "C" #include "callbacks.h" } -extern string s_strIniPath; GtkWidget *Conf, *About, *MsgDlg; GtkWidget *s_devicecombo; diff --git a/plugins/onepad/Linux/ini.cpp b/plugins/onepad/Linux/ini.cpp index 6b381134b3..b313d87b2c 100644 --- a/plugins/onepad/Linux/ini.cpp +++ b/plugins/onepad/Linux/ini.cpp @@ -35,6 +35,8 @@ extern "C" #include "callbacks.h" } +extern std::string s_strIniPath; + string KeyName(int pad, int key) { string tmp; @@ -123,11 +125,11 @@ void SaveConfig() FILE *f; char cfg[255]; - strcpy(cfg, s_strIniPath.c_str()); - f = fopen(cfg, "w"); + const std::string iniFile(s_strIniPath + "OnePAD.ini"); + f = fopen(iniFile.c_str(), "w"); if (f == NULL) { - printf("ZeroPAD: failed to save ini %s\n", s_strIniPath.c_str()); + printf("ZeroPAD: failed to save ini %s\n", iniFile.c_str()); return; } @@ -147,17 +149,16 @@ void LoadConfig() { FILE *f; char str[256]; - char cfg[255]; memset(&conf, 0, sizeof(conf)); DefaultValues(); conf.log = 0; - strcpy(cfg, s_strIniPath.c_str()); - f = fopen(cfg, "r"); + const std::string iniFile(s_strIniPath + "OnePAD.ini"); + f = fopen(iniFile.c_str(), "r"); if (f == NULL) { - printf("OnePAD: failed to load ini %s\n", s_strIniPath.c_str()); + printf("OnePAD: failed to load ini %s\n", iniFile.c_str()); SaveConfig(); //save and return return; } diff --git a/plugins/onepad/Linux/linux.cpp b/plugins/onepad/Linux/linux.cpp index 789f7632b4..45de28a607 100644 --- a/plugins/onepad/Linux/linux.cpp +++ b/plugins/onepad/Linux/linux.cpp @@ -338,11 +338,6 @@ void OnConf_Key(GtkButton *button, gpointer user_data) EXPORT_C_(void) PADconfigure() { - char strcurdir[256]; - getcwd(strcurdir, 256); - s_strIniPath = strcurdir; - s_strIniPath += "/inis/OnePAD.ini"; - LoadConfig(); Conf = create_Conf(); diff --git a/plugins/onepad/Linux/linux.h b/plugins/onepad/Linux/linux.h index 8e1017014f..f48bcb09ae 100644 --- a/plugins/onepad/Linux/linux.h +++ b/plugins/onepad/Linux/linux.h @@ -37,7 +37,6 @@ extern "C" } extern GtkWidget *Conf, *s_devicecombo; -extern string s_strIniPath; extern void init_tree_view(); extern void destroy_tree_view(); diff --git a/plugins/onepad/onepad.cpp b/plugins/onepad/onepad.cpp index 58688a387b..089ef00bc4 100644 --- a/plugins/onepad/onepad.cpp +++ b/plugins/onepad/onepad.cpp @@ -43,7 +43,7 @@ keyEvent event; u16 status[2]; int pressure; static keyEvent s_event; -string s_strIniPath = "inis/OnePAD.ini"; +std::string s_strIniPath("inis/"); bool toggleAutoRepeat = true; const u32 version = PS2E_PAD_VERSION; @@ -243,13 +243,6 @@ EXPORT_C_(s32) PADinit(u32 flags) status[0] = 0xffff; status[1] = 0xffff; -#ifdef __LINUX__ - /*char strcurdir[256]; - getcwd(strcurdir, 256); - s_strIniPath = strcurdir; - s_strIniPath += "/inis/OnePAD.ini";*/ -#endif - LoadConfig(); PADsetMode(0, 0); @@ -286,6 +279,13 @@ EXPORT_C_(s32) PADopen(void *pDsp) return _PADopen(pDsp); } +void CALLBACK PADsetSettingsDir(const char* dir) +{ + // Get the path to the ini directory. + s_strIniPath = (dir==NULL) ? "inis/" : dir; +} + + EXPORT_C_(void) PADclose() { pthread_spin_destroy(&s_mutexStatus);