Linux: Get the locations of ini files for plugins mostly working again (I know about the USB & FW stubs). (Issue 55). This is still somewhat hackish; I'll probably be cleaning up bits later, and this does put LOCAL_PLUGIN_INIS out of commission for the moment. It will come back eventually. This ought to also take care of issue 54. You may need to delete pcsx2.cfg for everything to work properly.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@568 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
arcum42 2009-02-22 12:08:05 +00:00
parent bff3a20adf
commit 85c6db67c2
11 changed files with 186 additions and 98 deletions

View File

@ -51,24 +51,23 @@ static void ConfPlugin(PluginConf confs, char* plugin, const char* name)
{
void *drv;
void (*conf)();
char file[g_MaxPath];
char file[g_MaxPath], file2[g_MaxPath];
GetComboText(confs.Combo, confs.plist, plugin);
strcpy(file, Config.PluginsDir);
strcat(file, plugin);
drv = SysLoadLibrary(file);
#ifndef LOCAL_PLUGIN_INIS
getcwd(file, ARRAYSIZE(file)); /* store current dir */
chdir(Config.PluginsDir); /* change dirs so that plugins can find their config file*/
#endif
//#ifndef LOCAL_PLUGIN_INIS
// chdir(Config.PluginsDir); /* change dirs so that plugins can find their config file*/
//#endif
if (drv == NULL) return;
conf = (void (*)()) SysLoadSym(drv, name);
if (SysLibError() == NULL) conf();
#ifndef LOCAL_PLUGIN_INIS
chdir(file); /* change back*/
#endif
//#ifndef LOCAL_PLUGIN_INIS
// chdir(MAIN_DIR); /* change back*/
//#endif
SysCloseLibrary(drv);
}
@ -85,13 +84,12 @@ static void TestPlugin(PluginConf confs, char* plugin, const char* name)
strcat(file, plugin);
drv = SysLoadLibrary(file);
getcwd(file, ARRAYSIZE(file)); /* store current dir */
chdir(Config.PluginsDir); /* change dirs so that plugins can find their config file*/
// chdir(Config.PluginsDir); /* change dirs so that plugins can find their config file*/
if (drv == NULL) return;
conf = (s32(* (*)())()) SysLoadSym(drv, name);
if (SysLibError() == NULL) ret = (s32) conf();
chdir(file); /* change back*/
// chdir(MAIN_DIR);
SysCloseLibrary(drv);
if (ret == 0)
@ -104,11 +102,9 @@ void OnConf_Gs(GtkMenuItem *menuitem, gpointer user_data)
{
char file[255];
getcwd(file, ARRAYSIZE(file));
chdir(Config.PluginsDir);
// chdir(Config.PluginsDir);
gtk_widget_set_sensitive(MainWindow, FALSE);
GSconfigure();
chdir(file);
gtk_widget_set_sensitive(MainWindow, TRUE);
}
@ -116,12 +112,11 @@ void OnConf_Pads(GtkMenuItem *menuitem, gpointer user_data)
{
char file[255];
getcwd(file, ARRAYSIZE(file));
chdir(Config.PluginsDir);
// chdir(Config.PluginsDir);
gtk_widget_set_sensitive(MainWindow, FALSE);
PAD1configure();
if (strcmp(Config.PAD1, Config.PAD2)) PAD2configure();
chdir(file);
// chdir(MAIN_DIR);
gtk_widget_set_sensitive(MainWindow, TRUE);
}
@ -129,60 +124,55 @@ void OnConf_Spu2(GtkMenuItem *menuitem, gpointer user_data)
{
char file[255];
getcwd(file, ARRAYSIZE(file));
chdir(Config.PluginsDir);
// chdir(Config.PluginsDir);
gtk_widget_set_sensitive(MainWindow, FALSE);
SPU2configure();
gtk_widget_set_sensitive(MainWindow, TRUE);
chdir(file);
// chdir(MAIN_DIR);
}
void OnConf_Cdvd(GtkMenuItem *menuitem, gpointer user_data)
{
char file[255];
getcwd(file, ARRAYSIZE(file));
chdir(Config.PluginsDir);
// chdir(Config.PluginsDir);
gtk_widget_set_sensitive(MainWindow, FALSE);
CDVDconfigure();
gtk_widget_set_sensitive(MainWindow, TRUE);
chdir(file);
// chdir(MAIN_DIR);
}
void OnConf_Dev9(GtkMenuItem *menuitem, gpointer user_data)
{
char file[255];
getcwd(file, ARRAYSIZE(file));
chdir(Config.PluginsDir);
// chdir(Config.PluginsDir);
gtk_widget_set_sensitive(MainWindow, FALSE);
DEV9configure();
gtk_widget_set_sensitive(MainWindow, TRUE);
chdir(file);
// chdir(MAIN_DIR);
}
void OnConf_Usb(GtkMenuItem *menuitem, gpointer user_data)
{
char file[255];
getcwd(file, ARRAYSIZE(file));
chdir(Config.PluginsDir);
// chdir(Config.PluginsDir);
gtk_widget_set_sensitive(MainWindow, FALSE);
USBconfigure();
gtk_widget_set_sensitive(MainWindow, TRUE);
chdir(file);
// chdir(MAIN_DIR);
}
void OnConf_Fw(GtkMenuItem *menuitem, gpointer user_data)
{
char file[255];
getcwd(file, ARRAYSIZE(file));
chdir(Config.PluginsDir);
// chdir(Config.PluginsDir);
gtk_widget_set_sensitive(MainWindow, FALSE);
FWconfigure();
gtk_widget_set_sensitive(MainWindow, TRUE);
chdir(file);
// chdir(MAIN_DIR);
}
void SetActiveComboItem(GtkComboBox *widget, char plist[255][255], GList *list, char *conf)
@ -252,6 +242,9 @@ void OnConfConf_Ok(GtkButton *button, gpointer user_data)
gtk_widget_destroy(ConfDlg);
if (MainWindow) gtk_widget_set_sensitive(MainWindow, TRUE);
gtk_main_quit();
chdir(MAIN_DIR);
}
void OnConfConf_GsConf(GtkButton *button, gpointer user_data)
@ -419,6 +412,7 @@ void UpdateConfDlg()
ConfCreatePConf("Usb", &USBConfS, Config.USB);
ConfCreatePConf("FW", &FWConfS, Config.FW);
ConfCreatePConf("Bios", &BiosConfS, Config.Bios);
chdir(MAIN_DIR);
}
void GetDirectory(GtkWidget *topWindow, const char *message, char *reply)
@ -466,6 +460,7 @@ void OnConfConf_BiosPath(GtkButton *button, gpointer user_data)
void OnConf_Conf(GtkMenuItem *menuitem, gpointer user_data)
{
chdir(MAIN_DIR);
FindPlugins();
ConfDlg = create_ConfDlg();

View File

@ -41,6 +41,9 @@ int main(int argc, char *argv[])
char elfname[g_MaxPath];
efile = 0;
getcwd(MAIN_DIR, ARRAYSIZE(MAIN_DIR)); /* store main dir */
Console::Notice("MAIN_DIR is %s", params MAIN_DIR);
#ifdef ENABLE_NLS
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, "Langs");
@ -79,10 +82,10 @@ int main(int argc, char *argv[])
{
memset(&Config, 0, sizeof(Config));
strcpy(Config.BiosDir, DEFAULT_BIOS_DIR "/");
strcpy(Config.PluginsDir, DEFAULT_PLUGINS_DIR "/");
strcpy(Config.Mcd[0].Filename, MEMCARDS_DIR "/" DEFAULT_MEMCARD1);
strcpy(Config.Mcd[1].Filename, MEMCARDS_DIR "/" DEFAULT_MEMCARD2);
sprintf(Config.BiosDir, "%s/%s/", MAIN_DIR, DEFAULT_BIOS_DIR);
sprintf(Config.PluginsDir, "%s/%s/", MAIN_DIR, DEFAULT_PLUGINS_DIR);
sprintf(Config.Mcd[0].Filename, "%s/%s/%s", MAIN_DIR, MEMCARDS_DIR, DEFAULT_MEMCARD1);
sprintf(Config.Mcd[1].Filename, "%s/%s/%s", MAIN_DIR, MEMCARDS_DIR, DEFAULT_MEMCARD2);
Config.Mcd[0].Enabled = 1;
Config.Mcd[1].Enabled = 1;
Config.McdEnableEject = 1;

View File

@ -55,7 +55,7 @@ void OnConf_Memcards(GtkMenuItem *menuitem, gpointer user_data)
{
char path[g_MaxPath];
sprintf( path, "%s/%s", MEMCARDS_DIR, entry->d_name);
sprintf(path, "%s/%s/%s", MAIN_DIR, MEMCARDS_DIR, entry->d_name);
for (j = 0; j < 2; j++)
{
@ -82,12 +82,18 @@ void OnConf_Memcards(GtkMenuItem *menuitem, gpointer user_data)
void OnMemcards_Ok(GtkButton *button, gpointer user_data)
{
if (gtk_combo_box_get_active(GTK_COMBO_BOX(lookup_widget(MemDlg, "memcard1combo"))) != -1)
sprintf(Config.Mcd[0].Filename, "%s/%s/%s", MAIN_DIR, MEMCARDS_DIR,
gtk_combo_box_get_active_text(GTK_COMBO_BOX(lookup_widget(MemDlg, "memcard1combo"))));
else
sprintf(Config.Mcd[0].Filename, "%s/%s/%s", MAIN_DIR, MEMCARDS_DIR, DEFAULT_MEMCARD1);
strcpy(Config.Mcd[0].Filename, MEMCARDS_DIR "/");
strcpy(Config.Mcd[1].Filename, MEMCARDS_DIR "/");
strcat(Config.Mcd[0].Filename, gtk_combo_box_get_active_text(GTK_COMBO_BOX(lookup_widget(MemDlg, "memcard1combo"))));
strcat(Config.Mcd[1].Filename, gtk_combo_box_get_active_text(GTK_COMBO_BOX(lookup_widget(MemDlg, "memcard2combo"))));
if (gtk_combo_box_get_active(GTK_COMBO_BOX(lookup_widget(MemDlg, "memcard2combo"))) != -1)
sprintf(Config.Mcd[1].Filename, "%s/%s/%s", MAIN_DIR, MEMCARDS_DIR,
gtk_combo_box_get_active_text(GTK_COMBO_BOX(lookup_widget(MemDlg, "memcard2combo"))));
else
sprintf(Config.Mcd[1].Filename, "%s/%s/%s", MAIN_DIR, MEMCARDS_DIR, DEFAULT_MEMCARD2);
Config.Mcd[0].Enabled = is_checked(MemDlg, "check_enable_mcd1");
Config.Mcd[1].Enabled = is_checked(MemDlg, "check_enable_mcd2");

View File

@ -1,6 +1,10 @@
#ifndef _PCSX2_PATHS_H_
#define _PCSX2_PATHS_H_
#define g_MaxPath 255 // 255 is safer with antiquated Win32 ASCII APIs.
char MAIN_DIR[g_MaxPath];
#define CONFIG_DIR "inis"
#define DEFAULT_BIOS_DIR "bios"
@ -16,8 +20,6 @@
#define DEFAULT_MEMCARD1 "Mcd001.ps2"
#define DEFAULT_MEMCARD2 "Mcd002.ps2"
#define g_MaxPath 255 // 255 is safer with antiquated Win32 ASCII APIs.
namespace Path
{
void Combine( std::string& dest, const std::string& srcPath, const std::string& srcFile );

View File

@ -635,6 +635,9 @@ int InitPlugins()
//if( !loadp )
// throw Exception::InvalidOperation( "Bad coder mojo - InitPlugins called prior to plugins having been loaded." );
#ifndef _WIN32
chdir(MAIN_DIR);
#endif
int ret;
ret = GSinit();
@ -700,17 +703,17 @@ int OpenPlugins(const char* pTitleFilename)
GSdriverInfo info;
int ret;
if ( !initp )
InitPlugins();
if ( !initp ) InitPlugins();
//throw Exception::InvalidOperation( "Bad coder mojo -- OpenPlugins called prior to InitPlugins." );
#ifndef _WIN32
// change dir so that CDVD can find its config file
char file[255], pNewTitle[255];
getcwd(file, ARRAYSIZE(file));
chdir(MAIN_DIR);
chdir(Config.PluginsDir);
if( pTitleFilename != NULL && pTitleFilename[0] != '/' ) {
if( pTitleFilename != NULL && pTitleFilename[0] != '/' )
{
// because we are changing the dir, we have to set a new title if it is a relative dir
sprintf(pNewTitle, "%s/%s", file, pTitleFilename);
pTitleFilename = pNewTitle;
@ -800,15 +803,15 @@ int OpenPlugins(const char* pTitleFilename)
OpenStatus.FW = true;
}
#ifdef __LINUX__
chdir(file);
#ifndef _WIN32
chdir(MAIN_DIR);
#endif
return 0;
OpenError:
ClosePlugins( true );
#ifdef __LINUX__
chdir(file);
#ifndef _WIN32
chdir(MAIN_DIR);
#endif
return -1;
@ -863,6 +866,7 @@ void ClosePlugins( bool closegs )
void ResetPlugins()
{
mtgsWaitGS();
ShutdownPlugins();

View File

@ -21,6 +21,7 @@
#include <stdarg.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include "Config.h"
#include "CDVDiso.h"
@ -38,6 +39,14 @@ void ExecCfg(char *arg)
return;
}
strcpy(cfg, "./plugins/cfgCDVDiso");
if (stat(cfg, &buf) != -1)
{
sprintf(cfg, "%s %s", cfg, arg);
system(cfg);
return;
}
strcpy(cfg, "./cfg/cfgCDVDiso");
if (stat(cfg, &buf) != -1)
{
@ -59,17 +68,29 @@ void ExecCfg(char *arg)
void CDVDconfigure()
{
char *file;
getcwd(file, ARRAYSIZE(file));
chdir("plugins");
ExecCfg("configure");
chdir(file);
}
void CDVDabout()
{
char *file;
getcwd(file, ARRAYSIZE(file));
chdir("plugins");
ExecCfg("about");
chdir(file);
}
void CfgOpenFile()
{
char *file;
getcwd(file, ARRAYSIZE(file));
chdir("plugins");
ExecCfg("open");
chdir(file);
}
void SysMessage(char *fmt, ...)

View File

@ -23,27 +23,39 @@
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <pthread.h>
#include <unistd.h>
#include "FW.h"
int ExecCfg(char *arg) {
int ExecCfg(char *arg)
{
char cfg[256];
struct stat buf;
strcpy(cfg, "./cfgFWnull");
if (stat(cfg, &buf) != -1) {
if (stat(cfg, &buf) != -1)
{
sprintf(cfg, "%s %s", cfg, arg);
return system(cfg);
}
strcpy(cfg, "./plugins/cfgFWnull");
if (stat(cfg, &buf) != -1)
{
sprintf(cfg, "%s %s", cfg, arg);
return system(cfg);
}
strcpy(cfg, "./cfg/cfgFWnull");
if (stat(cfg, &buf) != -1) {
if (stat(cfg, &buf) != -1)
{
sprintf(cfg, "%s %s", cfg, arg);
return system(cfg);
}
sprintf(cfg, "%s/cfgFWnull", getenv("HOME"));
if (stat(cfg, &buf) != -1) {
if (stat(cfg, &buf) != -1)
{
sprintf(cfg, "%s %s", cfg, arg);
return system(cfg);
}
@ -52,7 +64,8 @@ int ExecCfg(char *arg) {
return -1;
}
void SysMessage(char *fmt, ...) {
void SysMessage(char *fmt, ...)
{
va_list list;
char msg[512];
char cmd[512];
@ -65,11 +78,21 @@ void SysMessage(char *fmt, ...) {
ExecCfg(cmd);
}
void FWconfigure() {
void FWconfigure()
{
char *file;
getcwd(file, ARRAYSIZE(file));
chdir("plugins");
ExecCfg("configure");
chdir(file);
}
void FWabout() {
void FWabout()
{
char *file;
getcwd(file, ARRAYSIZE(file));
chdir("plugins");
ExecCfg("about");
chdir(file);
}

View File

@ -23,26 +23,39 @@
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <pthread.h>
#include <unistd.h>
#include "USB.h"
int ExecCfg(char *arg) {
int ExecCfg(char *arg)
{
char cfg[256];
struct stat buf;
strcpy(cfg, "./cfgUSBnull");
if (stat(cfg, &buf) != -1) {
if (stat(cfg, &buf) != -1)
{
sprintf(cfg, "%s %s", cfg, arg);
return system(cfg);
}
strcpy(cfg, "./plugins/cfgUSBnull");
if (stat(cfg, &buf) != -1)
{
sprintf(cfg, "%s %s", cfg, arg);
return system(cfg);
}
strcpy(cfg, "./cfg/cfgUSBnull");
if (stat(cfg, &buf) != -1) {
sprintf(cfg, "%s %s", cfg, arg);
if (stat(cfg, &buf) != -1)
{ sprintf(cfg, "%s %s", cfg, arg);
return system(cfg);
}
sprintf(cfg, "%s/cfgUSBnull", getenv("HOME"));
if (stat(cfg, &buf) != -1) {
if (stat(cfg, &buf) != -1)
{
sprintf(cfg, "%s %s", cfg, arg);
return system(cfg);
}
@ -51,7 +64,8 @@ int ExecCfg(char *arg) {
return -1;
}
void SysMessage(char *fmt, ...) {
void SysMessage(char *fmt, ...)
{
va_list list;
char msg[512];
char cmd[512];
@ -64,11 +78,21 @@ void SysMessage(char *fmt, ...) {
ExecCfg(cmd);
}
void USBconfigure() {
void USBconfigure()
{
char *file;
getcwd(file, ARRAYSIZE(file));
chdir("plugins");
ExecCfg("configure");
chdir(file);
}
void USBabout() {
void USBabout()
{
char *file;
getcwd(file, ARRAYSIZE(file));
chdir("plugins");
ExecCfg("about");
chdir(file);
}

View File

@ -35,13 +35,10 @@ extern "C" {
#include <map>
GtkWidget *Conf;
GtkWidget *Logging;
GList *fresl;
GList *wresl;
GList *cachesizel;
GList *codecl;
GList *filtersl;
extern string s_strIniPath;
GtkWidget *Conf, *Logging, *About;
GList *fresl, *wresl, *cachesizel, *codecl, *filtersl;
static int prevbilinearfilter;
@ -58,8 +55,6 @@ extern void OnKeyboardF6(int);
extern void OnKeyboardF7(int);
extern void OnKeyboardF9(int);
GtkWidget *About;
void CALLBACK GSkeyEvent(keyEvent *ev)
{
//static bool bShift = false;
@ -196,6 +191,11 @@ void CALLBACK GSconfigure()
GtkTreeIter treeiter;
GtkTreeViewColumn *treecol;
char strcurdir[256];
getcwd(strcurdir, 256);
s_strIniPath = strcurdir;
s_strIniPath += "/inis/zerogs.ini";
if (!(conf.options & GSOPTION_LOADED)) LoadConfig();
Conf = create_Config();

View File

@ -603,6 +603,11 @@ void OnConf_Cancel(GtkButton *button, gpointer user_data)
void CALLBACK PADconfigure()
{
char strcurdir[256];
getcwd(strcurdir, 256);
s_strIniPath = strcurdir;
s_strIniPath += "/inis/zeropad.ini";
LoadConfig();
Conf = create_Conf();

View File

@ -29,6 +29,9 @@ extern "C" {
#include "zerospu2.h"
#include "Linux.h"
extern char *libraryName;
extern string s_strIniPath;
// This is a bit ugly. I'll see if I can work out a better way to do this later.
int SetupSound()
{
@ -113,6 +116,11 @@ void SysMessage(char *fmt, ...) {
void CALLBACK SPU2configure()
{
char strcurdir[256];
getcwd(strcurdir, 256);
s_strIniPath = strcurdir;
s_strIniPath += "/inis/zerospu2.ini";
LOG_CALLBACK("SPU2configure()\n");
ConfDlg = create_Config();
LoadConfig();
@ -153,9 +161,6 @@ void on_Conf_Cancel (GtkButton *button, gpointer user_data)
}
extern char *libraryName;
extern string s_strIniPath;
void CALLBACK SPU2about()
{
LOG_CALLBACK("SPU2about()\n");