(Most Plugins) Updated plugins to obey PCSX2's ini folder requests. This will fix problems with plugins failing to save settings on Vista/Win7 due to lack of Admin rights, and also ensures all the plugin inis show up where you would expect them to.

Fixed a couple UI bugs: FirstTime Wizard display bug and the "Configure..." button in the plugin control panel grays out when it should.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2361 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
Jake.Stine 2009-12-19 18:30:56 +00:00
parent 53357b9efc
commit 9f41fc4793
51 changed files with 460 additions and 294 deletions

View File

@ -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;

View File

@ -13,7 +13,8 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
// This file is just for backwards compatability.
// This file is just for backwards compatibility.
#ifndef __PS2ETYPES_H__
#define __PS2ETYPES_H__

View File

@ -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();

View File

@ -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; }

View File

@ -20,19 +20,11 @@
#include <wx/imaglist.h>
#include <wx/apptrait.h>
#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

View File

@ -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"

View File

@ -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;

View File

@ -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 );

View File

@ -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.

View File

@ -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) );
}

View File

@ -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<int> m_Listener_SettingsApplied;
EventListenerBinding<IniInterface> m_Listener_SettingsLoadSave;
// ------------------------------------------------------------------------
// MainEmuFrame Constructors and Member Methods
// ------------------------------------------------------------------------
public:
MainEmuFrame(wxWindow* parent, const wxString& title);
virtual ~MainEmuFrame() throw();

View File

@ -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<PluginEventType> 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<wxArrayString> m_FileList; // list of potential plugin files
ScopedPtr<EnumThread> m_EnumeratorThread;
EventListenerBinding<PluginEventType> 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 );

View File

@ -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<PluginEventType> ( 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; i<NumPluginTypes; ++i )
const PluginInfo* pi = tbl_PluginInfo; do
{
wxStaticText* text = new wxStaticText( this, wxID_ANY, tbl_PluginInfo[i].GetShortname() );
const PluginsEnum_t pid = pi->id;
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; i<NumPluginTypes; ++i )
for( int i=0; i<PluginId_Count; ++i )
{
m_combobox[i]->Clear();
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<PluginEventType> ( 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; i<NumPluginTypes; ++i )
const PluginInfo* pi = tbl_PluginInfo; do
{
int sel = m_ComponentBoxes->Get(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; i<NumPluginTypes; ++i )
const PluginInfo* pi = tbl_PluginInfo; do
{
if( m_ComponentBoxes->Get(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; i<NumPluginTypes; ++i )
const PluginInfo* pi = tbl_PluginInfo; do
{
if( result.TypeMask & tbl_PluginInfo[i].typemask )
const PluginsEnum_t pid = pi->id;
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; pidx<PluginId_Count; ++pidx )
const PluginInfo* pi = tbl_PluginInfo; do
{
const PluginsEnum_t pid = (PluginsEnum_t)pidx;
result.TypeMask |= tbl_PluginInfo[pid].typemask;
const PluginsEnum_t pid = pi->id;
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 )
{

View File

@ -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;

View File

@ -23,7 +23,6 @@
#pragma warning(disable:4018)
#endif
#include "PS2Etypes.h"
#include "PS2Edefs.h"
#include "libiso.h"

View File

@ -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)

View File

@ -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

View File

@ -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;

View File

@ -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) {

View File

@ -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())

View File

@ -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;
}

View File

@ -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)

View File

@ -36,6 +36,7 @@ EXPORTS
GSsetFrameLimit
GSsetVsync
GSsetExclusive
GSsetSettingsDir
GSgetLastTag
GSReplay
GSBenchmark

View File

@ -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;

View File

@ -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)())

View File

@ -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()

View File

@ -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) {

View File

@ -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);
}
}

View File

@ -52,7 +52,6 @@ inline void * realloc(void *mem, size_t size);
// Only needed for DBT_DEVNODES_CHANGED
#include <Dbt.h>
#include "PS2Etypes.h"
#include "PS2Edefs.h"
extern HINSTANCE hInst;

View File

@ -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"

View File

@ -21,4 +21,5 @@ EXPORTS
PADupdate
PADfreeze
PADsetSlot
PADsetSettingsDir
PADqueryMtap

View File

@ -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;

View File

@ -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) {

View File

@ -127,6 +127,11 @@ char bfr[2352];
///////////////////////////////////////////////////////////////////////////////
// CDVD Pluin Interface //
void CALLBACK CDVDsetSettingsDir(const char* dir)
{
CfgSetSettingsDir(dir);
}
s32 CALLBACK CDVDinit()
{
return 0;

View File

@ -137,6 +137,7 @@ s32 cdvdGetMediaType();
void ReadSettings();
void WriteSettings();
void CfgSetSettingsDir( const char* dir );
extern char csrc[];
extern BOOL cdvd_is_open;

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Version="9.00"
Name="cdvdGigaherz"
ProjectGUID="{5CF88D5F-64DD-4EDC-9F1A-436BD502940A}"
RootNamespace="cdvdGigaherz"
@ -248,6 +248,10 @@
RelativePath=".\cdvdGigaherz.rc"
>
</File>
<File
RelativePath=".\plugin.def"
>
</File>
</Filter>
</Files>
<Globals>

View File

@ -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: |¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯*\

View File

@ -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;

View File

@ -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;
}

View File

@ -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: |¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯*\

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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);

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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

View File

@ -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;

View File

@ -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;
}

View File

@ -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);

View File

@ -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.