diff --git a/common/include/PS2Edefs.h b/common/include/PS2Edefs.h
index 5d02a7016a..3bf3731fe2 100644
--- a/common/include/PS2Edefs.h
+++ b/common/include/PS2Edefs.h
@@ -206,6 +206,8 @@ s32 CALLBACK GSinit();
s32 CALLBACK GSopen(void *pDsp, char *Title, int multithread);
void CALLBACK GSclose();
void CALLBACK GSshutdown();
+void CALLBACK GSsetSettingsDir( const char* dir );
+
void CALLBACK GSvsync(int field);
void CALLBACK GSgifTransfer1(u32 *pMem, u32 addr);
void CALLBACK GSgifTransfer2(u32 *pMem, u32 size);
@@ -260,6 +262,8 @@ s32 CALLBACK PADinit(u32 flags);
s32 CALLBACK PADopen(void *pDsp);
void CALLBACK PADclose();
void CALLBACK PADshutdown();
+void CALLBACK PADsetSettingsDir( const char* dir );
+
// PADkeyEvent is called every vsync (return NULL if no event)
keyEvent* CALLBACK PADkeyEvent();
u8 CALLBACK PADstartPoll(int pad);
@@ -287,31 +291,6 @@ s32 CALLBACK PADtest();
#endif
-/* SIO plugin API */
-
-// if this file is included with this define
-// the next api will not be skipped by the compiler
-#ifdef SIOdefs
-
-// basic funcs
-
-s32 CALLBACK SIOinit(u32 port, u32 slot, SIOchangeSlotCB f);
-s32 CALLBACK SIOopen(void *pDsp);
-void CALLBACK SIOclose();
-void CALLBACK SIOshutdown();
-u8 CALLBACK SIOstartPoll(u8 value);
-u8 CALLBACK SIOpoll(u8 value);
-// returns: SIO_TYPE_{PAD,MTAP,RM,MC}
-u32 CALLBACK SIOquery();
-
-// extended funcs
-
-void CALLBACK SIOconfigure();
-void CALLBACK SIOabout();
-s32 CALLBACK SIOtest();
-
-#endif
-
/* SPU2 plugin API */
// if this file is included with this define
@@ -324,6 +303,8 @@ s32 CALLBACK SPU2init();
s32 CALLBACK SPU2open(void *pDsp);
void CALLBACK SPU2close();
void CALLBACK SPU2shutdown();
+void CALLBACK SPU2setSettingsDir( const char* dir );
+
void CALLBACK SPU2write(u32 mem, u16 value);
u16 CALLBACK SPU2read(u32 mem);
void CALLBACK SPU2readDMA4Mem(u16 *pMem, int size);
@@ -370,6 +351,8 @@ s32 CALLBACK CDVDinit();
s32 CALLBACK CDVDopen(const char* pTitleFilename);
void CALLBACK CDVDclose();
void CALLBACK CDVDshutdown();
+void CALLBACK CDVDsetSettingsDir( const char* dir );
+
s32 CALLBACK CDVDreadTrack(u32 lsn, int mode);
// return can be NULL (for async modes)
@@ -418,6 +401,8 @@ s32 CALLBACK DEV9init();
s32 CALLBACK DEV9open(void *pDsp);
void CALLBACK DEV9close();
void CALLBACK DEV9shutdown();
+void CALLBACK DEV9setSettingsDir( const char* dir );
+
u8 CALLBACK DEV9read8(u32 addr);
u16 CALLBACK DEV9read16(u32 addr);
u32 CALLBACK DEV9read32(u32 addr);
@@ -452,6 +437,8 @@ s32 CALLBACK USBinit();
s32 CALLBACK USBopen(void *pDsp);
void CALLBACK USBclose();
void CALLBACK USBshutdown();
+void CALLBACK USBsetSettingsDir( const char* dir );
+
u8 CALLBACK USBread8(u32 addr);
u16 CALLBACK USBread16(u32 addr);
u32 CALLBACK USBread32(u32 addr);
@@ -488,6 +475,8 @@ s32 CALLBACK FWinit();
s32 CALLBACK FWopen(void *pDsp);
void CALLBACK FWclose();
void CALLBACK FWshutdown();
+void CALLBACK FWsetSettingsDir( const char* dir );
+
u32 CALLBACK FWread32(u32 addr);
void CALLBACK FWwrite32(u32 addr, u32 value);
void CALLBACK FWirqCallback(void (*callback)());
@@ -552,19 +541,6 @@ typedef void (CALLBACK* _PADgsDriverInfo)(GSdriverInfo *info);
typedef s32 (CALLBACK* _PADsetSlot)(u8 port, u8 slot);
typedef s32 (CALLBACK* _PADqueryMtap)(u8 port);
-// SIO
-typedef s32 (CALLBACK* _SIOinit)(u32 port, u32 slot, SIOchangeSlotCB f);
-typedef s32 (CALLBACK* _SIOopen)(void *pDsp);
-typedef void (CALLBACK* _SIOclose)();
-typedef void (CALLBACK* _SIOshutdown)();
-typedef u8 (CALLBACK* _SIOstartPoll)(u8 value);
-typedef u8 (CALLBACK* _SIOpoll)(u8 value);
-typedef u32 (CALLBACK* _SIOquery)();
-
-typedef void (CALLBACK* _SIOconfigure)();
-typedef s32 (CALLBACK* _SIOtest)();
-typedef void (CALLBACK* _SIOabout)();
-
// SPU2
// NOTE: The read/write functions CANNOT use XMM/MMX regs
// If you want to use them, need to save and restore current ones
@@ -699,13 +675,6 @@ extern _PADgsDriverInfo PADgsDriverInfo;
extern _PADsetSlot PADsetSlot;
extern _PADqueryMtap PADqueryMtap;
-
-// SIO[2]
-extern _SIOopen SIOopen[2][9];
-extern _SIOstartPoll SIOstartPoll[2][9];
-extern _SIOpoll SIOpoll[2][9];
-extern _SIOquery SIOquery[2][9];
-
// SPU2
extern _SPU2open SPU2open;
extern _SPU2write SPU2write;
diff --git a/common/include/PS2Etypes.h b/common/include/PS2Etypes.h
index 44c7bf6705..eb1dde6a27 100644
--- a/common/include/PS2Etypes.h
+++ b/common/include/PS2Etypes.h
@@ -13,7 +13,8 @@
* If not, see .
*/
- // This file is just for backwards compatability.
+ // This file is just for backwards compatibility.
+
#ifndef __PS2ETYPES_H__
#define __PS2ETYPES_H__
diff --git a/pcsx2/PluginManager.cpp b/pcsx2/PluginManager.cpp
index 56b13c0609..ce6d6063ab 100644
--- a/pcsx2/PluginManager.cpp
+++ b/pcsx2/PluginManager.cpp
@@ -125,6 +125,7 @@ struct LegacyApi_OptMethod
static s32 CALLBACK fallback_freeze(int mode, freezeData *data) { data->size = 0; return 0; }
static void CALLBACK fallback_keyEvent(keyEvent *ev) {}
+static void CALLBACK fallback_setSettingsDir(const char* dir) {}
static void CALLBACK fallback_configure() {}
static void CALLBACK fallback_about() {}
static s32 CALLBACK fallback_test() { return 0; }
@@ -252,16 +253,17 @@ static s32 CALLBACK _hack_PADinit()
//
static const LegacyApi_CommonMethod s_MethMessCommon[] =
{
- { "init", NULL },
- { "close", NULL },
- { "shutdown", NULL },
+ { "init", NULL },
+ { "close", NULL },
+ { "shutdown", NULL },
- { "keyEvent", (vMeth*)fallback_keyEvent },
+ { "keyEvent", (vMeth*)fallback_keyEvent },
+ { "setSettingsDir", (vMeth*)fallback_setSettingsDir },
- { "freeze", (vMeth*)fallback_freeze },
- { "test", (vMeth*)fallback_test },
- { "configure", fallback_configure },
- { "about", fallback_about },
+ { "freeze", (vMeth*)fallback_freeze },
+ { "test", (vMeth*)fallback_test },
+ { "configure", fallback_configure },
+ { "about", fallback_about },
{ NULL }
@@ -771,6 +773,8 @@ PluginManager::PluginManager( const wxString (&folders)[PluginId_Count] )
}
g_plugins = this;
+
+ SendSettingsFolder();
}
PluginManager::~PluginManager() throw()
@@ -951,6 +955,8 @@ void PluginManager::Open()
Console.WriteLn( Color_StrongBlue, "Opening plugins..." );
+ SendSettingsFolder();
+
pi = tbl_PluginInfo; do {
Open( pi->id );
// If GS doesn't support GSopen2, need to wait until call to GSopen
@@ -1168,6 +1174,30 @@ bool PluginManager::KeyEvent( const keyEvent& evt )
return false;
}
+void PluginManager::SendSettingsFolder()
+{
+ if( m_SettingsFolder.IsEmpty() ) return;
+
+ wxCharBuffer utf8buffer( m_SettingsFolder.ToUTF8() );
+
+ const PluginInfo* pi = tbl_PluginInfo; do {
+ m_info[pi->id].CommonBindings.SetSettingsDir( utf8buffer );
+ } while( ++pi, pi->shortname != NULL );
+}
+
+void PluginManager::SetSettingsFolder( const wxString& folder )
+{
+ wxString fixedfolder( folder );
+ if( !fixedfolder.IsEmpty() && (fixedfolder[fixedfolder.length()-1] != wxFileName::GetPathSeparator() ) )
+ {
+ fixedfolder += wxFileName::GetPathSeparator();
+ }
+
+ if( m_SettingsFolder == fixedfolder ) return;
+ m_SettingsFolder = fixedfolder;
+ SendSettingsFolder();
+}
+
void PluginManager::Configure( PluginsEnum_t pid )
{
m_info[pid].CommonBindings.Configure();
diff --git a/pcsx2/Plugins.h b/pcsx2/Plugins.h
index b40d7233c9..bd21b530ea 100644
--- a/pcsx2/Plugins.h
+++ b/pcsx2/Plugins.h
@@ -171,20 +171,15 @@ struct LegacyPluginAPI_Common
void (CALLBACK* Shutdown)();
void (CALLBACK* KeyEvent)( keyEvent* evt );
+ void (CALLBACK* SetSettingsDir)( const char* dir );
s32 (CALLBACK* Freeze)(int mode, freezeData *data);
s32 (CALLBACK* Test)();
void (CALLBACK* Configure)();
void (CALLBACK* About)();
- LegacyPluginAPI_Common() :
- Init ( NULL )
- , Close ( NULL )
- , Shutdown( NULL )
- , Freeze ( NULL )
- , Test ( NULL )
- , Configure( NULL )
- , About ( NULL )
+ LegacyPluginAPI_Common()
{
+ memzero( *this );
}
};
@@ -204,10 +199,9 @@ protected:
PS2E_ComponentAPI_Mcd* Mcd;
public:
- SysPluginBindings() :
- Mcd( NULL )
+ SysPluginBindings()
{
-
+ Mcd = NULL;
}
bool McdIsPresent( uint port, uint slot );
@@ -280,18 +274,15 @@ protected:
LegacyPluginAPI_Common CommonBindings;
wxDynamicLibrary Lib;
- PluginStatus_t() :
- IsInitialized( false )
- , IsOpened( false )
- , CommonBindings()
- , Lib()
+ PluginStatus_t()
{
+ IsInitialized = false;
+ IsOpened = false;
}
};
- bool m_initialized;
-
const PS2E_LibraryAPI* m_mcdPlugin;
+ wxString m_SettingsFolder;
public: // hack until we unsuck plugins...
PluginStatus_t m_info[PluginId_Count];
@@ -312,6 +303,8 @@ public:
bool KeyEvent( const keyEvent& evt );
void Configure( PluginsEnum_t pid );
+ void SetSettingsFolder( const wxString& folder );
+ void SendSettingsFolder();
const wxString& GetName( PluginsEnum_t pid ) const { return m_info[pid].Name; }
const wxString& GetVersion( PluginsEnum_t pid ) const { return m_info[pid].Version; }
diff --git a/pcsx2/gui/App.h b/pcsx2/gui/App.h
index ded5d1bbb2..665660bfda 100644
--- a/pcsx2/gui/App.h
+++ b/pcsx2/gui/App.h
@@ -20,19 +20,11 @@
#include
#include
-#include "Utilities/EventSource.h"
#include "IniInterface.h"
-class MainEmuFrame;
-class GSFrame;
-class ConsoleLogFrame;
-class PipeRedirectionBase;
-class AppCoreThread;
-
#include "Utilities/HashMap.h"
-#include "Utilities/wxGuiTools.h"
-#include "AppConfig.h"
+#include "AppCommon.h"
#include "RecentIsoList.h"
#include "System.h"
@@ -150,22 +142,6 @@ enum MenuIdentifiers
MenuId_Config_ResetAll,
};
-enum AppEventType
-{
- // Maybe this will be expanded upon later..?
- AppStatus_Exiting
-};
-
-enum PluginEventType
-{
- PluginsEvt_Loaded,
- PluginsEvt_Init,
- PluginsEvt_Open,
- PluginsEvt_Close,
- PluginsEvt_Shutdown,
- PluginsEvt_Unloaded,
-};
-
// --------------------------------------------------------------------------------------
// KeyAcceleratorCode
diff --git a/pcsx2/gui/AppCommon.h b/pcsx2/gui/AppCommon.h
index e3eddf4012..603f015572 100644
--- a/pcsx2/gui/AppCommon.h
+++ b/pcsx2/gui/AppCommon.h
@@ -25,5 +25,27 @@
#include "Utilities/pxStaticText.h"
#include "Utilities/CheckedStaticBox.h"
+class MainEmuFrame;
+class GSFrame;
+class ConsoleLogFrame;
+class PipeRedirectionBase;
+class AppCoreThread;
+
+enum AppEventType
+{
+ // Maybe this will be expanded upon later..?
+ AppStatus_Exiting
+};
+
+enum PluginEventType
+{
+ PluginsEvt_Loaded,
+ PluginsEvt_Init,
+ PluginsEvt_Open,
+ PluginsEvt_Close,
+ PluginsEvt_Shutdown,
+ PluginsEvt_Unloaded,
+};
+
#include "AppConfig.h"
#include "Panels/BaseConfigPanel.h"
diff --git a/pcsx2/gui/AppConfig.cpp b/pcsx2/gui/AppConfig.cpp
index 3c41be2310..e36cb5c8fa 100644
--- a/pcsx2/gui/AppConfig.cpp
+++ b/pcsx2/gui/AppConfig.cpp
@@ -289,6 +289,21 @@ wxString AppConfig::FullpathTo( PluginsEnum_t pluginidx ) const
return Path::Combine( Folders.Plugins, BaseFilenames[pluginidx] );
}
+// returns true if the filenames are quite absolutely the equivalent. Works for all
+// types of filenames, relative and absolute. Very important that you use this function
+// rather than any other type of more direct string comparison!
+bool AppConfig::FullpathMatchTest( PluginsEnum_t pluginId, const wxString& cmpto ) const
+{
+ wxFileName right( cmpto );
+ wxFileName left( FullpathTo(pluginId) );
+
+ left.MakeAbsolute();
+ right.MakeAbsolute();
+
+ return left == right;
+}
+
+
wxDirName GetSettingsFolder()
{
return UseDefaultSettingsFolder ? PathDefs::GetSettings() : SettingsFolder;
diff --git a/pcsx2/gui/AppConfig.h b/pcsx2/gui/AppConfig.h
index 7c6c385372..d8c69833a1 100644
--- a/pcsx2/gui/AppConfig.h
+++ b/pcsx2/gui/AppConfig.h
@@ -187,7 +187,7 @@ public:
ConsoleLogOptions Ps2ConBox;
FolderOptions Folders;
FilenameOptions BaseFilenames;
- GSWindowOptions GSWindow;
+ GSWindowOptions GSWindow;
// PCSX2-core emulation options, which are passed to the emu core prior to initiating
// an emulation session. Note these are the options saved into the GUI ini file and
@@ -202,6 +202,8 @@ public:
wxString FullpathToMcd( uint port, uint slot ) const;
wxString FullpathTo( PluginsEnum_t pluginId ) const;
+ bool FullpathMatchTest( PluginsEnum_t pluginId, const wxString& cmpto ) const;
+
void LoadSaveUserMode( IniInterface& ini, const wxString& cwdhash );
void LoadSave( IniInterface& ini );
diff --git a/pcsx2/gui/AppMain.cpp b/pcsx2/gui/AppMain.cpp
index db5a82ae51..0bf4756890 100644
--- a/pcsx2/gui/AppMain.cpp
+++ b/pcsx2/gui/AppMain.cpp
@@ -421,10 +421,13 @@ void AppApplySettings( const AppConfig* oldconf )
g_Conf->EmuOptions.BiosFilename = g_Conf->FullpathToBios();
- RelocateLogfile();
-
ScopedCoreThreadSuspend suspend_core;
+ if( g_plugins != NULL )
+ g_plugins->SetSettingsFolder( GetSettingsFolder().ToString() );
+
+ RelocateLogfile();
+
// Update the compression attribute on the Memcards folder.
// Memcards generally compress very well via NTFS compression.
diff --git a/pcsx2/gui/Dialogs/FirstTimeWizard.cpp b/pcsx2/gui/Dialogs/FirstTimeWizard.cpp
index 5c852abc3f..1fe7112865 100644
--- a/pcsx2/gui/Dialogs/FirstTimeWizard.cpp
+++ b/pcsx2/gui/Dialogs/FirstTimeWizard.cpp
@@ -72,7 +72,7 @@ FirstTimeWizard::UsermodePage::UsermodePage( wxWizard* parent ) :
panel += 6;
panel += m_dirpick_settings | SubGroup();
- panel += panel | pxExpand;
+ *this += panel | pxExpand;
Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler(FirstTimeWizard::UsermodePage::OnUsermodeChanged) );
}
diff --git a/pcsx2/gui/MainFrame.h b/pcsx2/gui/MainFrame.h
index 57f3355846..40d18d5812 100644
--- a/pcsx2/gui/MainFrame.h
+++ b/pcsx2/gui/MainFrame.h
@@ -129,12 +129,11 @@ public:
operator const wxMenu*() const { return &MyMenu; }
};
+// --------------------------------------------------------------------------------------
+// MainEmuFrame
+// --------------------------------------------------------------------------------------
class MainEmuFrame : public wxFrame
{
-// ------------------------------------------------------------------------
-// MainEmuFrame Protected Variables
-// ------------------------------------------------------------------------
-
protected:
wxStatusBar& m_statusbar;
wxStaticBitmap m_background;
@@ -161,10 +160,6 @@ protected:
EventListenerBinding m_Listener_SettingsApplied;
EventListenerBinding m_Listener_SettingsLoadSave;
-// ------------------------------------------------------------------------
-// MainEmuFrame Constructors and Member Methods
-// ------------------------------------------------------------------------
-
public:
MainEmuFrame(wxWindow* parent, const wxString& title);
virtual ~MainEmuFrame() throw();
diff --git a/pcsx2/gui/Panels/ConfigurationPanels.h b/pcsx2/gui/Panels/ConfigurationPanels.h
index 6a23295be3..28e5974e59 100644
--- a/pcsx2/gui/Panels/ConfigurationPanels.h
+++ b/pcsx2/gui/Panels/ConfigurationPanels.h
@@ -337,8 +337,9 @@ namespace Panels
StandardPathsPanel( wxWindow* parent );
};
- //////////////////////////////////////////////////////////////////////////////////////////
- //
+ // --------------------------------------------------------------------------------------
+ // BaseSelectorPanel
+ // --------------------------------------------------------------------------------------
class BaseSelectorPanel: public BaseApplicableConfigPanel
{
public:
@@ -355,8 +356,9 @@ namespace Panels
virtual bool ValidateEnumerationStatus()=0;
};
- //////////////////////////////////////////////////////////////////////////////////////////
- //
+ // --------------------------------------------------------------------------------------
+ // BiosSelectorPanel
+ // --------------------------------------------------------------------------------------
class BiosSelectorPanel : public BaseSelectorPanel
{
protected:
@@ -375,24 +377,20 @@ namespace Panels
virtual bool ValidateEnumerationStatus();
};
- //////////////////////////////////////////////////////////////////////////////////////////
- //
+ // --------------------------------------------------------------------------------------
+ // PluginSelectorPanel
+ // --------------------------------------------------------------------------------------
class PluginSelectorPanel: public BaseSelectorPanel
{
protected:
- static const int NumPluginTypes = 7;
-
- // ------------------------------------------------------------------------
- // PluginSelectorPanel Subclasses
- // ------------------------------------------------------------------------
-
+ // ----------------------------------------------------------------------------
class EnumeratedPluginInfo
{
public:
uint PassedTest; // msk specifying which plugin types passed the mask test.
uint TypeMask; // indicates which combo boxes it should be listed in
wxString Name; // string to be pasted into the combo box
- wxString Version[NumPluginTypes];
+ wxString Version[PluginId_Count];
EnumeratedPluginInfo()
{
@@ -401,6 +399,7 @@ namespace Panels
}
};
+ // ----------------------------------------------------------------------------
class EnumThread : public Threading::PersistentThread
{
public:
@@ -422,22 +421,29 @@ namespace Panels
void ExecuteTaskInThread();
};
+ // ----------------------------------------------------------------------------
// This panel contains all of the plugin combo boxes. We stick them
// on a panel together so that we can hide/show the whole mess easily.
class ComboBoxPanel : public wxPanelWithHelpers
{
protected:
- wxComboBox* m_combobox[NumPluginTypes];
+ EventListenerBinding m_Listener_CorePluginStatus;
+
+ wxComboBox* m_combobox[PluginId_Count];
+ wxButton* m_configbutton[PluginId_Count];
DirPickerPanel& m_FolderPicker;
public:
ComboBoxPanel( PluginSelectorPanel* parent );
- wxComboBox& Get( int i ) { return *m_combobox[i]; }
+ wxComboBox& Get( PluginsEnum_t pid ) { return *m_combobox[pid]; }
+ wxButton& GetConfigButton( PluginsEnum_t pid ) { return *m_configbutton[pid]; }
wxDirName GetPluginsPath() const { return m_FolderPicker.GetPath(); }
DirPickerPanel& GetDirPicker() { return m_FolderPicker; }
void Reset();
+
};
+ // ----------------------------------------------------------------------------
class StatusPanel : public wxPanelWithHelpers
{
protected:
@@ -455,7 +461,6 @@ namespace Panels
// ------------------------------------------------------------------------
// PluginSelectorPanel Members
- // ------------------------------------------------------------------------
protected:
StatusPanel* m_StatusPanel;
@@ -465,6 +470,8 @@ namespace Panels
ScopedPtr m_FileList; // list of potential plugin files
ScopedPtr m_EnumeratorThread;
+ EventListenerBinding m_Listener_CorePluginStatus;
+
public:
virtual ~PluginSelectorPanel() throw();
PluginSelectorPanel( wxWindow* parent, int idealWidth=wxDefaultCoord );
@@ -473,8 +480,12 @@ namespace Panels
void Apply();
protected:
+ static void __evt_fastcall OnCorePluginStatusChanged( void* obj, PluginEventType& evt );
+
void OnConfigure_Clicked( wxCommandEvent& evt );
void OnShowStatusBar( wxCommandEvent& evt );
+ void OnPluginSelected( wxCommandEvent& evt );
+
virtual void OnProgress( wxCommandEvent& evt );
virtual void OnEnumComplete( wxCommandEvent& evt );
diff --git a/pcsx2/gui/Panels/PluginSelectorPanel.cpp b/pcsx2/gui/Panels/PluginSelectorPanel.cpp
index 4f8229eede..684dcbf037 100644
--- a/pcsx2/gui/Panels/PluginSelectorPanel.cpp
+++ b/pcsx2/gui/Panels/PluginSelectorPanel.cpp
@@ -45,8 +45,8 @@ DEFINE_EVENT_TYPE(pxEVT_EnumeratedNext)
DEFINE_EVENT_TYPE(pxEVT_EnumerationFinished);
DEFINE_EVENT_TYPE(pxEVT_ShowStatusBar);
-typedef s32 (CALLBACK* PluginTestFnptr)();
-typedef void (CALLBACK* PluginConfigureFnptr)();
+typedef s32 (CALLBACK* TestFnptr)();
+typedef void (CALLBACK* ConfigureFnptr)();
//////////////////////////////////////////////////////////////////////////////////////////
//
@@ -118,7 +118,7 @@ public:
bool Test( int pluginTypeIndex ) const
{
// all test functions use the same parameterless API, so just pick one arbitrarily (I pick PAD!)
- PluginTestFnptr testfunc = (PluginTestFnptr)m_plugin.GetSymbol( fromUTF8( tbl_PluginInfo[pluginTypeIndex].shortname ) + L"test" );
+ TestFnptr testfunc = (TestFnptr)m_plugin.GetSymbol( fromUTF8( tbl_PluginInfo[pluginTypeIndex].shortname ) + L"test" );
if( testfunc == NULL ) return false;
return (testfunc() == 0);
}
@@ -179,31 +179,35 @@ void Panels::PluginSelectorPanel::StatusPanel::Reset()
// Id for all Configure buttons (any non-negative arbitrary integer will do)
static const int ButtonId_Configure = 51;
-// ------------------------------------------------------------------------
+// =====================================================================================================
+// PluginSelectorPanel::ComboBoxPanel
+// =====================================================================================================
Panels::PluginSelectorPanel::ComboBoxPanel::ComboBoxPanel( PluginSelectorPanel* parent )
: wxPanelWithHelpers( parent, wxVERTICAL )
+ , m_Listener_CorePluginStatus( wxGetApp().Source_CorePluginStatus(), EventListener ( this, OnCorePluginStatusChanged ) )
, m_FolderPicker( *new DirPickerPanel( this, FolderId_Plugins,
_("Plugins Search Path:"),
_("Select a folder with PCSX2 plugins") )
)
{
- wxFlexGridSizer& s_plugin( *new wxFlexGridSizer( NumPluginTypes, 3, 16, 10 ) );
+ wxFlexGridSizer& s_plugin( *new wxFlexGridSizer( PluginId_Count, 3, 16, 10 ) );
s_plugin.SetFlexibleDirection( wxHORIZONTAL );
s_plugin.AddGrowableCol( 1 ); // expands combo boxes to full width.
- for( int i=0; iid;
+ wxStaticText* text = new wxStaticText( this, wxID_ANY, pi->GetShortname() );
- m_combobox[i] = new wxComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY );
+ m_combobox[pid] = new wxComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY );
- wxButton* confButton = new wxButton( this, ButtonId_Configure, L"Configure..." );
- confButton->SetClientData( (void*)(int)tbl_PluginInfo[i].id );
+ m_configbutton[pid] = new wxButton( this, ButtonId_Configure, L"Configure..." );
+ m_configbutton[pid]->SetClientData( (void*)(int)pid );
s_plugin += text | wxSF.Border( wxTOP | wxLEFT, 2 );
- s_plugin += m_combobox[i] | wxSF.Expand();
- s_plugin += confButton;
- }
+ s_plugin += m_combobox[pid] | wxSF.Expand();
+ s_plugin += m_configbutton[pid];
+ } while( ++pi, pi->shortname != NULL );
m_FolderPicker.SetStaticDesc( _("Click the Browse button to select a different folder for PCSX2 plugins.") );
@@ -214,17 +218,38 @@ Panels::PluginSelectorPanel::ComboBoxPanel::ComboBoxPanel( PluginSelectorPanel*
void Panels::PluginSelectorPanel::ComboBoxPanel::Reset()
{
- for( int i=0; iClear();
m_combobox[i]->SetSelection( wxNOT_FOUND );
m_combobox[i]->SetValue( wxEmptyString );
+
+ m_configbutton[i]->Disable();
}
}
-// ------------------------------------------------------------------------
+// =====================================================================================================
+// PluginSelectorPanel
+// =====================================================================================================
+void __evt_fastcall Panels::PluginSelectorPanel::OnCorePluginStatusChanged( void* obj, PluginEventType& evt )
+{
+ if( obj == NULL ) return;
+ if( (evt != PluginsEvt_Loaded) && (evt != PluginsEvt_Unloaded) ) return; // everything else we don't care about
+
+ PluginSelectorPanel& panel = *(PluginSelectorPanel*)obj;
+
+ const PluginInfo* pi = tbl_PluginInfo; do {
+ panel.m_ComponentBoxes->GetConfigButton(pi->id).Enable(
+ (panel.m_FileList==NULL) ? false :
+ g_Conf->FullpathMatchTest( pi->id, (*panel.m_FileList)[pi->id] )
+ );
+ } while( ++pi, pi->shortname != NULL );
+
+}
+
Panels::PluginSelectorPanel::PluginSelectorPanel( wxWindow* parent, int idealWidth )
: BaseSelectorPanel( parent )
+ , m_Listener_CorePluginStatus( wxGetApp().Source_CorePluginStatus(), EventListener ( this, OnCorePluginStatusChanged ) )
{
if( idealWidth != wxDefaultCoord ) m_idealWidth = idealWidth;
@@ -244,9 +269,11 @@ Panels::PluginSelectorPanel::PluginSelectorPanel( wxWindow* parent, int idealWid
//s_main.Add( refresh );
//Connect( refresh->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PluginSelectorPanel::OnRefresh ) );
- Connect( pxEVT_EnumeratedNext, wxCommandEventHandler( PluginSelectorPanel::OnProgress ) );
- Connect( pxEVT_EnumerationFinished, wxCommandEventHandler( PluginSelectorPanel::OnEnumComplete ) );
- Connect( pxEVT_ShowStatusBar, wxCommandEventHandler( PluginSelectorPanel::OnShowStatusBar ) );
+ Connect( pxEVT_EnumeratedNext, wxCommandEventHandler( PluginSelectorPanel::OnProgress ) );
+ Connect( pxEVT_EnumerationFinished, wxCommandEventHandler( PluginSelectorPanel::OnEnumComplete ) );
+ Connect( pxEVT_ShowStatusBar, wxCommandEventHandler( PluginSelectorPanel::OnShowStatusBar ) );
+ Connect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( PluginSelectorPanel::OnPluginSelected ) );
+
Connect( ButtonId_Configure, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PluginSelectorPanel::OnConfigure_Clicked ) );
OnSettingsChanged();
@@ -278,12 +305,13 @@ void Panels::PluginSelectorPanel::Apply()
AppConfig curconf( *g_Conf );
- for( int i=0; iGet(i).GetSelection();
+ const PluginsEnum_t pid = pi->id;
+ int sel = m_ComponentBoxes->Get(pid).GetSelection();
if( sel == wxNOT_FOUND )
{
- wxString plugname( tbl_PluginInfo[i].GetShortname() );
+ wxString plugname( pi->GetShortname() );
throw Exception::CannotApplySettings( this,
// English Log
@@ -294,8 +322,8 @@ void Panels::PluginSelectorPanel::Apply()
);
}
- g_Conf->BaseFilenames.Plugins[tbl_PluginInfo[i].id] = GetFilename((int)m_ComponentBoxes->Get(i).GetClientData(sel));
- }
+ g_Conf->BaseFilenames.Plugins[pid] = GetFilename((int)m_ComponentBoxes->Get(pid).GetClientData(sel));
+ } while( ++pi, pi->shortname != NULL );
// ----------------------------------------------------------------------------
// Make sure folders are up to date, and try to load/reload plugins if needed...
@@ -305,7 +333,7 @@ void Panels::PluginSelectorPanel::Apply()
// Need to unload the current emulation state if the user changed plugins, because
// the whole plugin system needs to be re-loaded.
- const PluginInfo* pi = tbl_PluginInfo; do {
+ pi = tbl_PluginInfo; do {
if( g_Conf->FullpathTo( pi->id ) != curconf.FullpathTo( pi->id ) )
break;
} while( ++pi, pi->shortname != NULL );
@@ -440,20 +468,56 @@ bool Panels::PluginSelectorPanel::ValidateEnumerationStatus()
return validated;
}
+void Panels::PluginSelectorPanel::OnPluginSelected( wxCommandEvent& evt )
+{
+ if( IsBeingDeleted() || m_ComponentBoxes->IsBeingDeleted() ) return;
+
+ const PluginInfo* pi = tbl_PluginInfo; do
+ {
+ wxComboBox& box = m_ComponentBoxes->Get(pi->id);
+ if( box.GetId() == evt.GetId() )
+ {
+ // Button is enabled if:
+ // (a) plugins aren't even loaded yet.
+ // (b) current selection matches exactly the currently configured/loaded plugin.
+
+ bool isSame = (g_plugins==NULL) || g_Conf->FullpathMatchTest( pi->id, (*m_FileList)[(int)box.GetClientData(box.GetSelection())] );
+ m_ComponentBoxes->GetConfigButton( pi->id ).Enable( isSame );
+
+ if( !isSame ) evt.Skip(); // enabled Apply button! :D
+ return;
+ }
+ } while( ++pi, pi->shortname != NULL );
+}
+
void Panels::PluginSelectorPanel::OnConfigure_Clicked( wxCommandEvent& evt )
{
+ if( IsBeingDeleted() ) return;
+
PluginsEnum_t pid = (PluginsEnum_t)(int)((wxEvtHandler*)evt.GetEventObject())->GetClientData();
int sel = m_ComponentBoxes->Get(pid).GetSelection();
if( sel == wxNOT_FOUND ) return;
- wxDynamicLibrary dynlib( (*m_FileList)[(int)m_ComponentBoxes->Get(pid).GetClientData(sel)] );
- if( PluginConfigureFnptr configfunc = (PluginConfigureFnptr)dynlib.GetSymbol( tbl_PluginInfo[pid].GetShortname() + L"configure" ) )
+ // Only allow configuration if the selected plugin matches exactly our currently loaded one.
+ // Otherwise who knows what sort of funny business could happen configuring a plugin while
+ // another instance/version is running. >_<
+
+ const wxString filename( (*m_FileList)[(int)m_ComponentBoxes->Get(pid).GetClientData(sel)] );
+
+ if( g_plugins != NULL && !g_Conf->FullpathMatchTest( pid, filename ) )
+ {
+ Console.Warning( "(PluginSelector) Plugin name mismatch, configuration request ignored." );
+ return;
+ }
+
+ wxDynamicLibrary dynlib( filename );
+
+ if( ConfigureFnptr configfunc = (ConfigureFnptr)dynlib.GetSymbol( tbl_PluginInfo[pid].GetShortname() + L"configure" ) )
{
- bool resume = CoreThread.Suspend();
wxWindowDisabler disabler;
- configfunc();
- if( resume ) CoreThread.Resume();
+ SaveSinglePluginHelper helper( pid );
+ g_plugins->Configure( pid );
}
}
@@ -472,14 +536,18 @@ void Panels::PluginSelectorPanel::OnEnumComplete( wxCommandEvent& evt )
// (for now we just force it to selection zero if nothing's selected)
int emptyBoxes = 0;
- for( int i=0; iGet(i).GetCount() <= 0 )
+ const PluginsEnum_t pid = pi->id;
+ if( m_ComponentBoxes->Get(pid).GetCount() <= 0 )
emptyBoxes++;
- else if( m_ComponentBoxes->Get(i).GetSelection() == wxNOT_FOUND )
- m_ComponentBoxes->Get(i).SetSelection( 0 );
- }
+ else if( m_ComponentBoxes->Get(pid).GetSelection() == wxNOT_FOUND )
+ {
+ m_ComponentBoxes->Get(pid).SetSelection( 0 );
+ m_ComponentBoxes->GetConfigButton(pid).Enable( g_plugins == NULL );
+ }
+ } while( ++pi, pi->shortname != NULL );
m_ComponentBoxes->Show();
m_StatusPanel->Hide();
@@ -524,28 +592,26 @@ void Panels::PluginSelectorPanel::OnProgress( wxCommandEvent& evt )
Console.Error( L"Some kinda plugin failure: " + (*m_FileList)[evtidx] );
}
- for( int i=0; iid;
+ if( result.TypeMask & pi->typemask )
{
- if( result.PassedTest & tbl_PluginInfo[i].typemask )
+ if( result.PassedTest & pi->typemask )
{
- int sel = m_ComponentBoxes->Get(i).Append( wxsFormat( L"%s %s [%s]",
- result.Name.c_str(), result.Version[i].c_str(), Path::GetFilenameWithoutExt( (*m_FileList)[evtidx] ).c_str() ),
+ int sel = m_ComponentBoxes->Get(pid).Append( wxsFormat( L"%s %s [%s]",
+ result.Name.c_str(), result.Version[pid].c_str(), Path::GetFilenameWithoutExt( (*m_FileList)[evtidx] ).c_str() ),
(void*)evtidx
);
- wxFileName left( (*m_FileList)[evtidx] );
- wxFileName right( g_Conf->FullpathTo(tbl_PluginInfo[i].id) );
-
- left.MakeAbsolute();
- right.MakeAbsolute();
-
- if( left == right )
- m_ComponentBoxes->Get(i).SetSelection( sel );
+ if( g_Conf->FullpathMatchTest( pid, (*m_FileList)[evtidx] ) )
+ {
+ m_ComponentBoxes->Get(pid).SetSelection( sel );
+ m_ComponentBoxes->GetConfigButton(pid).Enable();
+ }
}
}
- }
+ } while( ++pi, pi->shortname != NULL );
}
@@ -574,16 +640,16 @@ void Panels::PluginSelectorPanel::EnumThread::DoNextPlugin( int curidx )
PluginEnumerator penum( m_master.GetFilename( curidx ) );
result.Name = penum.GetName();
- for( int pidx=0; pidxid;
+ result.TypeMask |= pi->typemask;
if( penum.CheckVersion( pid ) )
{
result.PassedTest |= tbl_PluginInfo[pid].typemask;
- penum.GetVersionString( result.Version[pid], pidx );
+ penum.GetVersionString( result.Version[pid], pid );
}
- }
+ } while( ++pi, pi->shortname != NULL );
}
catch( Exception::BadStream& ex )
{
@@ -600,8 +666,8 @@ void Panels::PluginSelectorPanel::EnumThread::ExecuteTaskInThread()
{
DevCon.WriteLn( "Plugin Enumeration Thread started..." );
- Sleep( 15 ); // give the window some time to paint.
YieldToMain();
+ Sleep( 15 ); // give the window some time to paint.
for( int curidx=0; curidx < m_master.FileCount(); ++curidx )
{
diff --git a/pcsx2/gui/Plugins.cpp b/pcsx2/gui/Plugins.cpp
index 54076bc22b..4228bdfda2 100644
--- a/pcsx2/gui/Plugins.cpp
+++ b/pcsx2/gui/Plugins.cpp
@@ -45,6 +45,7 @@ class AppPluginManager : public PluginManager
public:
AppPluginManager( const wxString (&folders)[PluginId_Count] ) : PluginManager( folders )
{
+ SetSettingsFolder( GetSettingsFolder().ToString() );
}
virtual ~AppPluginManager() throw()
@@ -55,6 +56,8 @@ public:
void Init()
{
+ SetSettingsFolder( GetSettingsFolder().ToString() );
+
_parent::Init();
PluginEventType pevt = PluginsEvt_Init;
@@ -79,6 +82,8 @@ public:
void Open()
{
+ SetSettingsFolder( GetSettingsFolder().ToString() );
+
_parent::Open();
PluginEventType pevt = PluginsEvt_Open;
diff --git a/plugins/CDVDiso/src/CDVDiso.h b/plugins/CDVDiso/src/CDVDiso.h
index 8226a6e912..41f8d1968b 100644
--- a/plugins/CDVDiso/src/CDVDiso.h
+++ b/plugins/CDVDiso/src/CDVDiso.h
@@ -23,7 +23,6 @@
#pragma warning(disable:4018)
#endif
-#include "PS2Etypes.h"
#include "PS2Edefs.h"
#include "libiso.h"
diff --git a/plugins/CDVDiso/src/Windows/Win32.cpp b/plugins/CDVDiso/src/Windows/Win32.cpp
index 4c666218b2..03f9215b98 100755
--- a/plugins/CDVDiso/src/Windows/Win32.cpp
+++ b/plugins/CDVDiso/src/Windows/Win32.cpp
@@ -33,7 +33,7 @@ void SysMessage(char *fmt, ...)
va_start(list, fmt);
vsprintf(tmp, fmt, list);
va_end(list);
- MessageBox(0, tmp, "CDVDiso Msg", 0);
+ MessageBox(GetActiveWindow(), tmp, "CDVDiso Msg", 0);
}
int _GetFile(char *out)
diff --git a/plugins/CDVDnull/CDVD.cpp b/plugins/CDVDnull/CDVD.cpp
index 2e10927ac0..59cc06b555 100644
--- a/plugins/CDVDnull/CDVD.cpp
+++ b/plugins/CDVDnull/CDVD.cpp
@@ -48,7 +48,7 @@ void SysMessage(const char *fmt, ...)
vsprintf(tmp, fmt, list);
va_end(list);
- MessageBox(0, tmp, "CDVDnull Msg", 0);
+ MessageBox(GetActiveWindow(), tmp, "CDVDnull Msg", MB_SETFOREGROUND | MB_OK);
}
#endif
diff --git a/plugins/FWnull/FW.cpp b/plugins/FWnull/FW.cpp
index 174d1a356a..9c435a8c31 100644
--- a/plugins/FWnull/FW.cpp
+++ b/plugins/FWnull/FW.cpp
@@ -29,7 +29,6 @@ const u8 revision = 0;
const u8 build = 5; // increase that with each version
static char *libraryName = "FWnull Driver";
-string s_strIniPath="inis/FWnull.ini";
s8 *fwregs;
FILE *fwLog;
diff --git a/plugins/FWnull/Windows/Win32.cpp b/plugins/FWnull/Windows/Win32.cpp
index c09edf89f0..80a47c50f6 100644
--- a/plugins/FWnull/Windows/Win32.cpp
+++ b/plugins/FWnull/Windows/Win32.cpp
@@ -15,7 +15,7 @@ void SysMessage(char *fmt, ...) {
va_start(list,fmt);
vsprintf(tmp,fmt,list);
va_end(list);
- MessageBox(0, tmp, "FW Plugin Msg", 0);
+ MessageBox(GetActiveWindow(), tmp, "FW Plugin Msg", MB_SETFOREGROUND | MB_OK);
}
BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
diff --git a/plugins/GSdx/GS.cpp b/plugins/GSdx/GS.cpp
index 7437a4333d..d0553b0e23 100644
--- a/plugins/GSdx/GS.cpp
+++ b/plugins/GSdx/GS.cpp
@@ -79,6 +79,11 @@ EXPORT_C GSsetBaseMem(uint8* mem)
}
}
+EXPORT_C GSsetSettingsDir(const char* dir)
+{
+ theApp.SetConfigDir(dir);
+}
+
EXPORT_C_(INT32) GSinit()
{
if(!GSUtil::CheckSSE())
diff --git a/plugins/GSdx/GSUtil.cpp b/plugins/GSdx/GSUtil.cpp
index 1abf9e25db..c240b13ee5 100644
--- a/plugins/GSdx/GSUtil.cpp
+++ b/plugins/GSdx/GSUtil.cpp
@@ -181,7 +181,7 @@ bool GSUtil::CheckSSE()
{
string s = format("This CPU does not support SSE %d.%02d", _M_SSE >> 8, _M_SSE & 0xff);
- MessageBox(NULL, s.c_str(), "GSdx", MB_OK);
+ MessageBox(GetActiveWindow(), s.c_str(), "GSdx", MB_OK);
return false;
}
diff --git a/plugins/GSdx/GSdx.cpp b/plugins/GSdx/GSdx.cpp
index d5fe5c69d4..e9e54f7f52 100644
--- a/plugins/GSdx/GSdx.cpp
+++ b/plugins/GSdx/GSdx.cpp
@@ -41,7 +41,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
GSdxApp theApp;
-const char* GSdxApp::m_ini = "inis/GSdx.ini";
+std::string GSdxApp::m_ini( "inis/GSdx.ini" );
const char* GSdxApp::m_section = "Settings";
GSdxApp::GSdxApp()
@@ -53,21 +53,40 @@ HMODULE GSdxApp::GetModuleHandle()
return s_hModule;
}
+void GSdxApp::SetConfigDir(const char* dir)
+{
+ if( dir == NULL )
+ {
+ m_ini = "inis/GSdx.ini";
+ }
+ else
+ {
+ m_ini = dir;
+
+ if((m_ini[m_ini.length()-1] != '/') && (m_ini[m_ini.length()-1] != '\\'))
+ {
+ m_ini += '\\';
+ }
+
+ m_ini += "GSdx.ini";
+ }
+}
+
string GSdxApp::GetConfig(const char* entry, const char* value)
{
char buff[4096] = {0};
- GetPrivateProfileString(m_section, entry, value, buff, countof(buff), m_ini);
+ GetPrivateProfileString(m_section, entry, value, buff, countof(buff), m_ini.c_str());
return string(buff);
}
void GSdxApp::SetConfig(const char* entry, const char* value)
{
- WritePrivateProfileString(m_section, entry, value, m_ini);
+ WritePrivateProfileString(m_section, entry, value, m_ini.c_str());
}
int GSdxApp::GetConfig(const char* entry, int value)
{
- return GetPrivateProfileInt(m_section, entry, value, m_ini);
+ return GetPrivateProfileInt(m_section, entry, value, m_ini.c_str());
}
void GSdxApp::SetConfig(const char* entry, int value)
diff --git a/plugins/GSdx/GSdx.def b/plugins/GSdx/GSdx.def
index 64c849feb5..fa5ccfb804 100644
--- a/plugins/GSdx/GSdx.def
+++ b/plugins/GSdx/GSdx.def
@@ -36,6 +36,7 @@ EXPORTS
GSsetFrameLimit
GSsetVsync
GSsetExclusive
+ GSsetSettingsDir
GSgetLastTag
GSReplay
GSBenchmark
diff --git a/plugins/GSdx/GSdx.h b/plugins/GSdx/GSdx.h
index 6b1f73b1ab..93fc2c38db 100644
--- a/plugins/GSdx/GSdx.h
+++ b/plugins/GSdx/GSdx.h
@@ -23,7 +23,7 @@
class GSdxApp
{
- static const char* m_ini;
+ static std::string m_ini;
static const char* m_section;
public:
@@ -35,6 +35,8 @@ public:
void SetConfig(const char* entry, const char* value);
int GetConfig(const char* entry, int value);
void SetConfig(const char* entry, int value);
+
+ void SetConfigDir(const char* dir);
};
extern GSdxApp theApp;
\ No newline at end of file
diff --git a/plugins/GSnull/GS.cpp b/plugins/GSnull/GS.cpp
index 7d0b531fb2..9c8e5a78b9 100644
--- a/plugins/GSnull/GS.cpp
+++ b/plugins/GSnull/GS.cpp
@@ -37,7 +37,9 @@ Config conf;
u32 GSKeyEvent = 0;
bool GSShift = false, GSAlt = false;
-string s_strIniPath="inis/GSnull.ini";
+string s_strIniPath="inis";
+const char* s_iniFilename = "GSnull.ini";
+
void (*GSirq)();
EXPORT_C_(u32) PS2EgetLibType()
@@ -111,11 +113,12 @@ EXPORT_C_(s32) GSinit()
EXPORT_C_(void) GSshutdown()
{
+ SysPrintf("Shutting down GSnull\n");
+ GSCloseWindow();
+
#ifdef GS_LOG
if (gsLog) fclose(gsLog);
#endif
-
- SysPrintf("Shutting down GSnull\n");
}
EXPORT_C_(s32) GSopen(void *pDsp, char *Title, int multithread)
@@ -135,7 +138,10 @@ EXPORT_C_(s32) GSopen(void *pDsp, char *Title, int multithread)
EXPORT_C_(void) GSclose()
{
SysPrintf("Closing GSnull\n");
- GSCloseWindow();
+
+ // Better to only close the window on Shutdown. All the other plugins
+ // pretty much worked that way, and all old PCSX2 versions expect it as well.
+ //GSCloseWindow();
}
EXPORT_C_(void) GSirqCallback(void (*callback)())
diff --git a/plugins/GSnull/Windows/GSwin.cpp b/plugins/GSnull/Windows/GSwin.cpp
index c5a23aa499..f509afe056 100644
--- a/plugins/GSnull/Windows/GSwin.cpp
+++ b/plugins/GSnull/Windows/GSwin.cpp
@@ -16,7 +16,7 @@
#include "../GS.h"
HINSTANCE HInst;
-HWND GShwnd;
+HWND GShwnd = NULL;
LRESULT CALLBACK MsgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
@@ -50,13 +50,14 @@ int GSOpenWindow(void *pDsp, char *Title)
return -1;
}
- if( pDsp != NULL ) *(int*)pDsp = (int)GShwnd;
+ if( pDsp != NULL ) *(uptr*)pDsp = (uptr)GShwnd;
return 0;
}
void GSCloseWindow()
{
+ DestroyWindow( GShwnd );
}
void GSProcessMessages()
diff --git a/plugins/GSnull/Windows/Win32.cpp b/plugins/GSnull/Windows/Win32.cpp
index 42865e5561..987fbca64b 100644
--- a/plugins/GSnull/Windows/Win32.cpp
+++ b/plugins/GSnull/Windows/Win32.cpp
@@ -22,6 +22,7 @@
#include "../GS.h"
HINSTANCE hInst;
+extern HWND GShwnd;
void SysMessage(char *fmt, ...) {
va_list list;
@@ -30,7 +31,7 @@ void SysMessage(char *fmt, ...) {
va_start(list,fmt);
vsprintf(tmp,fmt,list);
va_end(list);
- MessageBox(0, tmp, "GS Plugin Msg", 0);
+ MessageBox((GShwnd!=NULL) ? GShwnd : GetActiveWindow(), tmp, "GS Plugin Msg", 0);
}
BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
diff --git a/plugins/LilyPad/Config.cpp b/plugins/LilyPad/Config.cpp
index e18eb7d55d..1fce72a7c4 100644
--- a/plugins/LilyPad/Config.cpp
+++ b/plugins/LilyPad/Config.cpp
@@ -24,6 +24,11 @@ HWND hWndProp = 0;
int selected = 0;
+// Older versions of PCSX2 don't always create the ini dir on startup, so LilyPad does it
+// for it. But if PCSX2 sets the ini path with a call to setSettingsDir, then it means
+// we shouldn't make our own.
+bool createIniDir = true;
+
HWND hWnds[2][4];
HWND hWndGeneral = 0;
@@ -267,8 +272,15 @@ wchar_t *GetCommandStringW(u8 command, int port, int slot) {
return L"";
}
-inline void GetSettingsFileName(wchar_t *out) {
- wcscpy(out, L"inis\\LilyPad.ini");
+static wchar_t iniFile[MAX_PATH*2] = L"inis\\LilyPad.ini";
+
+void CALLBACK PADsetSettingsDir(wchar_t *dir)
+{
+ // emulator assures a trailing slash/backslash (yay!)
+ wcscpy(iniFile, (dir==NULL) ? L"inis\\" : dir);
+ wcscat(iniFile, L"LilyPad.ini");
+
+ createIniDir = false;
}
int GetBinding(int port, int slot, int index, Device *&dev, Binding *&b, ForceFeedbackBinding *&ffb);
@@ -701,18 +713,14 @@ void SetVolume(int volume) {
for (int i=waveOutGetNumDevs()-1; i>=0; i--) {
waveOutSetVolume((HWAVEOUT)i, val);
}
- wchar_t ini[MAX_PATH+20];
- GetSettingsFileName(ini);
- WritePrivateProfileInt(L"General Settings", L"Volume", config.volume, ini);
+ WritePrivateProfileInt(L"General Settings", L"Volume", config.volume, iniFile);
}
int SaveSettings(wchar_t *file=0) {
- wchar_t ini[MAX_PATH+20];
// Need this either way for saving path.
- GetSettingsFileName(ini);
if (!file) {
- file = ini;
+ file = iniFile;
}
else {
wchar_t *c = wcsrchr(file, '\\');
@@ -725,8 +733,8 @@ int SaveSettings(wchar_t *file=0) {
}
DeleteFileW(file);
- WritePrivateProfileStringW(L"General Settings", L"Last Config Path", config.lastSaveConfigPath, ini);
- WritePrivateProfileStringW(L"General Settings", L"Last Config Name", config.lastSaveConfigFileName, ini);
+ WritePrivateProfileStringW(L"General Settings", L"Last Config Path", config.lastSaveConfigPath, iniFile);
+ WritePrivateProfileStringW(L"General Settings", L"Last Config Name", config.lastSaveConfigFileName, iniFile);
// Just check first, last, and all pad bindings. Should be more than enough. No real need to check
// config path.
@@ -808,16 +816,20 @@ u8 GetPrivateProfileBool(wchar_t *s1, wchar_t *s2, int def, wchar_t *ini) {
int LoadSettings(int force, wchar_t *file) {
if (dm && !force) return 0;
- CreateDirectory(L"inis", 0);
+
+ if( createIniDir )
+ {
+ CreateDirectory(L"inis", 0);
+ createIniDir = false;
+ }
+
// Could just do ClearDevices() instead, but if I ever add any extra stuff,
// this will still work.
UnloadConfigs();
dm = new InputDeviceManager();
- wchar_t ini[MAX_PATH+20];
- GetSettingsFileName(ini);
if (!file) {
- file = ini;
+ file = iniFile;
GetPrivateProfileStringW(L"General Settings", L"Last Config Path", L"inis", config.lastSaveConfigPath, sizeof(config.lastSaveConfigPath), file);
GetPrivateProfileStringW(L"General Settings", L"Last Config Name", L"LilyPad.lily", config.lastSaveConfigFileName, sizeof(config.lastSaveConfigFileName), file);
}
@@ -828,8 +840,8 @@ int LoadSettings(int force, wchar_t *file) {
wcscpy(config.lastSaveConfigPath, file);
wcscpy(config.lastSaveConfigFileName, c+1);
*c = '\\';
- WritePrivateProfileStringW(L"General Settings", L"Last Config Path", config.lastSaveConfigPath, ini);
- WritePrivateProfileStringW(L"General Settings", L"Last Config Name", config.lastSaveConfigFileName, ini);
+ WritePrivateProfileStringW(L"General Settings", L"Last Config Path", config.lastSaveConfigPath, iniFile);
+ WritePrivateProfileStringW(L"General Settings", L"Last Config Name", config.lastSaveConfigFileName, iniFile);
}
}
diff --git a/plugins/LilyPad/Global.h b/plugins/LilyPad/Global.h
index 9d4d39eff0..233041a05e 100644
--- a/plugins/LilyPad/Global.h
+++ b/plugins/LilyPad/Global.h
@@ -52,7 +52,6 @@ inline void * realloc(void *mem, size_t size);
// Only needed for DBT_DEVNODES_CHANGED
#include
-#include "PS2Etypes.h"
#include "PS2Edefs.h"
extern HINSTANCE hInst;
diff --git a/plugins/LilyPad/LilyPad.cpp b/plugins/LilyPad/LilyPad.cpp
index df38b41635..ba039a2838 100644
--- a/plugins/LilyPad/LilyPad.cpp
+++ b/plugins/LilyPad/LilyPad.cpp
@@ -948,7 +948,7 @@ s32 CALLBACK PADopen(void *pDsp) {
}
else {
openCount = 0;
- MessageBoxA(0,
+ MessageBoxA(GetActiveWindow(),
"Invalid Window handle passed to LilyPad.\n"
"\n"
"Either your emulator or gs plugin is buggy,\n"
diff --git a/plugins/LilyPad/LilyPad.def b/plugins/LilyPad/LilyPad.def
index 43ea74abed..b422fe418d 100644
--- a/plugins/LilyPad/LilyPad.def
+++ b/plugins/LilyPad/LilyPad.def
@@ -21,4 +21,5 @@ EXPORTS
PADupdate
PADfreeze
PADsetSlot
+ PADsetSettingsDir
PADqueryMtap
diff --git a/plugins/USBnull/USB.cpp b/plugins/USBnull/USB.cpp
index 3afa17d50f..4fde055f80 100644
--- a/plugins/USBnull/USB.cpp
+++ b/plugins/USBnull/USB.cpp
@@ -1,5 +1,5 @@
-/* USBlinuz
- * Copyright (C) 2002-2005 USBlinuz Team
+/* USBnull
+ * Copyright (C) 2002-2009 PCSX2 Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -29,7 +29,7 @@ const unsigned char revision = 0;
const unsigned char build = 6; // increase that with each version
static char *libraryName = "USBnull Driver";
-string s_strIniPath="inis/USBnull.ini";
+
//void (*USBirq)();
USBcallback USBirq;
Config conf;
diff --git a/plugins/USBnull/Windows/Win32.cpp b/plugins/USBnull/Windows/Win32.cpp
index 412b836d5b..d62646aadc 100644
--- a/plugins/USBnull/Windows/Win32.cpp
+++ b/plugins/USBnull/Windows/Win32.cpp
@@ -14,7 +14,7 @@ void SysMessage(char *fmt, ...) {
va_start(list,fmt);
vsprintf(tmp,fmt,list);
va_end(list);
- MessageBox(0, tmp, "USBnull Msg", 0);
+ MessageBox(GetActiveWindow(), tmp, "USBnull Msg", MB_SETFOREGROUND | MB_OK);
}
BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
diff --git a/plugins/cdvdGigaherz/src/CDVD.cpp b/plugins/cdvdGigaherz/src/CDVD.cpp
index 8aadec64a1..951e99252e 100644
--- a/plugins/cdvdGigaherz/src/CDVD.cpp
+++ b/plugins/cdvdGigaherz/src/CDVD.cpp
@@ -127,6 +127,11 @@ char bfr[2352];
///////////////////////////////////////////////////////////////////////////////
// CDVD Pluin Interface //
+void CALLBACK CDVDsetSettingsDir(const char* dir)
+{
+ CfgSetSettingsDir(dir);
+}
+
s32 CALLBACK CDVDinit()
{
return 0;
diff --git a/plugins/cdvdGigaherz/src/CDVD.h b/plugins/cdvdGigaherz/src/CDVD.h
index bb3f0890f0..748d5a9c7d 100644
--- a/plugins/cdvdGigaherz/src/CDVD.h
+++ b/plugins/cdvdGigaherz/src/CDVD.h
@@ -137,6 +137,7 @@ s32 cdvdGetMediaType();
void ReadSettings();
void WriteSettings();
+void CfgSetSettingsDir( const char* dir );
extern char csrc[];
extern BOOL cdvd_is_open;
diff --git a/plugins/cdvdGigaherz/src/Windows/cdvdGigaherz2008.vcproj b/plugins/cdvdGigaherz/src/Windows/cdvdGigaherz2008.vcproj
index c1ebea976a..5f4e182c65 100644
--- a/plugins/cdvdGigaherz/src/Windows/cdvdGigaherz2008.vcproj
+++ b/plugins/cdvdGigaherz/src/Windows/cdvdGigaherz2008.vcproj
@@ -1,7 +1,7 @@
+
+
diff --git a/plugins/cdvdGigaherz/src/Windows/config.cpp b/plugins/cdvdGigaherz/src/Windows/config.cpp
index e2a0a18f65..4092ef7ec5 100644
--- a/plugins/cdvdGigaherz/src/Windows/config.cpp
+++ b/plugins/cdvdGigaherz/src/Windows/config.cpp
@@ -27,9 +27,19 @@
// DEBUG
char source_drive;
-char source_file[256];
+char source_file[MAX_PATH];
-char CfgFile[]="inis\\cdvdGigaherz.ini";
+char CfgFile[MAX_PATH+10] = "inis\\cdvdGigaherz.ini";
+
+void CfgSetSettingsDir( const char* dir )
+{
+ // a better std::string version, but it's inconvenient for other reasons.
+ //CfgFile = std::string(( dir == NULL ) ? "inis\\" : dir) + "cdvdGigaherz.ini";
+
+ // emulator assures a trailing slash/backslash (yay!)
+ strcpy_s(CfgFile, (dir==NULL) ? "inis\\" : dir);
+ strcat_s(CfgFile, "cdvdGigaherz.ini");
+}
/*| Config File Format: |ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ*\
diff --git a/plugins/dev9null/DEV9.cpp b/plugins/dev9null/DEV9.cpp
index 42842824ec..ff1b3d2307 100644
--- a/plugins/dev9null/DEV9.cpp
+++ b/plugins/dev9null/DEV9.cpp
@@ -26,7 +26,6 @@ const unsigned char revision = 0;
const unsigned char build = 4; // increase that with each version
const char *libraryName = "DEV9null Driver";
-string s_strIniPath="inis/DEV9null.ini";
void (*DEV9irq)(int);
FILE *dev9Log;
diff --git a/plugins/spu2-x/src/PS2E-spu2.cpp b/plugins/spu2-x/src/PS2E-spu2.cpp
index 3c00c0a615..56a6888c51 100644
--- a/plugins/spu2-x/src/PS2E-spu2.cpp
+++ b/plugins/spu2-x/src/PS2E-spu2.cpp
@@ -20,6 +20,8 @@
#include "dma.h"
#include "Dialogs.h"
+#include "x86emitter/tools.h"
+
#ifdef _MSC_VER
# include "svnrev.h"
#endif
@@ -41,8 +43,9 @@ HINSTANCE hInstance;
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved)
{
if( dwReason == DLL_PROCESS_ATTACH )
+ {
hInstance = hinstDLL;
-
+ }
else if( dwReason == DLL_PROCESS_DETACH )
{
// TODO : perform shutdown procedure, just in case PCSX2 itself failed
@@ -103,11 +106,16 @@ static void InitLibraryName()
}
-#include "x86emitter/tools.h"
+static bool cpu_detected = false;
static bool CheckSSE()
{
- cpudetectInit();
+ if( !cpu_detected )
+ {
+ cpudetectInit();
+ cpu_detected = true;
+ }
+
if( !x86caps.hasStreamingSIMDExtensions || !x86caps.hasStreamingSIMD2Extensions )
{
SysMessage( "Your CPU does not support SSE2 instructions.\nThe SPU2-X plugin requires SSE2 to run." );
@@ -182,6 +190,11 @@ EXPORT_C_(void) CALLBACK SPU2setDMABaseAddr(uptr baseaddr)
DMABaseAddr = (u16*)baseaddr;
}
+EXPORT_C_(void) CALLBACK SPU2setSettingsDir(const char* dir)
+{
+ CfgSetSettingsDir( dir );
+}
+
EXPORT_C_(void) CALLBACK SPU2readDMA4Mem(u16 *pMem, u32 size) // size now in 16bit units
{
if( cyclePtr != NULL ) TimeUpdate( *cyclePtr );
@@ -321,11 +334,18 @@ EXPORT_C_(s32) SPU2init()
return 0;
}
+uptr gsWindowHandle = 0;
+
EXPORT_C_(s32) SPU2open(void *pDsp)
{
if( IsOpened ) return 0;
FileLog("[%10d] SPU2 Open\n",Cycles);
+
+ if( pDsp != NULL )
+ gsWindowHandle = *(uptr*)pDsp;
+ else
+ gsWindowHandle = 0;
/*
if(debugDialogOpen==0)
@@ -345,8 +365,9 @@ EXPORT_C_(s32) SPU2open(void *pDsp)
DspLoadLibrary(dspPlugin,dspPluginModule);
WaveDump::Open();
}
- catch( ... )
+ catch( std::exception& ex )
{
+ fprintf( stderr, "SPU2-X Error: Could not initialize device, or something.\nReason: %s", ex.what() );
SPU2close();
return -1;
}
diff --git a/plugins/spu2-x/src/Windows/CfgHelpers.cpp b/plugins/spu2-x/src/Windows/CfgHelpers.cpp
index cb38b463ba..2d964ee6cd 100644
--- a/plugins/spu2-x/src/Windows/CfgHelpers.cpp
+++ b/plugins/spu2-x/src/Windows/CfgHelpers.cpp
@@ -18,6 +18,10 @@
#include "Global.h"
#include "Dialogs.h"
+#include "Utilities/StringHelpers.h"
+
+extern uptr gsWindowHandle;
+
void SysMessage(const char *fmt, ...)
{
va_list list;
@@ -28,23 +32,31 @@ void SysMessage(const char *fmt, ...)
vsprintf_s(tmp,fmt,list);
va_end(list);
swprintf_s(wtmp, L"%S", tmp);
- MessageBox( GetActiveWindow(), wtmp, L"SPU2-X System Message", MB_OK | MB_SETFOREGROUND);
+ MessageBox( (!!gsWindowHandle) ? (HWND)gsWindowHandle : GetActiveWindow(), wtmp,
+ L"SPU2-X System Message", MB_OK | MB_SETFOREGROUND);
}
void SysMessage(const wchar_t *fmt, ...)
{
va_list list;
- wchar_t wtmp[512];
-
va_start(list,fmt);
- vswprintf_s(wtmp,fmt,list);
+ wxString wtmp;
+ wtmp.PrintfV( fmt, list );
va_end(list);
- MessageBox( GetActiveWindow(), wtmp, L"SPU2-X System Message", MB_OK | MB_SETFOREGROUND);
+ MessageBox( (!!gsWindowHandle) ? (HWND)gsWindowHandle : GetActiveWindow(), wtmp,
+ L"SPU2-X System Message", MB_OK | MB_SETFOREGROUND);
}
//////
-const TCHAR CfgFile[] = L"inis\\SPU2-X.ini";
+#include "Utilities/Path.h"
+
+static wxString CfgFile( L"inis\\SPU2-X.ini" );
+
+void CfgSetSettingsDir( const char* dir )
+{
+ CfgFile = Path::Combine( (dir==NULL) ? wxString(L"inis") : fromUTF8(dir), L"SPU2-X.ini" );
+}
/*| Config File Format: |ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ*\
diff --git a/plugins/spu2-x/src/Windows/Config.cpp b/plugins/spu2-x/src/Windows/Config.cpp
index d2059a031f..fdc4eae152 100644
--- a/plugins/spu2-x/src/Windows/Config.cpp
+++ b/plugins/spu2-x/src/Windows/Config.cpp
@@ -292,7 +292,7 @@ void configure()
ret = DialogBoxParam(hInstance,MAKEINTRESOURCE(IDD_CONFIG),GetActiveWindow(),(DLGPROC)ConfigProc,1);
if(ret==-1)
{
- MessageBoxEx(GetActiveWindow(),L"Error Opening the config dialog.",L"OMG ERROR!",MB_OK,0);
+ MessageBox(GetActiveWindow(),L"Error Opening the config dialog.",L"OMG ERROR!",MB_OK | MB_SETFOREGROUND);
return;
}
ReadSettings();
diff --git a/plugins/spu2-x/src/Windows/ConfigDebug.cpp b/plugins/spu2-x/src/Windows/ConfigDebug.cpp
index ef38cd54e4..f029f329d2 100644
--- a/plugins/spu2-x/src/Windows/ConfigDebug.cpp
+++ b/plugins/spu2-x/src/Windows/ConfigDebug.cpp
@@ -220,7 +220,7 @@ void OpenDialog()
INT_PTR ret = DialogBoxParam(hInstance,MAKEINTRESOURCE(IDD_CONFIG_DEBUG),GetActiveWindow(),(DLGPROC)DialogProc,1);
if(ret == -1)
{
- MessageBoxEx(GetActiveWindow(),L"Error Opening the debug configuration dialog.",L"OMG ERROR!",MB_OK,0);
+ MessageBox(GetActiveWindow(),L"Error Opening the debug configuration dialog.",L"OMG ERROR!",MB_OK | MB_SETFOREGROUND);
return;
}
ReadSettings();
diff --git a/plugins/spu2-x/src/Windows/ConfigSoundtouch.cpp b/plugins/spu2-x/src/Windows/ConfigSoundtouch.cpp
index dd524b736f..c71992186e 100644
--- a/plugins/spu2-x/src/Windows/ConfigSoundtouch.cpp
+++ b/plugins/spu2-x/src/Windows/ConfigSoundtouch.cpp
@@ -121,7 +121,7 @@ void SoundtouchCfg::OpenDialog( HWND hWnd )
ret = DialogBox( hInstance, MAKEINTRESOURCE(IDD_CONFIG_SOUNDTOUCH), hWnd, (DLGPROC)DialogProc );
if(ret==-1)
{
- MessageBoxEx(GetActiveWindow(), L"Error Opening the Soundtouch advanced dialog.", L"OMG ERROR!", MB_OK, 0);
+ MessageBox(GetActiveWindow(), L"Error Opening the Soundtouch advanced dialog.", L"OMG ERROR!", MB_OK | MB_SETFOREGROUND);
return;
}
ReadSettings();
diff --git a/plugins/spu2-x/src/Windows/Dialogs.h b/plugins/spu2-x/src/Windows/Dialogs.h
index 0568591da7..02807e6e06 100644
--- a/plugins/spu2-x/src/Windows/Dialogs.h
+++ b/plugins/spu2-x/src/Windows/Dialogs.h
@@ -47,6 +47,7 @@ extern void AssignSliderValue( HWND hWnd, int idc, int editbox, int value );
extern int GetSliderValue( HWND hWnd, int idc );
extern BOOL DoHandleScrollMessage( HWND hwndDisplay, WPARAM wParam, LPARAM lParam );
+extern void CfgSetSettingsDir( const char* dir );
extern bool CfgFindName( const TCHAR *Section, const TCHAR* Name);
extern void CfgWriteBool(const TCHAR* Section, const TCHAR* Name, bool Value);
diff --git a/plugins/spu2-x/src/Windows/SndOut_DSound.cpp b/plugins/spu2-x/src/Windows/SndOut_DSound.cpp
index 4edb1131f7..032bab5e6b 100644
--- a/plugins/spu2-x/src/Windows/SndOut_DSound.cpp
+++ b/plugins/spu2-x/src/Windows/SndOut_DSound.cpp
@@ -417,7 +417,7 @@ public:
ret=DialogBoxParam(hInstance,MAKEINTRESOURCE(IDD_DSOUND),(HWND)parent,(DLGPROC)ConfigProc,1);
if(ret==-1)
{
- MessageBoxEx((HWND)parent,L"Error Opening the config dialog.",L"OMG ERROR!",MB_OK,0);
+ MessageBox((HWND)parent,L"Error Opening the config dialog.",L"OMG ERROR!",MB_OK | MB_SETFOREGROUND);
return;
}
}
diff --git a/plugins/spu2-x/src/Windows/SndOut_waveOut.cpp b/plugins/spu2-x/src/Windows/SndOut_waveOut.cpp
index 378c0871de..96fa2dde5f 100644
--- a/plugins/spu2-x/src/Windows/SndOut_waveOut.cpp
+++ b/plugins/spu2-x/src/Windows/SndOut_waveOut.cpp
@@ -277,7 +277,7 @@ public:
ret=DialogBoxParam(hInstance,MAKEINTRESOURCE(IDD_WAVEOUT), (HWND)parent, (DLGPROC)ConfigProc,1);
if(ret==-1)
{
- MessageBoxEx((HWND)parent, L"Error Opening the config dialog.", L"OMG ERROR!", MB_OK, 0);
+ MessageBox((HWND)parent, L"Error Opening the config dialog.", L"OMG ERROR!", MB_OK | MB_SETFOREGROUND);
return;
}
}
diff --git a/plugins/zerospu2/Linux/Linux.cpp b/plugins/zerospu2/Linux/Linux.cpp
index 1d4fe18420..a987844db8 100644
--- a/plugins/zerospu2/Linux/Linux.cpp
+++ b/plugins/zerospu2/Linux/Linux.cpp
@@ -30,7 +30,6 @@ extern "C" {
#include "zerospu2.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()
@@ -118,11 +117,6 @@ 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();
@@ -173,15 +167,12 @@ void CALLBACK SPU2about()
void SaveConfig()
{
- FILE *f;
- char cfg[255];
-
- strcpy(cfg, s_strIniPath.c_str());
+ string iniFile( s_strIniPath + "zerospu2.ini" );
- f = fopen(cfg,"w");
+ FILE* f = fopen(iniFile.c_str(),"w");
if (f == NULL)
{
- ERROR_LOG("Failed to open %s\n", s_strIniPath.c_str());
+ ERROR_LOG("Failed to open %s\n", iniFile.c_str());
return;
}
@@ -196,20 +187,18 @@ void SaveConfig()
fclose(f);
}
-void LoadConfig()
+void LoadConfig()
{
- FILE *f;
- char cfg[255];
int temp;
memset(&conf, 0, sizeof(conf));
- strcpy(cfg, s_strIniPath.c_str());
+ string iniFile( s_strIniPath + "zerospu2.ini" );
- f = fopen(cfg, "r");
+ FILE* f = fopen(iniFile.c_str(), "r");
if (f == NULL)
{
- ERROR_LOG("Failed to open %s\n", s_strIniPath.c_str());
+ ERROR_LOG("Failed to open %s\n", iniFile.c_str());
conf.Log = 0;
conf.options = 0;
SaveConfig();//save and return
diff --git a/plugins/zerospu2/Windows/Win32.cpp b/plugins/zerospu2/Windows/Win32.cpp
index 15ba6591f9..aab484d1b6 100644
--- a/plugins/zerospu2/Windows/Win32.cpp
+++ b/plugins/zerospu2/Windows/Win32.cpp
@@ -24,6 +24,7 @@
#include "resource.h"
extern HINSTANCE hInst;
+extern HWND hWMain;
/////////
// GUI //
/////////
@@ -38,7 +39,7 @@ void SysMessage(char *fmt, ...)
vsprintf_s(tmp,fmt,list);
va_end(list);
- MessageBox(0, tmp, "SPU2NULL Msg", 0);
+ MessageBox((hWMain==NULL) ? GetActiveWindow() : hWMain, tmp, "ZeroSPU2 Msg", MB_SETFOREGROUND | MB_OK);
}
BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
@@ -117,6 +118,7 @@ void CALLBACK SPU2about()
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUT), GetActiveWindow(), (DLGPROC)AboutDlgProc);
}
+
// DLL INIT
BOOL APIENTRY DllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
{
@@ -124,44 +126,32 @@ BOOL APIENTRY DllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
return TRUE; // very quick :)
}
-void SaveConfig()
+void SaveConfig()
{
Config *Conf1 = &conf;
- char *szTemp;
- char szIniFile[256], szValue[256];
+ char szValue[256];
- GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
- szTemp = strrchr(szIniFile, '\\');
+ string iniFile( s_strIniPath + "zerospu2.ini" );
- if(!szTemp) return;
- szTemp[0] = 0; // this modifies szInitFile also.
-
- strcat_s(szIniFile, "\\inis\\zerospu2.ini");
sprintf_s(szValue,"%u",Conf1->Log);
- WritePrivateProfileString("Interface", "Logging",szValue,szIniFile);
+ WritePrivateProfileString("Interface", "Logging",szValue, iniFile.c_str());
sprintf_s(szValue,"%u",Conf1->options);
- WritePrivateProfileString("Interface", "Options",szValue,szIniFile);
+ WritePrivateProfileString("Interface", "Options",szValue, iniFile.c_str());
}
void LoadConfig()
{
FILE *fp;
Config *Conf1 = &conf;
- char *szTemp;
- char szIniFile[256], szValue[256];
+ char szValue[256];
- GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
- szTemp = strrchr(szIniFile, '\\');
+ string iniFile( s_strIniPath + "zerospu2.ini" );
- if(!szTemp) return ;
- szTemp[0] = 0;
-
- strcat_s(szIniFile, "\\inis\\zerospu2.ini");
- fopen_s(&fp, "inis\\zerospu2.ini","rt");//check if zerospu2.ini really exists
+ fopen_s(&fp, iniFile.c_str(), "rt");//check if zerospu2.ini really exists
if (!fp)
{
- CreateDirectory("inis",NULL);
+ CreateDirectory(s_strIniPath.c_str(), NULL);
memset(&conf, 0, sizeof(conf));
conf.Log = 0;//default value
conf.options = OPTION_TIMESTRETCH;
@@ -170,9 +160,9 @@ void LoadConfig()
}
fclose(fp);
- GetPrivateProfileString("Interface", "Logging", NULL, szValue, 20, szIniFile);
+ GetPrivateProfileString("Interface", "Logging", NULL, szValue, 20, iniFile.c_str());
Conf1->Log = strtoul(szValue, NULL, 10);
- GetPrivateProfileString("Interface", "Options", NULL, szValue, 20, szIniFile);
+ GetPrivateProfileString("Interface", "Options", NULL, szValue, 20, iniFile.c_str());
Conf1->options = strtoul(szValue, NULL, 10);
return;
diff --git a/plugins/zerospu2/Windows/dsound51.cpp b/plugins/zerospu2/Windows/dsound51.cpp
index dbf7bd51f1..2abb826ac5 100644
--- a/plugins/zerospu2/Windows/dsound51.cpp
+++ b/plugins/zerospu2/Windows/dsound51.cpp
@@ -26,7 +26,7 @@
//4*48*73
#define SOUNDSIZE 76800
-HWND hWMain;
+HWND hWMain = NULL;
LPDIRECTSOUND lpDS;
LPDIRECTSOUNDBUFFER lpDSBPRIMARY = NULL;
@@ -49,7 +49,7 @@ int SetupSound()
dsval = DirectSoundCreate(NULL,&lpDS,NULL);
if(dsval != DS_OK)
{
- MessageBox(NULL,"DirectSoundCreate!","Error",MB_OK);
+ MessageBox(hWMain,"DirectSoundCreate!","Error",MB_OK);
return -1;
}
@@ -57,7 +57,7 @@ int SetupSound()
{
if(DS_OK != IDirectSound_SetCooperativeLevel(lpDS,hWMain, DSSCL_NORMAL))
{
- MessageBox(NULL,"SetCooperativeLevel!","Error",MB_OK);
+ MessageBox(hWMain,"SetCooperativeLevel!","Error",MB_OK);
return -1;
}
}
@@ -71,7 +71,7 @@ int SetupSound()
dsval = IDirectSound_CreateSoundBuffer(lpDS,&dsbd,&lpDSBPRIMARY,NULL);
if(dsval != DS_OK)
{
- MessageBox(NULL, "CreateSoundBuffer (Primary)", "Error",MB_OK);
+ MessageBox(hWMain, "CreateSoundBuffer (Primary)", "Error",MB_OK);
return -1;
}
@@ -89,7 +89,7 @@ int SetupSound()
dsval = IDirectSoundBuffer_SetFormat(lpDSBPRIMARY,&pcmwf);
if(dsval != DS_OK)
{
- MessageBox(NULL, "SetFormat!", "Error",MB_OK);
+ MessageBox(hWMain, "SetFormat!", "Error",MB_OK);
return -1;
}
@@ -112,7 +112,7 @@ int SetupSound()
dsval = IDirectSound_CreateSoundBuffer(lpDS,&dsbdesc,&lpDSBSECONDARY1,NULL);
if(dsval != DS_OK)
{
- MessageBox(NULL,"CreateSoundBuffer (Secondary1)", "Error",MB_OK);
+ MessageBox(hWMain,"CreateSoundBuffer (Secondary1)", "Error",MB_OK);
return -1;
}
}
@@ -120,14 +120,14 @@ int SetupSound()
dsval = IDirectSoundBuffer_Play(lpDSBPRIMARY,0,0,DSBPLAY_LOOPING);
if(dsval != DS_OK)
{
- MessageBox(NULL,"Play (Primary)","Error",MB_OK);
+ MessageBox(hWMain,"Play (Primary)","Error",MB_OK);
return -1;
}
dsval = IDirectSoundBuffer_Play(lpDSBSECONDARY1,0,0,DSBPLAY_LOOPING);
if(dsval != DS_OK)
{
- MessageBox(NULL,"Play (Secondary1)","Error",MB_OK);
+ MessageBox(hWMain,"Play (Secondary1)","Error",MB_OK);
return -1;
}
diff --git a/plugins/zerospu2/zerospu2.cpp b/plugins/zerospu2/zerospu2.cpp
index fcb46f22e9..84b4abc07d 100644
--- a/plugins/zerospu2/zerospu2.cpp
+++ b/plugins/zerospu2/zerospu2.cpp
@@ -52,7 +52,7 @@ s32 s_buffers[NSSIZE][2]; // left and right buffers
// mixer thread variables
static bool s_bThreadExit = true;
static s32 s_nDropPacket = 0;
-string s_strIniPath="inis/zerospu2.ini";
+string s_strIniPath( "inis/" );
#ifdef _WIN32
LARGE_INTEGER g_counterfreq;
@@ -202,6 +202,11 @@ void __LogToConsole(const char *fmt, ...)
va_end(list);
}
+void CALLBACK SPU2setSettingsDir(const char* dir)
+{
+ s_strIniPath = (dir==NULL) ? "inis/" : dir;
+}
+
s32 CALLBACK SPU2init()
{
LOG_CALLBACK("SPU2init()\n");
@@ -213,11 +218,6 @@ s32 CALLBACK SPU2init()
#ifdef _WIN32
QueryPerformanceFrequency(&g_counterfreq);
-#else
- char strcurdir[256];
- getcwd(strcurdir, 256);
- s_strIniPath = strcurdir;
- s_strIniPath += "/inis/zerospu2.ini";
#endif
spu2regs = (s8*)malloc(0x10000);
diff --git a/plugins/zerospu2/zerospu2.h b/plugins/zerospu2/zerospu2.h
index d68142c779..0ca4130940 100644
--- a/plugins/zerospu2/zerospu2.h
+++ b/plugins/zerospu2/zerospu2.h
@@ -34,6 +34,7 @@
using namespace std;
extern FILE *spu2Log;
+extern string s_strIniPath;
// Prints most of the function names of the callbacks as they are called by pcsx2.
// I'm keeping the code in because I have a feeling it will come in handy.