diff --git a/Source/Core/Core/Src/ConfigManager.cpp b/Source/Core/Core/Src/ConfigManager.cpp index 25c00268c7..e601b9cd99 100644 --- a/Source/Core/Core/Src/ConfigManager.cpp +++ b/Source/Core/Core/Src/ConfigManager.cpp @@ -296,8 +296,8 @@ void SConfig::LoadSettings() // Plugins ini.Get("Core", "GFXPlugin", &m_LocalCoreStartupParameter.m_strVideoPlugin, m_DefaultGFXPlugin.c_str()); ini.Get("Core", "DSPPlugin", &m_LocalCoreStartupParameter.m_strDSPPlugin, m_DefaultDSPPlugin.c_str()); - ini.Get("Core", "PadPlugin", &m_LocalCoreStartupParameter.m_strPadPlugin[0], m_DefaultPADPlugin.c_str()); - ini.Get("Core", "WiiMotePlugin", &m_LocalCoreStartupParameter.m_strWiimotePlugin[0], m_DefaultWiiMotePlugin.c_str()); + ini.Get("Core", "PadPlugin", &m_LocalCoreStartupParameter.m_strPadPlugin, m_DefaultPADPlugin.c_str()); + ini.Get("Core", "WiiMotePlugin", &m_LocalCoreStartupParameter.m_strWiimotePlugin, m_DefaultWiiMotePlugin.c_str()); } diff --git a/Source/Core/Core/Src/Core.cpp b/Source/Core/Core/Src/Core.cpp index 7cb17e010b..6d0c252521 100644 --- a/Source/Core/Core/Src/Core.cpp +++ b/Source/Core/Core/Src/Core.cpp @@ -392,7 +392,7 @@ THREAD_RETURN EmuThread(void *pArg) PADInitialize.pRendererHasFocus = Callback_RendererHasFocus; // This is may be needed to avoid a SDL problem //Plugins.FreeWiimote(); - Plugins.GetPad(0)->Initialize(&PADInitialize); + Plugins.GetPad()->Initialize(&PADInitialize); // Load and Init WiimotePlugin - only if we are booting in wii mode if (_CoreParameter.bWii) @@ -407,7 +407,7 @@ THREAD_RETURN EmuThread(void *pArg) WiimoteInitialize.pWiimoteInterruptChannel = Callback_WiimoteInterruptChannel; WiimoteInitialize.pRendererHasFocus = Callback_RendererHasFocus; // Wait for Wiiuse to find the number of connected Wiimotes - Plugins.GetWiimote(0)->Initialize((void *)&WiimoteInitialize); + Plugins.GetWiimote()->Initialize((void *)&WiimoteInitialize); } // The hardware is initialized. diff --git a/Source/Core/Core/Src/CoreParameter.h b/Source/Core/Core/Src/CoreParameter.h index e769b682e6..1432665108 100644 --- a/Source/Core/Core/Src/CoreParameter.h +++ b/Source/Core/Core/Src/CoreParameter.h @@ -21,9 +21,6 @@ #include "IniFile.h" #include -#define MAXPADS 1 -#define MAXWIIMOTES 1 - enum Hotkey { HK_FULLSCREEN, HK_PLAY_PAUSE, @@ -121,9 +118,9 @@ struct SCoreStartupParameter // files std::string m_strVideoPlugin; - std::string m_strPadPlugin[MAXPADS]; + std::string m_strPadPlugin; std::string m_strDSPPlugin; - std::string m_strWiimotePlugin[MAXWIIMOTES]; + std::string m_strWiimotePlugin; std::string m_strFilename; std::string m_strBootROM; diff --git a/Source/Core/Core/Src/HW/SI_DeviceAMBaseboard.cpp b/Source/Core/Core/Src/HW/SI_DeviceAMBaseboard.cpp index 9b6986579d..cea97ac82b 100644 --- a/Source/Core/Core/Src/HW/SI_DeviceAMBaseboard.cpp +++ b/Source/Core/Core/Src/HW/SI_DeviceAMBaseboard.cpp @@ -144,7 +144,7 @@ int CSIDevice_AMBaseboard::RunBuffer(u8* _pBuffer, int _iLength) DEBUG_LOG(AMBASEBOARDDEBUG, "GC-AM: CMD 10, %02x (READ STATUS&SWITCHES)", ptr(1)); SPADStatus PadStatus; memset(&PadStatus, 0 ,sizeof(PadStatus)); - CPluginManager::GetInstance().GetPad(0) + CPluginManager::GetInstance().GetPad() ->PAD_GetStatus(ISIDevice::m_iDeviceNumber, &PadStatus); res[resp++] = 0x10; res[resp++] = 0x2; @@ -310,7 +310,7 @@ int CSIDevice_AMBaseboard::RunBuffer(u8* _pBuffer, int _iLength) for (i=0; iPAD_GetStatus(i, &PadStatus); unsigned char player_data[2] = {0,0}; if (PadStatus.button & PAD_BUTTON_START) @@ -348,7 +348,7 @@ int CSIDevice_AMBaseboard::RunBuffer(u8* _pBuffer, int _iLength) int slots = *jvs_io++; msg.addData(1); SPADStatus PadStatus; - CPluginManager::GetInstance().GetPad(0) + CPluginManager::GetInstance().GetPad() ->PAD_GetStatus(0, &PadStatus); while (slots--) { diff --git a/Source/Core/Core/Src/HW/SI_DeviceGCController.cpp b/Source/Core/Core/Src/HW/SI_DeviceGCController.cpp index b1036d9a8d..16839a63dd 100644 --- a/Source/Core/Core/Src/HW/SI_DeviceGCController.cpp +++ b/Source/Core/Core/Src/HW/SI_DeviceGCController.cpp @@ -128,7 +128,7 @@ bool CSIDevice_GCController::GetData(u32& _Hi, u32& _Low) { SPADStatus PadStatus; memset(&PadStatus, 0, sizeof(PadStatus)); - Common::PluginPAD* pad = CPluginManager::GetInstance().GetPad(0); + Common::PluginPAD* pad = CPluginManager::GetInstance().GetPad(); pad->PAD_GetStatus(ISIDevice::m_iDeviceNumber, &PadStatus); u32 netValues[2] = {0}; @@ -258,7 +258,7 @@ bool CSIDevice_GCController::GetData(u32& _Hi, u32& _Low) // SendCommand void CSIDevice_GCController::SendCommand(u32 _Cmd, u8 _Poll) { - Common::PluginPAD* pad = CPluginManager::GetInstance().GetPad(0); + Common::PluginPAD* pad = CPluginManager::GetInstance().GetPad(); UCommand command(_Cmd); switch (command.Command) diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp index 74efe59246..5d10198288 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp @@ -497,7 +497,7 @@ u32 CWII_IPC_HLE_Device_usb_oh1_57e_305::Update() #if defined(HAVE_WX) && HAVE_WX NetPlay_WiimoteUpdate(i); #endif - CPluginManager::GetInstance().GetWiimote(0)->Wiimote_Update(i); + CPluginManager::GetInstance().GetWiimote()->Wiimote_Update(i); return true; } } diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp index 11f0baa8c2..37689dfaf0 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp @@ -182,7 +182,7 @@ void CWII_IPC_HLE_WiiMote::EventDisconnect() { // Send disconnect message to plugin u8 Message = WIIMOTE_DISCONNECT; - CPluginManager::GetInstance().GetWiimote(0)->Wiimote_ControlChannel(m_ConnectionHandle & 0xFF, 99, &Message, 0); + CPluginManager::GetInstance().GetWiimote()->Wiimote_ControlChannel(m_ConnectionHandle & 0xFF, 99, &Message, 0); m_Connected = -1; // Clear channel flags @@ -264,7 +264,7 @@ void CWII_IPC_HLE_WiiMote::ExecuteL2capCmd(u8* _pData, u32 _Size) const int number = 0; #endif - Common::PluginWiimote* mote = CPluginManager::GetInstance().GetWiimote(0); + Common::PluginWiimote* mote = CPluginManager::GetInstance().GetWiimote(); if (itr != m_Channel.end()) { SChannel& rChannel = itr->second; diff --git a/Source/Core/Core/Src/PluginManager.cpp b/Source/Core/Core/Src/PluginManager.cpp index a876705b56..f349eb6d05 100644 --- a/Source/Core/Core/Src/PluginManager.cpp +++ b/Source/Core/Core/Src/PluginManager.cpp @@ -70,10 +70,8 @@ CPluginManager::CPluginManager() // Set initial values to NULL. m_video = NULL; m_dsp = NULL; - for (int i = 0; i < MAXPADS; i++) - m_pad[i] = NULL; - for (int i = 0; i < MAXWIIMOTES; i++) - m_wiimote[i] = NULL; + m_pad = NULL; + m_wiimote = NULL; } // This will call FreeLibrary() for all plugins @@ -84,23 +82,17 @@ CPluginManager::~CPluginManager() delete m_PluginGlobals; delete m_dsp; - for (int i = 0; i < MAXPADS; i++) + if (m_pad) { - if (m_pad[i]) - { - delete m_pad[i]; - m_pad[i] = NULL; - } + delete m_pad; + m_pad = NULL; } - for (int i = 0; i < MAXWIIMOTES; i++) + if (m_wiimote) { - if (m_wiimote[i]) - { - m_wiimote[i]->Shutdown(); - delete m_wiimote[i]; - m_wiimote[i] = NULL; - } + m_wiimote->Shutdown(); + delete m_wiimote; + m_wiimote = NULL; } delete m_video; @@ -131,40 +123,27 @@ bool CPluginManager::InitPlugins() PanicAlert("Can't init DSP Plugin"); return false; } - // Check if we get at least one pad or wiimote - bool pad = false; - bool wiimote = false; // Init pad - for (int i = 0; i < MAXPADS; i++) + // Check that the plugin has a name + if (!m_params->m_strPadPlugin.empty()) + GetPad(); + + // Check that GetPad succeeded + if (!m_pad) { - // Check that the plugin has a name - if (!m_params->m_strPadPlugin[i].empty()) - GetPad(i); - // Check that GetPad succeeded - if (m_pad[i] != NULL) - pad = true; - } - if (!pad) - { - PanicAlert("Can't init any PAD Plugins"); + PanicAlert("Can't init PAD Plugin"); return false; } // Init wiimote if (m_params->bWii) { - for (int i = 0; i < MAXWIIMOTES; i++) + if (!m_params->m_strWiimotePlugin.empty()) + GetWiimote(); + if (!m_wiimote) { - if (!m_params->m_strWiimotePlugin[i].empty()) - GetWiimote(i); - - if (m_wiimote[i] != NULL) - wiimote = true; - } - if (!wiimote) - { - PanicAlert("Can't init any Wiimote Plugins"); + PanicAlert("Can't init Wiimote Plugin"); return false; } } @@ -177,22 +156,16 @@ bool CPluginManager::InitPlugins() // for an explanation about the current LoadLibrary() and FreeLibrary() behavior. void CPluginManager::ShutdownPlugins() { - for (int i = 0; i < MAXPADS; i++) + if (m_pad) { - if (m_pad[i]) - { - m_pad[i]->Shutdown(); - FreePad(i); - } + m_pad->Shutdown(); + FreePad(); } - for (int i = 0; i < MAXWIIMOTES; i++) + if (m_wiimote) { - if (m_wiimote[i]) - { - m_wiimote[i]->Shutdown(); - FreeWiimote(i); - } + m_wiimote->Shutdown(); + FreeWiimote(); } if (m_dsp) @@ -381,34 +354,34 @@ void CPluginManager::ScanForPlugins() if it's not valid. */ // ------------ -Common::PluginPAD *CPluginManager::GetPad(int controller) +Common::PluginPAD *CPluginManager::GetPad() { - if (m_pad[controller] != NULL) + if (m_pad != NULL) { - if (m_pad[controller]->GetFilename() == m_params->m_strPadPlugin[controller]) - return m_pad[controller]; + if (m_pad->GetFilename() == m_params->m_strPadPlugin) + return m_pad; else - FreePad(controller); + FreePad(); } // Else load a new plugin - m_pad[controller] = (Common::PluginPAD*)LoadPlugin(m_params->m_strPadPlugin[controller].c_str()); - return m_pad[controller]; + m_pad = (Common::PluginPAD*)LoadPlugin(m_params->m_strPadPlugin.c_str()); + return m_pad; } -Common::PluginWiimote *CPluginManager::GetWiimote(int controller) +Common::PluginWiimote *CPluginManager::GetWiimote() { - if (m_wiimote[controller] != NULL) + if (m_wiimote != NULL) { - if (m_wiimote[controller]->GetFilename() == m_params->m_strWiimotePlugin[controller]) - return m_wiimote[controller]; + if (m_wiimote->GetFilename() == m_params->m_strWiimotePlugin) + return m_wiimote; else - FreeWiimote(controller); + FreeWiimote(); } // Else load a new plugin - m_wiimote[controller] = (Common::PluginWiimote*)LoadPlugin(m_params->m_strWiimotePlugin[controller].c_str()); - return m_wiimote[controller]; + m_wiimote = (Common::PluginWiimote*)LoadPlugin(m_params->m_strWiimotePlugin.c_str()); + return m_wiimote; } Common::PluginDSP *CPluginManager::GetDSP() @@ -462,22 +435,16 @@ void CPluginManager::FreeDSP() m_dsp = NULL; } -void CPluginManager::FreePad(u32 Pad) +void CPluginManager::FreePad() { - if (Pad < MAXPADS) - { - delete m_pad[Pad]; - m_pad[Pad] = NULL; - } + delete m_pad; + m_pad = NULL; } -void CPluginManager::FreeWiimote(u32 Wiimote) +void CPluginManager::FreeWiimote() { - if (Wiimote < MAXWIIMOTES) - { - delete m_wiimote[Wiimote]; - m_wiimote[Wiimote] = NULL; - } + delete m_wiimote; + m_wiimote = NULL; } void CPluginManager::EmuStateChange(PLUGIN_EMUSTATE newState) @@ -488,8 +455,8 @@ void CPluginManager::EmuStateChange(PLUGIN_EMUSTATE newState) // Would we need to call all plugins? // If yes, how would one check if the plugin was not // just created by GetXxx(idx) because there was none? - GetPad(0)->EmuStateChange(newState); - GetWiimote(0)->EmuStateChange(newState); + GetPad()->EmuStateChange(newState); + GetWiimote()->EmuStateChange(newState); } @@ -515,10 +482,10 @@ void CPluginManager::OpenConfig(void* _Parent, const char *_rFilename, PLUGIN_TY GetDSP()->Config((HWND)_Parent); break; case PLUGIN_TYPE_PAD: - GetPad(0)->Config((HWND)_Parent); + GetPad()->Config((HWND)_Parent); break; case PLUGIN_TYPE_WIIMOTE: - GetWiimote(0)->Config((HWND)_Parent); + GetWiimote()->Config((HWND)_Parent); break; default: PanicAlert("Type %d config not supported in plugin %s", Type, _rFilename); diff --git a/Source/Core/Core/Src/PluginManager.h b/Source/Core/Core/Src/PluginManager.h index b683f15966..0652c98337 100644 --- a/Source/Core/Core/Src/PluginManager.h +++ b/Source/Core/Core/Src/PluginManager.h @@ -51,13 +51,13 @@ public: Common::PluginVideo *GetVideo(); Common::PluginDSP *GetDSP(); - Common::PluginPAD *GetPad(int controller); - Common::PluginWiimote *GetWiimote(int controller); + Common::PluginPAD *GetPad(); + Common::PluginWiimote *GetWiimote(); void FreeVideo(); void FreeDSP(); - void FreePad(u32 Pad); - void FreeWiimote(u32 Wiimote); + void FreePad(); + void FreeWiimote(); void EmuStateChange(PLUGIN_EMUSTATE newState); @@ -69,6 +69,7 @@ public: 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; @@ -76,8 +77,8 @@ private: PLUGIN_GLOBALS *m_PluginGlobals; Common::PluginVideo *m_video; Common::PluginDSP *m_dsp; - Common::PluginPAD *m_pad[4]; - Common::PluginWiimote *m_wiimote[4]; + Common::PluginPAD *m_pad; + Common::PluginWiimote *m_wiimote; SCoreStartupParameter * m_params; CPluginManager(); diff --git a/Source/Core/Core/Src/State.cpp b/Source/Core/Core/Src/State.cpp index 1da95de50f..dfeb3a3417 100644 --- a/Source/Core/Core/Src/State.cpp +++ b/Source/Core/Core/Src/State.cpp @@ -92,9 +92,9 @@ void DoState(PointerWrap &p) CPluginManager &pm = CPluginManager::GetInstance(); pm.GetVideo()->DoState(p.GetPPtr(), p.GetMode()); pm.GetDSP()->DoState(p.GetPPtr(), p.GetMode()); - pm.GetPad(0)->DoState(p.GetPPtr(), p.GetMode()); + pm.GetPad()->DoState(p.GetPPtr(), p.GetMode()); if (Core::g_CoreStartupParameter.bWii) - pm.GetWiimote(0)->DoState(p.GetPPtr(), p.GetMode()); + pm.GetWiimote()->DoState(p.GetPPtr(), p.GetMode()); PowerPC::DoState(p); HW::DoState(p); CoreTiming::DoState(p); diff --git a/Source/Core/DolphinWX/Src/ConfigMain.cpp b/Source/Core/DolphinWX/Src/ConfigMain.cpp index 07dd66bf1b..17a0ae71be 100644 --- a/Source/Core/DolphinWX/Src/ConfigMain.cpp +++ b/Source/Core/DolphinWX/Src/ConfigMain.cpp @@ -319,10 +319,8 @@ void CConfigMain::InitializeGUIValues() // Plugins FillChoiceBox(GraphicSelection, PLUGIN_TYPE_VIDEO, SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoPlugin); FillChoiceBox(DSPSelection, PLUGIN_TYPE_DSP, SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDSPPlugin); - for (int i = 0; i < MAXPADS; i++) - FillChoiceBox(PADSelection, PLUGIN_TYPE_PAD, SConfig::GetInstance().m_LocalCoreStartupParameter.m_strPadPlugin[i]); - for (int i=0; i < MAXWIIMOTES; i++) - FillChoiceBox(WiimoteSelection, PLUGIN_TYPE_WIIMOTE, SConfig::GetInstance().m_LocalCoreStartupParameter.m_strWiimotePlugin[i]); + FillChoiceBox(PADSelection, PLUGIN_TYPE_PAD, SConfig::GetInstance().m_LocalCoreStartupParameter.m_strPadPlugin); + FillChoiceBox(WiimoteSelection, PLUGIN_TYPE_WIIMOTE, SConfig::GetInstance().m_LocalCoreStartupParameter.m_strWiimotePlugin); } void CConfigMain::InitializeGUITooltips() @@ -1144,10 +1142,8 @@ void CConfigMain::OnSelectionChanged(wxCommandEvent& WXUNUSED (event)) // Update plugin filenames 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]); - for (int i = 0; i < MAXWIIMOTES; i++) - GetFilename(WiimoteSelection, SConfig::GetInstance().m_LocalCoreStartupParameter.m_strWiimotePlugin[i]); + GetFilename(PADSelection, SConfig::GetInstance().m_LocalCoreStartupParameter.m_strPadPlugin); + GetFilename(WiimoteSelection, SConfig::GetInstance().m_LocalCoreStartupParameter.m_strWiimotePlugin); } void CConfigMain::OnConfig(wxCommandEvent& event) diff --git a/Source/Core/DolphinWX/Src/Frame.cpp b/Source/Core/DolphinWX/Src/Frame.cpp index 1623291dec..bbc7c640ea 100644 --- a/Source/Core/DolphinWX/Src/Frame.cpp +++ b/Source/Core/DolphinWX/Src/Frame.cpp @@ -882,8 +882,8 @@ void CFrame::OnKeyDown(wxKeyEvent& event) #endif // Send the keyboard status to the Input plugins - CPluginManager::GetInstance().GetPad(0)->PAD_Input(event.GetKeyCode(), 1); // 1 = Down - CPluginManager::GetInstance().GetWiimote(0)->Wiimote_Input(event.GetKeyCode(), 1); // 1 = Down + CPluginManager::GetInstance().GetPad()->PAD_Input(event.GetKeyCode(), 1); // 1 = Down + CPluginManager::GetInstance().GetWiimote()->Wiimote_Input(event.GetKeyCode(), 1); // 1 = Down } else event.Skip(); @@ -894,8 +894,8 @@ void CFrame::OnKeyUp(wxKeyEvent& event) event.Skip(); if(Core::GetState() != Core::CORE_UNINITIALIZED) { - CPluginManager::GetInstance().GetPad(0)->PAD_Input(event.GetKeyCode(), 0); // 0 = Up - CPluginManager::GetInstance().GetWiimote(0)->Wiimote_Input(event.GetKeyCode(), 0); // 0 = Up + CPluginManager::GetInstance().GetPad()->PAD_Input(event.GetKeyCode(), 0); // 0 = Up + CPluginManager::GetInstance().GetWiimote()->Wiimote_Input(event.GetKeyCode(), 0); // 0 = Up } } diff --git a/Source/Core/DolphinWX/Src/FrameTools.cpp b/Source/Core/DolphinWX/Src/FrameTools.cpp index 211c5811d2..3d4a41b88d 100644 --- a/Source/Core/DolphinWX/Src/FrameTools.cpp +++ b/Source/Core/DolphinWX/Src/FrameTools.cpp @@ -944,7 +944,7 @@ void CFrame::OnPluginPAD(wxCommandEvent& WXUNUSED (event)) { CPluginManager::GetInstance().OpenConfig( GetHandle(), - SConfig::GetInstance().m_LocalCoreStartupParameter.m_strPadPlugin[0].c_str(), + SConfig::GetInstance().m_LocalCoreStartupParameter.m_strPadPlugin.c_str(), PLUGIN_TYPE_PAD ); } @@ -952,7 +952,7 @@ void CFrame::OnPluginWiimote(wxCommandEvent& WXUNUSED (event)) { CPluginManager::GetInstance().OpenConfig( GetHandle(), - SConfig::GetInstance().m_LocalCoreStartupParameter.m_strWiimotePlugin[0].c_str(), + SConfig::GetInstance().m_LocalCoreStartupParameter.m_strWiimotePlugin.c_str(), PLUGIN_TYPE_WIIMOTE ); } diff --git a/Source/Core/DolphinWX/Src/Main.cpp b/Source/Core/DolphinWX/Src/Main.cpp index bb8d0391e3..b46a802fe3 100644 --- a/Source/Core/DolphinWX/Src/Main.cpp +++ b/Source/Core/DolphinWX/Src/Main.cpp @@ -354,20 +354,12 @@ bool DolphinApp::OnInit() std::string(audioPluginFilename.mb_str()); if (selectPadPlugin && padPluginFilename != wxEmptyString) - { - int k; - for(k=0;k