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:
John Peterson 2009-01-24 12:09:30 +00:00
parent fb3e523401
commit fa7e857161
14 changed files with 221 additions and 134 deletions

View File

@ -64,6 +64,8 @@ CPlugin::CPlugin(const char* _szName) : valid(false)
m_DoState != 0)
valid = true;
// Save the filename for this plugin
Filename = _szName;
}
void *CPlugin::LoadSymbol(const char *sym) {

View File

@ -40,6 +40,7 @@ class CPlugin
~CPlugin();
virtual bool IsValid() {return valid;};
virtual std::string GetFilename() {return Filename;};
bool GetInfo(PLUGIN_INFO& _pluginInfo);
void SetGlobals(PLUGIN_GLOBALS* _PluginGlobals);
@ -56,6 +57,7 @@ class CPlugin
DynamicLibrary m_hInstLib;
bool valid;
std::string Filename;
// Functions
TGetDllInfo m_GetDllInfo;

View File

@ -1,24 +1,24 @@
#include "PluginPAD.h"
namespace Common {
PluginPAD::PluginPAD(const char *_Filename) : CPlugin(_Filename), validPAD(false) {
PAD_GetStatus = reinterpret_cast<TPAD_GetStatus>
(LoadSymbol("PAD_GetStatus"));
PAD_Input = reinterpret_cast<TPAD_Input>
(LoadSymbol("PAD_Input"));
PAD_Rumble = reinterpret_cast<TPAD_Rumble>
(LoadSymbol("PAD_Rumble"));
PAD_GetAttachedPads = reinterpret_cast<TPAD_GetAttachedPads>
(LoadSymbol("PAD_GetAttachedPads"));
namespace Common
{
PluginPAD::PluginPAD(const char *_Filename) : CPlugin(_Filename), validPAD(false)
{
PAD_GetStatus = reinterpret_cast<TPAD_GetStatus>
(LoadSymbol("PAD_GetStatus"));
PAD_Input = reinterpret_cast<TPAD_Input>
(LoadSymbol("PAD_Input"));
PAD_Rumble = reinterpret_cast<TPAD_Rumble>
(LoadSymbol("PAD_Rumble"));
PAD_GetAttachedPads = reinterpret_cast<TPAD_GetAttachedPads>
(LoadSymbol("PAD_GetAttachedPads"));
if ((PAD_GetStatus != 0) &&
(PAD_Input != 0) &&
(PAD_Rumble != 0) &&
(PAD_GetAttachedPads != 0))
validPAD = true;
if ((PAD_GetStatus != 0) &&
(PAD_Input != 0) &&
(PAD_Rumble != 0) &&
(PAD_GetAttachedPads != 0))
validPAD = true;
}
PluginPAD::~PluginPAD() {
}
PluginPAD::~PluginPAD() {}
}

View File

@ -13,22 +13,23 @@ namespace Common {
typedef void (__cdecl* TVideo_AddMessage)(const char* pstr, unsigned int milliseconds);
typedef void (__cdecl* TVideo_Stop)();
class PluginVideo : public CPlugin {
class PluginVideo : public CPlugin
{
public:
PluginVideo(const char *_Filename);
~PluginVideo();
virtual bool IsValid() {return validVideo;};
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;
};
}

View File

@ -347,7 +347,18 @@ THREAD_RETURN EmuThread(void *pArg)
PADInitialize.pLog = Callback_PADLog;
PADInitialize.padNumber = i;
// 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

View File

@ -255,8 +255,7 @@ void Init()
g_Channel[i].m_InLo.Hex = 0;
// 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
if (pad != NULL && (pad->PAD_GetAttachedPads() & (1 << i)))

View File

@ -120,8 +120,7 @@ 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 >= MAXPADS) ? (MAXPADS - 1): ISIDevice::m_iDeviceNumber);
CPluginManager::GetInstance().GetPad(ISIDevice::m_iDeviceNumber);
pad->PAD_GetStatus(ISIDevice::m_iDeviceNumber, &PadStatus);
_Hi = (u32)((u8)PadStatus.stickY);
@ -148,7 +147,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)

View File

@ -34,6 +34,8 @@
#include "ConsoleWindow.h"
CPluginManager CPluginManager::m_Instance;
//#define INPUTCOMMON
//////////////////////////////////////////////
@ -44,14 +46,26 @@ 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: This will be called when Dolphin is closed, not when we Stop a game
/* 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. */
CPluginManager::~CPluginManager()
{
Console::Print("Delete CPluginManager\n");
@ -108,7 +122,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;
}
@ -148,8 +162,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;
}
@ -157,10 +171,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();
}
//////////////////////////////////////////
@ -168,31 +182,35 @@ void CPluginManager::ShutdownPlugins()
//////////////////////////////////////////////////////////////////////////////////////////
// Supporting functions
// ¯¯¯¯¯¯¯¯¯¯¯¯
void *CPluginManager::LoadPlugin(const char *_rFilename)//, PLUGIN_TYPE type)
/* 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, int Number)//, PLUGIN_TYPE type)
{
CPluginInfo info(_rFilename);
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)
{
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_PAD:
plugin = new Common::PluginPAD(_rFilename);
break;
case PLUGIN_TYPE_WIIMOTE:
plugin = new Common::PluginWiimote(_rFilename);
break;
default:
default:
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)
{
//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;
// 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());
Console::Print("LoadPlugin: %i\n", controller);
}
else
{
Console::Print("Pointed: %i to %i\n", controller, OkayToInitPlugin(controller));
m_pad[controller] = m_pad[OkayToInitPlugin(controller)];
}
m_pad[controller] = (Common::PluginPAD*)LoadPlugin(m_params.m_strPadPlugin[controller].c_str(), controller);
Console::Print("LoadPlugin: %i\n", controller);
}
//Console::Print("Returned: %i\n", controller);
return m_pad[controller];
else
{
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)
{
if (m_wiimote[controller] == NULL)
m_wiimote[controller] = (Common::PluginWiimote*)LoadPlugin
(m_params.m_strWiimotePlugin[controller].c_str());
if (m_wiimote[controller] != NULL)
if (m_wiimote[controller]->GetFilename() == m_params.m_strWiimotePlugin[controller])
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];
}
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());
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());
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);
plugin->SetGlobals(m_PluginGlobals);
plugin->Config((HWND)_Parent);
delete plugin;
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
}
// ----------------------------------------
@ -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)
{
if (Type == PLUGIN_TYPE_VIDEO) {
switch(Type)
{
case PLUGIN_TYPE_VIDEO:
GetVideo()->Debug((HWND)_Parent, Show);
} else if (Type == PLUGIN_TYPE_DSP) {
break;
case PLUGIN_TYPE_DSP:
GetDSP()->Debug((HWND)_Parent, Show);
break;
}
}

View File

@ -46,16 +46,17 @@ 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);
void OpenConfig(void* _Parent, const char *_rFilename, PLUGIN_TYPE Type);
void OpenDebug(void* _Parent, const char *_rFilename, PLUGIN_TYPE Type, bool Show);
const CPluginInfos& GetPluginInfos() {return(m_PluginInfos);}
PLUGIN_GLOBALS* GetGlobals();
@ -73,7 +74,7 @@ private:
SCoreStartupParameter& m_params;
CPluginManager();
~CPluginManager();
void *LoadPlugin(const char *_rFilename);
void *LoadPlugin(const char *_rFilename, int Number = 0);
};

View File

@ -22,6 +22,7 @@
#include <vector>
#include "Core.h" // Core
#include "ConsoleWindow.h"
#include "Globals.h" // Local
#include "ConfigMain.h"
@ -682,17 +683,20 @@ 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)
@ -716,15 +720,25 @@ 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<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)
{
Console::Print("FillChoiceBox\n");
_pChoice->Clear();
int Index = -1;
@ -750,31 +764,16 @@ void CConfigMain::FillChoiceBox(wxChoice* _pChoice, int _PluginType, const std::
_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)
{
{
_rFilename.clear();
int Index = _pChoice->GetSelection();
printf("%i\n", Index);
if (Index >= 0)
{
const CPluginInfo* pInfo = static_cast<CPluginInfo*>(_pChoice->GetClientData(Index));
_rFilename = pInfo->GetFileName();
printf("%s\n", _rFilename.c_str());
Console::Print("GetFilename: %i %s\n", Index, _rFilename.c_str());
return(true);
}

View File

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

View File

@ -539,7 +539,8 @@ void CFrame::OnPluginGFX(wxCommandEvent& WXUNUSED (event))
{
CPluginManager::GetInstance().OpenConfig(
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(
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(
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))
{
CPluginManager::GetInstance().OpenConfig(
GetHandle(),
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strWiimotePlugin[0].c_str()
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strWiimotePlugin[0].c_str(),
PLUGIN_TYPE_WIIMOTE
);
}

View File

@ -146,6 +146,9 @@ 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

View File

@ -243,7 +243,7 @@ void Initialize(void *init)
//Console::Print("Initialize: %i\n", SDL_WasInit(0));
SPADInitialize _PADInitialize = *(SPADInitialize*)init;
SPADInitialize *_PADInitialize = (SPADInitialize*)init;
emulator_running = true;
#ifdef _DEBUG
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
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;
}
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;
}
#ifdef _WIN32
m_hWnd = (HWND)_PADInitialize.hWnd;
m_hWnd = (HWND)_PADInitialize->hWnd;
#endif
Search_Devices(); // Populate joyinfo for all attached devices
@ -275,6 +276,17 @@ void Initialize(void *init)
joystate[2].joy = SDL_JoystickOpen(PadMapping[2].ID);
if (PadMapping[3].enabled)
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());
}
}