mirror of https://github.com/PCSX2/pcsx2.git
Get rid of the worst of the defines in the Linux code.
git-svn-id: http://pcsx2-playground.googlecode.com/svn/trunk@309 a6443dda-0b58-4228-96e9-037be469359c
This commit is contained in:
parent
6ba744dea2
commit
6a41d4c782
|
@ -18,6 +18,27 @@
|
|||
|
||||
#include "ConfigDlg.h"
|
||||
|
||||
static void FindComboText(GtkWidget *combo, char plist[255][255], GList *list, char *conf)
|
||||
{
|
||||
if (strlen(conf) > 0) {
|
||||
SetActiveComboItem(GTK_COMBO_BOX(combo), plist, list, conf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void GetComboText(GtkWidget *combo, char plist[255][255], char *conf)
|
||||
{
|
||||
int i;
|
||||
|
||||
char *tmp = (char*)gtk_combo_box_get_active_text(GTK_COMBO_BOX(combo));
|
||||
for (i=2;i<255;i+=2) {
|
||||
if (!strcmp(tmp, plist[i-1])) {
|
||||
strcpy(conf, plist[i-2]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void ConfPlugin(PluginConf confs, char* plugin, const char* name)
|
||||
{
|
||||
void *drv;
|
||||
|
@ -179,7 +200,7 @@ void SetActiveComboItem(GtkComboBox *widget,char plist[255][255], GList *list, c
|
|||
}
|
||||
|
||||
void OnConfConf_Ok(GtkButton *button, gpointer user_data) {
|
||||
GetComboText(GSConfS.Combo, GSConfS.plist, Config.GS)
|
||||
GetComboText(GSConfS.Combo, GSConfS.plist, Config.GS);
|
||||
GetComboText(PAD1ConfS.Combo, PAD1ConfS.plist, Config.PAD1);
|
||||
GetComboText(PAD2ConfS.Combo, PAD2ConfS.plist, Config.PAD2);
|
||||
GetComboText(SPU2ConfS.Combo, SPU2ConfS.plist, Config.SPU2);
|
||||
|
@ -321,18 +342,28 @@ void SetComboToGList(GtkComboBox *widget, GList *list)
|
|||
gtk_combo_box_set_active(GTK_COMBO_BOX(widget), 0);
|
||||
}
|
||||
|
||||
static void ConfCreatePConf(const char *name, PluginConf *confs, char *config)
|
||||
{
|
||||
char tmp[50];
|
||||
|
||||
sprintf (tmp, "GtkCombo_%s", name);
|
||||
confs->Combo = lookup_widget(ConfDlg, tmp);
|
||||
SetComboToGList(GTK_COMBO_BOX(confs->Combo), confs->PluginNameList);
|
||||
FindComboText(confs->Combo, confs->plist, confs->PluginNameList, config);
|
||||
}
|
||||
|
||||
void UpdateConfDlg() {
|
||||
FindPlugins();
|
||||
|
||||
ConfCreatePConf("Gs", GS);
|
||||
ConfCreatePConf("Pad1", PAD1);
|
||||
ConfCreatePConf("Pad2", PAD2);
|
||||
ConfCreatePConf("Spu2", SPU2);
|
||||
ConfCreatePConf("Cdvd", CDVD);
|
||||
ConfCreatePConf("Dev9", DEV9);
|
||||
ConfCreatePConf("Usb", USB);
|
||||
ConfCreatePConf("FW", FW);
|
||||
ConfCreatePConf("Bios", Bios);
|
||||
ConfCreatePConf("Gs", &GSConfS, Config.GS);
|
||||
ConfCreatePConf("Pad1", &PAD1ConfS, Config.PAD1);
|
||||
ConfCreatePConf("Pad2", &PAD2ConfS, Config.PAD2);
|
||||
ConfCreatePConf("Spu2", &SPU2ConfS, Config.SPU2);
|
||||
ConfCreatePConf("Cdvd", &CDVDConfS, Config.CDVD);
|
||||
ConfCreatePConf("Dev9", &DEV9ConfS, Config.DEV9);
|
||||
ConfCreatePConf("Usb", &USBConfS, Config.USB);
|
||||
ConfCreatePConf("FW", &FWConfS, Config.FW);
|
||||
ConfCreatePConf("Bios", &BiosConfS, Config.Bios);
|
||||
}
|
||||
|
||||
void OnConfConf_PluginsPath(GtkButton *button, gpointer user_data) {
|
||||
|
@ -396,6 +427,14 @@ void OnConf_Conf(GtkMenuItem *menuitem, gpointer user_data) {
|
|||
gtk_main();
|
||||
}
|
||||
|
||||
static void ComboAddPlugin(char name[g_MaxPath], PluginConf *confs, u32 version, struct dirent *ent) {
|
||||
sprintf (name, "%s %ld.%ld.%ld", PS2EgetLibName(), (version>>8)&0xff ,version&0xff, (version>>24)&0xff);
|
||||
confs->plugins+=2;
|
||||
strcpy(confs->plist[confs->plugins-1], name);
|
||||
strcpy(confs->plist[confs->plugins-2], ent->d_name);
|
||||
confs->PluginNameList = g_list_append(confs->PluginNameList, confs->plist[confs->plugins-1]);
|
||||
}
|
||||
|
||||
void FindPlugins() {
|
||||
DIR *dir;
|
||||
struct dirent *ent;
|
||||
|
@ -436,7 +475,7 @@ void FindPlugins() {
|
|||
if (type & PS2E_LT_GS) {
|
||||
version = PS2EgetLibVersion2(PS2E_LT_GS);
|
||||
if (((version >> 16)&0xff) == PS2E_GS_VERSION) {
|
||||
ComboAddPlugin(GS);
|
||||
ComboAddPlugin(name, &GSConfS, version, ent);
|
||||
}
|
||||
else
|
||||
SysPrintf("Plugin %s: Version %x != %x\n", plugin, (version >> 16)&0xff, PS2E_GS_VERSION);
|
||||
|
@ -448,39 +487,39 @@ void FindPlugins() {
|
|||
version = PS2EgetLibVersion2(PS2E_LT_PAD);
|
||||
if (((version >> 16)&0xff) == PS2E_PAD_VERSION && query) {
|
||||
if (query() & 0x1)
|
||||
ComboAddPlugin(PAD1);
|
||||
ComboAddPlugin(name, &PAD1ConfS, version, ent);
|
||||
if (query() & 0x2)
|
||||
ComboAddPlugin(PAD2);
|
||||
ComboAddPlugin(name, &PAD2ConfS, version, ent);
|
||||
} else SysPrintf("Plugin %s: Version %x != %x\n", plugin, (version >> 16)&0xff, PS2E_PAD_VERSION);
|
||||
}
|
||||
if (type & PS2E_LT_SPU2) {
|
||||
version = PS2EgetLibVersion2(PS2E_LT_SPU2);
|
||||
if (((version >> 16)&0xff) == PS2E_SPU2_VERSION) {
|
||||
ComboAddPlugin(SPU2);
|
||||
ComboAddPlugin(name, &SPU2ConfS, version, ent);
|
||||
} else SysPrintf("Plugin %s: Version %x != %x\n", plugin, (version >> 16)&0xff, PS2E_SPU2_VERSION);
|
||||
}
|
||||
if (type & PS2E_LT_CDVD) {
|
||||
version = PS2EgetLibVersion2(PS2E_LT_CDVD);
|
||||
if (((version >> 16)&0xff) == PS2E_CDVD_VERSION) {
|
||||
ComboAddPlugin(CDVD);
|
||||
ComboAddPlugin(name, &CDVDConfS, version, ent);
|
||||
} else SysPrintf("Plugin %s: Version %x != %x\n", plugin, (version >> 16)&0xff, PS2E_CDVD_VERSION);
|
||||
}
|
||||
if (type & PS2E_LT_DEV9) {
|
||||
version = PS2EgetLibVersion2(PS2E_LT_DEV9);
|
||||
if (((version >> 16)&0xff) == PS2E_DEV9_VERSION) {
|
||||
ComboAddPlugin(DEV9);
|
||||
ComboAddPlugin(name, &DEV9ConfS, version, ent);
|
||||
} else SysPrintf("DEV9Plugin %s: Version %x != %x\n", plugin, (version >> 16)&0xff, PS2E_DEV9_VERSION);
|
||||
}
|
||||
if (type & PS2E_LT_USB) {
|
||||
version = PS2EgetLibVersion2(PS2E_LT_USB);
|
||||
if (((version >> 16)&0xff) == PS2E_USB_VERSION) {
|
||||
ComboAddPlugin(USB);
|
||||
ComboAddPlugin(name, &USBConfS, version, ent);
|
||||
} else SysPrintf("USBPlugin %s: Version %x != %x\n", plugin, (version >> 16)&0xff, PS2E_USB_VERSION);
|
||||
}
|
||||
if (type & PS2E_LT_FW) {
|
||||
version = PS2EgetLibVersion2(PS2E_LT_FW);
|
||||
if (((version >> 16)&0xff) == PS2E_FW_VERSION) {
|
||||
ComboAddPlugin(FW);
|
||||
ComboAddPlugin(name, &FWConfS, version, ent);
|
||||
} else SysPrintf("FWPlugin %s: Version %x != %x\n", plugin, (version >> 16)&0xff, PS2E_FW_VERSION);
|
||||
}
|
||||
}
|
||||
|
@ -502,9 +541,9 @@ void FindPlugins() {
|
|||
if (!IsBIOS(ent->d_name, description)) continue;//2002-09-28 (Florin)
|
||||
|
||||
BiosConfS.plugins+=2;
|
||||
snprintf(BiosConfS.plist[BiosConfS.plugins-1], sizeof(BiosConfS.plist[0]), "%s (", description);
|
||||
strncat(BiosConfS.plist[BiosConfS.plugins-1], ent->d_name, min(sizeof(BiosConfS.plist[0]-2), strlen(ent->d_name)));
|
||||
strcat(BiosConfS.plist[BiosConfS.plugins-1], ")");
|
||||
snprintf(BiosConfS.plist[BiosConfS.plugins-1], sizeof(BiosConfS.plist[0]), "%s (", description);
|
||||
strncat(BiosConfS.plist[BiosConfS.plugins-1], ent->d_name, min(sizeof(BiosConfS.plist[0]-2), strlen(ent->d_name)));
|
||||
strcat(BiosConfS.plist[BiosConfS.plugins-1], ")");
|
||||
strcpy(BiosConfS.plist[BiosConfS.plugins-2], ent->d_name);
|
||||
BiosConfS.PluginNameList = g_list_append(BiosConfS.PluginNameList, BiosConfS.plist[BiosConfS.plugins-1]);
|
||||
}
|
||||
|
|
|
@ -35,7 +35,6 @@ extern "C" {
|
|||
}
|
||||
#endif
|
||||
|
||||
|
||||
// Helper Functions
|
||||
void FindPlugins();
|
||||
void OnConf_Gs(GtkMenuItem *menuitem, gpointer user_data);
|
||||
|
@ -65,39 +64,9 @@ _PS2EgetLibType PS2EgetLibType = NULL;
|
|||
_PS2EgetLibVersion2 PS2EgetLibVersion2 = NULL;
|
||||
_PS2EgetLibName PS2EgetLibName = NULL;
|
||||
|
||||
// Evil Macros - Destroy when possible
|
||||
#define FindComboText(combo,plist, list, conf) \
|
||||
if (strlen(conf) > 0) { \
|
||||
SetActiveComboItem(GTK_COMBO_BOX(combo), plist, list, conf); \
|
||||
}
|
||||
|
||||
#define GetComboText(combo,list,conf) \
|
||||
{ \
|
||||
int i; \
|
||||
char *tmp = (char*)gtk_combo_box_get_active_text(GTK_COMBO_BOX(combo)); \
|
||||
for (i=2;i<255;i+=2) { \
|
||||
if (!strcmp(tmp, list[i-1])) { \
|
||||
strcpy(conf, list[i-2]); \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
void SetActiveComboItem(GtkComboBox *widget,char plist[255][255], GList *list, char *conf);
|
||||
void SetComboToGList(GtkComboBox *widget, GList *list);
|
||||
static void ConfPlugin(PluginConf confs, char* plugin, const char* name);
|
||||
static void TestPlugin(PluginConf confs, char* plugin, const char* name);
|
||||
|
||||
#define ConfCreatePConf(name, type) \
|
||||
type##ConfS.Combo = lookup_widget(ConfDlg, "GtkCombo_" name); \
|
||||
SetComboToGList(GTK_COMBO_BOX(type##ConfS.Combo), type##ConfS.PluginNameList); \
|
||||
FindComboText(type##ConfS.Combo, type##ConfS.plist, type##ConfS.PluginNameList, Config.type);
|
||||
|
||||
#define ComboAddPlugin(type) { \
|
||||
sprintf (name, "%s %ld.%ld.%ld", PS2EgetLibName(), (version>>8)&0xff ,version&0xff, (version>>24)&0xff); \
|
||||
type##ConfS.plugins+=2; \
|
||||
strcpy(type##ConfS.plist[type##ConfS.plugins-1], name); \
|
||||
strcpy(type##ConfS.plist[type##ConfS.plugins-2], ent->d_name); \
|
||||
type##ConfS.PluginNameList = g_list_append(type##ConfS.PluginNameList, type##ConfS.plist[type##ConfS.plugins-1]); \
|
||||
}
|
||||
|
||||
#endif // __CONFIGDLG_H__
|
|
@ -26,45 +26,54 @@ extern "C" {
|
|||
#include "Linux.h"
|
||||
}
|
||||
|
||||
#define GetValue(name, var) \
|
||||
FILE *pref_file;
|
||||
char *data;
|
||||
|
||||
static void SetValue( const char *name, char *var)
|
||||
{
|
||||
fprintf (pref_file,"%s = %s\n", name, var);
|
||||
}
|
||||
|
||||
static void SetValuel( const char *name, s32 var)
|
||||
{
|
||||
fprintf (pref_file,"%s = %x\n", name, var);
|
||||
}
|
||||
|
||||
#define GetValue(name, var) {\
|
||||
char * tmp; \
|
||||
tmp = strstr(data, name); \
|
||||
if (tmp != NULL) { \
|
||||
tmp+=strlen(name); \
|
||||
while ((*tmp == ' ') || (*tmp == '=')) tmp++; \
|
||||
if (*tmp != '\n') sscanf(tmp, "%s", var); \
|
||||
}
|
||||
} \
|
||||
}
|
||||
|
||||
#define GetValuel(name, var) \
|
||||
#define GetValuel(name, var) {\
|
||||
char * tmp; \
|
||||
tmp = strstr(data, name); \
|
||||
if (tmp != NULL) { \
|
||||
tmp+=strlen(name); \
|
||||
while ((*tmp == ' ') || (*tmp == '=')) tmp++; \
|
||||
if (*tmp != '\n') sscanf(tmp, "%x", &var); \
|
||||
}
|
||||
|
||||
#define SetValue(name, var) \
|
||||
fprintf (f,"%s = %s\n", name, var);
|
||||
|
||||
#define SetValuel(name, var) \
|
||||
fprintf (f,"%s = %x\n", name, var);
|
||||
|
||||
} \
|
||||
}
|
||||
|
||||
int LoadConfig() {
|
||||
struct stat buf;
|
||||
FILE *f;
|
||||
int size;
|
||||
char *data,*tmp;
|
||||
|
||||
|
||||
if (stat(cfgfile, &buf) == -1) return -1;
|
||||
size = buf.st_size;
|
||||
|
||||
f = fopen(cfgfile,"r");
|
||||
if (f == NULL) return -1;
|
||||
pref_file = fopen(cfgfile,"r");
|
||||
if (pref_file == NULL) return -1;
|
||||
|
||||
data = (char*)malloc(size);
|
||||
if (data == NULL) return -1;
|
||||
|
||||
fread(data, 1, size, f);
|
||||
fclose(f);
|
||||
fread(data, 1, size, pref_file);
|
||||
fclose(pref_file);
|
||||
|
||||
GetValue("Bios", Config.Bios);
|
||||
Config.Lang[0] = 0;
|
||||
|
@ -76,7 +85,6 @@ int LoadConfig() {
|
|||
GetValue("Mcd1", Config.Mcd1);
|
||||
GetValue("Mcd2", Config.Mcd2);
|
||||
|
||||
// plugins
|
||||
GetValue("GS", Config.GS);
|
||||
GetValue("SPU2", Config.SPU2);
|
||||
GetValue("CDVD", Config.CDVD);
|
||||
|
@ -86,19 +94,14 @@ int LoadConfig() {
|
|||
GetValue("USB", Config.USB);
|
||||
GetValue("FW", Config.FW);
|
||||
|
||||
|
||||
// cpu
|
||||
GetValuel("Options", Config.Options);
|
||||
//hacks
|
||||
GetValuel("Hacks", Config.Hacks);
|
||||
GetValuel("Fixes", Config.GameFixes);
|
||||
|
||||
Config.sseMXCSR = DEFAULT_sseMXCSR;
|
||||
Config.sseVUMXCSR = DEFAULT_sseVUMXCSR;
|
||||
|
||||
//sseMXCSR
|
||||
|
||||
GetValuel("sseMXCSR", Config.sseMXCSR);
|
||||
//sseVUMXCSR
|
||||
GetValuel("sseVUMXCSR", Config.sseVUMXCSR);
|
||||
|
||||
GetValuel("Patch", Config.Patch);
|
||||
|
@ -124,12 +127,10 @@ int LoadConfig() {
|
|||
/////////////////////////////////////////////////////////
|
||||
|
||||
void SaveConfig() {
|
||||
FILE *f;
|
||||
|
||||
f = fopen(cfgfile,"w");
|
||||
if (f == NULL) return;
|
||||
pref_file = fopen(cfgfile,"w");
|
||||
if (pref_file == NULL) return;
|
||||
|
||||
// interface
|
||||
SetValue("Bios", Config.Bios);
|
||||
SetValue("Lang", Config.Lang);
|
||||
SetValue("PluginsDir", Config.PluginsDir);
|
||||
|
@ -138,7 +139,7 @@ void SaveConfig() {
|
|||
SetValuel("ThPriority", Config.ThPriority);
|
||||
SetValue("Mcd1", Config.Mcd1);
|
||||
SetValue("Mcd2", Config.Mcd2);
|
||||
// plugins
|
||||
|
||||
SetValue("GS", Config.GS);
|
||||
SetValue("SPU2", Config.SPU2);
|
||||
SetValue("CDVD", Config.CDVD);
|
||||
|
@ -147,16 +148,14 @@ void SaveConfig() {
|
|||
SetValue("DEV9", Config.DEV9);
|
||||
SetValue("USB", Config.USB);
|
||||
SetValue("FW", Config.FW);
|
||||
//cpu
|
||||
|
||||
SetValuel("Options", Config.Options);
|
||||
//hacks
|
||||
SetValuel("Hacks", Config.Hacks);
|
||||
SetValuel("Fixes", Config.GameFixes);
|
||||
//sseMXCSR
|
||||
|
||||
SetValuel("sseMXCSR", Config.sseMXCSR);
|
||||
//sseVUMXCSR
|
||||
SetValuel("sseVUMXCSR", Config.sseVUMXCSR);
|
||||
// misc
|
||||
|
||||
SetValuel("Patch", Config.Patch);
|
||||
|
||||
#ifdef PCSX2_DEVBUILD
|
||||
|
@ -164,7 +163,7 @@ void SaveConfig() {
|
|||
#endif
|
||||
|
||||
|
||||
fclose(f);
|
||||
fclose(pref_file);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue