mirror of
https://github.com/simple64/simple64.git
synced 2026-11-13 07:18:42 +01:00
update gui
This commit is contained in:
1 parent
bcb0702504
commit
6488c7b84d
25 files changed
+330
-882
No files matched your search
@@ -25,8 +25,8 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "cheat.h"
|
||||
#include "core_interface.h"
|
||||
#include "common.h"
|
||||
#include "core_commands.h"
|
||||
|
||||
/* local definitions */
|
||||
#define CHEAT_FILE "mupencheat.txt"
|
||||
|
||||
@@ -29,14 +29,13 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include "common.h"
|
||||
#include "plugin.h"
|
||||
#include "core_interface.h"
|
||||
#include <SDL_keycode.h>
|
||||
#include <QProcess>
|
||||
#include "version.h"
|
||||
#include "cheat.h"
|
||||
#include "mainwindow.h"
|
||||
#include "logviewer.h"
|
||||
#include "core_commands.h"
|
||||
|
||||
/*********************************************************************************************************
|
||||
* Callback functions from the core
|
||||
@@ -79,8 +78,7 @@ void DebugCallback(void *Context, int level, const char *message)
|
||||
}
|
||||
else
|
||||
output = QString("%1 Unknown: %2\n").arg((const char *) Context, message);
|
||||
|
||||
if (!output.isEmpty())
|
||||
if (w != nullptr && !output.isEmpty())
|
||||
w->getLogViewer()->addLog(output);
|
||||
}
|
||||
|
||||
@@ -160,9 +158,6 @@ static m64p_media_loader media_loader =
|
||||
|
||||
m64p_error loadROM(std::string filename)
|
||||
{
|
||||
if (!QtAttachCoreLib())
|
||||
return M64ERR_INVALID_STATE;
|
||||
|
||||
char *ROM_buffer = NULL;
|
||||
size_t romlength = 0;
|
||||
|
||||
@@ -179,7 +174,6 @@ m64p_error loadROM(std::string filename)
|
||||
if (romlength == 0)
|
||||
{
|
||||
DebugMessage(M64MSG_ERROR, "couldn't open file '%s' for reading.", filename.c_str());
|
||||
DetachCoreLib();
|
||||
return M64ERR_INVALID_STATE;
|
||||
}
|
||||
ROM_buffer = (char *) malloc(romlength);
|
||||
@@ -192,7 +186,6 @@ m64p_error loadROM(std::string filename)
|
||||
if (!file.open(QIODevice::ReadOnly))
|
||||
{
|
||||
DebugMessage(M64MSG_ERROR, "couldn't open ROM file '%s' for reading.", filename.c_str());
|
||||
DetachCoreLib();
|
||||
return M64ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
@@ -204,7 +197,6 @@ m64p_error loadROM(std::string filename)
|
||||
DebugMessage(M64MSG_ERROR, "couldn't read %li bytes from ROM image file '%s'.", romlength, filename.c_str());
|
||||
free(ROM_buffer);
|
||||
file.close();
|
||||
DetachCoreLib();
|
||||
return M64ERR_INVALID_STATE;
|
||||
}
|
||||
file.close();
|
||||
@@ -215,7 +207,6 @@ m64p_error loadROM(std::string filename)
|
||||
{
|
||||
DebugMessage(M64MSG_ERROR, "core failed to open ROM image file '%s'.", filename.c_str());
|
||||
free(ROM_buffer);
|
||||
DetachCoreLib();
|
||||
return M64ERR_INVALID_STATE;
|
||||
}
|
||||
free(ROM_buffer); /* the core copies the ROM image, so we can release this buffer immediately */
|
||||
@@ -249,31 +240,14 @@ static void loadPif()
|
||||
|
||||
m64p_error launchGame(QString netplay_ip, int netplay_port, int netplay_player)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
if (!netplay_port)
|
||||
loadPif();
|
||||
|
||||
/* search for and load plugins */
|
||||
m64p_error rval = PluginSearchLoad();
|
||||
if (rval != M64ERR_SUCCESS)
|
||||
{
|
||||
(*CoreDoCommand)(M64CMD_ROM_CLOSE, 0, NULL);
|
||||
DetachCoreLib();
|
||||
return M64ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
/* attach plugins to core */
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if ((*CoreAttachPlugin)(g_PluginMap[i].type, g_PluginMap[i].handle) != M64ERR_SUCCESS)
|
||||
{
|
||||
DebugMessage(M64MSG_ERROR, "core error while attaching %s plugin.", g_PluginMap[i].name);
|
||||
(*CoreDoCommand)(M64CMD_ROM_CLOSE, 0, NULL);
|
||||
DetachCoreLib();
|
||||
return M64ERR_INVALID_STATE;
|
||||
}
|
||||
}
|
||||
(*CoreAttachPlugin)(M64PLUGIN_GFX, w->getGfxPlugin());
|
||||
(*CoreAttachPlugin)(M64PLUGIN_AUDIO, w->getAudioPlugin());
|
||||
(*CoreAttachPlugin)(M64PLUGIN_INPUT, w->getInputPlugin());
|
||||
(*CoreAttachPlugin)(M64PLUGIN_RSP, w->getRspPlugin());
|
||||
|
||||
m64p_rom_header l_RomHeader;
|
||||
/* get the ROM header for the currently loaded ROM image from the core */
|
||||
@@ -281,7 +255,6 @@ m64p_error launchGame(QString netplay_ip, int netplay_port, int netplay_player)
|
||||
{
|
||||
DebugMessage(M64MSG_WARNING, "couldn't get ROM header information from core library");
|
||||
(*CoreDoCommand)(M64CMD_ROM_CLOSE, 0, NULL);
|
||||
DetachCoreLib();
|
||||
return M64ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
@@ -338,10 +311,10 @@ m64p_error launchGame(QString netplay_ip, int netplay_port, int netplay_player)
|
||||
if (netplay_port)
|
||||
(*CoreDoCommand)(M64CMD_NETPLAY_CLOSE, 0, NULL);
|
||||
|
||||
/* detach plugins from core and unload them */
|
||||
for (i = 0; i < 4; i++)
|
||||
(*CoreDetachPlugin)(g_PluginMap[i].type);
|
||||
PluginUnload();
|
||||
(*CoreDetachPlugin)(M64PLUGIN_GFX);
|
||||
(*CoreDetachPlugin)(M64PLUGIN_AUDIO);
|
||||
(*CoreDetachPlugin)(M64PLUGIN_INPUT);
|
||||
(*CoreDetachPlugin)(M64PLUGIN_RSP);
|
||||
|
||||
/* close the ROM image */
|
||||
(*CoreDoCommand)(M64CMD_ROM_CLOSE, 0, NULL);
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
#include "core_commands.h"
|
||||
|
||||
ptr_CoreStartup CoreStartup = nullptr;
|
||||
ptr_CoreShutdown CoreShutdown = nullptr;
|
||||
ptr_CoreDoCommand CoreDoCommand = nullptr;
|
||||
ptr_CoreAttachPlugin CoreAttachPlugin = nullptr;
|
||||
ptr_CoreDetachPlugin CoreDetachPlugin = nullptr;
|
||||
ptr_CoreOverrideVidExt CoreOverrideVidExt = nullptr;
|
||||
|
||||
ptr_ConfigGetUserConfigPath ConfigGetUserConfigPath = nullptr;
|
||||
ptr_ConfigSaveFile ConfigSaveFile = nullptr;
|
||||
ptr_ConfigGetParameterHelp ConfigGetParameterHelp = nullptr;
|
||||
ptr_ConfigGetParamInt ConfigGetParamInt = nullptr;
|
||||
ptr_ConfigGetParamFloat ConfigGetParamFloat = nullptr;
|
||||
ptr_ConfigGetParamBool ConfigGetParamBool = nullptr;
|
||||
ptr_ConfigGetParamString ConfigGetParamString = nullptr;
|
||||
ptr_ConfigSetParameter ConfigSetParameter = nullptr;
|
||||
ptr_ConfigDeleteSection ConfigDeleteSection = nullptr;
|
||||
ptr_ConfigOpenSection ConfigOpenSection = nullptr;
|
||||
ptr_ConfigListParameters ConfigListParameters = nullptr;
|
||||
ptr_ConfigGetSharedDataFilepath ConfigGetSharedDataFilepath = nullptr;
|
||||
|
||||
ptr_CoreAddCheat CoreAddCheat = nullptr;
|
||||
ptr_CoreCheatEnabled CoreCheatEnabled = nullptr;
|
||||
@@ -0,0 +1,29 @@
|
||||
#ifndef __CORE_COMMANDS_H__
|
||||
#define __CORE_COMMANDS_H__
|
||||
|
||||
#include "m64p_frontend.h"
|
||||
#include "m64p_config.h"
|
||||
|
||||
extern ptr_CoreStartup CoreStartup;
|
||||
extern ptr_CoreShutdown CoreShutdown;
|
||||
extern ptr_CoreDoCommand CoreDoCommand;
|
||||
extern ptr_CoreAttachPlugin CoreAttachPlugin;
|
||||
extern ptr_CoreDetachPlugin CoreDetachPlugin;
|
||||
extern ptr_CoreOverrideVidExt CoreOverrideVidExt;
|
||||
|
||||
extern ptr_ConfigGetUserConfigPath ConfigGetUserConfigPath;
|
||||
extern ptr_ConfigSaveFile ConfigSaveFile;
|
||||
extern ptr_ConfigGetParameterHelp ConfigGetParameterHelp;
|
||||
extern ptr_ConfigGetParamInt ConfigGetParamInt;
|
||||
extern ptr_ConfigGetParamFloat ConfigGetParamFloat;
|
||||
extern ptr_ConfigGetParamBool ConfigGetParamBool;
|
||||
extern ptr_ConfigGetParamString ConfigGetParamString;
|
||||
extern ptr_ConfigSetParameter ConfigSetParameter;
|
||||
extern ptr_ConfigDeleteSection ConfigDeleteSection;
|
||||
extern ptr_ConfigOpenSection ConfigOpenSection;
|
||||
extern ptr_ConfigListParameters ConfigListParameters;
|
||||
extern ptr_ConfigGetSharedDataFilepath ConfigGetSharedDataFilepath;
|
||||
|
||||
extern ptr_CoreAddCheat CoreAddCheat;
|
||||
extern ptr_CoreCheatEnabled CoreCheatEnabled;
|
||||
#endif
|
||||
@@ -1,388 +0,0 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Mupen64plus-ui-console - core_interface.c *
|
||||
* Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
|
||||
* Copyright (C) 2009 Richard Goedeken *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
/* This file contains the routines for attaching to the Mupen64Plus core
|
||||
* library and pointers to the core functions
|
||||
*/
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QCoreApplication>
|
||||
#include <QDir>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "core_interface.h"
|
||||
#include "m64p_common.h"
|
||||
#include "m64p_config.h"
|
||||
#include "m64p_debugger.h"
|
||||
#include "m64p_frontend.h"
|
||||
#include "m64p_types.h"
|
||||
#include "common.h"
|
||||
extern "C" {
|
||||
#include "osal_dynamiclib.h"
|
||||
#include "osal_preproc.h"
|
||||
}
|
||||
#include "version.h"
|
||||
#include "vidext.h"
|
||||
|
||||
/* global data definitions */
|
||||
int g_CoreCapabilities;
|
||||
int g_CoreAPIVersion;
|
||||
QString qtCoreDirPath;
|
||||
QString qtConfigDir;
|
||||
int coreStarted = 0;
|
||||
|
||||
/* definitions of pointers to Core common functions */
|
||||
ptr_CoreErrorMessage CoreErrorMessage = NULL;
|
||||
|
||||
/* definitions of pointers to Core front-end functions */
|
||||
ptr_CoreStartup CoreStartup = NULL;
|
||||
ptr_CoreShutdown CoreShutdown = NULL;
|
||||
ptr_CoreAttachPlugin CoreAttachPlugin = NULL;
|
||||
ptr_CoreDetachPlugin CoreDetachPlugin = NULL;
|
||||
ptr_CoreDoCommand CoreDoCommand = NULL;
|
||||
ptr_CoreOverrideVidExt CoreOverrideVidExt = NULL;
|
||||
ptr_CoreAddCheat CoreAddCheat = NULL;
|
||||
ptr_CoreCheatEnabled CoreCheatEnabled = NULL;
|
||||
|
||||
/* definitions of pointers to Core config functions */
|
||||
ptr_ConfigListSections ConfigListSections = NULL;
|
||||
ptr_ConfigOpenSection ConfigOpenSection = NULL;
|
||||
ptr_ConfigDeleteSection ConfigDeleteSection = NULL;
|
||||
ptr_ConfigSaveSection ConfigSaveSection = NULL;
|
||||
ptr_ConfigListParameters ConfigListParameters = NULL;
|
||||
ptr_ConfigSaveFile ConfigSaveFile = NULL;
|
||||
ptr_ConfigSetParameter ConfigSetParameter = NULL;
|
||||
ptr_ConfigGetParameter ConfigGetParameter = NULL;
|
||||
ptr_ConfigGetParameterType ConfigGetParameterType = NULL;
|
||||
ptr_ConfigGetParameterHelp ConfigGetParameterHelp = NULL;
|
||||
ptr_ConfigSetDefaultInt ConfigSetDefaultInt = NULL;
|
||||
ptr_ConfigSetDefaultFloat ConfigSetDefaultFloat = NULL;
|
||||
ptr_ConfigSetDefaultBool ConfigSetDefaultBool = NULL;
|
||||
ptr_ConfigSetDefaultString ConfigSetDefaultString = NULL;
|
||||
ptr_ConfigGetParamInt ConfigGetParamInt = NULL;
|
||||
ptr_ConfigGetParamFloat ConfigGetParamFloat = NULL;
|
||||
ptr_ConfigGetParamBool ConfigGetParamBool = NULL;
|
||||
ptr_ConfigGetParamString ConfigGetParamString = NULL;
|
||||
|
||||
ptr_ConfigGetSharedDataFilepath ConfigGetSharedDataFilepath = NULL;
|
||||
ptr_ConfigGetUserConfigPath ConfigGetUserConfigPath = NULL;
|
||||
ptr_ConfigGetUserDataPath ConfigGetUserDataPath = NULL;
|
||||
ptr_ConfigGetUserCachePath ConfigGetUserCachePath = NULL;
|
||||
|
||||
/* definitions of pointers to Core debugger functions */
|
||||
ptr_DebugSetCallbacks DebugSetCallbacks = NULL;
|
||||
ptr_DebugSetCoreCompare DebugSetCoreCompare = NULL;
|
||||
ptr_DebugSetRunState DebugSetRunState = NULL;
|
||||
ptr_DebugGetState DebugGetState = NULL;
|
||||
ptr_DebugStep DebugStep = NULL;
|
||||
ptr_DebugDecodeOp DebugDecodeOp = NULL;
|
||||
ptr_DebugMemGetRecompInfo DebugMemGetRecompInfo = NULL;
|
||||
ptr_DebugMemGetMemInfo DebugMemGetMemInfo = NULL;
|
||||
ptr_DebugMemGetPointer DebugMemGetPointer = NULL;
|
||||
|
||||
ptr_DebugMemRead64 DebugMemRead64 = NULL;
|
||||
ptr_DebugMemRead32 DebugMemRead32 = NULL;
|
||||
ptr_DebugMemRead16 DebugMemRead16 = NULL;
|
||||
ptr_DebugMemRead8 DebugMemRead8 = NULL;
|
||||
|
||||
ptr_DebugMemWrite64 DebugMemWrite64 = NULL;
|
||||
ptr_DebugMemWrite32 DebugMemWrite32 = NULL;
|
||||
ptr_DebugMemWrite16 DebugMemWrite16 = NULL;
|
||||
ptr_DebugMemWrite8 DebugMemWrite8 = NULL;
|
||||
|
||||
ptr_DebugGetCPUDataPtr DebugGetCPUDataPtr = NULL;
|
||||
ptr_DebugBreakpointLookup DebugBreakpointLookup = NULL;
|
||||
ptr_DebugBreakpointCommand DebugBreakpointCommand = NULL;
|
||||
|
||||
/* global variables */
|
||||
m64p_dynlib_handle CoreHandle = NULL;
|
||||
m64p_video_extension_functions vidExtFunctions = {14,
|
||||
qtVidExtFuncInit,
|
||||
qtVidExtFuncQuit,
|
||||
qtVidExtFuncListModes,
|
||||
qtVidExtFuncListRates,
|
||||
qtVidExtFuncSetMode,
|
||||
qtVidExtFuncSetModeWithRate,
|
||||
qtVidExtFuncGLGetProc,
|
||||
qtVidExtFuncGLSetAttr,
|
||||
qtVidExtFuncGLGetAttr,
|
||||
qtVidExtFuncGLSwapBuf,
|
||||
qtVidExtFuncSetCaption,
|
||||
qtVidExtFuncToggleFS,
|
||||
qtVidExtFuncResizeWindow,
|
||||
qtVidExtFuncGLGetDefaultFramebuffer};
|
||||
|
||||
bool QtAttachCoreLib()
|
||||
{
|
||||
if (AttachCoreLib(qtCoreDirPath.toLatin1().data()) != M64ERR_SUCCESS && CoreHandle == NULL) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText("Couldn't load core library, please set the path in settings.");
|
||||
msgBox.exec();
|
||||
return false;
|
||||
}
|
||||
if (!coreStarted) {
|
||||
/* start the Mupen64Plus core library, load the configuration file */
|
||||
m64p_error rval;
|
||||
if (!qtConfigDir.isEmpty())
|
||||
rval = (*CoreStartup)(CORE_API_VERSION, qtConfigDir.toLatin1().data() /*Config dir*/, QCoreApplication::applicationDirPath().toLatin1().data(), (char*)"Core", DebugCallback, NULL, NULL);
|
||||
else
|
||||
rval = (*CoreStartup)(CORE_API_VERSION, NULL /*Config dir*/, QCoreApplication::applicationDirPath().toLatin1().data(), (char*)"Core", DebugCallback, NULL, NULL);
|
||||
if (rval != M64ERR_SUCCESS)
|
||||
{
|
||||
DebugMessage(M64MSG_ERROR, "couldn't start Mupen64Plus core library.");
|
||||
DetachCoreLib();
|
||||
return false;
|
||||
}
|
||||
|
||||
rval = CoreOverrideVidExt(&vidExtFunctions);
|
||||
if (rval != M64ERR_SUCCESS)
|
||||
{
|
||||
DebugMessage(M64MSG_ERROR, "couldn't start VidExt library.");
|
||||
DetachCoreLib();
|
||||
return false;
|
||||
}
|
||||
coreStarted = 1;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* functions */
|
||||
m64p_error AttachCoreLib(const char *CoreLibFilepath)
|
||||
{
|
||||
/* check if Core DLL is already attached */
|
||||
if (CoreHandle != NULL)
|
||||
return M64ERR_INVALID_STATE;
|
||||
|
||||
/* load the DLL */
|
||||
m64p_error rval = M64ERR_INTERNAL;
|
||||
if (CoreLibFilepath != NULL)
|
||||
{
|
||||
rval = osal_dynlib_open(&CoreHandle, CoreLibFilepath);
|
||||
}
|
||||
if (rval != M64ERR_SUCCESS || CoreHandle == NULL)
|
||||
{
|
||||
QString corePath = QDir(QCoreApplication::applicationDirPath()).filePath(OSAL_DEFAULT_DYNLIB_FILENAME);
|
||||
rval = osal_dynlib_open(&CoreHandle, corePath.toLatin1().data());
|
||||
}
|
||||
/* if we haven't found a good core library by now, then we're screwed */
|
||||
if (rval != M64ERR_SUCCESS || CoreHandle == NULL)
|
||||
{
|
||||
DebugMessage(M64MSG_ERROR, "AttachCoreLib() Error: failed to find Mupen64Plus Core library");
|
||||
CoreHandle = NULL;
|
||||
return M64ERR_INPUT_NOT_FOUND;
|
||||
}
|
||||
|
||||
/* attach and call the PluginGetVersion function, check the Core and API versions for compatibility with this front-end */
|
||||
ptr_PluginGetVersion CoreVersionFunc;
|
||||
CoreVersionFunc = (ptr_PluginGetVersion) osal_dynlib_getproc(CoreHandle, "PluginGetVersion");
|
||||
if (CoreVersionFunc == NULL)
|
||||
{
|
||||
DebugMessage(M64MSG_ERROR, "AttachCoreLib() Error: Shared library '%s' invalid; no PluginGetVersion() function found.", CoreLibFilepath);
|
||||
osal_dynlib_close(CoreHandle);
|
||||
CoreHandle = NULL;
|
||||
return M64ERR_INPUT_INVALID;
|
||||
}
|
||||
m64p_plugin_type PluginType = (m64p_plugin_type) 0;
|
||||
int Compatible = 0;
|
||||
int CoreVersion = 0;
|
||||
const char *CoreName = NULL;
|
||||
(*CoreVersionFunc)(&PluginType, &CoreVersion, &g_CoreAPIVersion, &CoreName, &g_CoreCapabilities);
|
||||
if (PluginType != M64PLUGIN_CORE)
|
||||
DebugMessage(M64MSG_ERROR, "AttachCoreLib() Error: Shared library '%s' invalid; this is not the emulator core.", CoreLibFilepath);
|
||||
else if (CoreVersion < MINIMUM_CORE_VERSION)
|
||||
DebugMessage(M64MSG_ERROR, "AttachCoreLib() Error: Shared library '%s' incompatible; core version %i.%i.%i is below minimum supported %i.%i.%i",
|
||||
CoreLibFilepath, VERSION_PRINTF_SPLIT(CoreVersion), VERSION_PRINTF_SPLIT(MINIMUM_CORE_VERSION));
|
||||
else if ((g_CoreAPIVersion & 0xffff0000) != (CORE_API_VERSION & 0xffff0000))
|
||||
DebugMessage(M64MSG_ERROR, "AttachCoreLib() Error: Shared library '%s' incompatible; core API major version %i.%i.%i doesn't match with this application (%i.%i.%i)",
|
||||
CoreLibFilepath, VERSION_PRINTF_SPLIT(g_CoreAPIVersion), VERSION_PRINTF_SPLIT(CORE_API_VERSION));
|
||||
else
|
||||
Compatible = 1;
|
||||
/* exit if not compatible */
|
||||
if (Compatible == 0)
|
||||
{
|
||||
osal_dynlib_close(CoreHandle);
|
||||
CoreHandle = NULL;
|
||||
return M64ERR_INCOMPATIBLE;
|
||||
}
|
||||
|
||||
/* attach and call the CoreGetAPIVersion function, check Config API version for compatibility */
|
||||
ptr_CoreGetAPIVersions CoreAPIVersionFunc;
|
||||
CoreAPIVersionFunc = (ptr_CoreGetAPIVersions) osal_dynlib_getproc(CoreHandle, "CoreGetAPIVersions");
|
||||
if (CoreAPIVersionFunc == NULL)
|
||||
{
|
||||
DebugMessage(M64MSG_ERROR, "AttachCoreLib() Error: Library '%s' broken; no CoreAPIVersionFunc() function found.", CoreLibFilepath);
|
||||
osal_dynlib_close(CoreHandle);
|
||||
CoreHandle = NULL;
|
||||
return M64ERR_INPUT_INVALID;
|
||||
}
|
||||
int ConfigAPIVersion, DebugAPIVersion, VidextAPIVersion;
|
||||
(*CoreAPIVersionFunc)(&ConfigAPIVersion, &DebugAPIVersion, &VidextAPIVersion, NULL);
|
||||
if ((ConfigAPIVersion & 0xffff0000) != (CONFIG_API_VERSION & 0xffff0000))
|
||||
{
|
||||
DebugMessage(M64MSG_ERROR, "AttachCoreLib() Error: Emulator core '%s' incompatible; Config API major version %i.%i.%i doesn't match application: %i.%i.%i",
|
||||
CoreLibFilepath, VERSION_PRINTF_SPLIT(ConfigAPIVersion), VERSION_PRINTF_SPLIT(CONFIG_API_VERSION));
|
||||
osal_dynlib_close(CoreHandle);
|
||||
CoreHandle = NULL;
|
||||
return M64ERR_INCOMPATIBLE;
|
||||
}
|
||||
|
||||
/* print some information about the core library */
|
||||
DebugMessage(M64MSG_INFO, "attached to core library '%s' version %i.%i.%i", CoreName, VERSION_PRINTF_SPLIT(CoreVersion));
|
||||
if (g_CoreCapabilities & M64CAPS_DYNAREC)
|
||||
DebugMessage(M64MSG_INFO, " Includes support for Dynamic Recompiler.");
|
||||
if (g_CoreCapabilities & M64CAPS_DEBUGGER)
|
||||
DebugMessage(M64MSG_INFO, " Includes support for MIPS r4300 Debugger.");
|
||||
if (g_CoreCapabilities & M64CAPS_CORE_COMPARE)
|
||||
DebugMessage(M64MSG_INFO, " Includes support for r4300 Core Comparison.");
|
||||
|
||||
/* get function pointers to the common and front-end functions */
|
||||
CoreErrorMessage = (ptr_CoreErrorMessage) osal_dynlib_getproc(CoreHandle, "CoreErrorMessage");
|
||||
CoreStartup = (ptr_CoreStartup) osal_dynlib_getproc(CoreHandle, "CoreStartup");
|
||||
CoreShutdown = (ptr_CoreShutdown) osal_dynlib_getproc(CoreHandle, "CoreShutdown");
|
||||
CoreAttachPlugin = (ptr_CoreAttachPlugin) osal_dynlib_getproc(CoreHandle, "CoreAttachPlugin");
|
||||
CoreDetachPlugin = (ptr_CoreDetachPlugin) osal_dynlib_getproc(CoreHandle, "CoreDetachPlugin");
|
||||
CoreDoCommand = (ptr_CoreDoCommand) osal_dynlib_getproc(CoreHandle, "CoreDoCommand");
|
||||
CoreOverrideVidExt = (ptr_CoreOverrideVidExt) osal_dynlib_getproc(CoreHandle, "CoreOverrideVidExt");
|
||||
CoreAddCheat = (ptr_CoreAddCheat) osal_dynlib_getproc(CoreHandle, "CoreAddCheat");
|
||||
CoreCheatEnabled = (ptr_CoreCheatEnabled) osal_dynlib_getproc(CoreHandle, "CoreCheatEnabled");
|
||||
|
||||
/* get function pointers to the configuration functions */
|
||||
ConfigListSections = (ptr_ConfigListSections) osal_dynlib_getproc(CoreHandle, "ConfigListSections");
|
||||
ConfigOpenSection = (ptr_ConfigOpenSection) osal_dynlib_getproc(CoreHandle, "ConfigOpenSection");
|
||||
ConfigDeleteSection = (ptr_ConfigDeleteSection) osal_dynlib_getproc(CoreHandle, "ConfigDeleteSection");
|
||||
ConfigSaveSection = (ptr_ConfigSaveSection) osal_dynlib_getproc(CoreHandle, "ConfigSaveSection");
|
||||
ConfigListParameters = (ptr_ConfigListParameters) osal_dynlib_getproc(CoreHandle, "ConfigListParameters");
|
||||
ConfigSaveFile = (ptr_ConfigSaveFile) osal_dynlib_getproc(CoreHandle, "ConfigSaveFile");
|
||||
ConfigSetParameter = (ptr_ConfigSetParameter) osal_dynlib_getproc(CoreHandle, "ConfigSetParameter");
|
||||
ConfigGetParameter = (ptr_ConfigGetParameter) osal_dynlib_getproc(CoreHandle, "ConfigGetParameter");
|
||||
ConfigGetParameterType = (ptr_ConfigGetParameterType) osal_dynlib_getproc(CoreHandle, "ConfigGetParameterType");
|
||||
ConfigGetParameterHelp = (ptr_ConfigGetParameterHelp) osal_dynlib_getproc(CoreHandle, "ConfigGetParameterHelp");
|
||||
ConfigSetDefaultInt = (ptr_ConfigSetDefaultInt) osal_dynlib_getproc(CoreHandle, "ConfigSetDefaultInt");
|
||||
ConfigSetDefaultFloat = (ptr_ConfigSetDefaultFloat) osal_dynlib_getproc(CoreHandle, "ConfigSetDefaultFloat");
|
||||
ConfigSetDefaultBool = (ptr_ConfigSetDefaultBool) osal_dynlib_getproc(CoreHandle, "ConfigSetDefaultBool");
|
||||
ConfigSetDefaultString = (ptr_ConfigSetDefaultString) osal_dynlib_getproc(CoreHandle, "ConfigSetDefaultString");
|
||||
ConfigGetParamInt = (ptr_ConfigGetParamInt) osal_dynlib_getproc(CoreHandle, "ConfigGetParamInt");
|
||||
ConfigGetParamFloat = (ptr_ConfigGetParamFloat) osal_dynlib_getproc(CoreHandle, "ConfigGetParamFloat");
|
||||
ConfigGetParamBool = (ptr_ConfigGetParamBool) osal_dynlib_getproc(CoreHandle, "ConfigGetParamBool");
|
||||
ConfigGetParamString = (ptr_ConfigGetParamString) osal_dynlib_getproc(CoreHandle, "ConfigGetParamString");
|
||||
|
||||
ConfigGetSharedDataFilepath = (ptr_ConfigGetSharedDataFilepath) osal_dynlib_getproc(CoreHandle, "ConfigGetSharedDataFilepath");
|
||||
ConfigGetUserConfigPath = (ptr_ConfigGetUserConfigPath) osal_dynlib_getproc(CoreHandle, "ConfigGetUserConfigPath");
|
||||
ConfigGetUserDataPath = (ptr_ConfigGetUserDataPath) osal_dynlib_getproc(CoreHandle, "ConfigGetUserDataPath");
|
||||
ConfigGetUserCachePath = (ptr_ConfigGetUserCachePath) osal_dynlib_getproc(CoreHandle, "ConfigGetUserCachePath");
|
||||
|
||||
/* get function pointers to the debugger functions */
|
||||
DebugSetCallbacks = (ptr_DebugSetCallbacks) osal_dynlib_getproc(CoreHandle, "DebugSetCallbacks");
|
||||
DebugSetCoreCompare = (ptr_DebugSetCoreCompare) osal_dynlib_getproc(CoreHandle, "DebugSetCoreCompare");
|
||||
DebugSetRunState = (ptr_DebugSetRunState) osal_dynlib_getproc(CoreHandle, "DebugSetRunState");
|
||||
DebugGetState = (ptr_DebugGetState) osal_dynlib_getproc(CoreHandle, "DebugGetState");
|
||||
DebugStep = (ptr_DebugStep) osal_dynlib_getproc(CoreHandle, "DebugStep");
|
||||
DebugDecodeOp = (ptr_DebugDecodeOp) osal_dynlib_getproc(CoreHandle, "DebugDecodeOp");
|
||||
DebugMemGetRecompInfo = (ptr_DebugMemGetRecompInfo) osal_dynlib_getproc(CoreHandle, "DebugMemGetRecompInfo");
|
||||
DebugMemGetMemInfo = (ptr_DebugMemGetMemInfo) osal_dynlib_getproc(CoreHandle, "DebugMemGetMemInfo");
|
||||
DebugMemGetPointer = (ptr_DebugMemGetPointer) osal_dynlib_getproc(CoreHandle, "DebugMemGetPointer");
|
||||
|
||||
DebugMemRead64 = (ptr_DebugMemRead64) osal_dynlib_getproc(CoreHandle, "DebugMemRead64");
|
||||
DebugMemRead32 = (ptr_DebugMemRead32) osal_dynlib_getproc(CoreHandle, "DebugMemRead32");
|
||||
DebugMemRead16 = (ptr_DebugMemRead16) osal_dynlib_getproc(CoreHandle, "DebugMemRead16");
|
||||
DebugMemRead8 = (ptr_DebugMemRead8) osal_dynlib_getproc(CoreHandle, "DebugMemRead8");
|
||||
|
||||
DebugMemWrite64 = (ptr_DebugMemWrite64) osal_dynlib_getproc(CoreHandle, "DebugMemRead64");
|
||||
DebugMemWrite32 = (ptr_DebugMemWrite32) osal_dynlib_getproc(CoreHandle, "DebugMemRead32");
|
||||
DebugMemWrite16 = (ptr_DebugMemWrite16) osal_dynlib_getproc(CoreHandle, "DebugMemRead16");
|
||||
DebugMemWrite8 = (ptr_DebugMemWrite8) osal_dynlib_getproc(CoreHandle, "DebugMemRead8");
|
||||
|
||||
DebugGetCPUDataPtr = (ptr_DebugGetCPUDataPtr) osal_dynlib_getproc(CoreHandle, "DebugGetCPUDataPtr");
|
||||
DebugBreakpointLookup = (ptr_DebugBreakpointLookup) osal_dynlib_getproc(CoreHandle, "DebugBreakpointLookup");
|
||||
DebugBreakpointCommand = (ptr_DebugBreakpointCommand) osal_dynlib_getproc(CoreHandle, "DebugBreakpointCommand");
|
||||
|
||||
return M64ERR_SUCCESS;
|
||||
}
|
||||
|
||||
m64p_error DetachCoreLib(void)
|
||||
{
|
||||
if (CoreHandle == NULL)
|
||||
return M64ERR_INVALID_STATE;
|
||||
|
||||
(*CoreShutdown)();
|
||||
|
||||
/* set the core function pointers to NULL */
|
||||
CoreErrorMessage = NULL;
|
||||
CoreStartup = NULL;
|
||||
CoreShutdown = NULL;
|
||||
CoreAttachPlugin = NULL;
|
||||
CoreDetachPlugin = NULL;
|
||||
CoreDoCommand = NULL;
|
||||
CoreOverrideVidExt = NULL;
|
||||
CoreAddCheat = NULL;
|
||||
CoreCheatEnabled = NULL;
|
||||
|
||||
ConfigListSections = NULL;
|
||||
ConfigOpenSection = NULL;
|
||||
ConfigDeleteSection = NULL;
|
||||
ConfigSaveSection = NULL;
|
||||
ConfigListParameters = NULL;
|
||||
ConfigSetParameter = NULL;
|
||||
ConfigGetParameter = NULL;
|
||||
ConfigGetParameterType = NULL;
|
||||
ConfigGetParameterHelp = NULL;
|
||||
ConfigSetDefaultInt = NULL;
|
||||
ConfigSetDefaultBool = NULL;
|
||||
ConfigSetDefaultString = NULL;
|
||||
ConfigGetParamInt = NULL;
|
||||
ConfigGetParamBool = NULL;
|
||||
ConfigGetParamString = NULL;
|
||||
|
||||
ConfigGetSharedDataFilepath = NULL;
|
||||
ConfigGetUserDataPath = NULL;
|
||||
ConfigGetUserCachePath = NULL;
|
||||
|
||||
DebugSetCallbacks = NULL;
|
||||
DebugSetCoreCompare = NULL;
|
||||
DebugSetRunState = NULL;
|
||||
DebugGetState = NULL;
|
||||
DebugStep = NULL;
|
||||
DebugDecodeOp = NULL;
|
||||
DebugMemGetRecompInfo = NULL;
|
||||
DebugMemGetMemInfo = NULL;
|
||||
DebugMemGetPointer = NULL;
|
||||
|
||||
DebugMemRead64 = NULL;
|
||||
DebugMemRead32 = NULL;
|
||||
DebugMemRead16 = NULL;
|
||||
DebugMemRead8 = NULL;
|
||||
|
||||
DebugMemWrite64 = NULL;
|
||||
DebugMemWrite32 = NULL;
|
||||
DebugMemWrite16 = NULL;
|
||||
DebugMemWrite8 = NULL;
|
||||
|
||||
DebugGetCPUDataPtr = NULL;
|
||||
DebugBreakpointLookup = NULL;
|
||||
DebugBreakpointCommand = NULL;
|
||||
|
||||
/* detach the shared library */
|
||||
osal_dynlib_close(CoreHandle);
|
||||
CoreHandle = NULL;
|
||||
coreStarted = 0;
|
||||
|
||||
return M64ERR_SUCCESS;
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Mupen64plus-ui-console - core_interface.h *
|
||||
* Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
|
||||
* Copyright (C) 2009 Richard Goedeken *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#if !defined(CORE_INTERFACE_H)
|
||||
#define CORE_INTERFACE_H
|
||||
|
||||
#include "m64p_common.h"
|
||||
#include "m64p_config.h"
|
||||
#include "m64p_debugger.h"
|
||||
#include "m64p_frontend.h"
|
||||
#include "m64p_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <QString>
|
||||
extern QString qtCoreDirPath;
|
||||
extern QString qtConfigDir;
|
||||
#endif
|
||||
|
||||
/* function declarations */
|
||||
m64p_error AttachCoreLib(const char *CoreLibFilepath);
|
||||
m64p_error DetachCoreLib(void);
|
||||
bool QtAttachCoreLib(void);
|
||||
|
||||
/* global variables from core_interface.c */
|
||||
extern int g_CoreCapabilities;
|
||||
extern int g_CoreAPIVersion;
|
||||
extern int coreStarted;
|
||||
|
||||
/* declarations of Core library handle and pointers to common functions */
|
||||
extern m64p_dynlib_handle CoreHandle;
|
||||
extern ptr_CoreErrorMessage CoreErrorMessage;
|
||||
|
||||
/* declarations of pointers to Core front-end functions */
|
||||
extern ptr_CoreStartup CoreStartup;
|
||||
extern ptr_CoreShutdown CoreShutdown;
|
||||
extern ptr_CoreAttachPlugin CoreAttachPlugin;
|
||||
extern ptr_CoreDetachPlugin CoreDetachPlugin;
|
||||
extern ptr_CoreDoCommand CoreDoCommand;
|
||||
extern ptr_CoreOverrideVidExt CoreOverrideVidExt;
|
||||
extern ptr_CoreAddCheat CoreAddCheat;
|
||||
extern ptr_CoreCheatEnabled CoreCheatEnabled;
|
||||
|
||||
/* declarations of pointers to Core config functions */
|
||||
extern ptr_ConfigListSections ConfigListSections;
|
||||
extern ptr_ConfigOpenSection ConfigOpenSection;
|
||||
extern ptr_ConfigDeleteSection ConfigDeleteSection;
|
||||
extern ptr_ConfigSaveSection ConfigSaveSection;
|
||||
extern ptr_ConfigListParameters ConfigListParameters;
|
||||
extern ptr_ConfigSaveFile ConfigSaveFile;
|
||||
extern ptr_ConfigSetParameter ConfigSetParameter;
|
||||
extern ptr_ConfigGetParameter ConfigGetParameter;
|
||||
extern ptr_ConfigGetParameterType ConfigGetParameterType;
|
||||
extern ptr_ConfigGetParameterHelp ConfigGetParameterHelp;
|
||||
extern ptr_ConfigSetDefaultInt ConfigSetDefaultInt;
|
||||
extern ptr_ConfigSetDefaultFloat ConfigSetDefaultFloat;
|
||||
extern ptr_ConfigSetDefaultBool ConfigSetDefaultBool;
|
||||
extern ptr_ConfigSetDefaultString ConfigSetDefaultString;
|
||||
extern ptr_ConfigGetParamInt ConfigGetParamInt;
|
||||
extern ptr_ConfigGetParamFloat ConfigGetParamFloat;
|
||||
extern ptr_ConfigGetParamBool ConfigGetParamBool;
|
||||
extern ptr_ConfigGetParamString ConfigGetParamString;
|
||||
|
||||
extern ptr_ConfigGetSharedDataFilepath ConfigGetSharedDataFilepath;
|
||||
extern ptr_ConfigGetUserConfigPath ConfigGetUserConfigPath;
|
||||
extern ptr_ConfigGetUserDataPath ConfigGetUserDataPath;
|
||||
extern ptr_ConfigGetUserCachePath ConfigGetUserCachePath;
|
||||
|
||||
/* declarations of pointers to Core debugger functions */
|
||||
extern ptr_DebugSetCallbacks DebugSetCallbacks;
|
||||
extern ptr_DebugSetCoreCompare DebugSetCoreCompare;
|
||||
extern ptr_DebugSetRunState DebugSetRunState;
|
||||
extern ptr_DebugGetState DebugGetState;
|
||||
extern ptr_DebugStep DebugStep;
|
||||
extern ptr_DebugDecodeOp DebugDecodeOp;
|
||||
extern ptr_DebugMemGetRecompInfo DebugMemGetRecompInfo;
|
||||
extern ptr_DebugMemGetMemInfo DebugMemGetMemInfo;
|
||||
extern ptr_DebugMemGetPointer DebugMemGetPointer;
|
||||
|
||||
extern ptr_DebugMemRead64 DebugMemRead64;
|
||||
extern ptr_DebugMemRead32 DebugMemRead32;
|
||||
extern ptr_DebugMemRead16 DebugMemRead16;
|
||||
extern ptr_DebugMemRead8 DebugMemRead8;
|
||||
|
||||
extern ptr_DebugMemWrite64 DebugMemWrite64;
|
||||
extern ptr_DebugMemWrite32 DebugMemWrite32;
|
||||
extern ptr_DebugMemWrite16 DebugMemWrite16;
|
||||
extern ptr_DebugMemWrite8 DebugMemWrite8;
|
||||
|
||||
extern ptr_DebugGetCPUDataPtr DebugGetCPUDataPtr;
|
||||
extern ptr_DebugBreakpointLookup DebugBreakpointLookup;
|
||||
extern ptr_DebugBreakpointCommand DebugBreakpointCommand;
|
||||
|
||||
#endif /* #define CORE_INTERFACE_H */
|
||||
|
||||
@@ -1,195 +0,0 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Mupen64plus-ui-console - plugin.c *
|
||||
* Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
|
||||
* Copyright (C) 2009 Richard42 *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <QCoreApplication>
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "core_interface.h"
|
||||
#include "m64p_common.h"
|
||||
#include "m64p_types.h"
|
||||
#include "common.h" /* for the debug callback function */
|
||||
extern "C" {
|
||||
#include "osal_dynamiclib.h"
|
||||
#include "osal_files.h"
|
||||
#include "osal_preproc.h"
|
||||
}
|
||||
#include "plugin.h"
|
||||
#include "version.h"
|
||||
|
||||
/* global variables */
|
||||
QString qtPluginDir;
|
||||
QString qtGfxPlugin;
|
||||
QString qtAudioPlugin;
|
||||
QString qtInputPlugin;
|
||||
QString qtRspPlugin;
|
||||
|
||||
plugin_map_node g_PluginMap[] = {{M64PLUGIN_GFX, "Video", NULL, "", "", 0 },
|
||||
{M64PLUGIN_AUDIO, "Audio", NULL, "", "", 0 },
|
||||
{M64PLUGIN_INPUT, "Input", NULL, "", "", 0 },
|
||||
{M64PLUGIN_RSP, "RSP", NULL, "", "", 0 } };
|
||||
|
||||
/* local functions */
|
||||
static m64p_error PluginLoadTry(std::string filepath, int MapIndex)
|
||||
{
|
||||
/* try to open a shared library at the given filepath */
|
||||
m64p_dynlib_handle handle;
|
||||
m64p_error rval = osal_dynlib_open(&handle, filepath.c_str());
|
||||
if (rval != M64ERR_SUCCESS)
|
||||
return rval;
|
||||
|
||||
/* call the GetVersion function for the plugin and check compatibility */
|
||||
ptr_PluginGetVersion PluginGetVersion = (ptr_PluginGetVersion) osal_dynlib_getproc(handle, "PluginGetVersion");
|
||||
if (PluginGetVersion == NULL)
|
||||
{
|
||||
DebugMessage(M64MSG_ERROR, "library '%s' is not a Mupen64Plus library.", filepath.c_str());
|
||||
osal_dynlib_close(handle);
|
||||
return M64ERR_INCOMPATIBLE;
|
||||
}
|
||||
m64p_plugin_type PluginType = (m64p_plugin_type) 0;
|
||||
int PluginVersion = 0;
|
||||
const char *PluginName = NULL;
|
||||
(*PluginGetVersion)(&PluginType, &PluginVersion, NULL, &PluginName, NULL);
|
||||
if (PluginType != g_PluginMap[MapIndex].type)
|
||||
{
|
||||
/* the type of this plugin doesn't match with the type that was requested by the caller */
|
||||
osal_dynlib_close(handle);
|
||||
return M64ERR_INCOMPATIBLE;
|
||||
}
|
||||
/* the front-end doesn't talk to the plugins, so we don't care about the plugin version or api version */
|
||||
|
||||
/* call the plugin's initialization function and make sure it starts okay */
|
||||
ptr_PluginStartup PluginStartup = (ptr_PluginStartup) osal_dynlib_getproc(handle, "PluginStartup");
|
||||
if (PluginStartup == NULL)
|
||||
{
|
||||
DebugMessage(M64MSG_ERROR, "library '%s' broken. No PluginStartup() function found.", filepath.c_str());
|
||||
osal_dynlib_close(handle);
|
||||
return M64ERR_INCOMPATIBLE;
|
||||
}
|
||||
rval = (*PluginStartup)(CoreHandle, g_PluginMap[MapIndex].name, DebugCallback); /* DebugCallback is in main.c */
|
||||
if (rval != M64ERR_SUCCESS)
|
||||
{
|
||||
DebugMessage(M64MSG_ERROR, "Error: %s plugin library '%s' failed to start.", g_PluginMap[MapIndex].name, filepath.c_str());
|
||||
osal_dynlib_close(handle);
|
||||
return rval;
|
||||
}
|
||||
|
||||
/* plugin loaded successfully, so set the plugin map's members */
|
||||
g_PluginMap[MapIndex].handle = handle;
|
||||
g_PluginMap[MapIndex].filename = filepath;
|
||||
g_PluginMap[MapIndex].libname = PluginName;
|
||||
g_PluginMap[MapIndex].libversion = PluginVersion;
|
||||
|
||||
return M64ERR_SUCCESS;
|
||||
}
|
||||
|
||||
/* global functions */
|
||||
m64p_error PluginSearchLoad()
|
||||
{
|
||||
osal_lib_search *lib_filelist = NULL;
|
||||
int i;
|
||||
|
||||
/* start by checking the directory given on the command line */
|
||||
if (!qtPluginDir.isEmpty())
|
||||
lib_filelist = osal_library_search(qtPluginDir.toLatin1().data());
|
||||
if (lib_filelist == NULL)
|
||||
lib_filelist = osal_library_search(QCoreApplication::applicationDirPath().toLatin1().data());
|
||||
|
||||
/* try to load one of each type of plugin */
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
m64p_plugin_type type = g_PluginMap[i].type;
|
||||
std::string cmdline_path;
|
||||
switch (type)
|
||||
{
|
||||
case M64PLUGIN_RSP: cmdline_path = qtRspPlugin.toStdString(); break;
|
||||
case M64PLUGIN_GFX: cmdline_path = qtGfxPlugin.toStdString(); break;
|
||||
case M64PLUGIN_AUDIO: cmdline_path = qtAudioPlugin.toStdString(); break;
|
||||
case M64PLUGIN_INPUT: cmdline_path = qtInputPlugin.toStdString(); break;
|
||||
default: cmdline_path = "";
|
||||
}
|
||||
|
||||
/* if full path was given, try loading exactly this file */
|
||||
if (strchr(cmdline_path.c_str(), OSAL_DIR_SEPARATOR) != NULL)
|
||||
{
|
||||
PluginLoadTry(cmdline_path, i);
|
||||
}
|
||||
else /* otherwise search through the plugin directory to find a match with this name */
|
||||
{
|
||||
osal_lib_search *curr = lib_filelist;
|
||||
while (curr != NULL && g_PluginMap[i].handle == NULL)
|
||||
{
|
||||
if (curr->filename == cmdline_path)
|
||||
PluginLoadTry(curr->filepath, i);
|
||||
curr = curr->next;
|
||||
}
|
||||
}
|
||||
|
||||
/* print out the particular plugin used */
|
||||
if (g_PluginMap[i].handle == NULL)
|
||||
{
|
||||
QString name = g_PluginMap[i].name;
|
||||
if (w->getWorkerThread() != nullptr) {
|
||||
if (w->getWorkerThread()->isRunning())
|
||||
w->getWorkerThread()->pluginWarning(name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugMessage(M64MSG_INFO, "using %s plugin: '%s' v%i.%i.%i", g_PluginMap[i].name,
|
||||
g_PluginMap[i].libname.c_str(), VERSION_PRINTF_SPLIT(g_PluginMap[i].libversion));
|
||||
DebugMessage(M64MSG_VERBOSE, "%s plugin library: %s", g_PluginMap[i].name, g_PluginMap[i].filename.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
/* free up the list of library files in the plugin search directory */
|
||||
osal_free_lib_list(lib_filelist);
|
||||
return M64ERR_SUCCESS;
|
||||
}
|
||||
|
||||
m64p_error PluginUnload(void)
|
||||
{
|
||||
typedef m64p_error (*ptr_PluginShutdown)(void);
|
||||
ptr_PluginShutdown PluginShutdown;
|
||||
int i;
|
||||
|
||||
/* shutdown each type of plugin */
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (g_PluginMap[i].handle == NULL)
|
||||
continue;
|
||||
/* call the destructor function for the plugin and release the library */
|
||||
PluginShutdown = (ptr_PluginShutdown) osal_dynlib_getproc(g_PluginMap[i].handle, "PluginShutdown");
|
||||
if (PluginShutdown != NULL)
|
||||
(*PluginShutdown)();
|
||||
osal_dynlib_close(g_PluginMap[i].handle);
|
||||
/* clear out the plugin map's members */
|
||||
g_PluginMap[i].handle = NULL;
|
||||
g_PluginMap[i].filename.clear();
|
||||
g_PluginMap[i].libname.clear();
|
||||
g_PluginMap[i].libversion = 0;
|
||||
}
|
||||
|
||||
return M64ERR_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Mupen64plus-ui-console - plugin.h *
|
||||
* Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
|
||||
* Copyright (C) 2009 Richard42 *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#if !defined(PLUGIN_H)
|
||||
#define PLUGIN_H
|
||||
|
||||
#include <QString>
|
||||
#include <limits.h>
|
||||
|
||||
#include "m64p_types.h"
|
||||
#include "osal_preproc.h"
|
||||
|
||||
extern m64p_error PluginSearchLoad(void);
|
||||
extern m64p_error PluginUnload(void);
|
||||
|
||||
extern QString qtPluginDir;
|
||||
extern QString qtGfxPlugin;
|
||||
extern QString qtAudioPlugin;
|
||||
extern QString qtInputPlugin;
|
||||
extern QString qtRspPlugin;
|
||||
|
||||
typedef struct {
|
||||
m64p_plugin_type type;
|
||||
char name[8];
|
||||
m64p_dynlib_handle handle;
|
||||
std::string filename;
|
||||
std::string libname;
|
||||
int libversion;
|
||||
} plugin_map_node;
|
||||
|
||||
extern plugin_map_node g_PluginMap[4];
|
||||
|
||||
#endif /* #define PLUGIN_H */
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "keypressfilter.h"
|
||||
#include "core_interface.h"
|
||||
#include "interface/core_commands.h"
|
||||
#include "common.h"
|
||||
#include "mainwindow.h"
|
||||
#include <QKeyEvent>
|
||||
|
||||
KeyPressFilter::KeyPressFilter(QObject *parent)
|
||||
@@ -11,7 +12,7 @@ KeyPressFilter::KeyPressFilter(QObject *parent)
|
||||
bool KeyPressFilter::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::KeyPress) {
|
||||
if (coreStarted) {
|
||||
if (w->getCoreStarted()) {
|
||||
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
|
||||
int modValue = QT2SDL2MOD(keyEvent->modifiers());
|
||||
int keyValue = QT2SDL2(keyEvent->key());
|
||||
@@ -20,7 +21,7 @@ bool KeyPressFilter::eventFilter(QObject *obj, QEvent *event)
|
||||
}
|
||||
return true;
|
||||
} else if (event->type() == QEvent::KeyRelease){
|
||||
if (coreStarted) {
|
||||
if (w->getCoreStarted()) {
|
||||
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
|
||||
int modValue = QT2SDL2MOD(keyEvent->modifiers());
|
||||
int keyValue = QT2SDL2(keyEvent->key());
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <QApplication>
|
||||
#include <QCommandLineParser>
|
||||
|
||||
MainWindow *w;
|
||||
MainWindow *w = nullptr;
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
srand (time(NULL));
|
||||
|
||||
+197
-55
@@ -6,30 +6,40 @@
|
||||
#include <QDesktopServices>
|
||||
#include "settingsdialog.h"
|
||||
#include "plugindialog.h"
|
||||
|
||||
extern "C" {
|
||||
#include "osal_dynamiclib.h"
|
||||
}
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "common.h"
|
||||
#include "core_interface.h"
|
||||
#include "plugin.h"
|
||||
#include "cheatdialog.h"
|
||||
#include "vidext.h"
|
||||
#include "netplay/createroom.h"
|
||||
#include "netplay/joinroom.h"
|
||||
|
||||
#include "osal/osal_preproc.h"
|
||||
#include "interface/core_commands.h"
|
||||
#include "interface/version.h"
|
||||
#include "m64p_common.h"
|
||||
|
||||
#define RECENT_SIZE 10
|
||||
|
||||
void MainWindow::resetTitle()
|
||||
{
|
||||
this->setWindowTitle(m_title);
|
||||
}
|
||||
m64p_video_extension_functions vidExtFunctions = {14,
|
||||
qtVidExtFuncInit,
|
||||
qtVidExtFuncQuit,
|
||||
qtVidExtFuncListModes,
|
||||
qtVidExtFuncListRates,
|
||||
qtVidExtFuncSetMode,
|
||||
qtVidExtFuncSetModeWithRate,
|
||||
qtVidExtFuncGLGetProc,
|
||||
qtVidExtFuncGLSetAttr,
|
||||
qtVidExtFuncGLGetAttr,
|
||||
qtVidExtFuncGLSwapBuf,
|
||||
qtVidExtFuncSetCaption,
|
||||
qtVidExtFuncToggleFS,
|
||||
qtVidExtFuncResizeWindow,
|
||||
qtVidExtFuncGLGetDefaultFramebuffer};
|
||||
|
||||
void MainWindow::updatePlugins()
|
||||
{
|
||||
QDir PluginDir(qtPluginDir);
|
||||
QDir PluginDir(settings->value("pluginDirPath").toString());
|
||||
PluginDir.setFilter(QDir::Files);
|
||||
QStringList Filter;
|
||||
Filter.append("");
|
||||
@@ -84,10 +94,6 @@ void MainWindow::updatePlugins()
|
||||
else
|
||||
settings->setValue("inputPlugin", current.at(0));
|
||||
}
|
||||
qtGfxPlugin = settings->value("videoPlugin").toString();
|
||||
qtAudioPlugin = settings->value("audioPlugin").toString();
|
||||
qtRspPlugin = settings->value("rspPlugin").toString();
|
||||
qtInputPlugin = settings->value("inputPlugin").toString();
|
||||
}
|
||||
|
||||
void MainWindow::updatePIF(Ui::MainWindow *ui)
|
||||
@@ -347,7 +353,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
|
||||
m_title = "mupen64plus-gui Build Date: ";
|
||||
m_title += __DATE__;
|
||||
resetTitle();
|
||||
this->setWindowTitle(m_title);
|
||||
|
||||
QString ini_path = QDir(QCoreApplication::applicationDirPath()).filePath("mupen64plus-gui.ini");
|
||||
settings = new QSettings(ini_path, QSettings::IniFormat, this);
|
||||
@@ -380,8 +386,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
connect(temp_slot, &QAction::triggered,[=](bool checked){
|
||||
if (checked) {
|
||||
int slot = temp_slot->text().remove("Slot ").toInt();
|
||||
if (QtAttachCoreLib())
|
||||
(*CoreDoCommand)(M64CMD_STATE_SET_SLOT, slot, NULL);
|
||||
(*CoreDoCommand)(M64CMD_STATE_SET_SLOT, slot, NULL);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -396,12 +401,6 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
settings->setValue("coreLibPath", QDir(QCoreApplication::applicationDirPath()).filePath(OSAL_DEFAULT_DYNLIB_FILENAME));
|
||||
if (!settings->contains("pluginDirPath"))
|
||||
settings->setValue("pluginDirPath", QCoreApplication::applicationDirPath());
|
||||
if (!settings->value("coreLibPath").isNull())
|
||||
qtCoreDirPath = settings->value("coreLibPath").toString();
|
||||
if (!settings->value("pluginDirPath").isNull())
|
||||
qtPluginDir = settings->value("pluginDirPath").toString();
|
||||
if (!settings->value("configDirPath").isNull())
|
||||
qtConfigDir = settings->value("configDirPath").toString();
|
||||
|
||||
updatePlugins();
|
||||
|
||||
@@ -411,11 +410,22 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
connect(volumeAction->slider(), SIGNAL(valueChanged(int)), this, SLOT(volumeValueChanged(int)));
|
||||
volumeAction->slider()->setValue(settings->value("volume").toInt());
|
||||
ui->menuEmulation->insertAction(ui->actionMute, volumeAction);
|
||||
|
||||
coreStarted = 0;
|
||||
coreLib = nullptr;
|
||||
gfxPlugin = nullptr;
|
||||
rspPlugin = nullptr;
|
||||
audioPlugin = nullptr;
|
||||
inputPlugin = nullptr;
|
||||
loadCoreLib();
|
||||
loadPlugins();
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
DetachCoreLib();
|
||||
closePlugins();
|
||||
closeCoreLib();
|
||||
|
||||
delete ui;
|
||||
}
|
||||
|
||||
@@ -601,9 +611,6 @@ void MainWindow::stopGame()
|
||||
QCoreApplication::processEvents();
|
||||
}
|
||||
}
|
||||
|
||||
PluginUnload();
|
||||
DetachCoreLib();
|
||||
}
|
||||
|
||||
void MainWindow::openROM(QString filename, QString netplay_ip, int netplay_port, int netplay_player)
|
||||
@@ -657,10 +664,8 @@ void MainWindow::on_actionExit_triggered()
|
||||
|
||||
void MainWindow::on_actionPlugin_Settings_triggered()
|
||||
{
|
||||
if (QtAttachCoreLib()) {
|
||||
PluginDialog *settings = new PluginDialog(this);
|
||||
settings->show();
|
||||
}
|
||||
PluginDialog *settings = new PluginDialog(this);
|
||||
settings->show();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionPause_Game_triggered()
|
||||
@@ -767,13 +772,10 @@ void MainWindow::on_actionCheats_triggered()
|
||||
|
||||
void MainWindow::on_actionController_Configuration_triggered()
|
||||
{
|
||||
if (QtAttachCoreLib()) {
|
||||
PluginSearchLoad();
|
||||
typedef void (*Config_Func)();
|
||||
Config_Func PluginConfig = (Config_Func) osal_dynlib_getproc(g_PluginMap[2].handle, "PluginConfig");
|
||||
if (PluginConfig)
|
||||
PluginConfig();
|
||||
}
|
||||
typedef void (*Config_Func)();
|
||||
Config_Func PluginConfig = (Config_Func) osal_dynlib_getproc(inputPlugin, "PluginConfig");
|
||||
if (PluginConfig)
|
||||
PluginConfig();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionToggle_Speed_Limiter_triggered()
|
||||
@@ -793,29 +795,22 @@ void MainWindow::on_actionView_Log_triggered()
|
||||
|
||||
void MainWindow::on_actionVideo_Settings_triggered()
|
||||
{
|
||||
if (QtAttachCoreLib()) {
|
||||
PluginSearchLoad();
|
||||
typedef void (*Config_Func)();
|
||||
Config_Func PluginConfig = (Config_Func) osal_dynlib_getproc(g_PluginMap[0].handle, "PluginConfig");
|
||||
if (PluginConfig)
|
||||
PluginConfig();
|
||||
}
|
||||
typedef void (*Config_Func)();
|
||||
Config_Func PluginConfig = (Config_Func) osal_dynlib_getproc(gfxPlugin, "PluginConfig");
|
||||
if (PluginConfig)
|
||||
PluginConfig();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionCreate_Room_triggered()
|
||||
{
|
||||
if (QtAttachCoreLib()) {
|
||||
CreateRoom *createRoom = new CreateRoom(this);
|
||||
createRoom->show();
|
||||
}
|
||||
CreateRoom *createRoom = new CreateRoom(this);
|
||||
createRoom->show();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionJoin_Room_triggered()
|
||||
{
|
||||
if (QtAttachCoreLib()) {
|
||||
JoinRoom *joinRoom = new JoinRoom(this);
|
||||
joinRoom->show();
|
||||
}
|
||||
JoinRoom *joinRoom = new JoinRoom(this);
|
||||
joinRoom->show();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionSupport_on_Patreon_triggered()
|
||||
@@ -847,3 +842,150 @@ LogViewer* MainWindow::getLogViewer()
|
||||
{
|
||||
return &logViewer;
|
||||
}
|
||||
|
||||
m64p_dynlib_handle MainWindow::getCoreLib()
|
||||
{
|
||||
return coreLib;
|
||||
}
|
||||
|
||||
m64p_dynlib_handle MainWindow::getAudioPlugin()
|
||||
{
|
||||
return audioPlugin;
|
||||
}
|
||||
|
||||
m64p_dynlib_handle MainWindow::getRspPlugin()
|
||||
{
|
||||
return rspPlugin;
|
||||
}
|
||||
|
||||
m64p_dynlib_handle MainWindow::getInputPlugin()
|
||||
{
|
||||
return inputPlugin;
|
||||
}
|
||||
|
||||
m64p_dynlib_handle MainWindow::getGfxPlugin()
|
||||
{
|
||||
return gfxPlugin;
|
||||
}
|
||||
|
||||
void MainWindow::setCoreStarted(int value)
|
||||
{
|
||||
coreStarted = value;
|
||||
|
||||
if (value == 0)
|
||||
{
|
||||
this->setWindowTitle(m_title);
|
||||
loadCoreLib();
|
||||
loadPlugins();
|
||||
}
|
||||
}
|
||||
|
||||
int MainWindow::getCoreStarted()
|
||||
{
|
||||
return coreStarted;
|
||||
}
|
||||
|
||||
void MainWindow::closeCoreLib()
|
||||
{
|
||||
if (coreLib != nullptr)
|
||||
{
|
||||
(*CoreShutdown)();
|
||||
osal_dynlib_close(coreLib);
|
||||
coreLib = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::loadCoreLib()
|
||||
{
|
||||
closeCoreLib();
|
||||
|
||||
osal_dynlib_open(&coreLib, settings->value("coreLibPath").toString().toLatin1().data());
|
||||
|
||||
CoreStartup = (ptr_CoreStartup) osal_dynlib_getproc(coreLib, "CoreStartup");
|
||||
CoreShutdown = (ptr_CoreShutdown) osal_dynlib_getproc(coreLib, "CoreShutdown");
|
||||
CoreDoCommand = (ptr_CoreDoCommand) osal_dynlib_getproc(coreLib, "CoreDoCommand");
|
||||
CoreAttachPlugin = (ptr_CoreAttachPlugin) osal_dynlib_getproc(coreLib, "CoreAttachPlugin");
|
||||
CoreDetachPlugin = (ptr_CoreDetachPlugin) osal_dynlib_getproc(coreLib, "CoreDetachPlugin");
|
||||
CoreOverrideVidExt = (ptr_CoreOverrideVidExt) osal_dynlib_getproc(coreLib, "CoreOverrideVidExt");
|
||||
|
||||
ConfigGetUserConfigPath = (ptr_ConfigGetUserConfigPath) osal_dynlib_getproc(coreLib, "ConfigGetUserConfigPath");
|
||||
ConfigSaveFile = (ptr_ConfigSaveFile) osal_dynlib_getproc(coreLib, "ConfigSaveFile");
|
||||
ConfigGetParameterHelp = (ptr_ConfigGetParameterHelp) osal_dynlib_getproc(coreLib, "ConfigSaveFile");
|
||||
ConfigGetParamInt = (ptr_ConfigGetParamInt) osal_dynlib_getproc(coreLib, "ConfigGetParamInt");
|
||||
ConfigGetParamFloat = (ptr_ConfigGetParamFloat) osal_dynlib_getproc(coreLib, "ConfigGetParamFloat");
|
||||
ConfigGetParamBool = (ptr_ConfigGetParamBool) osal_dynlib_getproc(coreLib, "ConfigGetParamBool");
|
||||
ConfigGetParamString = (ptr_ConfigGetParamString) osal_dynlib_getproc(coreLib, "ConfigGetParamString");
|
||||
ConfigSetParameter = (ptr_ConfigSetParameter) osal_dynlib_getproc(coreLib, "ConfigSetParameter");
|
||||
ConfigDeleteSection = (ptr_ConfigDeleteSection) osal_dynlib_getproc(coreLib, "ConfigDeleteSection");
|
||||
ConfigOpenSection = (ptr_ConfigOpenSection) osal_dynlib_getproc(coreLib, "ConfigOpenSection");
|
||||
ConfigListParameters = (ptr_ConfigListParameters) osal_dynlib_getproc(coreLib, "ConfigListParameters");
|
||||
ConfigGetSharedDataFilepath = (ptr_ConfigGetSharedDataFilepath) osal_dynlib_getproc(coreLib, "ConfigGetSharedDataFilepath");
|
||||
|
||||
CoreAddCheat = (ptr_CoreAddCheat) osal_dynlib_getproc(coreLib, "CoreAddCheat");
|
||||
CoreCheatEnabled = (ptr_CoreCheatEnabled) osal_dynlib_getproc(coreLib, "CoreCheatEnabled");
|
||||
|
||||
QString qtConfigDir = settings->value("configDirPath").toString();
|
||||
if (!qtConfigDir.isEmpty())
|
||||
(*CoreStartup)(CORE_API_VERSION, qtConfigDir.toLatin1().data() /*Config dir*/, QCoreApplication::applicationDirPath().toLatin1().data(), (char*)"Core", DebugCallback, NULL, NULL);
|
||||
else
|
||||
(*CoreStartup)(CORE_API_VERSION, NULL /*Config dir*/, QCoreApplication::applicationDirPath().toLatin1().data(), (char*)"Core", DebugCallback, NULL, NULL);
|
||||
|
||||
CoreOverrideVidExt(&vidExtFunctions);
|
||||
}
|
||||
|
||||
void MainWindow::closePlugins()
|
||||
{
|
||||
ptr_PluginShutdown PluginShutdown;
|
||||
|
||||
if (gfxPlugin != nullptr)
|
||||
{
|
||||
PluginShutdown = (ptr_PluginShutdown) osal_dynlib_getproc(gfxPlugin, "PluginShutdown");
|
||||
(*PluginShutdown)();
|
||||
osal_dynlib_close(gfxPlugin);
|
||||
gfxPlugin = nullptr;
|
||||
}
|
||||
if (audioPlugin != nullptr)
|
||||
{
|
||||
PluginShutdown = (ptr_PluginShutdown) osal_dynlib_getproc(audioPlugin, "PluginShutdown");
|
||||
(*PluginShutdown)();
|
||||
osal_dynlib_close(audioPlugin);
|
||||
audioPlugin = nullptr;
|
||||
}
|
||||
if (inputPlugin != nullptr)
|
||||
{
|
||||
PluginShutdown = (ptr_PluginShutdown) osal_dynlib_getproc(inputPlugin, "PluginShutdown");
|
||||
(*PluginShutdown)();
|
||||
osal_dynlib_close(inputPlugin);
|
||||
inputPlugin = nullptr;
|
||||
}
|
||||
if (rspPlugin != nullptr)
|
||||
{
|
||||
PluginShutdown = (ptr_PluginShutdown) osal_dynlib_getproc(rspPlugin, "PluginShutdown");
|
||||
(*PluginShutdown)();
|
||||
osal_dynlib_close(rspPlugin);
|
||||
rspPlugin = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::loadPlugins()
|
||||
{
|
||||
closePlugins();
|
||||
|
||||
ptr_PluginStartup PluginStartup;
|
||||
|
||||
osal_dynlib_open(&gfxPlugin, QDir(settings->value("pluginDirPath").toString()).filePath(settings->value("videoPlugin").toString()).toLatin1().data());
|
||||
PluginStartup = (ptr_PluginStartup) osal_dynlib_getproc(gfxPlugin, "PluginStartup");
|
||||
(*PluginStartup)(coreLib, (char*)"Video", DebugCallback);
|
||||
|
||||
osal_dynlib_open(&audioPlugin, QDir(settings->value("pluginDirPath").toString()).filePath(settings->value("audioPlugin").toString()).toLatin1().data());
|
||||
PluginStartup = (ptr_PluginStartup) osal_dynlib_getproc(audioPlugin, "PluginStartup");
|
||||
(*PluginStartup)(coreLib, (char*)"Audio", DebugCallback);
|
||||
|
||||
osal_dynlib_open(&inputPlugin, QDir(settings->value("pluginDirPath").toString()).filePath(settings->value("inputPlugin").toString()).toLatin1().data());
|
||||
PluginStartup = (ptr_PluginStartup) osal_dynlib_getproc(inputPlugin, "PluginStartup");
|
||||
(*PluginStartup)(coreLib, (char*)"Input", DebugCallback);
|
||||
|
||||
osal_dynlib_open(&rspPlugin, QDir(settings->value("pluginDirPath").toString()).filePath(settings->value("rspPlugin").toString()).toLatin1().data());
|
||||
PluginStartup = (ptr_PluginStartup) osal_dynlib_getproc(rspPlugin, "PluginStartup");
|
||||
(*PluginStartup)(coreLib, (char*)"RSP", DebugCallback);
|
||||
}
|
||||
@@ -5,7 +5,9 @@
|
||||
#include "workerthread.h"
|
||||
#include "logviewer.h"
|
||||
#include "keypressfilter.h"
|
||||
|
||||
extern "C" {
|
||||
#include "osal/osal_dynamiclib.h"
|
||||
}
|
||||
#include <QMainWindow>
|
||||
#include <QSettings>
|
||||
#include <QSurfaceFormat>
|
||||
@@ -27,8 +29,13 @@ public:
|
||||
QSettings* getSettings();
|
||||
LogViewer* getLogViewer();
|
||||
|
||||
m64p_dynlib_handle getCoreLib();
|
||||
m64p_dynlib_handle getAudioPlugin();
|
||||
m64p_dynlib_handle getRspPlugin();
|
||||
m64p_dynlib_handle getInputPlugin();
|
||||
m64p_dynlib_handle getGfxPlugin();
|
||||
|
||||
void openROM(QString filename, QString netplay_ip, int netplay_port, int netplay_player);
|
||||
void resetTitle();
|
||||
void setVerbose();
|
||||
int getVerbose();
|
||||
void setNoGUI();
|
||||
@@ -36,6 +43,9 @@ public:
|
||||
void setGLES();
|
||||
int getGLES();
|
||||
void updatePlugins();
|
||||
int getCoreStarted();
|
||||
void loadCoreLib();
|
||||
void loadPlugins();
|
||||
explicit MainWindow(QWidget *parent = 0);
|
||||
~MainWindow();
|
||||
|
||||
@@ -50,6 +60,7 @@ public slots:
|
||||
void setTitle(std::string title);
|
||||
void pluginWarning(QString name);
|
||||
void showMessage(QString message);
|
||||
void setCoreStarted(int value);
|
||||
|
||||
private slots:
|
||||
void volumeValueChanged(int value);
|
||||
@@ -109,6 +120,8 @@ private:
|
||||
void updateDD(Ui::MainWindow *ui);
|
||||
void updatePIF(Ui::MainWindow *ui);
|
||||
void findRecursion(const QString &path, const QString &pattern, QStringList *result);
|
||||
void closeCoreLib();
|
||||
void closePlugins();
|
||||
Ui::MainWindow *ui;
|
||||
QMenu * OpenRecent;
|
||||
int verbose;
|
||||
@@ -121,6 +134,14 @@ private:
|
||||
LogViewer logViewer;
|
||||
QSettings *settings = nullptr;
|
||||
KeyPressFilter keyPressFilter;
|
||||
|
||||
m64p_dynlib_handle coreLib;
|
||||
m64p_dynlib_handle rspPlugin;
|
||||
m64p_dynlib_handle audioPlugin;
|
||||
m64p_dynlib_handle gfxPlugin;
|
||||
m64p_dynlib_handle inputPlugin;
|
||||
|
||||
int coreStarted;
|
||||
};
|
||||
|
||||
extern MainWindow *w;
|
||||
|
||||
@@ -22,13 +22,12 @@ SOURCES += main.cpp \
|
||||
vidext.cpp \
|
||||
settingsdialog.cpp \
|
||||
interface/common.cpp \
|
||||
interface/core_interface.cpp \
|
||||
interface/plugin.cpp \
|
||||
plugindialog.cpp \
|
||||
oglwindow.cpp \
|
||||
workerthread.cpp \
|
||||
settingclasses.cpp \
|
||||
cheatdialog.cpp \
|
||||
interface/core_commands.cpp \
|
||||
interface/cheat.cpp \
|
||||
interface/sdl_key_converter.c \
|
||||
logviewer.cpp \
|
||||
@@ -70,14 +69,12 @@ INCLUDEPATH += /usr/local/include /usr/include/SDL2 /usr/local/include/SDL2
|
||||
HEADERS += mainwindow.h \
|
||||
vidext.h \
|
||||
interface/common.h \
|
||||
interface/core_interface.h \
|
||||
interface/plugin.h \
|
||||
settingsdialog.h \
|
||||
osal/osal_dynamiclib.h \
|
||||
workerthread.h \
|
||||
plugindialog.h \
|
||||
oglwindow.h \
|
||||
settingclasses.h \
|
||||
osal/osal_dynamiclib.h \
|
||||
cheatdialog.h \
|
||||
interface/cheat.h \
|
||||
interface/sdl_key_converter.h \
|
||||
@@ -90,7 +87,7 @@ HEADERS += mainwindow.h \
|
||||
|
||||
FORMS += mainwindow.ui
|
||||
|
||||
QMAKE_INCDIR += api osal interface
|
||||
QMAKE_INCDIR += api interface
|
||||
|
||||
CONFIG += optimize_full
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "createroom.h"
|
||||
#include "waitroom.h"
|
||||
#include "version.h"
|
||||
#include "interface/core_commands.h"
|
||||
#include <QGridLayout>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "joinroom.h"
|
||||
#include "waitroom.h"
|
||||
#include "mainwindow.h"
|
||||
#include "interface/core_commands.h"
|
||||
#include "version.h"
|
||||
#include <QGridLayout>
|
||||
#include <QLabel>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "waitroom.h"
|
||||
#include "mainwindow.h"
|
||||
#include "interface/core_commands.h"
|
||||
#include <QGridLayout>
|
||||
#include <QMessageBox>
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
|
||||
#include "oglwindow.h"
|
||||
#include "mainwindow.h"
|
||||
#include "interface/core_commands.h"
|
||||
|
||||
extern QThread* rendering_thread;
|
||||
|
||||
void OGLWindow::initializeGL() {
|
||||
@@ -20,7 +23,7 @@ void OGLWindow::resizeEvent(QResizeEvent *event) {
|
||||
|
||||
void OGLWindow::timerEvent(QTimerEvent *te) {
|
||||
int size = (m_width << 16) + m_height;
|
||||
if (coreStarted)
|
||||
if (w->getCoreStarted())
|
||||
(*CoreDoCommand)(M64CMD_CORE_STATE_SET, M64CORE_VIDEO_SIZE, &size);
|
||||
killTimer(te->timerId());
|
||||
timerId = 0;
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <QOpenGLWindow>
|
||||
#include <QOpenGLFunctions>
|
||||
#include "common.h"
|
||||
#include "core_interface.h"
|
||||
|
||||
class OGLWindow : public QOpenGLWindow
|
||||
{
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
#include "plugindialog.h"
|
||||
#include "mainwindow.h"
|
||||
#include "core_interface.h"
|
||||
#include "osal_preproc.h"
|
||||
#include "plugin.h"
|
||||
#include "interface/core_commands.h"
|
||||
|
||||
#include <QLabel>
|
||||
#include <QScrollArea>
|
||||
@@ -94,7 +92,6 @@ void PluginDialog::handleResetButton()
|
||||
(*ConfigDeleteSection)("Core");
|
||||
(*ConfigDeleteSection)("Video-General");
|
||||
(*ConfigSaveFile)();
|
||||
DetachCoreLib();
|
||||
this->close();
|
||||
}
|
||||
else {
|
||||
@@ -110,10 +107,6 @@ PluginDialog::PluginDialog(QWidget *parent)
|
||||
m64p_error res;
|
||||
int value;
|
||||
(*CoreDoCommand)(M64CMD_CORE_STATE_QUERY, M64CORE_EMU_STATE, &value);
|
||||
if (value == M64EMU_STOPPED) {
|
||||
PluginSearchLoad();
|
||||
PluginUnload();
|
||||
}
|
||||
|
||||
coreLayoutRow = 0;
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout(this);
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#include "settingclasses.h"
|
||||
#include "core_interface.h"
|
||||
#include "plugin.h"
|
||||
#include "cheat.h"
|
||||
#include "common.h"
|
||||
#include "interface/core_commands.h"
|
||||
#include <SDL.h>
|
||||
#include <QLabel>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "settingsdialog.h"
|
||||
#include "core_interface.h"
|
||||
#include "mainwindow.h"
|
||||
#include "plugin.h"
|
||||
#include "interface/core_commands.h"
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QSettings>
|
||||
@@ -15,7 +14,6 @@ void SettingsDialog::handleCoreButton()
|
||||
if (!fileName.isNull()) {
|
||||
corePath->setText(fileName);
|
||||
w->getSettings()->setValue("coreLibPath", fileName);
|
||||
qtCoreDirPath = w->getSettings()->value("coreLibPath").toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +26,6 @@ void SettingsDialog::handlePluginButton()
|
||||
if (!fileName.isNull()) {
|
||||
pluginPath->setText(fileName);
|
||||
w->getSettings()->setValue("pluginDirPath", fileName);
|
||||
qtPluginDir = w->getSettings()->value("pluginDirPath").toString();
|
||||
|
||||
w->getSettings()->remove("inputPlugin");
|
||||
w->getSettings()->remove("videoPlugin");
|
||||
@@ -48,7 +45,6 @@ void SettingsDialog::handleConfigButton()
|
||||
if (!fileName.isNull()) {
|
||||
configPath->setText(fileName);
|
||||
w->getSettings()->setValue("configDirPath", fileName);
|
||||
qtConfigDir = w->getSettings()->value("configDirPath").toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,19 +52,16 @@ void SettingsDialog::handleClearConfigButton()
|
||||
{
|
||||
configPath->setText("");
|
||||
w->getSettings()->remove("configDirPath");
|
||||
qtConfigDir = QString();
|
||||
}
|
||||
|
||||
void SettingsDialog::handleCoreEdit()
|
||||
{
|
||||
w->getSettings()->setValue("coreLibPath", corePath->text());
|
||||
qtCoreDirPath = w->getSettings()->value("coreLibPath").toString();
|
||||
}
|
||||
|
||||
void SettingsDialog::handlePluginEdit()
|
||||
{
|
||||
w->getSettings()->setValue("pluginDirPath", pluginPath->text());
|
||||
qtPluginDir = w->getSettings()->value("pluginDirPath").toString();
|
||||
|
||||
w->getSettings()->remove("inputPlugin");
|
||||
w->getSettings()->remove("videoPlugin");
|
||||
@@ -81,7 +74,6 @@ void SettingsDialog::handlePluginEdit()
|
||||
void SettingsDialog::handleConfigEdit()
|
||||
{
|
||||
w->getSettings()->setValue("configDirPath", configPath->text());
|
||||
qtConfigDir = w->getSettings()->value("configDirPath").toString();
|
||||
}
|
||||
|
||||
void SettingsDialog::initStuff()
|
||||
@@ -116,7 +108,7 @@ void SettingsDialog::initStuff()
|
||||
QString configDirPath = w->getSettings()->value("configDirPath").toString();
|
||||
if (!configDirPath.isEmpty())
|
||||
configPath->setText(configDirPath);
|
||||
else if (QtAttachCoreLib())
|
||||
else
|
||||
configPath->setText(ConfigGetUserConfigPath());
|
||||
QPushButton *configButton = new QPushButton("Set Path", this);
|
||||
connect(configButton, SIGNAL (released()),this, SLOT (handleConfigButton()));
|
||||
@@ -130,7 +122,7 @@ void SettingsDialog::initStuff()
|
||||
layout->addWidget(configButton,3,2);
|
||||
layout->addWidget(clearConfigButton,3,3);
|
||||
|
||||
QDir PluginDir(qtPluginDir);
|
||||
QDir PluginDir(w->getSettings()->value("pluginDirPath").toString());
|
||||
QStringList Filter;
|
||||
Filter.append("");
|
||||
QStringList current;
|
||||
@@ -141,6 +133,7 @@ void SettingsDialog::initStuff()
|
||||
Filter.replace(0,"mupen64plus-input*");
|
||||
current = PluginDir.entryList(Filter);
|
||||
inputChoice->addItems(current);
|
||||
QString qtInputPlugin = w->getSettings()->value("inputPlugin").toString();
|
||||
int my_index = inputChoice->findText(qtInputPlugin);
|
||||
if (my_index == -1) {
|
||||
inputChoice->addItem(qtInputPlugin);
|
||||
@@ -150,7 +143,6 @@ void SettingsDialog::initStuff()
|
||||
connect(inputChoice, static_cast<void(QComboBox::*)(const QString &)>(&QComboBox::activated),
|
||||
[=](const QString &text) {
|
||||
w->getSettings()->setValue("inputPlugin", text);
|
||||
qtInputPlugin = w->getSettings()->value("inputPlugin").toString();
|
||||
});
|
||||
layout->addWidget(inputChoice,5,1);
|
||||
|
||||
@@ -162,3 +154,13 @@ SettingsDialog::SettingsDialog(QWidget *parent)
|
||||
{
|
||||
initStuff();
|
||||
}
|
||||
|
||||
void SettingsDialog::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
if (w->getCoreStarted() == 0)
|
||||
{
|
||||
w->loadCoreLib();
|
||||
w->loadPlugins();
|
||||
}
|
||||
event->accept();
|
||||
}
|
||||
@@ -13,6 +13,8 @@ class SettingsDialog : public QDialog
|
||||
|
||||
public:
|
||||
SettingsDialog(QWidget *parent = nullptr);
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event);
|
||||
private slots:
|
||||
void handleCoreButton();
|
||||
void handlePluginButton();
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "common.h"
|
||||
#include "workerthread.h"
|
||||
#include "mainwindow.h"
|
||||
#include "interface/core_commands.h"
|
||||
#include <stdio.h>
|
||||
#include <QDesktopWidget>
|
||||
#include <QScreen>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "workerthread.h"
|
||||
#include "vidext.h"
|
||||
#include "mainwindow.h"
|
||||
#include "interface/core_commands.h"
|
||||
#ifndef _WIN32
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusReply>
|
||||
@@ -25,6 +26,7 @@ void WorkerThread::run()
|
||||
connect(this, SIGNAL(setTitle(std::string)), w, SLOT(setTitle(std::string)), Qt::BlockingQueuedConnection);
|
||||
connect(this, SIGNAL(pluginWarning(QString)), w, SLOT(pluginWarning(QString)), Qt::BlockingQueuedConnection);
|
||||
connect(this, SIGNAL(showMessage(QString)), w, SLOT(showMessage(QString)), Qt::BlockingQueuedConnection);
|
||||
connect(this, SIGNAL(setCoreStarted(int)), w, SLOT(setCoreStarted(int)), Qt::BlockingQueuedConnection);
|
||||
#ifdef _WIN32
|
||||
SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED);
|
||||
#else
|
||||
@@ -39,7 +41,10 @@ void WorkerThread::run()
|
||||
|
||||
m64p_error res = loadROM(m_fileName.toStdString());
|
||||
if (res == M64ERR_SUCCESS)
|
||||
{
|
||||
emit setCoreStarted(1);
|
||||
res = launchGame(netplay_ip, netplay_port, netplay_player);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
SetThreadExecutionState(ES_CONTINUOUS);
|
||||
@@ -47,13 +52,14 @@ void WorkerThread::run()
|
||||
if (cookieID)
|
||||
screenSaverInterface.call("UnInhibit", cookieID);
|
||||
#endif
|
||||
if (res == M64ERR_SUCCESS) {
|
||||
|
||||
if (res == M64ERR_SUCCESS)
|
||||
(*ConfigSaveFile)();
|
||||
|
||||
if (w->getNoGUI())
|
||||
QApplication::quit();
|
||||
}
|
||||
w->resetTitle();
|
||||
if (w->getNoGUI())
|
||||
QApplication::quit();
|
||||
else
|
||||
emit setCoreStarted(0);
|
||||
}
|
||||
|
||||
void WorkerThread::setFileName(QString filename)
|
||||
|
||||
@@ -23,6 +23,7 @@ signals:
|
||||
void setTitle(std::string title);
|
||||
void pluginWarning(QString name);
|
||||
void showMessage(QString message);
|
||||
void setCoreStarted(int value);
|
||||
|
||||
private:
|
||||
QString m_fileName;
|
||||
|
||||
Reference in new issue
Block a user