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:
John Peterson
2009-01-22 11:18:46 +00:00
parent 189285f071
commit e332e18ce6
9 changed files with 281 additions and 156 deletions

View File

@ -15,13 +15,21 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
/*
All plugins from Core > Plugins are loaded and unloaded with this class when Dolpin is started
and stopped.
//////////////////////////////////////////////////////////////////////////////////////////
// File description
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
All plugins from Core > Plugins are loaded and unloaded with this class when Dolpin is started
and stopped.
//////////////////////////////////////*/
#include <string.h>
//////////////////////////////////////////////////////////////////////////////////////////
// Include
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#include <string.h> // System
#ifdef _WIN32
#include <windows.h>
#else
@ -29,10 +37,13 @@ and stopped.
#include <stdio.h>
#endif
#include "Common.h"
#include "Common.h" // Local
#include "FileUtil.h"
#include "StringUtil.h"
#include "DynamicLibrary.h"
#include "ConsoleWindow.h"
////////////////////////////////////////
DynamicLibrary::DynamicLibrary()
{
@ -41,33 +52,33 @@ DynamicLibrary::DynamicLibrary()
std::string GetLastErrorAsString()
{
#ifdef _WIN32
LPVOID lpMsgBuf = 0;
DWORD error = GetLastError();
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
error,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0, NULL);
std::string s;
if (lpMsgBuf)
{
s = ((char *)lpMsgBuf);
LocalFree(lpMsgBuf);
} else {
s = StringFromFormat("(unknown error %08x)", error);
}
return s;
#else
static std::string errstr;
char *tmp = dlerror();
if (tmp)
errstr = tmp;
return errstr;
#endif
#ifdef _WIN32
LPVOID lpMsgBuf = 0;
DWORD error = GetLastError();
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
error,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0, NULL);
std::string s;
if (lpMsgBuf)
{
s = ((char *)lpMsgBuf);
LocalFree(lpMsgBuf);
} else {
s = StringFromFormat("(unknown error %08x)", error);
}
return s;
#else
static std::string errstr;
char *tmp = dlerror();
if (tmp)
errstr = tmp;
return errstr;
#endif
}
/* Function: Loading means loading the dll with LoadLibrary() to get an instance to the dll.
@ -93,6 +104,7 @@ int DynamicLibrary::Load(const char* filename)
}
#ifdef _WIN32
Console::Print("LoadLibrary: %s\n", filename);
library = LoadLibrary(filename);
#else
library = dlopen(filename, RTLD_NOW | RTLD_LOCAL);
@ -118,6 +130,7 @@ int DynamicLibrary::Unload()
}
#ifdef _WIN32
Console::Print("FreeLibrary: %i\n", library);
retval = FreeLibrary(library);
#else
retval = dlclose(library)?0:1;

View File

@ -70,25 +70,32 @@ void *CPlugin::LoadSymbol(const char *sym) {
return m_hInstLib.Get(sym);
}
// ______________________________________________________________________________________
// GetInfo: Get DLL info
bool CPlugin::GetInfo(PLUGIN_INFO& _pluginInfo) {
if (m_GetDllInfo != 0) {
m_GetDllInfo(&_pluginInfo);
return(true);
if (m_GetDllInfo != 0)
{
m_GetDllInfo(&_pluginInfo);
return(true);
}
return(false);
}
void CPlugin::Config(HWND _hwnd) {
if (m_DllConfig != 0)
m_DllConfig(_hwnd);
// ______________________________________________________________________________________
// Config: Open the Config window
void CPlugin::Config(HWND _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);
}