nJoy and SerialInterface: Fixed the crashes with MAXPADS more than 1, the downside is that it doesn't work well one the second boot
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1980 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
189285f071
commit
e332e18ce6
|
@ -15,13 +15,21 @@
|
||||||
// Official SVN repository and contact information can be found at
|
// Official SVN repository and contact information can be found at
|
||||||
// http://code.google.com/p/dolphin-emu/
|
// http://code.google.com/p/dolphin-emu/
|
||||||
|
|
||||||
/*
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// File description
|
||||||
|
/* ¯¯¯¯¯¯¯¯¯¯¯¯
|
||||||
|
|
||||||
All plugins from Core > Plugins are loaded and unloaded with this class when Dolpin is started
|
All plugins from Core > Plugins are loaded and unloaded with this class when Dolpin is started
|
||||||
and stopped.
|
and stopped.
|
||||||
|
|
||||||
//////////////////////////////////////*/
|
//////////////////////////////////////*/
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Include
|
||||||
|
// ¯¯¯¯¯¯¯¯¯¯¯¯
|
||||||
|
#include <string.h> // System
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#else
|
#else
|
||||||
|
@ -29,10 +37,13 @@ and stopped.
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h" // Local
|
||||||
#include "FileUtil.h"
|
#include "FileUtil.h"
|
||||||
#include "StringUtil.h"
|
#include "StringUtil.h"
|
||||||
#include "DynamicLibrary.h"
|
#include "DynamicLibrary.h"
|
||||||
|
#include "ConsoleWindow.h"
|
||||||
|
////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
DynamicLibrary::DynamicLibrary()
|
DynamicLibrary::DynamicLibrary()
|
||||||
{
|
{
|
||||||
|
@ -93,6 +104,7 @@ int DynamicLibrary::Load(const char* filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
Console::Print("LoadLibrary: %s\n", filename);
|
||||||
library = LoadLibrary(filename);
|
library = LoadLibrary(filename);
|
||||||
#else
|
#else
|
||||||
library = dlopen(filename, RTLD_NOW | RTLD_LOCAL);
|
library = dlopen(filename, RTLD_NOW | RTLD_LOCAL);
|
||||||
|
@ -118,6 +130,7 @@ int DynamicLibrary::Unload()
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
Console::Print("FreeLibrary: %i\n", library);
|
||||||
retval = FreeLibrary(library);
|
retval = FreeLibrary(library);
|
||||||
#else
|
#else
|
||||||
retval = dlclose(library)?0:1;
|
retval = dlclose(library)?0:1;
|
||||||
|
|
|
@ -70,8 +70,12 @@ void *CPlugin::LoadSymbol(const char *sym) {
|
||||||
return m_hInstLib.Get(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) {
|
if (m_GetDllInfo != 0)
|
||||||
|
{
|
||||||
m_GetDllInfo(&_pluginInfo);
|
m_GetDllInfo(&_pluginInfo);
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
@ -79,16 +83,19 @@ bool CPlugin::GetInfo(PLUGIN_INFO& _pluginInfo) {
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ______________________________________________________________________________________
|
||||||
void CPlugin::Config(HWND _hwnd) {
|
// Config: Open the Config window
|
||||||
if (m_DllConfig != 0)
|
void CPlugin::Config(HWND _hwnd)
|
||||||
m_DllConfig(_hwnd);
|
{
|
||||||
|
if (m_DllConfig != 0) m_DllConfig(_hwnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPlugin::Debug(HWND _hwnd, bool Show) {
|
|
||||||
if (m_DllDebugger != 0)
|
// ______________________________________________________________________________________
|
||||||
m_DllDebugger(_hwnd, Show);
|
// Debug: Open the Debugging window
|
||||||
|
void CPlugin::Debug(HWND _hwnd, bool Show)
|
||||||
|
{
|
||||||
|
if (m_DllDebugger != 0) m_DllDebugger(_hwnd, Show);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "Thread.h" // Common
|
#include "Thread.h" // Common
|
||||||
#include "Timer.h"
|
#include "Timer.h"
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
|
#include "ConsoleWindow.h"
|
||||||
|
|
||||||
#include "Console.h"
|
#include "Console.h"
|
||||||
#include "Core.h"
|
#include "Core.h"
|
||||||
|
@ -94,6 +95,7 @@ void Callback_KeyPress(int key, bool shift, bool control);
|
||||||
TPeekMessages Callback_PeekMessages = NULL;
|
TPeekMessages Callback_PeekMessages = NULL;
|
||||||
TUpdateFPSDisplay g_pUpdateFPSDisplay = NULL;
|
TUpdateFPSDisplay g_pUpdateFPSDisplay = NULL;
|
||||||
|
|
||||||
|
// Function declarations
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
DWORD WINAPI EmuThread(void *pArg);
|
DWORD WINAPI EmuThread(void *pArg);
|
||||||
#else
|
#else
|
||||||
|
@ -150,10 +152,13 @@ bool GetRealWiimote()
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// This is called from the GUI thread. See the booting call schedule in BootManager.cpp
|
// This is called from the GUI thread. See the booting call schedule in BootManager.cpp
|
||||||
//
|
// -----------------
|
||||||
bool Init()
|
bool Init()
|
||||||
{
|
{
|
||||||
if (g_pThread != NULL) {
|
//Console::Open();
|
||||||
|
|
||||||
|
if (g_pThread != NULL)
|
||||||
|
{
|
||||||
PanicAlert("ERROR: Emu Thread already running. Report this bug.");
|
PanicAlert("ERROR: Emu Thread already running. Report this bug.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -165,9 +170,10 @@ bool Init()
|
||||||
LogManager::Init();
|
LogManager::Init();
|
||||||
Host_SetWaitCursor(true);
|
Host_SetWaitCursor(true);
|
||||||
|
|
||||||
// start the thread again
|
// Start the thread again
|
||||||
_dbg_assert_(HLE, g_pThread == NULL);
|
_dbg_assert_(HLE, g_pThread == NULL);
|
||||||
|
|
||||||
|
// LoadLibrary()
|
||||||
if (!pManager.InitPlugins())
|
if (!pManager.InitPlugins())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -224,7 +230,7 @@ void Stop() // - Hammertime!
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Create the CPU thread
|
// Create the CPU thread
|
||||||
//
|
// ---------------
|
||||||
THREAD_RETURN CpuThread(void *pArg)
|
THREAD_RETURN CpuThread(void *pArg)
|
||||||
{
|
{
|
||||||
Common::SetCurrentThreadName("CPU thread");
|
Common::SetCurrentThreadName("CPU thread");
|
||||||
|
@ -274,7 +280,7 @@ THREAD_RETURN CpuThread(void *pArg)
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Initalize plugins and create emulation thread
|
// Initalize plugins and create emulation thread
|
||||||
//
|
// -------------
|
||||||
/* Call browser: Init():g_pThread(). See the BootManager.cpp file description for a complete
|
/* Call browser: Init():g_pThread(). See the BootManager.cpp file description for a complete
|
||||||
call schedule. */
|
call schedule. */
|
||||||
THREAD_RETURN EmuThread(void *pArg)
|
THREAD_RETURN EmuThread(void *pArg)
|
||||||
|
@ -340,7 +346,8 @@ THREAD_RETURN EmuThread(void *pArg)
|
||||||
PADInitialize.hWnd = g_pWindowHandle;
|
PADInitialize.hWnd = g_pWindowHandle;
|
||||||
PADInitialize.pLog = Callback_PADLog;
|
PADInitialize.pLog = Callback_PADLog;
|
||||||
PADInitialize.padNumber = i;
|
PADInitialize.padNumber = i;
|
||||||
Plugins.GetPAD(i)->Initialize((void *)&PADInitialize);
|
// Check if we should init the plugin
|
||||||
|
if(Plugins.OkayToInitPlugin(i)) Plugins.GetPAD(i)->Initialize((void *)&PADInitialize);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load and Init WiimotePlugin - only if we are booting in wii mode
|
// Load and Init WiimotePlugin - only if we are booting in wii mode
|
||||||
|
@ -439,13 +446,15 @@ THREAD_RETURN EmuThread(void *pArg)
|
||||||
// so we can restart the plugins (or load new ones) for the next game.
|
// so we can restart the plugins (or load new ones) for the next game.
|
||||||
if (_CoreParameter.hMainWindow == g_pWindowHandle)
|
if (_CoreParameter.hMainWindow == g_pWindowHandle)
|
||||||
Host_UpdateMainFrame();
|
Host_UpdateMainFrame();
|
||||||
|
|
||||||
|
//Console::Close();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Set or get the running state
|
// Set or get the running state
|
||||||
//
|
// --------------
|
||||||
bool SetState(EState _State)
|
bool SetState(EState _State)
|
||||||
{
|
{
|
||||||
switch(_State)
|
switch(_State)
|
||||||
|
@ -485,7 +494,7 @@ EState GetState()
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Save or recreate the emulation state
|
// Save or recreate the emulation state
|
||||||
//
|
// ----------
|
||||||
void SaveState() {
|
void SaveState() {
|
||||||
State_Save(0);
|
State_Save(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -256,6 +256,7 @@ void Init()
|
||||||
|
|
||||||
// Access the pad and check the MAXPADS limit
|
// 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 >= MAXPADS) ? (MAXPADS - 1): i);
|
||||||
|
//Common::PluginPAD* pad = CPluginManager::GetInstance().GetPAD(i);
|
||||||
|
|
||||||
// Check if this pad is attached for the current plugin
|
// Check if this pad is attached for the current plugin
|
||||||
if (pad != NULL && (pad->PAD_GetAttachedPads() & (1 << i)))
|
if (pad != NULL && (pad->PAD_GetAttachedPads() & (1 << i)))
|
||||||
|
|
|
@ -120,6 +120,7 @@ CSIDevice_GCController::GetData(u32& _Hi, u32& _Low)
|
||||||
SPADStatus PadStatus;
|
SPADStatus PadStatus;
|
||||||
memset(&PadStatus, 0 ,sizeof(PadStatus));
|
memset(&PadStatus, 0 ,sizeof(PadStatus));
|
||||||
Common::PluginPAD* pad =
|
Common::PluginPAD* pad =
|
||||||
|
//CPluginManager::GetInstance().GetPAD(ISIDevice::m_iDeviceNumber);
|
||||||
CPluginManager::GetInstance().GetPAD((ISIDevice::m_iDeviceNumber >= MAXPADS) ? (MAXPADS - 1): ISIDevice::m_iDeviceNumber);
|
CPluginManager::GetInstance().GetPAD((ISIDevice::m_iDeviceNumber >= MAXPADS) ? (MAXPADS - 1): ISIDevice::m_iDeviceNumber);
|
||||||
pad->PAD_GetStatus(ISIDevice::m_iDeviceNumber, &PadStatus);
|
pad->PAD_GetStatus(ISIDevice::m_iDeviceNumber, &PadStatus);
|
||||||
|
|
||||||
|
|
|
@ -15,21 +15,31 @@
|
||||||
// Official SVN repository and contact information can be found at
|
// Official SVN repository and contact information can be found at
|
||||||
// http://code.google.com/p/dolphin-emu/
|
// http://code.google.com/p/dolphin-emu/
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Include
|
||||||
|
// ¯¯¯¯¯¯¯¯¯¯¯¯
|
||||||
|
#include <string> // System
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
//#include "Globals.h"
|
//#include "Globals.h" // Local
|
||||||
#include "FileSearch.h"
|
|
||||||
#include "FileUtil.h"
|
|
||||||
#include "PluginManager.h"
|
#include "PluginManager.h"
|
||||||
#include "ConfigManager.h"
|
#include "ConfigManager.h"
|
||||||
#include "LogManager.h"
|
#include "LogManager.h"
|
||||||
#include "StringUtil.h"
|
#include "Core.h"
|
||||||
|
|
||||||
|
#include "FileSearch.h" // Common
|
||||||
|
#include "FileUtil.h"
|
||||||
|
#include "StringUtil.h"
|
||||||
|
#include "ConsoleWindow.h"
|
||||||
|
|
||||||
CPluginManager CPluginManager::m_Instance;
|
CPluginManager CPluginManager::m_Instance;
|
||||||
|
//////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// The Plugin Manager Class
|
||||||
|
// ¯¯¯¯¯¯¯¯¯¯¯¯
|
||||||
CPluginManager::CPluginManager() :
|
CPluginManager::CPluginManager() :
|
||||||
m_params(SConfig::GetInstance().m_LocalCoreStartupParameter)
|
m_params(SConfig::GetInstance().m_LocalCoreStartupParameter)
|
||||||
{
|
{
|
||||||
|
@ -40,58 +50,77 @@ CPluginManager::CPluginManager() :
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Function: FreeLibrary()
|
||||||
|
// Called from: This will be called when Dolphin is closed, not when we Stop a game
|
||||||
CPluginManager::~CPluginManager()
|
CPluginManager::~CPluginManager()
|
||||||
{
|
{
|
||||||
if (m_PluginGlobals)
|
Console::Print("Delete CPluginManager\n");
|
||||||
delete m_PluginGlobals;
|
|
||||||
|
|
||||||
if (m_dsp)
|
if (m_PluginGlobals) delete m_PluginGlobals;
|
||||||
delete m_dsp;
|
|
||||||
|
|
||||||
if (m_video)
|
if (m_dsp) delete m_dsp;
|
||||||
delete m_video;
|
|
||||||
|
|
||||||
for (int i=0;i<MAXPADS;i++) {
|
if (m_video) delete m_video;
|
||||||
if (m_pad[i])
|
|
||||||
|
/**/
|
||||||
|
for (int i = 0; i < MAXPADS; i++)
|
||||||
|
{
|
||||||
|
if (m_pad[i] && OkayToInitPlugin(i))
|
||||||
|
{
|
||||||
|
Console::Print("Delete: %i\n", i);
|
||||||
delete m_pad[i];
|
delete m_pad[i];
|
||||||
}
|
}
|
||||||
|
m_pad[i] = NULL;
|
||||||
for (int i=0;i<MAXWIIMOTES;i++) {
|
|
||||||
if (m_wiimote[i])
|
|
||||||
delete m_wiimote[i];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CPluginManager::InitPlugins() {
|
|
||||||
|
|
||||||
if (! GetVideo()) {
|
for (int i = 0; i < MAXWIIMOTES; i++)
|
||||||
|
if (m_wiimote[i]) delete m_wiimote[i];
|
||||||
|
}
|
||||||
|
//////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Init and ShutDown Plugins
|
||||||
|
// ¯¯¯¯¯¯¯¯¯¯¯¯
|
||||||
|
|
||||||
|
// Point the m_pad[] and other variables to a certain plugin
|
||||||
|
bool CPluginManager::InitPlugins()
|
||||||
|
{
|
||||||
|
|
||||||
|
if (! GetVideo())
|
||||||
|
{
|
||||||
PanicAlert("Can't init Video Plugin");
|
PanicAlert("Can't init Video Plugin");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! GetDSP()) {
|
if (! GetDSP())
|
||||||
|
{
|
||||||
PanicAlert("Can't init DSP Plugin");
|
PanicAlert("Can't init DSP Plugin");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if we get at least one pad or wiimote
|
||||||
bool pad = false;
|
bool pad = false;
|
||||||
bool wiimote = false;
|
bool wiimote = false;
|
||||||
|
|
||||||
|
// Init pad
|
||||||
for (int i = 0; i < MAXPADS; i++)
|
for (int i = 0; i < MAXPADS; i++)
|
||||||
{
|
{
|
||||||
if (! m_params.m_strPadPlugin[i].empty())
|
if (! m_params.m_strPadPlugin[i].empty())
|
||||||
GetPAD(i);
|
GetPAD(i);
|
||||||
|
|
||||||
if (m_pad[i] != NULL)
|
if (m_pad[i] != NULL)
|
||||||
pad = true;
|
pad = true;
|
||||||
}
|
}
|
||||||
|
if (! pad)
|
||||||
if (! pad) {
|
{
|
||||||
PanicAlert("Can't init any PAD Plugins");
|
PanicAlert("Can't init any PAD Plugins");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (m_params.bWii) {
|
|
||||||
|
// Init wiimote
|
||||||
|
if (m_params.bWii)
|
||||||
|
{
|
||||||
for (int i = 0; i < MAXWIIMOTES; i++)
|
for (int i = 0; i < MAXWIIMOTES; i++)
|
||||||
{
|
{
|
||||||
if (! m_params.m_strWiimotePlugin[i].empty())
|
if (! m_params.m_strWiimotePlugin[i].empty())
|
||||||
|
@ -100,8 +129,8 @@ bool CPluginManager::InitPlugins() {
|
||||||
if (m_wiimote[i] != NULL)
|
if (m_wiimote[i] != NULL)
|
||||||
wiimote = true;
|
wiimote = true;
|
||||||
}
|
}
|
||||||
|
if (! wiimote)
|
||||||
if (! wiimote) {
|
{
|
||||||
PanicAlert("Can't init any Wiimote Plugins");
|
PanicAlert("Can't init any Wiimote Plugins");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -112,8 +141,17 @@ bool CPluginManager::InitPlugins() {
|
||||||
|
|
||||||
void CPluginManager::ShutdownPlugins()
|
void CPluginManager::ShutdownPlugins()
|
||||||
{
|
{
|
||||||
|
// Check if we can shutdown the plugin
|
||||||
for (int i = 0; i < MAXPADS; i++)
|
for (int i = 0; i < MAXPADS; i++)
|
||||||
if (m_pad[i]) m_pad[i]->Shutdown();
|
{
|
||||||
|
if (m_pad[i] && OkayToInitPlugin(i))
|
||||||
|
{
|
||||||
|
//Console::Print("Shutdown: %i\n", i);
|
||||||
|
m_pad[i]->Shutdown();
|
||||||
|
}
|
||||||
|
//delete m_pad[i];
|
||||||
|
//m_pad[i] = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < MAXWIIMOTES; i++)
|
for (int i = 0; i < MAXWIIMOTES; i++)
|
||||||
if (m_wiimote[i]) m_wiimote[i]->Shutdown();
|
if (m_wiimote[i]) m_wiimote[i]->Shutdown();
|
||||||
|
@ -124,11 +162,74 @@ void CPluginManager::ShutdownPlugins()
|
||||||
if (m_dsp)
|
if (m_dsp)
|
||||||
m_dsp->Shutdown();
|
m_dsp->Shutdown();
|
||||||
}
|
}
|
||||||
|
//////////////////////////////////////////
|
||||||
|
|
||||||
PLUGIN_GLOBALS* CPluginManager::GetGlobals() {
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Supporting functions
|
||||||
|
// ¯¯¯¯¯¯¯¯¯¯¯¯
|
||||||
|
|
||||||
|
|
||||||
|
void *CPluginManager::LoadPlugin(const char *_rFilename)//, PLUGIN_TYPE type)
|
||||||
|
{
|
||||||
|
CPluginInfo info(_rFilename);
|
||||||
|
PLUGIN_TYPE type = info.GetPluginInfo().Type;
|
||||||
|
Common::CPlugin *plugin = NULL;
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case PLUGIN_TYPE_VIDEO:
|
||||||
|
plugin = new Common::PluginVideo(_rFilename);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PLUGIN_TYPE_PAD:
|
||||||
|
plugin = new Common::PluginPAD(_rFilename);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PLUGIN_TYPE_DSP:
|
||||||
|
plugin = new Common::PluginDSP(_rFilename);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PLUGIN_TYPE_WIIMOTE:
|
||||||
|
plugin = new Common::PluginWiimote(_rFilename);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
PanicAlert("Trying to load unsupported type %d", type);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!plugin->IsValid())
|
||||||
|
{
|
||||||
|
PanicAlert("Can't open %s", _rFilename);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin->SetGlobals(m_PluginGlobals);
|
||||||
|
return plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------
|
||||||
|
/* Check if the plugin has already been initialized. If so, return the Id of the duplicate pad
|
||||||
|
so we can point the new m_pad[] to that */
|
||||||
|
// -------------
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PLUGIN_GLOBALS* CPluginManager::GetGlobals()
|
||||||
|
{
|
||||||
return m_PluginGlobals;
|
return m_PluginGlobals;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
// Create list of available plugins
|
// Create list of available plugins
|
||||||
// -------------
|
// -------------
|
||||||
|
@ -166,12 +267,29 @@ void CPluginManager::ScanForPlugins()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// 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] == NULL)
|
||||||
|
{
|
||||||
|
if(OkayToInitPlugin(controller) == -1)
|
||||||
|
{
|
||||||
m_pad[controller] = (Common::PluginPAD*)LoadPlugin(m_params.m_strPadPlugin[controller].c_str());
|
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)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Console::Print("Returned: %i\n", controller);
|
||||||
return m_pad[controller];
|
return m_pad[controller];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,42 +317,12 @@ Common::PluginVideo *CPluginManager::GetVideo() {
|
||||||
|
|
||||||
return m_video;
|
return m_video;
|
||||||
}
|
}
|
||||||
|
///////////////////////////////////////////
|
||||||
void *CPluginManager::LoadPlugin(const char *_rFilename)//, PLUGIN_TYPE type)
|
|
||||||
{
|
|
||||||
CPluginInfo info(_rFilename);
|
|
||||||
PLUGIN_TYPE type = info.GetPluginInfo().Type;
|
|
||||||
Common::CPlugin *plugin = NULL;
|
|
||||||
switch (type) {
|
|
||||||
case PLUGIN_TYPE_VIDEO:
|
|
||||||
plugin = new Common::PluginVideo(_rFilename);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PLUGIN_TYPE_PAD:
|
|
||||||
plugin = new Common::PluginPAD(_rFilename);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PLUGIN_TYPE_DSP:
|
|
||||||
plugin = new Common::PluginDSP(_rFilename);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PLUGIN_TYPE_WIIMOTE:
|
|
||||||
plugin = new Common::PluginWiimote(_rFilename);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
PanicAlert("Trying to load unsupported type %d", type);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!plugin->IsValid()) {
|
|
||||||
PanicAlert("Can't open %s", _rFilename);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
plugin->SetGlobals(m_PluginGlobals);
|
|
||||||
|
|
||||||
|
|
||||||
return plugin;
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
}
|
// Call DLL functions
|
||||||
|
// ¯¯¯¯¯¯¯¯¯¯¯¯
|
||||||
|
|
||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
// Open config window. _rFilename = plugin filename , ret = the dll slot number
|
// Open config window. _rFilename = plugin filename , ret = the dll slot number
|
||||||
|
@ -278,5 +366,5 @@ CPluginInfo::CPluginInfo(const char *_rFileName)
|
||||||
delete plugin;
|
delete plugin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
///////////////////////////////////////////
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,7 @@ public:
|
||||||
|
|
||||||
bool InitPlugins();
|
bool InitPlugins();
|
||||||
void ShutdownPlugins();
|
void ShutdownPlugins();
|
||||||
|
int OkayToInitPlugin(int Plugin);
|
||||||
void ScanForPlugins();
|
void ScanForPlugins();
|
||||||
void OpenConfig(void* _Parent, const char *_rFilename);
|
void OpenConfig(void* _Parent, const char *_rFilename);
|
||||||
void OpenDebug(void* _Parent, const char *_rFilename, PLUGIN_TYPE Type, bool Show);
|
void OpenDebug(void* _Parent, const char *_rFilename, PLUGIN_TYPE Type, bool Show);
|
||||||
|
|
|
@ -241,6 +241,8 @@ void Initialize(void *init)
|
||||||
// Debugging
|
// Debugging
|
||||||
//Console::Open();
|
//Console::Open();
|
||||||
|
|
||||||
|
//Console::Print("Initialize: %i\n", SDL_WasInit(0));
|
||||||
|
|
||||||
SPADInitialize _PADInitialize = *(SPADInitialize*)init;
|
SPADInitialize _PADInitialize = *(SPADInitialize*)init;
|
||||||
emulator_running = true;
|
emulator_running = true;
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
|
@ -348,6 +350,8 @@ int Search_Devices()
|
||||||
Called from: The Dolphin Core, ConfigBox::OnClose() */
|
Called from: The Dolphin Core, ConfigBox::OnClose() */
|
||||||
void Shutdown()
|
void Shutdown()
|
||||||
{
|
{
|
||||||
|
//Console::Print("Shutdown: %i\n", SDL_WasInit(0));
|
||||||
|
|
||||||
if (PadMapping[0].enabled && SDL_JoystickOpened(PadMapping[0].ID))
|
if (PadMapping[0].enabled && SDL_JoystickOpened(PadMapping[0].ID))
|
||||||
SDL_JoystickClose(joystate[0].joy);
|
SDL_JoystickClose(joystate[0].joy);
|
||||||
if (PadMapping[1].enabled && SDL_JoystickOpened(PadMapping[1].ID))
|
if (PadMapping[1].enabled && SDL_JoystickOpened(PadMapping[1].ID))
|
||||||
|
@ -364,6 +368,7 @@ void Shutdown()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
delete [] joyinfo;
|
delete [] joyinfo;
|
||||||
|
joyinfo = NULL;
|
||||||
|
|
||||||
emulator_running = false;
|
emulator_running = false;
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
#include "Common.h" // Common
|
#include "Common.h" // Common
|
||||||
#include "pluginspecs_pad.h"
|
#include "pluginspecs_pad.h"
|
||||||
#include "IniFile.h"
|
#include "IniFile.h"
|
||||||
//#include "ConsoleWindow.h"
|
#include "ConsoleWindow.h"
|
||||||
//#include "Timer.h"
|
//#include "Timer.h"
|
||||||
|
|
||||||
#include "Config.h" // Local
|
#include "Config.h" // Local
|
||||||
|
|
Loading…
Reference in New Issue