1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-02 09:03:37 +00:00

Add API function FindPluginPath()

since plugin's path is different for Mupen64Plus and Zilmar specs emus.
This commit is contained in:
Sergey Lipskiy 2015-02-04 15:23:21 +06:00
parent e2ddef7520
commit c7c86b7152
4 changed files with 55 additions and 28 deletions

View File

@ -44,6 +44,8 @@ public:
int InitiateGFX(const GFX_INFO & _gfxInfo);
void ChangeWindow();
void FindPluginPath(wchar_t * _strPath);
#ifndef MUPENPLUSAPI
// Zilmar
void DllTest(HWND /*_hParent*/) {}
@ -86,7 +88,7 @@ private:
PluginAPI()
#ifdef RSPTHREAD
: m_pRspThread(NULL), m_command(acNone)
#endif
#endif
{}
PluginAPI(const PluginAPI &);

29
RSP.cpp
View File

@ -10,6 +10,7 @@
#include "FrameBuffer.h"
#include "DepthBuffer.h"
#include "GBI.h"
#include "PluginAPI.h"
#include "Config.h"
using namespace std;
@ -265,32 +266,6 @@ void RSP_SetDefaultState()
gDPPipelineMode(G_PM_NPRIMITIVE);
}
static
void _findPluginPath()
{
#ifdef OS_WINDOWS
GetModuleFileNameW(NULL, RSP.pluginpath, PLUGIN_PATH_SIZE);
#elif OS_LINUX
char path[512];
int res = readlink("/proc/self/exe", path, 510);
if (res != -1) {
path[res] = 0;
::mbstowcs(RSP.pluginpath, path, PLUGIN_PATH_SIZE);
}
#elif OS_MAC_OS_X
char path[MAXPATHLEN];
uint32_t pathLen = MAXPATHLEN*2;
if (_NSGetExecutablePath(path, pathLen) == 0) {
::mbstowcs(RSP.pluginpath, path, PLUGIN_PATH_SIZE);
}
#else
RSP.pluginpath = L"\0";
#endif
wstring pluginPath(RSP.pluginpath);
wstring::size_type pos = pluginPath.find_last_of(L"\\/");
wcscpy(RSP.pluginpath, pluginPath.substr(0, pos).c_str());
}
void RSP_Init()
{
#ifdef OS_WINDOWS
@ -333,7 +308,7 @@ void RSP_Init()
if (strstr(RSP.romname, (const char *)"OgreBattle64"))
config.generalEmulation.hacks |= hack_Ogre64;
_findPluginPath();
api().FindPluginPath(RSP.pluginpath);
RSP_SetDefaultState();
}

View File

@ -1,6 +1,7 @@
#include "../PluginAPI.h"
#include "../OpenGL.h"
#include "../Config.h"
#include "../RSP.h"
int PluginAPI::InitiateGFX(const GFX_INFO & _gfxInfo)
{
@ -10,3 +11,30 @@ int PluginAPI::InitiateGFX(const GFX_INFO & _gfxInfo)
return TRUE;
}
void PluginAPI::FindPluginPath(wchar_t * _strPath)
{
if (_strPath == NULL)
return;
#ifdef OS_WINDOWS
GetModuleFileNameW(NULL, _strPath, PLUGIN_PATH_SIZE);
#elif OS_LINUX
char path[512];
int res = readlink("/proc/self/exe", path, 510);
if (res != -1) {
path[res] = 0;
::mbstowcs(_strPath, path, PLUGIN_PATH_SIZE);
}
#elif OS_MAC_OS_X
char path[MAXPATHLEN];
uint32_t pathLen = MAXPATHLEN * 2;
if (_NSGetExecutablePath(path, pathLen) == 0) {
::mbstowcs(_strPath, path, PLUGIN_PATH_SIZE);
}
#else
_strPath = L"\0";
#endif
std::wstring pluginPath(_strPath);
std::wstring::size_type pos = pluginPath.find_last_of(L"\\/");
wcscpy(_strPath, pluginPath.substr(0, pos).c_str());
}

View File

@ -2,6 +2,11 @@
#include <commctrl.h>
#include "../PluginAPI.h"
#include "../OpenGL.h"
#include "../RSP.h"
#ifdef OS_WINDOWS
EXTERN_C IMAGE_DOS_HEADER __ImageBase;
#endif
BOOL CALLBACK FindToolBarProc( HWND hWnd, LPARAM lParam )
{
@ -23,3 +28,20 @@ int PluginAPI::InitiateGFX(const GFX_INFO & _gfxInfo)
EnumChildWindows( hWnd, FindToolBarProc, 0 );
return TRUE;
}
void PluginAPI::FindPluginPath(wchar_t * _strPath)
{
if (_strPath == NULL)
return;
#ifdef OS_WINDOWS
TCHAR strDLLPath[PLUGIN_PATH_SIZE];
::GetModuleFileName((HINSTANCE)&__ImageBase, strDLLPath, PLUGIN_PATH_SIZE);
::mbstowcs(_strPath, strDLLPath, PLUGIN_PATH_SIZE);
#else
// TODO: for other OS
return;
#endif
std::wstring pluginPath(_strPath);
std::wstring::size_type pos = pluginPath.find_last_of(L"\\/");
wcscpy(_strPath, pluginPath.substr(0, pos).c_str());
}