From 70bc8167f8af6aa053b9335209c80f554d8fb597 Mon Sep 17 00:00:00 2001 From: hrydgard Date: Fri, 23 Jan 2009 21:28:55 +0000 Subject: [PATCH] Warp back to 1983!!! (rev 1983, that is, not the year :P) git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1997 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Src/Common.h | 1 - Source/Core/Common/Src/Plugin.cpp | 24 +-- Source/Core/Common/Src/Plugin.h | 46 +++-- Source/Core/Common/Src/PluginPAD.h | 22 ++- Source/Core/Common/Src/PluginVideo.cpp | 8 +- Source/Core/Common/Src/PluginVideo.h | 27 ++- Source/Core/Core/Core.vcproj | 4 +- Source/Core/Core/Src/Core.cpp | 15 +- Source/Core/Core/Src/HW/SI.cpp | 5 +- .../Core/Src/HW/SI_DeviceGCController.cpp | 5 +- Source/Core/Core/Src/PluginManager.cpp | 158 ++++++------------ Source/Core/Core/Src/PluginManager.h | 11 +- Source/Core/Core/Src/SConscript | 2 +- Source/Core/DebuggerWX/DebuggerWX.vcproj | 4 +- Source/Core/DiscIO/Src/BannerLoader.cpp | 4 +- Source/Core/DiscIO/Src/BannerLoaderWii.cpp | 5 - Source/Core/DolphinWX/Src/ConfigMain.cpp | 55 +++--- Source/Core/DolphinWX/Src/Frame.cpp | 6 +- Source/Core/DolphinWX/Src/FrameTools.cpp | 12 +- Source/Core/InputCommon/InputCommon.vcproj | 22 +-- Source/Core/InputCommon/Src/InputManager.cpp | 94 ----------- Source/Core/InputCommon/Src/InputManager.h | 43 ----- Source/Core/InputCommon/Src/SConscript | 1 - Source/MusicMod.sln | 3 - Source/PluginSpecs/PluginSpecs.h | 1 - Source/PluginSpecs/pluginspecs_pad.h | 2 +- Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp | 102 +++++------ Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.h | 2 - .../Plugins/Plugin_nJoy_Testing/Src/nJoy.cpp | 114 ++++++++----- 29 files changed, 294 insertions(+), 504 deletions(-) delete mode 100644 Source/Core/InputCommon/Src/InputManager.cpp delete mode 100644 Source/Core/InputCommon/Src/InputManager.h diff --git a/Source/Core/Common/Src/Common.h b/Source/Core/Common/Src/Common.h index 712006c1d2..7df31f7cb7 100644 --- a/Source/Core/Common/Src/Common.h +++ b/Source/Core/Common/Src/Common.h @@ -38,7 +38,6 @@ #include "../../../PluginSpecs/CommonTypes.h" #define HAVE_WIIUSE 1 - #define HAVE_SDL 1 #define HAVE_WX 1 #else #include "CommonTypes.h" diff --git a/Source/Core/Common/Src/Plugin.cpp b/Source/Core/Common/Src/Plugin.cpp index dd67c76b3b..15bd184bcf 100644 --- a/Source/Core/Common/Src/Plugin.cpp +++ b/Source/Core/Common/Src/Plugin.cpp @@ -37,10 +37,8 @@ CPlugin::~CPlugin() CPlugin::CPlugin(const char* _szName) : valid(false) { - if (m_hInstLib.Load(_szName)) - { + if (m_hInstLib.Load(_szName)) { - // Create pointers to the DLL functions m_GetDllInfo = reinterpret_cast (m_hInstLib.Get("GetDllInfo")); m_DllConfig = reinterpret_cast @@ -58,28 +56,24 @@ CPlugin::CPlugin(const char* _szName) : valid(false) } if (m_GetDllInfo != 0 && - m_DllConfig != 0 && - m_DllDebugger != 0 && - m_SetDllGlobals != 0 && - m_Initialize != 0 && - m_Shutdown != 0 && - m_DoState != 0) + m_DllConfig != 0 && + m_DllDebugger != 0 && + m_SetDllGlobals != 0 && + m_Initialize != 0 && + m_Shutdown != 0 && + m_DoState != 0) valid = true; - // Save the filename for this plugin - Filename = _szName; } -void *CPlugin::LoadSymbol(const char *sym) -{ +void *CPlugin::LoadSymbol(const char *sym) { return m_hInstLib.Get(sym); } // ______________________________________________________________________________________ // GetInfo: Get DLL info -bool CPlugin::GetInfo(PLUGIN_INFO& _pluginInfo) -{ +bool CPlugin::GetInfo(PLUGIN_INFO& _pluginInfo) { if (m_GetDllInfo != 0) { m_GetDllInfo(&_pluginInfo); diff --git a/Source/Core/Common/Src/Plugin.h b/Source/Core/Common/Src/Plugin.h index 553b2419ed..0be36eeb24 100644 --- a/Source/Core/Common/Src/Plugin.h +++ b/Source/Core/Common/Src/Plugin.h @@ -36,37 +36,35 @@ class CPlugin { public: - CPlugin(const char* _szName); - ~CPlugin(); + CPlugin(const char* _szName); + ~CPlugin(); - virtual bool IsValid() {return valid;}; - virtual std::string GetFilename() {return Filename;}; + virtual bool IsValid() {return valid;}; - bool GetInfo(PLUGIN_INFO& _pluginInfo); - void SetGlobals(PLUGIN_GLOBALS* _PluginGlobals); - void *LoadSymbol(const char *sym); + bool GetInfo(PLUGIN_INFO& _pluginInfo); + void SetGlobals(PLUGIN_GLOBALS* _PluginGlobals); + void *LoadSymbol(const char *sym); - void Config(HWND _hwnd); - void About(HWND _hwnd); - void Debug(HWND _hwnd, bool Show); - void DoState(unsigned char **ptr, int mode); - void Initialize(void *init); - void Shutdown(); + void Config(HWND _hwnd); + void About(HWND _hwnd); + void Debug(HWND _hwnd, bool Show); + void DoState(unsigned char **ptr, int mode); + void Initialize(void *init); + void Shutdown(); private: - DynamicLibrary m_hInstLib; - bool valid; - std::string Filename; + DynamicLibrary m_hInstLib; + bool valid; - // Functions - TGetDllInfo m_GetDllInfo; - TDllConfig m_DllConfig; - TDllDebugger m_DllDebugger; - TSetDllGlobals m_SetDllGlobals; - TInitialize m_Initialize; - TShutdown m_Shutdown; - TDoState m_DoState; + // Functions + TGetDllInfo m_GetDllInfo; + TDllConfig m_DllConfig; + TDllDebugger m_DllDebugger; + TSetDllGlobals m_SetDllGlobals; + TInitialize m_Initialize; + TShutdown m_Shutdown; + TDoState m_DoState; }; } // end of namespace Common diff --git a/Source/Core/Common/Src/PluginPAD.h b/Source/Core/Common/Src/PluginPAD.h index fa779ac069..755c581011 100644 --- a/Source/Core/Common/Src/PluginPAD.h +++ b/Source/Core/Common/Src/PluginPAD.h @@ -4,27 +4,25 @@ #include "pluginspecs_pad.h" #include "Plugin.h" -namespace Common -{ +namespace Common { typedef void (__cdecl* TPAD_GetStatus)(u8, SPADStatus*); typedef void (__cdecl* TPAD_Input)(u16, u8); typedef void (__cdecl* TPAD_Rumble)(u8, unsigned int, unsigned int); typedef unsigned int (__cdecl* TPAD_GetAttachedPads)(); - class PluginPAD : public CPlugin - { + class PluginPAD : public CPlugin { public: - PluginPAD(const char *_Filename); - ~PluginPAD(); - virtual bool IsValid() {return validPAD;}; + PluginPAD(const char *_Filename); + ~PluginPAD(); + virtual bool IsValid() {return validPAD;}; - TPAD_GetStatus PAD_GetStatus; - TPAD_Input PAD_Input; - TPAD_Rumble PAD_Rumble; - TPAD_GetAttachedPads PAD_GetAttachedPads; + TPAD_GetStatus PAD_GetStatus; + TPAD_Input PAD_Input; + TPAD_Rumble PAD_Rumble; + TPAD_GetAttachedPads PAD_GetAttachedPads; private: - bool validPAD; + bool validPAD; }; } diff --git a/Source/Core/Common/Src/PluginVideo.cpp b/Source/Core/Common/Src/PluginVideo.cpp index 9b9f3db06c..b3330a42ed 100644 --- a/Source/Core/Common/Src/PluginVideo.cpp +++ b/Source/Core/Common/Src/PluginVideo.cpp @@ -1,11 +1,7 @@ #include "PluginVideo.h" -namespace Common -{ - PluginVideo::PluginVideo(const char *_Filename) : - CPlugin(_Filename), - validVideo(false) - { +namespace Common { + PluginVideo::PluginVideo(const char *_Filename) : CPlugin(_Filename), validVideo(false) { Video_Prepare = reinterpret_cast (LoadSymbol("Video_Prepare")); diff --git a/Source/Core/Common/Src/PluginVideo.h b/Source/Core/Common/Src/PluginVideo.h index bb3f16f691..f679191177 100644 --- a/Source/Core/Common/Src/PluginVideo.h +++ b/Source/Core/Common/Src/PluginVideo.h @@ -13,23 +13,22 @@ namespace Common { typedef void (__cdecl* TVideo_AddMessage)(const char* pstr, unsigned int milliseconds); typedef void (__cdecl* TVideo_Stop)(); - class PluginVideo : public CPlugin - { - public: - PluginVideo(const char *_Filename); - ~PluginVideo(); - virtual bool IsValid() {return validVideo;}; + class PluginVideo : public CPlugin { + public: + PluginVideo(const char *_Filename); + ~PluginVideo(); + virtual bool IsValid() {return validVideo;}; - TVideo_Prepare Video_Prepare; - TVideo_SendFifoData Video_SendFifoData; - TVideo_UpdateXFB Video_UpdateXFB; - TVideo_Screenshot Video_Screenshot; - TVideo_EnterLoop Video_EnterLoop; - TVideo_AddMessage Video_AddMessage; - TVideo_Stop Video_Stop; + TVideo_Prepare Video_Prepare; + TVideo_SendFifoData Video_SendFifoData; + TVideo_UpdateXFB Video_UpdateXFB; + TVideo_Screenshot Video_Screenshot; + TVideo_EnterLoop Video_EnterLoop; + TVideo_AddMessage Video_AddMessage; + TVideo_Stop Video_Stop; private: - bool validVideo; + bool validVideo; }; } diff --git a/Source/Core/Core/Core.vcproj b/Source/Core/Core/Core.vcproj index fca0197913..af0d405876 100644 --- a/Source/Core/Core/Core.vcproj +++ b/Source/Core/Core/Core.vcproj @@ -1,7 +1,7 @@ Initialize(&PADInitialize); - - // Check if joypad open failed, in that case try again - if(PADInitialize.padNumber == -1) - { - Plugins.GetPad(i)->Shutdown(); - Plugins.FreePad(); - Plugins.GetPad(i)->Initialize(&PADInitialize); - } - } + if(Plugins.OkayToInitPlugin(i)) Plugins.GetPAD(i)->Initialize((void *)&PADInitialize); } // Load and Init WiimotePlugin - only if we are booting in wii mode diff --git a/Source/Core/Core/Src/HW/SI.cpp b/Source/Core/Core/Src/HW/SI.cpp index e0355d30de..88bfbd59a9 100644 --- a/Source/Core/Core/Src/HW/SI.cpp +++ b/Source/Core/Core/Src/HW/SI.cpp @@ -254,8 +254,9 @@ void Init() g_Channel[i].m_InHi.Hex = 0; g_Channel[i].m_InLo.Hex = 0; - // Access the pap - Common::PluginPAD* pad = CPluginManager::GetInstance().GetPad(i); + // Access the pad and check the MAXPADS limit + Common::PluginPAD* pad = CPluginManager::GetInstance().GetPAD((i >= MAXPADS) ? (MAXPADS - 1): i); + //Common::PluginPAD* pad = CPluginManager::GetInstance().GetPAD(i); // Check if this pad is attached for the current plugin if (pad != NULL && (pad->PAD_GetAttachedPads() & (1 << i))) diff --git a/Source/Core/Core/Src/HW/SI_DeviceGCController.cpp b/Source/Core/Core/Src/HW/SI_DeviceGCController.cpp index a9bab50773..f133bb247a 100644 --- a/Source/Core/Core/Src/HW/SI_DeviceGCController.cpp +++ b/Source/Core/Core/Src/HW/SI_DeviceGCController.cpp @@ -120,7 +120,8 @@ CSIDevice_GCController::GetData(u32& _Hi, u32& _Low) SPADStatus PadStatus; memset(&PadStatus, 0 ,sizeof(PadStatus)); Common::PluginPAD* pad = - CPluginManager::GetInstance().GetPad(ISIDevice::m_iDeviceNumber); + //CPluginManager::GetInstance().GetPAD(ISIDevice::m_iDeviceNumber); + CPluginManager::GetInstance().GetPAD((ISIDevice::m_iDeviceNumber >= MAXPADS) ? (MAXPADS - 1): ISIDevice::m_iDeviceNumber); pad->PAD_GetStatus(ISIDevice::m_iDeviceNumber, &PadStatus); _Hi = (u32)((u8)PadStatus.stickY); @@ -147,7 +148,7 @@ CSIDevice_GCController::GetData(u32& _Hi, u32& _Low) void CSIDevice_GCController::SendCommand(u32 _Cmd) { - Common::PluginPAD* pad = CPluginManager::GetInstance().GetPad(0); + Common::PluginPAD* pad = CPluginManager::GetInstance().GetPAD(0); UCommand command(_Cmd); switch(command.Command) diff --git a/Source/Core/Core/Src/PluginManager.cpp b/Source/Core/Core/Src/PluginManager.cpp index b4b0ce0257..b6d8159a4e 100644 --- a/Source/Core/Core/Src/PluginManager.cpp +++ b/Source/Core/Core/Src/PluginManager.cpp @@ -34,8 +34,6 @@ #include "ConsoleWindow.h" CPluginManager CPluginManager::m_Instance; - -//#define INPUTCOMMON ////////////////////////////////////////////// @@ -46,26 +44,14 @@ CPluginManager::CPluginManager() : m_params(SConfig::GetInstance().m_LocalCoreStartupParameter) { m_PluginGlobals = new PLUGIN_GLOBALS; - - m_PluginGlobals->eventHandler = EventHandler::GetInstance(); m_PluginGlobals->config = (void *)&SConfig::GetInstance(); m_PluginGlobals->messageLogger = NULL; - #ifdef INPUTCOMMON - m_InputManager = new InputManager(); - m_PluginGlobals->inputManager = m_InputManager; - #endif } -/* Function: FreeLibrary() - Called from: In an attempt to avoid the crash that occurs when the use LoadLibrary() and - FreeLibrary() often (every game a game is stopped and started) these functions will only - be used when - 1. Dolphin is started - 2. A plugin is changed - 3. Dolphin is closed - it will not be used when we Start and Stop games. */ +// Function: FreeLibrary() +// Called from: This will be called when Dolphin is closed, not when we Stop a game CPluginManager::~CPluginManager() { Console::Print("Delete CPluginManager\n"); @@ -122,7 +108,7 @@ bool CPluginManager::InitPlugins() for (int i = 0; i < MAXPADS; i++) { if (! m_params.m_strPadPlugin[i].empty()) - GetPad(i); + GetPAD(i); if (m_pad[i] != NULL) pad = true; } @@ -162,8 +148,8 @@ void CPluginManager::ShutdownPlugins() { //Console::Print("Shutdown: %i\n", i); m_pad[i]->Shutdown(); - //delete m_pad[i]; - } + } + //delete m_pad[i]; //m_pad[i] = NULL; } @@ -171,10 +157,10 @@ void CPluginManager::ShutdownPlugins() if (m_wiimote[i]) m_wiimote[i]->Shutdown(); if (m_video) - m_video->Shutdown(); + m_video->Shutdown(); if (m_dsp) - m_dsp->Shutdown(); + m_dsp->Shutdown(); } ////////////////////////////////////////// @@ -182,34 +168,31 @@ void CPluginManager::ShutdownPlugins() ////////////////////////////////////////////////////////////////////////////////////////// // Supporting functions // ŻŻŻŻŻŻŻŻŻŻŻŻ -// Called from: Get__() functions in this file only (not from anywhere else) -void *CPluginManager::LoadPlugin(const char *_rFilename, int Number)//, PLUGIN_TYPE type) + + +void *CPluginManager::LoadPlugin(const char *_rFilename)//, PLUGIN_TYPE type) { CPluginInfo info(_rFilename); PLUGIN_TYPE type = info.GetPluginInfo().Type; - //std::string Filename = info.GetPluginInfo().Filename; - std::string Filename = _rFilename; - Common::CPlugin *plugin = NULL; - + Common::CPlugin *plugin = NULL; switch (type) { case PLUGIN_TYPE_VIDEO: plugin = new Common::PluginVideo(_rFilename); break; - case PLUGIN_TYPE_DSP: - plugin = new Common::PluginDSP(_rFilename); + case PLUGIN_TYPE_PAD: + plugin = new Common::PluginPAD(_rFilename); break; - case PLUGIN_TYPE_PAD: - plugin = new Common::PluginPAD(_rFilename); + case PLUGIN_TYPE_DSP: + plugin = new Common::PluginDSP(_rFilename); break; case PLUGIN_TYPE_WIIMOTE: plugin = new Common::PluginWiimote(_rFilename); break; - - default: + default: PanicAlert("Trying to load unsupported type %d", type); } @@ -229,13 +212,15 @@ void *CPluginManager::LoadPlugin(const char *_rFilename, int Number)//, PLUGIN_T // ------------- int CPluginManager::OkayToInitPlugin(int Plugin) { + //Console::Print("OkayToInitShutdown: %i", Plugin); // Compare it to the earlier plugins for(int i = 0; i < Plugin; i++) if (m_params.m_strPadPlugin[Plugin] == m_params.m_strPadPlugin[i]) + { + //Console::Print("(%i %i) %s\n", Plugin, i, g_CoreStartupParameter.m_strPadPlugin[Plugin].c_str()); return i; - - // No there is no duplicate plugin - return -1; + } + return -1; } @@ -286,67 +271,52 @@ void CPluginManager::ScanForPlugins() ////////////////////////////////////////////////////////////////////////////////////////// -/* Create or return the already created plugin pointers. This will be called often for the - Pad and Wiimote from the SI_.cpp files. */ +// Create or return the already created plugin pointers // ŻŻŻŻŻŻŻŻŻŻŻŻ -Common::PluginPAD *CPluginManager::GetPad(int controller) +Common::PluginPAD *CPluginManager::GetPAD(int controller) { - if (m_pad[controller] != NULL) - if (m_pad[controller]->GetFilename() == m_params.m_strPadPlugin[controller]) - return m_pad[controller]; - - // Else do this - if(OkayToInitPlugin(controller) == -1) + if (m_pad[controller] == NULL) { - m_pad[controller] = (Common::PluginPAD*)LoadPlugin(m_params.m_strPadPlugin[controller].c_str(), controller); - Console::Print("LoadPlugin: %i\n", controller); + if(OkayToInitPlugin(controller) == -1) + { + m_pad[controller] = (Common::PluginPAD*)LoadPlugin(m_params.m_strPadPlugin[controller].c_str()); + Console::Print("LoadPlugin: %i\n", controller); + } + else + { + Console::Print("Pointed: %i to %i\n", controller, OkayToInitPlugin(controller)); + m_pad[controller] = m_pad[OkayToInitPlugin(controller)]; + } } - else - { - Console::Print("Pointed: %i to %i\n", controller, OkayToInitPlugin(controller)); - m_pad[controller] = m_pad[OkayToInitPlugin(controller)]; - } - return m_pad[controller]; + + //Console::Print("Returned: %i\n", controller); + return m_pad[controller]; } Common::PluginWiimote *CPluginManager::GetWiimote(int controller) { - if (m_pad[controller] != NULL) - if (m_wiimote[controller]->GetFilename() == m_params.m_strWiimotePlugin[controller]) - return m_wiimote[controller]; + if (m_wiimote[controller] == NULL) + m_wiimote[controller] = (Common::PluginWiimote*)LoadPlugin + (m_params.m_strWiimotePlugin[controller].c_str()); - // Else load a new plugin - m_wiimote[controller] = (Common::PluginWiimote*)LoadPlugin(m_params.m_strWiimotePlugin[controller].c_str()); return m_wiimote[controller]; } Common::PluginDSP *CPluginManager::GetDSP() { - if (m_dsp != NULL) - if (m_dsp->GetFilename() == m_params.m_strDSPPlugin) - return m_dsp; - // Else load a new plugin + if (m_dsp == NULL) m_dsp = (Common::PluginDSP*)LoadPlugin(m_params.m_strDSPPlugin.c_str()); + return m_dsp; } -Common::PluginVideo *CPluginManager::GetVideo() -{ - if (m_video != NULL) - if (m_video->GetFilename() == m_params.m_strVideoPlugin) - return m_video; +Common::PluginVideo *CPluginManager::GetVideo() { - // Else load a new plugin + if (m_video == NULL) m_video = (Common::PluginVideo*)LoadPlugin(m_params.m_strVideoPlugin.c_str()); + return m_video; } -Common::PluginPAD *CPluginManager::FreePad() -{ - delete m_pad[0]; - m_pad[0] = NULL; m_pad[1] = NULL; m_pad[2] = NULL; m_pad[3] = NULL; - m_pad[0] = (Common::PluginPAD*)LoadPlugin(m_params.m_strPadPlugin[0].c_str(), 0); - return m_pad[0]; -} /////////////////////////////////////////// @@ -355,33 +325,15 @@ Common::PluginPAD *CPluginManager::FreePad() // ŻŻŻŻŻŻŻŻŻŻŻŻ // ---------------------------------------- -// Open config window. Input: _rFilename = Plugin filename , Type = Plugin type +// Open config window. _rFilename = plugin filename , ret = the dll slot number // ------------- -void CPluginManager::OpenConfig(void* _Parent, const char *_rFilename, PLUGIN_TYPE Type) +void CPluginManager::OpenConfig(void* _Parent, const char *_rFilename) { - #ifdef INPUTCOMMON - m_InputManager->Init(); - #endif - switch(Type) - { - case PLUGIN_TYPE_VIDEO: - GetVideo()->Config((HWND)_Parent); - break; - case PLUGIN_TYPE_DSP: - GetDSP()->Config((HWND)_Parent); - break; - case PLUGIN_TYPE_PAD: - GetPad(0)->Config((HWND)_Parent); - break; - case PLUGIN_TYPE_WIIMOTE: - GetWiimote(0)->Config((HWND)_Parent); - break; - } - - #ifdef INPUTCOMMON - m_InputManager->Shutdown(); - #endif + Common::CPlugin *plugin = new Common::CPlugin(_rFilename); + plugin->SetGlobals(m_PluginGlobals); + plugin->Config((HWND)_Parent); + delete plugin; } // ---------------------------------------- @@ -389,14 +341,10 @@ void CPluginManager::OpenConfig(void* _Parent, const char *_rFilename, PLUGIN_TY // ------------- void CPluginManager::OpenDebug(void* _Parent, const char *_rFilename, PLUGIN_TYPE Type, bool Show) { - switch(Type) - { - case PLUGIN_TYPE_VIDEO: + if (Type == PLUGIN_TYPE_VIDEO) { GetVideo()->Debug((HWND)_Parent, Show); - break; - case PLUGIN_TYPE_DSP: + } else if (Type == PLUGIN_TYPE_DSP) { GetDSP()->Debug((HWND)_Parent, Show); - break; } } diff --git a/Source/Core/Core/Src/PluginManager.h b/Source/Core/Core/Src/PluginManager.h index 0348f25e5b..f71c92cce0 100644 --- a/Source/Core/Core/Src/PluginManager.h +++ b/Source/Core/Core/Src/PluginManager.h @@ -25,7 +25,6 @@ #include "PluginWiimote.h" #include "EventHandler.h" #include "CoreParameter.h" -#include "InputManager.h" class CPluginInfo { @@ -47,23 +46,20 @@ class CPluginManager { public: static CPluginManager& GetInstance() {return(m_Instance);} - Common::PluginPAD *GetPad(int controller); + Common::PluginPAD *GetPAD(int controller); Common::PluginWiimote *GetWiimote(int controller); Common::PluginDSP *GetDSP(); Common::PluginVideo *GetVideo(); - Common::PluginPAD *FreePad(); bool InitPlugins(); void ShutdownPlugins(); int OkayToInitPlugin(int Plugin); void ScanForPlugins(); - void OpenConfig(void* _Parent, const char *_rFilename, PLUGIN_TYPE Type); + void OpenConfig(void* _Parent, const char *_rFilename); void OpenDebug(void* _Parent, const char *_rFilename, PLUGIN_TYPE Type, bool Show); const CPluginInfos& GetPluginInfos() {return(m_PluginInfos);} PLUGIN_GLOBALS* GetGlobals(); - private: - static CPluginManager m_Instance; bool m_Initialized; @@ -74,11 +70,10 @@ private: Common::PluginWiimote *m_wiimote[4]; Common::PluginDSP *m_dsp; - InputManager *m_InputManager; SCoreStartupParameter& m_params; CPluginManager(); ~CPluginManager(); - void *LoadPlugin(const char *_rFilename, int Number = 0); + void *LoadPlugin(const char *_rFilename); }; diff --git a/Source/Core/Core/Src/SConscript b/Source/Core/Core/Src/SConscript index 45a289b431..9838f39e16 100644 --- a/Source/Core/Core/Src/SConscript +++ b/Source/Core/Core/Src/SConscript @@ -15,7 +15,7 @@ files = ["Console.cpp", "PatchEngine.cpp", "State.cpp", "Tracer.cpp", - "PluginManager.cpp", + 'PluginManager.cpp', "VolumeHandler.cpp", "Boot/Boot.cpp", "Boot/Boot_BIOSEmu.cpp", diff --git a/Source/Core/DebuggerWX/DebuggerWX.vcproj b/Source/Core/DebuggerWX/DebuggerWX.vcproj index e1e6379768..f71ee20ce3 100644 --- a/Source/Core/DebuggerWX/DebuggerWX.vcproj +++ b/Source/Core/DebuggerWX/DebuggerWX.vcproj @@ -1,7 +1,7 @@ m_Comment[0]); @@ -138,9 +136,6 @@ CBannerLoaderWii::GetName(std::string& _rName, DiscIO::IVolume::ECountry languag _rName = StupidWideCharToString(pBanner->m_Comment[0], WII_BANNER_COMMENT_SIZE); return true; } -#else - _rName = StupidWideCharToString(pBanner->m_Comment[0], WII_BANNER_COMMENT_SIZE); -#endif return true; } diff --git a/Source/Core/DolphinWX/Src/ConfigMain.cpp b/Source/Core/DolphinWX/Src/ConfigMain.cpp index bd039df4d6..cbe147539e 100644 --- a/Source/Core/DolphinWX/Src/ConfigMain.cpp +++ b/Source/Core/DolphinWX/Src/ConfigMain.cpp @@ -22,7 +22,6 @@ #include #include "Core.h" // Core -#include "ConsoleWindow.h" // Core #include "Globals.h" // Local #include "ConfigMain.h" @@ -682,23 +681,18 @@ void CConfigMain::DVDRootChanged(wxFileDirPickerEvent& WXUNUSED (event)) { SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDVDRoot = DVDRoot->GetPath().ToAscii(); } -// ========================== - - -// ======================================================= -// Plugins settings -// ------------- - -// Update plugin filenames void CConfigMain::OnSelectionChanged(wxCommandEvent& WXUNUSED (event)) { GetFilename(GraphicSelection, SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoPlugin); GetFilename(DSPSelection, SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDSPPlugin); + for (int i = 0; i < MAXPADS; i++) - GetFilename(PADSelection, SConfig::GetInstance().m_LocalCoreStartupParameter.m_strPadPlugin[i]); + GetFilename(PADSelection, SConfig::GetInstance().m_LocalCoreStartupParameter.m_strPadPlugin[i]); + for (int i = 0; i < MAXWIIMOTES; i++) GetFilename(WiimoteSelection, SConfig::GetInstance().m_LocalCoreStartupParameter.m_strWiimotePlugin[i]); + } void CConfigMain::OnConfig(wxCommandEvent& event) @@ -722,25 +716,15 @@ void CConfigMain::OnConfig(wxCommandEvent& event) break; } } +// ========================== -void CConfigMain::CallConfig(wxChoice* _pChoice) -{ - int Index = _pChoice->GetSelection(); - Console::Print("CallConfig: %i\n", Index); - if (Index >= 0) - { - const CPluginInfo* pInfo = static_cast(_pChoice->GetClientData(Index)); - - if (pInfo != NULL) - CPluginManager::GetInstance().OpenConfig((HWND) this->GetHandle(), pInfo->GetFileName().c_str(), pInfo->GetPluginInfo().Type); - } -} +// ======================================================= +// Plugins settings +// ------------- void CConfigMain::FillChoiceBox(wxChoice* _pChoice, int _PluginType, const std::string& _SelectFilename) { - Console::Print("FillChoiceBox\n"); - _pChoice->Clear(); int Index = -1; @@ -766,16 +750,31 @@ void CConfigMain::FillChoiceBox(wxChoice* _pChoice, int _PluginType, const std:: _pChoice->Select(Index); } -bool CConfigMain::GetFilename(wxChoice* _pChoice, std::string& _rFilename) -{ - _rFilename.clear(); +void CConfigMain::CallConfig(wxChoice* _pChoice) +{ int Index = _pChoice->GetSelection(); + if (Index >= 0) + { + const CPluginInfo* pInfo = static_cast(_pChoice->GetClientData(Index)); + + if (pInfo != NULL) + CPluginManager::GetInstance().OpenConfig((HWND) this->GetHandle(), pInfo->GetFileName().c_str()); + } +} + +bool CConfigMain::GetFilename(wxChoice* _pChoice, std::string& _rFilename) +{ + _rFilename.clear(); + + int Index = _pChoice->GetSelection(); + printf("%i\n", Index); + if (Index >= 0) { const CPluginInfo* pInfo = static_cast(_pChoice->GetClientData(Index)); _rFilename = pInfo->GetFileName(); - Console::Print("GetFilename: %i %s\n", Index, _rFilename.c_str()); + printf("%s\n", _rFilename.c_str()); return(true); } diff --git a/Source/Core/DolphinWX/Src/Frame.cpp b/Source/Core/DolphinWX/Src/Frame.cpp index e4a55b99a4..af08c306c1 100644 --- a/Source/Core/DolphinWX/Src/Frame.cpp +++ b/Source/Core/DolphinWX/Src/Frame.cpp @@ -435,7 +435,7 @@ void CFrame::OnKeyDown(wxKeyEvent& event) else { if(Core::GetState() != Core::CORE_UNINITIALIZED) - CPluginManager::GetInstance().GetPad(0)->PAD_Input(event.GetKeyCode(), 1); // 1 = Down + CPluginManager::GetInstance().GetPAD(0)->PAD_Input(event.GetKeyCode(), 1); // 1 = Down event.Skip(); } } @@ -443,7 +443,7 @@ void CFrame::OnKeyDown(wxKeyEvent& event) void CFrame::OnKeyUp(wxKeyEvent& event) { if(Core::GetState() != Core::CORE_UNINITIALIZED) - CPluginManager::GetInstance().GetPad(0)->PAD_Input(event.GetKeyCode(), 0); // 0 = Up + CPluginManager::GetInstance().GetPAD(0)->PAD_Input(event.GetKeyCode(), 0); // 0 = Up event.Skip(); } @@ -453,7 +453,7 @@ void CFrame::OnKeyUp(wxKeyEvent& event) double GetDoubleTime() { wxDateTime datetime = wxDateTime::UNow(); // Get timestamp - u64 TmpSeconds = Common::Timer::GetTimeSinceJan1970(); // Get continuous timestamp + u64 TmpSeconds = Common::Timer::GetTimeSinceJan1970(); // Get continous timestamp /* Remove a few years. We only really want enough seconds to make sure that we are detecting actual actions, perhaps 60 seconds is enough really, but I leave a diff --git a/Source/Core/DolphinWX/Src/FrameTools.cpp b/Source/Core/DolphinWX/Src/FrameTools.cpp index ef5eb3e6f8..d25dafc9e8 100644 --- a/Source/Core/DolphinWX/Src/FrameTools.cpp +++ b/Source/Core/DolphinWX/Src/FrameTools.cpp @@ -539,8 +539,7 @@ void CFrame::OnPluginGFX(wxCommandEvent& WXUNUSED (event)) { CPluginManager::GetInstance().OpenConfig( GetHandle(), - SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoPlugin.c_str(), - PLUGIN_TYPE_VIDEO + SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoPlugin.c_str() ); } @@ -549,8 +548,7 @@ void CFrame::OnPluginDSP(wxCommandEvent& WXUNUSED (event)) { CPluginManager::GetInstance().OpenConfig( GetHandle(), - SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDSPPlugin.c_str(), - PLUGIN_TYPE_DSP + SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDSPPlugin.c_str() ); } @@ -558,16 +556,14 @@ void CFrame::OnPluginPAD(wxCommandEvent& WXUNUSED (event)) { CPluginManager::GetInstance().OpenConfig( GetHandle(), - SConfig::GetInstance().m_LocalCoreStartupParameter.m_strPadPlugin[0].c_str(), - PLUGIN_TYPE_PAD + SConfig::GetInstance().m_LocalCoreStartupParameter.m_strPadPlugin[0].c_str() ); } void CFrame::OnPluginWiimote(wxCommandEvent& WXUNUSED (event)) { CPluginManager::GetInstance().OpenConfig( GetHandle(), - SConfig::GetInstance().m_LocalCoreStartupParameter.m_strWiimotePlugin[0].c_str(), - PLUGIN_TYPE_WIIMOTE + SConfig::GetInstance().m_LocalCoreStartupParameter.m_strWiimotePlugin[0].c_str() ); } diff --git a/Source/Core/InputCommon/InputCommon.vcproj b/Source/Core/InputCommon/InputCommon.vcproj index 932f84b920..7176f2bdd3 100644 --- a/Source/Core/InputCommon/InputCommon.vcproj +++ b/Source/Core/InputCommon/InputCommon.vcproj @@ -1,7 +1,7 @@ - - - - diff --git a/Source/Core/InputCommon/Src/InputManager.cpp b/Source/Core/InputCommon/Src/InputManager.cpp deleted file mode 100644 index e9fc976251..0000000000 --- a/Source/Core/InputCommon/Src/InputManager.cpp +++ /dev/null @@ -1,94 +0,0 @@ -#include "InputManager.h" - -bool InputManager::Init() { - - if (! SDLInit()) - return false; - - ScanDevices(); - return true; -} - -bool InputManager::Shutdown() { - SDLShutdown(); - sdlInit = false; - - return true; -} - -bool InputManager::SDLInit() { -#ifdef HAVE_SDL - // Move also joystick opening code here. - if (! sdlInit) { - /* SDL 1.3 use DirectInput instead of the old Microsoft Multimeda API, - and with this we need the SDL_INIT_VIDEO flag as well */ - if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) { - PanicAlert("Could not initialize SDL! (%s)\n", SDL_GetError()); - } else { - sdlInit = true; - } - } - return sdlInit; -#endif - - return true; -} -void InputManager::SDLShutdown() { - for(int i = 0; i < numjoy; i++ ) { - if (SDL_JoystickOpened(m_joyinfo[i].ID)) - SDL_JoystickClose(m_joyinfo[i].joy); - } - SDL_Quit(); -} - -int InputManager::ScanDevices() { - - int res = SDLScanDevices(); - return res; -} - -int InputManager::SDLScanDevices() { -#if defined HAVE_SDL && HAVE_SDL - numjoy = SDL_NumJoysticks(); - - if(numjoy == 0) { - PanicAlert("No Joystick detected!\n"); - return 0; - } - - if(m_joyinfo) - delete [] m_joyinfo; - - m_joyinfo = new ControllerInfo[numjoy]; - -#ifdef _DEBUG - fprintf(pFile, "Scanning for devices\n"); - fprintf(pFile, "ÂŻÂŻÂŻÂŻÂŻÂŻÂŻÂŻÂŻÂŻÂŻÂŻÂŻÂŻÂŻÂŻÂŻÂŻÂŻÂŻ\n"); -#endif - - for(int i = 0; i < numjoy; i++ ) { - m_joyinfo[i].joy = SDL_JoystickOpen(i); - m_joyinfo[i].ID = i; - m_joyinfo[i].NumAxes = SDL_JoystickNumAxes(m_joyinfo[i].joy); - m_joyinfo[i].NumButtons = SDL_JoystickNumButtons(m_joyinfo[i].joy); - m_joyinfo[i].NumBalls = SDL_JoystickNumBalls(m_joyinfo[i].joy); - m_joyinfo[i].NumHats = SDL_JoystickNumHats(m_joyinfo[i].joy); - m_joyinfo[i].Name = SDL_JoystickName(i); - - printf("ID: %d\n", i); - printf("Name: %s\n", m_joyinfo[i].Name); - printf("Buttons: %d\n", m_joyinfo[i].NumButtons); - printf("Axises: %d\n", m_joyinfo[i].NumAxes); - printf("Hats: %d\n", m_joyinfo[i].NumHats); - printf("Balls: %d\n\n", m_joyinfo[i].NumBalls); - - // Close if opened - if(SDL_JoystickOpened(i)) - SDL_JoystickClose(m_joyinfo[i].joy); - } - - return numjoy; -#else - return 0; -#endif -} diff --git a/Source/Core/InputCommon/Src/InputManager.h b/Source/Core/InputCommon/Src/InputManager.h deleted file mode 100644 index 88ec46dec4..0000000000 --- a/Source/Core/InputCommon/Src/InputManager.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef INPUTMANAGER_H -#define INPUTMANAGER_H -#include "Common.h" - -#if defined HAVE_SDL && HAVE_SDL -#include - - -struct ControllerInfo { // CONNECTED WINDOWS DEVICES INFO - int NumAxes; // Amount of Axes - int NumButtons; // Amount of Buttons - int NumBalls; // Amount of Balls - int NumHats; // Amount of Hats (POV) - const char *Name; // Joypad/stickname - int ID; // SDL joystick device ID - SDL_Joystick *joy; // SDL joystick device -}; -#endif - -class InputManager { - -public: - bool Init(); - bool Shutdown(); - - InputManager(): sdlInit(false) {} - ~InputManager() { - if(m_joyinfo) - delete [] m_joyinfo; - } - -private: - bool sdlInit; - int ScanDevices(); - - // sdl specific - bool SDLInit(); - void SDLShutdown(); - int SDLScanDevices(); - ControllerInfo *m_joyinfo; - int numjoy; -}; -#endif diff --git a/Source/Core/InputCommon/Src/SConscript b/Source/Core/InputCommon/Src/SConscript index e5eeff99b5..e5fe35e802 100644 --- a/Source/Core/InputCommon/Src/SConscript +++ b/Source/Core/InputCommon/Src/SConscript @@ -5,7 +5,6 @@ Import('env') files = [ 'EventHandler.cpp', 'InputCommon.cpp', - "InputManager.cpp", ] env_inputcommon = env.Clone() diff --git a/Source/MusicMod.sln b/Source/MusicMod.sln index 3cd69edccf..f1579fa39a 100644 --- a/Source/MusicMod.sln +++ b/Source/MusicMod.sln @@ -146,9 +146,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Main", "..\Branches\MusicMo EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Player", "..\Branches\MusicMod\Player\Player.vcproj", "{0B72B5D6-5D72-4391-84A7-9CCA5392668A}" - ProjectSection(ProjectDependencies) = postProject - {C573CAF7-EE6A-458E-8049-16C0BF34C2E9} = {C573CAF7-EE6A-458E-8049-16C0BF34C2E9} - EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestPlayer", "..\Branches\MusicMod\TestPlayer\TestPlayer.vcproj", "{0D14F1E9-490B-4A2D-A4EF-0535E8B3C718}" EndProject diff --git a/Source/PluginSpecs/PluginSpecs.h b/Source/PluginSpecs/PluginSpecs.h index c66bc7180d..c35acc4b9c 100644 --- a/Source/PluginSpecs/PluginSpecs.h +++ b/Source/PluginSpecs/PluginSpecs.h @@ -82,7 +82,6 @@ typedef struct void *eventHandler; void *config; void *messageLogger; - void *inputManager; } PLUGIN_GLOBALS; /////////////////////////////// diff --git a/Source/PluginSpecs/pluginspecs_pad.h b/Source/PluginSpecs/pluginspecs_pad.h index befe45198a..aa1b8e4a2f 100644 --- a/Source/PluginSpecs/pluginspecs_pad.h +++ b/Source/PluginSpecs/pluginspecs_pad.h @@ -35,7 +35,7 @@ typedef struct { HWND hWnd; TLog pLog; - int padNumber; + int padNumber; } SPADInitialize; typedef struct diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp b/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp index 7885b8450d..d4ae404180 100644 --- a/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp +++ b/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp @@ -185,6 +185,8 @@ void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals) { // ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ void DllConfig(HWND _hParent) { + #ifdef _WIN32 + // Start the pads so we can use them in the configuration and advanced controls if(!emulator_running) { @@ -195,10 +197,31 @@ void DllConfig(HWND _hParent) emulator_running = false; // Set it back to false } + g_Config.Load(); // Load settings + + // We don't need a parent for this wxDialog + //wxWindow win; + //win.SetHWND(_hParent); + //ConfigBox frame(&win); + //win.SetHWND(0); + + m_frame = new ConfigBox(NULL); + m_frame->ShowModal(); + + #else + if (SDL_Init(SDL_INIT_JOYSTICK ) < 0) + { + printf("Could not initialize SDL! (%s)\n", SDL_GetError()); + return; + } + + g_Config.Load(); // load settings + #if defined(HAVE_WX) && HAVE_WX - g_Config.Load(); // Load settings - m_frame = new ConfigBox(NULL); - m_frame->ShowModal(); + ConfigBox frame(NULL); + frame.ShowModal(); + #endif + #endif } @@ -217,33 +240,29 @@ void Initialize(void *init) { // Debugging //Console::Open(); - SPADInitialize *_PADInitialize = (SPADInitialize*)init; - #ifndef INPUTCOMMON - Console::Print("Initialize: %i, %i\n", _PADInitialize->padNumber, SDL_WasInit(0)); - #endif - + + //Console::Print("Initialize: %i\n", SDL_WasInit(0)); + + SPADInitialize _PADInitialize = *(SPADInitialize*)init; emulator_running = true; #ifdef _DEBUG DEBUG_INIT(); #endif + /* SDL 1.3 use DirectInput instead of the old Microsoft Multimeda API, and with this we need + the SDL_INIT_VIDEO flag to */ + if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) + { + #ifdef _WIN32 + MessageBox(NULL, SDL_GetError(), "Could not initialize SDL!", MB_ICONERROR); + #else + printf("Could not initialize SDL! (%s)\n", SDL_GetError()); + #endif + return; + } + #ifdef _WIN32 - m_hWnd = (HWND)_PADInitialize->hWnd; - #endif - - #ifndef INPUTCOMMON - /* SDL 1.3 use DirectInput instead of the old Microsoft Multimeda API, and with this we need - the SDL_INIT_VIDEO flag to */ - if (!SDL_WasInit(0)) - if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) - { - #ifdef _WIN32 - MessageBox(NULL, SDL_GetError(), "Could not initialize SDL!", MB_ICONERROR); - #else - printf("Could not initialize SDL! (%s)\n", SDL_GetError()); - #endif - return; - } + m_hWnd = (HWND)_PADInitialize.hWnd; #endif Search_Devices(); // Populate joyinfo for all attached devices @@ -256,18 +275,6 @@ void Initialize(void *init) joystate[2].joy = SDL_JoystickOpen(PadMapping[2].ID); if (PadMapping[3].enabled) joystate[3].joy = SDL_JoystickOpen(PadMapping[3].ID); - - //_PADInitialize->padNumber = 55; - /* Check if any of the pads failed to open. In Windows there is a strange "IDirectInputDevice2:: - SetDataFormat() DirectX error -2147024809" after a few Open and Close */ - if( (PadMapping[0].enabled && joystate[0].joy == NULL) - || (PadMapping[1].enabled && joystate[1].joy == NULL) - || (PadMapping[2].enabled && joystate[2].joy == NULL) - || (PadMapping[3].enabled && joystate[3].joy == NULL)) - { - _PADInitialize->padNumber = -1; - Console::Print("%s\n", SDL_GetError()); - } } @@ -295,7 +302,11 @@ int Search_Devices() // Warn the user if no PadMapping are detected if (numjoy == 0) { - PanicAlert("No Joystick detected"); + #ifdef _WIN32 + //MessageBox(NULL, "No Joystick detected!", NULL, MB_ICONWARNING); + #else + printf("No Joystick detected!\n"); + #endif return 0; } @@ -339,7 +350,7 @@ int Search_Devices() Called from: The Dolphin Core, ConfigBox::OnClose() */ void Shutdown() { - Console::Print("Shutdown: %i\n", SDL_WasInit(0)); + //Console::Print("Shutdown: %i\n", SDL_WasInit(0)); if (PadMapping[0].enabled && SDL_JoystickOpened(PadMapping[0].ID)) SDL_JoystickClose(joystate[0].joy); @@ -348,11 +359,9 @@ void Shutdown() if (PadMapping[2].enabled && SDL_JoystickOpened(PadMapping[2].ID)) SDL_JoystickClose(joystate[2].joy); if (PadMapping[3].enabled && SDL_JoystickOpened(PadMapping[3].ID)) - SDL_JoystickClose(joystate[3].joy); + SDL_JoystickClose(joystate[3].joy); - #ifndef INPUTCOMMON - SDL_Quit(); - #endif + SDL_Quit(); #ifdef _DEBUG DEBUG_QUIT(); @@ -544,14 +553,11 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus) Console::ClearScreen(); Console::Print( "Trigger type: %s Left:%04x Right:%04x Value:%i\n" - "D-Pad type: %s L:%i R:%i U:%i D:%i" - "Main stick x, y: %i %i", - + "D-Pad type: %s L:%i R:%i U:%i D:%i", (PadMapping[_numPAD].triggertype ? "CTL_TRIGGER_XINPUT" : "CTL_TRIGGER_SDL"), TriggerLeft, TriggerRight, TriggerValue, (PadMapping[_numPAD].controllertype ? "CTL_DPAD_CUSTOM" : "CTL_DPAD_HAT"), - 0, 0, 0, 0, - main_stick_x, main_stick_y + 0, 0, 0, 0 );*/ } @@ -766,7 +772,7 @@ void GetJoyState(int controller) ReadButton(controller, CTL_START); // - if (PadMapping[controller].halfpress < Buttons) + if (PadMapping[controller].halfpress < joyinfo[controller].NumButtons) joystate[controller].halfpress = SDL_JoystickGetButton(joystate[controller].joy, PadMapping[controller].halfpress); // Check if we have an analog or digital joypad diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.h b/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.h index 688c108442..f960fec7a6 100644 --- a/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.h +++ b/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.h @@ -95,8 +95,6 @@ // Define // ŻŻŻŻŻŻŻŻŻŻ -//#define INPUTCOMMON - #define INPUT_VERSION "0.3" #define INPUT_STATE "PUBLIC RELEASE" #define RELDAY "21" diff --git a/Source/Plugins/Plugin_nJoy_Testing/Src/nJoy.cpp b/Source/Plugins/Plugin_nJoy_Testing/Src/nJoy.cpp index 5363f2f560..2d1746b608 100644 --- a/Source/Plugins/Plugin_nJoy_Testing/Src/nJoy.cpp +++ b/Source/Plugins/Plugin_nJoy_Testing/Src/nJoy.cpp @@ -51,10 +51,7 @@ HWND m_hWnd; #ifdef USE_RUMBLE_DINPUT_HACK bool g_rumbleEnable = FALSE; #endif -// Declare config window so that we can write debugging info to it from functions in this file -#if defined(HAVE_WX) && HAVE_WX - ConfigBox* m_frame; -#endif + // Rumble in windows #ifdef _WIN32 HINSTANCE nJoy_hInst = NULL; @@ -167,22 +164,37 @@ void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals) { // Call config dialog // ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ void DllConfig(HWND _hParent) -{ - // Start the pads so we can use them in the configuration and advanced controls - if(!emulator_running) +{ + #ifdef _WIN32 + if(SDL_Init(SDL_INIT_JOYSTICK ) < 0) { - SPADInitialize _PADInitialize; - _PADInitialize.hWnd = NULL; - _PADInitialize.pLog = NULL; - Initialize((void*)&_PADInitialize); - emulator_running = false; // Set it back to false + MessageBox(NULL, SDL_GetError(), "Could not initialize SDL!", MB_ICONERROR); + return; } -#if defined(HAVE_WX) && HAVE_WX - m_frame = new ConfigBox(NULL); - m_frame->ShowModal(); -#endif + LoadConfig(); // load settings +#if defined(HAVE_WX) && HAVE_WX + wxWindow win; + win.SetHWND(_hParent); + ConfigBox frame(&win); + frame.ShowModal(); + win.SetHWND(0); +#endif + #else + if(SDL_Init(SDL_INIT_JOYSTICK ) < 0) + { + printf("Could not initialize SDL! (%s)\n", SDL_GetError()); + return; + } + + LoadConfig(); // load settings + +#if defined(HAVE_WX) && HAVE_WX + ConfigBox frame(NULL); + frame.ShowModal(); +#endif + #endif } void DllDebugger(HWND _hParent, bool Show) { @@ -198,6 +210,16 @@ void Initialize(void *init) DEBUG_INIT(); #endif + if(SDL_Init(SDL_INIT_JOYSTICK ) < 0) + { + #ifdef _WIN32 + MessageBox(NULL, SDL_GetError(), "Could not initialize SDL!", MB_ICONERROR); + #else + printf("Could not initialize SDL! (%s)\n", SDL_GetError()); + #endif + return; + } + #ifdef _WIN32 m_hWnd = (HWND)_PADInitialize.hWnd; #endif @@ -218,32 +240,32 @@ void Initialize(void *init) // ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ void Shutdown() { - if(joysticks[0].enabled) - SDL_JoystickClose(joystate[0].joy); - if(joysticks[1].enabled) - SDL_JoystickClose(joystate[1].joy); - if(joysticks[2].enabled) - SDL_JoystickClose(joystate[2].joy); - if(joysticks[3].enabled) - SDL_JoystickClose(joystate[3].joy); - -#ifdef _DEBUG - DEBUG_QUIT(); -#endif - - if (joyinfo) { + if(joysticks[0].enabled) + SDL_JoystickClose(joystate[0].joy); + if(joysticks[1].enabled) + SDL_JoystickClose(joystate[1].joy); + if(joysticks[2].enabled) + SDL_JoystickClose(joystate[2].joy); + if(joysticks[3].enabled) + SDL_JoystickClose(joystate[3].joy); + + SDL_Quit(); + + #ifdef _DEBUG + DEBUG_QUIT(); + #endif + delete [] joyinfo; - joyinfo = NULL; - } - emulator_running = FALSE; - -#ifdef _WIN32 -#ifdef USE_RUMBLE_DINPUT_HACK - FreeDirectInput(); -#endif -#elif defined(__linux__) - close(fd); -#endif + + emulator_running = FALSE; + + #ifdef _WIN32 + #ifdef USE_RUMBLE_DINPUT_HACK + FreeDirectInput(); + #endif + #elif defined(__linux__) + close(fd); + #endif } void DoState(unsigned char **ptr, int mode) { @@ -678,9 +700,13 @@ int Search_Devices() int numjoy = SDL_NumJoysticks(); if(numjoy == 0) - { - PanicAlert("No Joystick detected!\n"); - return 0; + { + #ifdef _WIN32 + MessageBox(NULL, "No Joystick detected!", NULL, MB_ICONWARNING); + #else + printf("No Joystick detected!\n"); + #endif + return 0; } if(joyinfo)