nJoy: Readded some fixes to nJoy (Notice: these changes have nothing to do with the argument earlier. These are only for fixing nJoy (point one and three in the 1991 revision)). Now opening the Wiimote plugin doesn't crash either (it was just a typo in GetWiimote()).
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2000 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
fb3e523401
commit
fa7e857161
|
@ -64,6 +64,8 @@ CPlugin::CPlugin(const char* _szName) : valid(false)
|
||||||
m_DoState != 0)
|
m_DoState != 0)
|
||||||
valid = true;
|
valid = true;
|
||||||
|
|
||||||
|
// Save the filename for this plugin
|
||||||
|
Filename = _szName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *CPlugin::LoadSymbol(const char *sym) {
|
void *CPlugin::LoadSymbol(const char *sym) {
|
||||||
|
|
|
@ -40,6 +40,7 @@ class CPlugin
|
||||||
~CPlugin();
|
~CPlugin();
|
||||||
|
|
||||||
virtual bool IsValid() {return valid;};
|
virtual bool IsValid() {return valid;};
|
||||||
|
virtual std::string GetFilename() {return Filename;};
|
||||||
|
|
||||||
bool GetInfo(PLUGIN_INFO& _pluginInfo);
|
bool GetInfo(PLUGIN_INFO& _pluginInfo);
|
||||||
void SetGlobals(PLUGIN_GLOBALS* _PluginGlobals);
|
void SetGlobals(PLUGIN_GLOBALS* _PluginGlobals);
|
||||||
|
@ -56,6 +57,7 @@ class CPlugin
|
||||||
|
|
||||||
DynamicLibrary m_hInstLib;
|
DynamicLibrary m_hInstLib;
|
||||||
bool valid;
|
bool valid;
|
||||||
|
std::string Filename;
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
TGetDllInfo m_GetDllInfo;
|
TGetDllInfo m_GetDllInfo;
|
||||||
|
|
|
@ -1,24 +1,24 @@
|
||||||
#include "PluginPAD.h"
|
#include "PluginPAD.h"
|
||||||
|
|
||||||
namespace Common {
|
namespace Common
|
||||||
PluginPAD::PluginPAD(const char *_Filename) : CPlugin(_Filename), validPAD(false) {
|
{
|
||||||
|
PluginPAD::PluginPAD(const char *_Filename) : CPlugin(_Filename), validPAD(false)
|
||||||
PAD_GetStatus = reinterpret_cast<TPAD_GetStatus>
|
{
|
||||||
(LoadSymbol("PAD_GetStatus"));
|
PAD_GetStatus = reinterpret_cast<TPAD_GetStatus>
|
||||||
PAD_Input = reinterpret_cast<TPAD_Input>
|
(LoadSymbol("PAD_GetStatus"));
|
||||||
(LoadSymbol("PAD_Input"));
|
PAD_Input = reinterpret_cast<TPAD_Input>
|
||||||
PAD_Rumble = reinterpret_cast<TPAD_Rumble>
|
(LoadSymbol("PAD_Input"));
|
||||||
(LoadSymbol("PAD_Rumble"));
|
PAD_Rumble = reinterpret_cast<TPAD_Rumble>
|
||||||
PAD_GetAttachedPads = reinterpret_cast<TPAD_GetAttachedPads>
|
(LoadSymbol("PAD_Rumble"));
|
||||||
(LoadSymbol("PAD_GetAttachedPads"));
|
PAD_GetAttachedPads = reinterpret_cast<TPAD_GetAttachedPads>
|
||||||
|
(LoadSymbol("PAD_GetAttachedPads"));
|
||||||
|
|
||||||
if ((PAD_GetStatus != 0) &&
|
if ((PAD_GetStatus != 0) &&
|
||||||
(PAD_Input != 0) &&
|
(PAD_Input != 0) &&
|
||||||
(PAD_Rumble != 0) &&
|
(PAD_Rumble != 0) &&
|
||||||
(PAD_GetAttachedPads != 0))
|
(PAD_GetAttachedPads != 0))
|
||||||
validPAD = true;
|
validPAD = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
PluginPAD::~PluginPAD() {
|
PluginPAD::~PluginPAD() {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,22 +13,23 @@ namespace Common {
|
||||||
typedef void (__cdecl* TVideo_AddMessage)(const char* pstr, unsigned int milliseconds);
|
typedef void (__cdecl* TVideo_AddMessage)(const char* pstr, unsigned int milliseconds);
|
||||||
typedef void (__cdecl* TVideo_Stop)();
|
typedef void (__cdecl* TVideo_Stop)();
|
||||||
|
|
||||||
class PluginVideo : public CPlugin {
|
class PluginVideo : public CPlugin
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
PluginVideo(const char *_Filename);
|
PluginVideo(const char *_Filename);
|
||||||
~PluginVideo();
|
~PluginVideo();
|
||||||
virtual bool IsValid() {return validVideo;};
|
virtual bool IsValid() {return validVideo;};
|
||||||
|
|
||||||
TVideo_Prepare Video_Prepare;
|
TVideo_Prepare Video_Prepare;
|
||||||
TVideo_SendFifoData Video_SendFifoData;
|
TVideo_SendFifoData Video_SendFifoData;
|
||||||
TVideo_UpdateXFB Video_UpdateXFB;
|
TVideo_UpdateXFB Video_UpdateXFB;
|
||||||
TVideo_Screenshot Video_Screenshot;
|
TVideo_Screenshot Video_Screenshot;
|
||||||
TVideo_EnterLoop Video_EnterLoop;
|
TVideo_EnterLoop Video_EnterLoop;
|
||||||
TVideo_AddMessage Video_AddMessage;
|
TVideo_AddMessage Video_AddMessage;
|
||||||
TVideo_Stop Video_Stop;
|
TVideo_Stop Video_Stop;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool validVideo;
|
bool validVideo;
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -347,7 +347,18 @@ THREAD_RETURN EmuThread(void *pArg)
|
||||||
PADInitialize.pLog = Callback_PADLog;
|
PADInitialize.pLog = Callback_PADLog;
|
||||||
PADInitialize.padNumber = i;
|
PADInitialize.padNumber = i;
|
||||||
// Check if we should init the plugin
|
// Check if we should init the plugin
|
||||||
if(Plugins.OkayToInitPlugin(i)) Plugins.GetPAD(i)->Initialize((void *)&PADInitialize);
|
if(Plugins.OkayToInitPlugin(i))
|
||||||
|
{
|
||||||
|
Plugins.GetPad(i)->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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load and Init WiimotePlugin - only if we are booting in wii mode
|
// Load and Init WiimotePlugin - only if we are booting in wii mode
|
||||||
|
|
|
@ -255,8 +255,7 @@ void Init()
|
||||||
g_Channel[i].m_InLo.Hex = 0;
|
g_Channel[i].m_InLo.Hex = 0;
|
||||||
|
|
||||||
// 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);
|
||||||
//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,8 +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);
|
||||||
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);
|
||||||
|
|
||||||
_Hi = (u32)((u8)PadStatus.stickY);
|
_Hi = (u32)((u8)PadStatus.stickY);
|
||||||
|
@ -148,7 +147,7 @@ CSIDevice_GCController::GetData(u32& _Hi, u32& _Low)
|
||||||
void
|
void
|
||||||
CSIDevice_GCController::SendCommand(u32 _Cmd)
|
CSIDevice_GCController::SendCommand(u32 _Cmd)
|
||||||
{
|
{
|
||||||
Common::PluginPAD* pad = CPluginManager::GetInstance().GetPAD(0);
|
Common::PluginPAD* pad = CPluginManager::GetInstance().GetPad(0);
|
||||||
UCommand command(_Cmd);
|
UCommand command(_Cmd);
|
||||||
|
|
||||||
switch(command.Command)
|
switch(command.Command)
|
||||||
|
|
|
@ -34,6 +34,8 @@
|
||||||
#include "ConsoleWindow.h"
|
#include "ConsoleWindow.h"
|
||||||
|
|
||||||
CPluginManager CPluginManager::m_Instance;
|
CPluginManager CPluginManager::m_Instance;
|
||||||
|
|
||||||
|
//#define INPUTCOMMON
|
||||||
//////////////////////////////////////////////
|
//////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,14 +46,26 @@ CPluginManager::CPluginManager() :
|
||||||
m_params(SConfig::GetInstance().m_LocalCoreStartupParameter)
|
m_params(SConfig::GetInstance().m_LocalCoreStartupParameter)
|
||||||
{
|
{
|
||||||
m_PluginGlobals = new PLUGIN_GLOBALS;
|
m_PluginGlobals = new PLUGIN_GLOBALS;
|
||||||
|
|
||||||
|
|
||||||
m_PluginGlobals->eventHandler = EventHandler::GetInstance();
|
m_PluginGlobals->eventHandler = EventHandler::GetInstance();
|
||||||
m_PluginGlobals->config = (void *)&SConfig::GetInstance();
|
m_PluginGlobals->config = (void *)&SConfig::GetInstance();
|
||||||
m_PluginGlobals->messageLogger = NULL;
|
m_PluginGlobals->messageLogger = NULL;
|
||||||
|
|
||||||
|
#ifdef INPUTCOMMON
|
||||||
|
m_InputManager = new InputManager();
|
||||||
|
m_PluginGlobals->inputManager = m_InputManager;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function: FreeLibrary()
|
/* Function: FreeLibrary()
|
||||||
// Called from: This will be called when Dolphin is closed, not when we Stop a game
|
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. */
|
||||||
CPluginManager::~CPluginManager()
|
CPluginManager::~CPluginManager()
|
||||||
{
|
{
|
||||||
Console::Print("Delete CPluginManager\n");
|
Console::Print("Delete CPluginManager\n");
|
||||||
|
@ -108,7 +122,7 @@ bool CPluginManager::InitPlugins()
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -148,8 +162,8 @@ void CPluginManager::ShutdownPlugins()
|
||||||
{
|
{
|
||||||
//Console::Print("Shutdown: %i\n", i);
|
//Console::Print("Shutdown: %i\n", i);
|
||||||
m_pad[i]->Shutdown();
|
m_pad[i]->Shutdown();
|
||||||
}
|
//delete m_pad[i];
|
||||||
//delete m_pad[i];
|
}
|
||||||
//m_pad[i] = NULL;
|
//m_pad[i] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,10 +171,10 @@ void CPluginManager::ShutdownPlugins()
|
||||||
if (m_wiimote[i]) m_wiimote[i]->Shutdown();
|
if (m_wiimote[i]) m_wiimote[i]->Shutdown();
|
||||||
|
|
||||||
if (m_video)
|
if (m_video)
|
||||||
m_video->Shutdown();
|
m_video->Shutdown();
|
||||||
|
|
||||||
if (m_dsp)
|
if (m_dsp)
|
||||||
m_dsp->Shutdown();
|
m_dsp->Shutdown();
|
||||||
}
|
}
|
||||||
//////////////////////////////////////////
|
//////////////////////////////////////////
|
||||||
|
|
||||||
|
@ -168,31 +182,35 @@ void CPluginManager::ShutdownPlugins()
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Supporting functions
|
// Supporting functions
|
||||||
// ¯¯¯¯¯¯¯¯¯¯¯¯
|
// ¯¯¯¯¯¯¯¯¯¯¯¯
|
||||||
|
/* Called from: Get__() functions in this file only (not from anywhere else), therefore we
|
||||||
|
can leave all condition checks in the Get__() functions below. */
|
||||||
void *CPluginManager::LoadPlugin(const char *_rFilename)//, PLUGIN_TYPE type)
|
void *CPluginManager::LoadPlugin(const char *_rFilename, int Number)//, PLUGIN_TYPE type)
|
||||||
{
|
{
|
||||||
CPluginInfo info(_rFilename);
|
CPluginInfo info(_rFilename);
|
||||||
PLUGIN_TYPE type = info.GetPluginInfo().Type;
|
PLUGIN_TYPE type = info.GetPluginInfo().Type;
|
||||||
Common::CPlugin *plugin = NULL;
|
//std::string Filename = info.GetPluginInfo().Filename;
|
||||||
|
std::string Filename = _rFilename;
|
||||||
|
Common::CPlugin *plugin = NULL;
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case PLUGIN_TYPE_VIDEO:
|
case PLUGIN_TYPE_VIDEO:
|
||||||
plugin = new Common::PluginVideo(_rFilename);
|
plugin = new Common::PluginVideo(_rFilename);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PLUGIN_TYPE_PAD:
|
|
||||||
plugin = new Common::PluginPAD(_rFilename);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PLUGIN_TYPE_DSP:
|
case PLUGIN_TYPE_DSP:
|
||||||
plugin = new Common::PluginDSP(_rFilename);
|
plugin = new Common::PluginDSP(_rFilename);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PLUGIN_TYPE_PAD:
|
||||||
|
plugin = new Common::PluginPAD(_rFilename);
|
||||||
|
break;
|
||||||
|
|
||||||
case PLUGIN_TYPE_WIIMOTE:
|
case PLUGIN_TYPE_WIIMOTE:
|
||||||
plugin = new Common::PluginWiimote(_rFilename);
|
plugin = new Common::PluginWiimote(_rFilename);
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
|
default:
|
||||||
PanicAlert("Trying to load unsupported type %d", type);
|
PanicAlert("Trying to load unsupported type %d", type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,15 +230,13 @@ void *CPluginManager::LoadPlugin(const char *_rFilename)//, PLUGIN_TYPE type)
|
||||||
// -------------
|
// -------------
|
||||||
int CPluginManager::OkayToInitPlugin(int Plugin)
|
int CPluginManager::OkayToInitPlugin(int Plugin)
|
||||||
{
|
{
|
||||||
//Console::Print("OkayToInitShutdown: %i", Plugin);
|
|
||||||
// Compare it to the earlier plugins
|
// Compare it to the earlier plugins
|
||||||
for(int i = 0; i < Plugin; i++)
|
for(int i = 0; i < Plugin; i++)
|
||||||
if (m_params.m_strPadPlugin[Plugin] == m_params.m_strPadPlugin[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 i;
|
||||||
}
|
|
||||||
return -1;
|
// No there is no duplicate plugin
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -271,52 +287,68 @@ void CPluginManager::ScanForPlugins()
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Create or return the already created plugin pointers
|
/* Create or return the already created plugin pointers. This will be called often for the
|
||||||
|
Pad and Wiimote from the SI_.cpp files. And often for the DSP from the DSP files. */
|
||||||
// ¯¯¯¯¯¯¯¯¯¯¯¯
|
// ¯¯¯¯¯¯¯¯¯¯¯¯
|
||||||
Common::PluginPAD *CPluginManager::GetPAD(int controller)
|
Common::PluginPAD *CPluginManager::GetPad(int controller)
|
||||||
{
|
{
|
||||||
if (m_pad[controller] == NULL)
|
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(OkayToInitPlugin(controller) == -1)
|
m_pad[controller] = (Common::PluginPAD*)LoadPlugin(m_params.m_strPadPlugin[controller].c_str(), controller);
|
||||||
{
|
Console::Print("LoadPlugin: %i\n", controller);
|
||||||
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("Returned: %i\n", controller);
|
{
|
||||||
return m_pad[controller];
|
Console::Print("Pointed: %i to %i\n", controller, OkayToInitPlugin(controller));
|
||||||
|
m_pad[controller] = m_pad[OkayToInitPlugin(controller)];
|
||||||
|
}
|
||||||
|
return m_pad[controller];
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::PluginWiimote *CPluginManager::GetWiimote(int controller)
|
Common::PluginWiimote *CPluginManager::GetWiimote(int controller)
|
||||||
{
|
{
|
||||||
if (m_wiimote[controller] == NULL)
|
if (m_wiimote[controller] != NULL)
|
||||||
m_wiimote[controller] = (Common::PluginWiimote*)LoadPlugin
|
if (m_wiimote[controller]->GetFilename() == m_params.m_strWiimotePlugin[controller])
|
||||||
(m_params.m_strWiimotePlugin[controller].c_str());
|
return m_wiimote[controller];
|
||||||
|
|
||||||
|
// Else load a new plugin
|
||||||
|
m_wiimote[controller] = (Common::PluginWiimote*)LoadPlugin(m_params.m_strWiimotePlugin[controller].c_str());
|
||||||
return m_wiimote[controller];
|
return m_wiimote[controller];
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::PluginDSP *CPluginManager::GetDSP()
|
Common::PluginDSP *CPluginManager::GetDSP()
|
||||||
{
|
{
|
||||||
if (m_dsp == NULL)
|
if (m_dsp != NULL)
|
||||||
|
if (m_dsp->GetFilename() == m_params.m_strDSPPlugin)
|
||||||
|
return m_dsp;
|
||||||
|
// Else load a new plugin
|
||||||
m_dsp = (Common::PluginDSP*)LoadPlugin(m_params.m_strDSPPlugin.c_str());
|
m_dsp = (Common::PluginDSP*)LoadPlugin(m_params.m_strDSPPlugin.c_str());
|
||||||
|
|
||||||
return m_dsp;
|
return m_dsp;
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::PluginVideo *CPluginManager::GetVideo() {
|
Common::PluginVideo *CPluginManager::GetVideo()
|
||||||
|
{
|
||||||
|
if (m_video != NULL)
|
||||||
|
if (m_video->GetFilename() == m_params.m_strVideoPlugin)
|
||||||
|
return m_video;
|
||||||
|
|
||||||
if (m_video == NULL)
|
// Else load a new plugin
|
||||||
m_video = (Common::PluginVideo*)LoadPlugin(m_params.m_strVideoPlugin.c_str());
|
m_video = (Common::PluginVideo*)LoadPlugin(m_params.m_strVideoPlugin.c_str());
|
||||||
|
|
||||||
return m_video;
|
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];
|
||||||
|
}
|
||||||
///////////////////////////////////////////
|
///////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
@ -325,15 +357,33 @@ Common::PluginVideo *CPluginManager::GetVideo() {
|
||||||
// ¯¯¯¯¯¯¯¯¯¯¯¯
|
// ¯¯¯¯¯¯¯¯¯¯¯¯
|
||||||
|
|
||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
// Open config window. _rFilename = plugin filename , ret = the dll slot number
|
// Open config window. Input: _rFilename = Plugin filename , Type = Plugin type
|
||||||
// -------------
|
// -------------
|
||||||
void CPluginManager::OpenConfig(void* _Parent, const char *_rFilename)
|
void CPluginManager::OpenConfig(void* _Parent, const char *_rFilename, PLUGIN_TYPE Type)
|
||||||
{
|
{
|
||||||
|
#ifdef INPUTCOMMON
|
||||||
|
m_InputManager->Init();
|
||||||
|
#endif
|
||||||
|
|
||||||
Common::CPlugin *plugin = new Common::CPlugin(_rFilename);
|
switch(Type)
|
||||||
plugin->SetGlobals(m_PluginGlobals);
|
{
|
||||||
plugin->Config((HWND)_Parent);
|
case PLUGIN_TYPE_VIDEO:
|
||||||
delete plugin;
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
|
@ -341,10 +391,14 @@ void CPluginManager::OpenConfig(void* _Parent, const char *_rFilename)
|
||||||
// -------------
|
// -------------
|
||||||
void CPluginManager::OpenDebug(void* _Parent, const char *_rFilename, PLUGIN_TYPE Type, bool Show)
|
void CPluginManager::OpenDebug(void* _Parent, const char *_rFilename, PLUGIN_TYPE Type, bool Show)
|
||||||
{
|
{
|
||||||
if (Type == PLUGIN_TYPE_VIDEO) {
|
switch(Type)
|
||||||
|
{
|
||||||
|
case PLUGIN_TYPE_VIDEO:
|
||||||
GetVideo()->Debug((HWND)_Parent, Show);
|
GetVideo()->Debug((HWND)_Parent, Show);
|
||||||
} else if (Type == PLUGIN_TYPE_DSP) {
|
break;
|
||||||
|
case PLUGIN_TYPE_DSP:
|
||||||
GetDSP()->Debug((HWND)_Parent, Show);
|
GetDSP()->Debug((HWND)_Parent, Show);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,16 +46,17 @@ class CPluginManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static CPluginManager& GetInstance() {return(m_Instance);}
|
static CPluginManager& GetInstance() {return(m_Instance);}
|
||||||
Common::PluginPAD *GetPAD(int controller);
|
Common::PluginPAD *GetPad(int controller);
|
||||||
Common::PluginWiimote *GetWiimote(int controller);
|
Common::PluginWiimote *GetWiimote(int controller);
|
||||||
Common::PluginDSP *GetDSP();
|
Common::PluginDSP *GetDSP();
|
||||||
Common::PluginVideo *GetVideo();
|
Common::PluginVideo *GetVideo();
|
||||||
|
Common::PluginPAD *FreePad();
|
||||||
|
|
||||||
bool InitPlugins();
|
bool InitPlugins();
|
||||||
void ShutdownPlugins();
|
void ShutdownPlugins();
|
||||||
int OkayToInitPlugin(int Plugin);
|
int OkayToInitPlugin(int Plugin);
|
||||||
void ScanForPlugins();
|
void ScanForPlugins();
|
||||||
void OpenConfig(void* _Parent, const char *_rFilename);
|
void OpenConfig(void* _Parent, const char *_rFilename, PLUGIN_TYPE Type);
|
||||||
void OpenDebug(void* _Parent, const char *_rFilename, PLUGIN_TYPE Type, bool Show);
|
void OpenDebug(void* _Parent, const char *_rFilename, PLUGIN_TYPE Type, bool Show);
|
||||||
const CPluginInfos& GetPluginInfos() {return(m_PluginInfos);}
|
const CPluginInfos& GetPluginInfos() {return(m_PluginInfos);}
|
||||||
PLUGIN_GLOBALS* GetGlobals();
|
PLUGIN_GLOBALS* GetGlobals();
|
||||||
|
@ -73,7 +74,7 @@ private:
|
||||||
SCoreStartupParameter& m_params;
|
SCoreStartupParameter& m_params;
|
||||||
CPluginManager();
|
CPluginManager();
|
||||||
~CPluginManager();
|
~CPluginManager();
|
||||||
void *LoadPlugin(const char *_rFilename);
|
void *LoadPlugin(const char *_rFilename, int Number = 0);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "Core.h" // Core
|
#include "Core.h" // Core
|
||||||
|
#include "ConsoleWindow.h"
|
||||||
|
|
||||||
#include "Globals.h" // Local
|
#include "Globals.h" // Local
|
||||||
#include "ConfigMain.h"
|
#include "ConfigMain.h"
|
||||||
|
@ -682,17 +683,20 @@ void CConfigMain::DVDRootChanged(wxFileDirPickerEvent& WXUNUSED (event))
|
||||||
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDVDRoot = DVDRoot->GetPath().ToAscii();
|
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDVDRoot = DVDRoot->GetPath().ToAscii();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// =======================================================
|
||||||
|
// Plugins settings
|
||||||
|
// -------------
|
||||||
|
|
||||||
|
// Update plugin filenames
|
||||||
void CConfigMain::OnSelectionChanged(wxCommandEvent& WXUNUSED (event))
|
void CConfigMain::OnSelectionChanged(wxCommandEvent& WXUNUSED (event))
|
||||||
{
|
{
|
||||||
GetFilename(GraphicSelection, SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoPlugin);
|
GetFilename(GraphicSelection, SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoPlugin);
|
||||||
GetFilename(DSPSelection, SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDSPPlugin);
|
GetFilename(DSPSelection, SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDSPPlugin);
|
||||||
|
|
||||||
for (int i = 0; i < MAXPADS; i++)
|
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++)
|
for (int i = 0; i < MAXWIIMOTES; i++)
|
||||||
GetFilename(WiimoteSelection, SConfig::GetInstance().m_LocalCoreStartupParameter.m_strWiimotePlugin[i]);
|
GetFilename(WiimoteSelection, SConfig::GetInstance().m_LocalCoreStartupParameter.m_strWiimotePlugin[i]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CConfigMain::OnConfig(wxCommandEvent& event)
|
void CConfigMain::OnConfig(wxCommandEvent& event)
|
||||||
|
@ -716,15 +720,25 @@ void CConfigMain::OnConfig(wxCommandEvent& event)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ==========================
|
|
||||||
|
|
||||||
|
void CConfigMain::CallConfig(wxChoice* _pChoice)
|
||||||
|
{
|
||||||
|
int Index = _pChoice->GetSelection();
|
||||||
|
Console::Print("CallConfig: %i\n", Index);
|
||||||
|
|
||||||
|
if (Index >= 0)
|
||||||
|
{
|
||||||
|
const CPluginInfo* pInfo = static_cast<CPluginInfo*>(_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)
|
void CConfigMain::FillChoiceBox(wxChoice* _pChoice, int _PluginType, const std::string& _SelectFilename)
|
||||||
{
|
{
|
||||||
|
Console::Print("FillChoiceBox\n");
|
||||||
|
|
||||||
_pChoice->Clear();
|
_pChoice->Clear();
|
||||||
|
|
||||||
int Index = -1;
|
int Index = -1;
|
||||||
|
@ -750,31 +764,16 @@ void CConfigMain::FillChoiceBox(wxChoice* _pChoice, int _PluginType, const std::
|
||||||
_pChoice->Select(Index);
|
_pChoice->Select(Index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CConfigMain::CallConfig(wxChoice* _pChoice)
|
|
||||||
{
|
|
||||||
int Index = _pChoice->GetSelection();
|
|
||||||
|
|
||||||
if (Index >= 0)
|
|
||||||
{
|
|
||||||
const CPluginInfo* pInfo = static_cast<CPluginInfo*>(_pChoice->GetClientData(Index));
|
|
||||||
|
|
||||||
if (pInfo != NULL)
|
|
||||||
CPluginManager::GetInstance().OpenConfig((HWND) this->GetHandle(), pInfo->GetFileName().c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CConfigMain::GetFilename(wxChoice* _pChoice, std::string& _rFilename)
|
bool CConfigMain::GetFilename(wxChoice* _pChoice, std::string& _rFilename)
|
||||||
{
|
{
|
||||||
_rFilename.clear();
|
_rFilename.clear();
|
||||||
|
|
||||||
int Index = _pChoice->GetSelection();
|
int Index = _pChoice->GetSelection();
|
||||||
printf("%i\n", Index);
|
|
||||||
|
|
||||||
if (Index >= 0)
|
if (Index >= 0)
|
||||||
{
|
{
|
||||||
const CPluginInfo* pInfo = static_cast<CPluginInfo*>(_pChoice->GetClientData(Index));
|
const CPluginInfo* pInfo = static_cast<CPluginInfo*>(_pChoice->GetClientData(Index));
|
||||||
_rFilename = pInfo->GetFileName();
|
_rFilename = pInfo->GetFileName();
|
||||||
printf("%s\n", _rFilename.c_str());
|
Console::Print("GetFilename: %i %s\n", Index, _rFilename.c_str());
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -435,7 +435,7 @@ void CFrame::OnKeyDown(wxKeyEvent& event)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(Core::GetState() != Core::CORE_UNINITIALIZED)
|
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();
|
event.Skip();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -443,7 +443,7 @@ void CFrame::OnKeyDown(wxKeyEvent& event)
|
||||||
void CFrame::OnKeyUp(wxKeyEvent& event)
|
void CFrame::OnKeyUp(wxKeyEvent& event)
|
||||||
{
|
{
|
||||||
if(Core::GetState() != Core::CORE_UNINITIALIZED)
|
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();
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -539,7 +539,8 @@ void CFrame::OnPluginGFX(wxCommandEvent& WXUNUSED (event))
|
||||||
{
|
{
|
||||||
CPluginManager::GetInstance().OpenConfig(
|
CPluginManager::GetInstance().OpenConfig(
|
||||||
GetHandle(),
|
GetHandle(),
|
||||||
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoPlugin.c_str()
|
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoPlugin.c_str(),
|
||||||
|
PLUGIN_TYPE_VIDEO
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -548,7 +549,8 @@ void CFrame::OnPluginDSP(wxCommandEvent& WXUNUSED (event))
|
||||||
{
|
{
|
||||||
CPluginManager::GetInstance().OpenConfig(
|
CPluginManager::GetInstance().OpenConfig(
|
||||||
GetHandle(),
|
GetHandle(),
|
||||||
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDSPPlugin.c_str()
|
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDSPPlugin.c_str(),
|
||||||
|
PLUGIN_TYPE_DSP
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -556,14 +558,16 @@ void CFrame::OnPluginPAD(wxCommandEvent& WXUNUSED (event))
|
||||||
{
|
{
|
||||||
CPluginManager::GetInstance().OpenConfig(
|
CPluginManager::GetInstance().OpenConfig(
|
||||||
GetHandle(),
|
GetHandle(),
|
||||||
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strPadPlugin[0].c_str()
|
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strPadPlugin[0].c_str(),
|
||||||
|
PLUGIN_TYPE_PAD
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
void CFrame::OnPluginWiimote(wxCommandEvent& WXUNUSED (event))
|
void CFrame::OnPluginWiimote(wxCommandEvent& WXUNUSED (event))
|
||||||
{
|
{
|
||||||
CPluginManager::GetInstance().OpenConfig(
|
CPluginManager::GetInstance().OpenConfig(
|
||||||
GetHandle(),
|
GetHandle(),
|
||||||
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strWiimotePlugin[0].c_str()
|
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strWiimotePlugin[0].c_str(),
|
||||||
|
PLUGIN_TYPE_WIIMOTE
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -146,6 +146,9 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Main", "..\Branches\MusicMo
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Player", "..\Branches\MusicMod\Player\Player.vcproj", "{0B72B5D6-5D72-4391-84A7-9CCA5392668A}"
|
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
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestPlayer", "..\Branches\MusicMod\TestPlayer\TestPlayer.vcproj", "{0D14F1E9-490B-4A2D-A4EF-0535E8B3C718}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestPlayer", "..\Branches\MusicMod\TestPlayer\TestPlayer.vcproj", "{0D14F1E9-490B-4A2D-A4EF-0535E8B3C718}"
|
||||||
EndProject
|
EndProject
|
||||||
|
|
|
@ -243,7 +243,7 @@ void Initialize(void *init)
|
||||||
|
|
||||||
//Console::Print("Initialize: %i\n", SDL_WasInit(0));
|
//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
|
||||||
DEBUG_INIT();
|
DEBUG_INIT();
|
||||||
|
@ -251,18 +251,19 @@ void Initialize(void *init)
|
||||||
|
|
||||||
/* SDL 1.3 use DirectInput instead of the old Microsoft Multimeda API, and with this we need
|
/* SDL 1.3 use DirectInput instead of the old Microsoft Multimeda API, and with this we need
|
||||||
the SDL_INIT_VIDEO flag to */
|
the SDL_INIT_VIDEO flag to */
|
||||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0)
|
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);
|
#ifdef _WIN32
|
||||||
#else
|
MessageBox(NULL, SDL_GetError(), "Could not initialize SDL!", MB_ICONERROR);
|
||||||
printf("Could not initialize SDL! (%s)\n", SDL_GetError());
|
#else
|
||||||
#endif
|
printf("Could not initialize SDL! (%s)\n", SDL_GetError());
|
||||||
return;
|
#endif
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
m_hWnd = (HWND)_PADInitialize.hWnd;
|
m_hWnd = (HWND)_PADInitialize->hWnd;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Search_Devices(); // Populate joyinfo for all attached devices
|
Search_Devices(); // Populate joyinfo for all attached devices
|
||||||
|
@ -275,6 +276,17 @@ void Initialize(void *init)
|
||||||
joystate[2].joy = SDL_JoystickOpen(PadMapping[2].ID);
|
joystate[2].joy = SDL_JoystickOpen(PadMapping[2].ID);
|
||||||
if (PadMapping[3].enabled)
|
if (PadMapping[3].enabled)
|
||||||
joystate[3].joy = SDL_JoystickOpen(PadMapping[3].ID);
|
joystate[3].joy = SDL_JoystickOpen(PadMapping[3].ID);
|
||||||
|
|
||||||
|
/* 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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue