Reformat InteropDll (Resharper)

This commit is contained in:
Vladimir Kononovich 2020-12-19 23:30:40 +03:00
parent 3764af908f
commit f3f15a32fe
10 changed files with 564 additions and 495 deletions

View file

@ -9,60 +9,60 @@ extern unique_ptr<IAudioDevice> _soundManager;
static string _returnString;
extern "C" {
DllExport void __stdcall SetVideoConfig(VideoConfig config)
{
DllExport void __stdcall SetVideoConfig(VideoConfig config)
{
_console->GetSettings()->SetVideoConfig(config);
}
}
DllExport void __stdcall SetAudioConfig(AudioConfig config)
{
DllExport void __stdcall SetAudioConfig(AudioConfig config)
{
_console->GetSettings()->SetAudioConfig(config);
}
}
DllExport void __stdcall SetInputConfig(InputConfig config)
{
DllExport void __stdcall SetInputConfig(InputConfig config)
{
_console->GetSettings()->SetInputConfig(config);
}
}
DllExport void __stdcall SetEmulationConfig(EmulationConfig config)
{
DllExport void __stdcall SetEmulationConfig(EmulationConfig config)
{
_console->GetSettings()->SetEmulationConfig(config);
}
}
DllExport void __stdcall SetGameboyConfig(GameboyConfig config)
{
DllExport void __stdcall SetGameboyConfig(GameboyConfig config)
{
_console->GetSettings()->SetGameboyConfig(config);
}
}
DllExport void __stdcall SetPreferences(PreferencesConfig config)
{
DllExport void __stdcall SetPreferences(PreferencesConfig config)
{
_console->GetSettings()->SetPreferences(config);
}
}
DllExport void __stdcall SetShortcutKeys(ShortcutKeyInfo shortcuts[], uint32_t count)
{
DllExport void __stdcall SetShortcutKeys(ShortcutKeyInfo shortcuts[], uint32_t count)
{
vector<ShortcutKeyInfo> shortcutList(shortcuts, shortcuts + count);
_console->GetSettings()->SetShortcutKeys(shortcutList);
}
}
DllExport ControllerType __stdcall GetControllerType(int player)
{
DllExport ControllerType __stdcall GetControllerType(int player)
{
return _console->GetSettings()->GetInputConfig().Controllers[player].Type;
}
}
DllExport const char* __stdcall GetAudioDevices()
{
DllExport const char* __stdcall GetAudioDevices()
{
_returnString = _soundManager ? _soundManager->GetAvailableDevices() : "";
return _returnString.c_str();
}
DllExport void __stdcall SetEmulationFlag(EmulationFlags flag, bool enabled)
{
_console->GetSettings()->SetFlagState(flag, enabled);
}
DllExport void __stdcall SetDebuggerFlag(DebuggerFlags flag, bool enabled)
{
_console->GetSettings()->SetDebuggerFlag(flag, enabled);
}
}
DllExport void __stdcall SetEmulationFlag(EmulationFlags flag, bool enabled)
{
_console->GetSettings()->SetFlagState(flag, enabled);
}
DllExport void __stdcall SetDebuggerFlag(DebuggerFlags flag, bool enabled)
{
_console->GetSettings()->SetDebuggerFlag(flag, enabled);
}
}

View file

@ -18,9 +18,9 @@
#include "InteropNotificationListeners.h"
#ifdef _WIN32
#include "../Windows/Renderer.h"
#include "../Windows/SoundManager.h"
#include "../Windows/WindowsKeyManager.h"
#include "../Windows/Renderer.h"
#include "../Windows/SoundManager.h"
#include "../Windows/WindowsKeyManager.h"
#else
#include "../Linux/SdlRenderer.h"
#include "../Linux/SdlSoundManager.h"
@ -61,12 +61,16 @@ enum class ConsoleId
shared_ptr<Console> GetConsoleById(ConsoleId consoleId)
{
shared_ptr<Console> console;
switch (consoleId) {
case ConsoleId::Main: console = _console; break;
case ConsoleId::HistoryViewer: console = _historyConsole; break;
switch (consoleId)
{
case ConsoleId::Main: console = _console;
break;
case ConsoleId::HistoryViewer: console = _historyConsole;
break;
}
if (!console) {
if (!console)
{
//Otherwise return the main CPU
console = _console;
}
@ -74,91 +78,101 @@ shared_ptr<Console> GetConsoleById(ConsoleId consoleId)
}
extern "C" {
DllExport bool __stdcall TestDll()
{
DllExport bool __stdcall TestDll()
{
return true;
}
}
DllExport uint32_t __stdcall GetMesenVersion() { return _console->GetSettings()->GetVersion(); }
DllExport uint32_t __stdcall GetMesenVersion() { return _console->GetSettings()->GetVersion(); }
DllExport void __stdcall InitDll()
{
DllExport void __stdcall InitDll()
{
_console.reset(new Console());
KeyManager::SetSettings(_console->GetSettings().get());
}
}
DllExport void __stdcall InitializeEmu(const char* homeFolder, void *windowHandle, void *viewerHandle, bool noAudio, bool noVideo, bool noInput)
{
DllExport void __stdcall InitializeEmu(const char* homeFolder, void* windowHandle, void* viewerHandle, bool noAudio,
bool noVideo, bool noInput)
{
_console->Initialize();
FolderUtilities::SetHomeFolder(homeFolder);
_shortcutKeyHandler.reset(new ShortcutKeyHandler(_console));
if(windowHandle != nullptr && viewerHandle != nullptr) {
if (windowHandle != nullptr && viewerHandle != nullptr)
{
_windowHandle = windowHandle;
_viewerHandle = viewerHandle;
if(!noVideo) {
#ifdef _WIN32
if (!noVideo)
{
#ifdef _WIN32
_renderer.reset(new Renderer(_console, (HWND)_viewerHandle, true));
#else
#else
_renderer.reset(new SdlRenderer(_console, _viewerHandle, true));
#endif
#endif
}
if(!noAudio) {
#ifdef _WIN32
if (!noAudio)
{
#ifdef _WIN32
_soundManager.reset(new SoundManager(_console, (HWND)_windowHandle));
#else
#else
_soundManager.reset(new SdlSoundManager(_console));
#endif
#endif
}
if(!noInput) {
#ifdef _WIN32
if (!noInput)
{
#ifdef _WIN32
_keyManager.reset(new WindowsKeyManager(_console, (HWND)_windowHandle));
#else
#else
_keyManager.reset(new LinuxKeyManager(_console));
#endif
#endif
KeyManager::RegisterKeyManager(_keyManager.get());
}
}
}
}
DllExport void __stdcall SetMasterVolume(double volume, ConsoleId consoleId) {
DllExport void __stdcall SetMasterVolume(double volume, ConsoleId consoleId)
{
AudioConfig config = GetConsoleById(consoleId)->GetSettings()->GetAudioConfig();
config.MasterVolume = volume;
GetConsoleById(consoleId)->GetSettings()->SetAudioConfig(config);
}
}
DllExport void __stdcall SetVideoScale(double scale, ConsoleId consoleId) {
DllExport void __stdcall SetVideoScale(double scale, ConsoleId consoleId)
{
VideoConfig config = GetConsoleById(consoleId)->GetSettings()->GetVideoConfig();
config.VideoScale = scale;
GetConsoleById(consoleId)->GetSettings()->SetVideoConfig(config);
}
}
DllExport void __stdcall SetFullscreenMode(bool fullscreen, void *windowHandle, uint32_t monitorWidth, uint32_t monitorHeight)
DllExport void __stdcall SetFullscreenMode(bool fullscreen, void* windowHandle, uint32_t monitorWidth,
uint32_t monitorHeight)
{
if (_renderer)
{
if(_renderer) {
_renderer->SetFullscreenMode(fullscreen, windowHandle, monitorWidth, monitorHeight);
}
}
}
DllExport bool __stdcall LoadRom(char* filename, char* patchFile)
{
DllExport bool __stdcall LoadRom(char* filename, char* patchFile)
{
GameClient::Disconnect();
return _console->LoadRom((VirtualFile)filename, patchFile ? (VirtualFile)patchFile : VirtualFile());
}
}
DllExport void __stdcall AddKnownGameFolder(char* folder) { FolderUtilities::AddKnownGameFolder(folder); }
DllExport void __stdcall AddKnownGameFolder(char* folder) { FolderUtilities::AddKnownGameFolder(folder); }
DllExport void __stdcall GetRomInfo(InteropRomInfo &info)
{
DllExport void __stdcall GetRomInfo(InteropRomInfo& info)
{
RomInfo romInfo = {};
string sha1;
if(_console->GetCartridge()) {
if (_console->GetCartridge())
{
romInfo = _console->GetCartridge()->GetRomInfo();
sha1 = _console->GetCartridge()->GetSha1Hash();
}
@ -172,79 +186,88 @@ extern "C" {
info.Coprocessor = romInfo.Coprocessor;
memcpy(info.Sha1, sha1.c_str(), sha1.size());
}
}
DllExport void __stdcall TakeScreenshot() { _console->GetVideoDecoder()->TakeScreenshot(); }
DllExport void __stdcall TakeScreenshot() { _console->GetVideoDecoder()->TakeScreenshot(); }
DllExport const char* __stdcall GetArchiveRomList(char* filename) {
DllExport const char* __stdcall GetArchiveRomList(char* filename)
{
std::ostringstream out;
shared_ptr<ArchiveReader> reader = ArchiveReader::GetReader(filename);
if(reader) {
for(string romName : reader->GetFileList(VirtualFile::RomExtensions)) {
if (reader)
{
for (string romName : reader->GetFileList(VirtualFile::RomExtensions))
{
out << romName << "[!|!]";
}
}
_returnString = out.str();
return _returnString.c_str();
}
}
DllExport bool __stdcall IsRunning()
{
DllExport bool __stdcall IsRunning()
{
return _console->IsRunning();
}
}
DllExport void __stdcall Stop()
{
DllExport void __stdcall Stop()
{
GameClient::Disconnect();
_console->Stop(true);
}
}
DllExport void __stdcall Pause(ConsoleId consoleId)
DllExport void __stdcall Pause(ConsoleId consoleId)
{
if (!GameClient::Connected())
{
if(!GameClient::Connected()) {
GetConsoleById(consoleId)->Pause();
}
}
}
DllExport void __stdcall Resume(ConsoleId consoleId)
DllExport void __stdcall Resume(ConsoleId consoleId)
{
if (!GameClient::Connected())
{
if(!GameClient::Connected()) {
GetConsoleById(consoleId)->Resume();
}
}
}
DllExport bool __stdcall IsPaused(ConsoleId consoleId)
{
DllExport bool __stdcall IsPaused(ConsoleId consoleId)
{
shared_ptr<Console> console = GetConsoleById(consoleId);
if(console) {
if (console)
{
return console->IsPaused();
}
return true;
}
}
DllExport void __stdcall Reset()
DllExport void __stdcall Reset()
{
if (!GameClient::Connected())
{
if(!GameClient::Connected()) {
_console->GetControlManager()->GetSystemActionManager()->Reset();
}
}
}
DllExport void __stdcall PowerCycle()
DllExport void __stdcall PowerCycle()
{
if (!GameClient::Connected())
{
if(!GameClient::Connected()) {
_console->GetControlManager()->GetSystemActionManager()->PowerCycle();
}
}
}
DllExport void __stdcall ReloadRom()
DllExport void __stdcall ReloadRom()
{
if (!GameClient::Connected())
{
if(!GameClient::Connected()) {
_console->ReloadRom(false);
}
}
}
DllExport void __stdcall Release()
{
DllExport void __stdcall Release()
{
GameClient::Disconnect();
GameServer::StopServer();
@ -258,47 +281,62 @@ extern "C" {
_renderer.reset();
_soundManager.reset();
_keyManager.reset();
}
}
DllExport INotificationListener* __stdcall RegisterNotificationCallback(NotificationListenerCallback callback)
{
DllExport INotificationListener* __stdcall RegisterNotificationCallback(NotificationListenerCallback callback)
{
return _listeners.RegisterNotificationCallback(callback, _console);
}
}
DllExport void __stdcall UnregisterNotificationCallback(INotificationListener *listener)
{
DllExport void __stdcall UnregisterNotificationCallback(INotificationListener* listener)
{
_listeners.UnregisterNotificationCallback(listener);
}
}
DllExport void __stdcall DisplayMessage(char* title, char* message, char* param1) { MessageManager::DisplayMessage(title, message, param1 ? param1 : ""); }
DllExport const char* __stdcall GetLog()
{
DllExport void __stdcall DisplayMessage(char* title, char* message, char* param1)
{
MessageManager::DisplayMessage(title, message, param1 ? param1 : "");
}
DllExport const char* __stdcall GetLog()
{
_logString = MessageManager::GetLog();
return _logString.c_str();
}
}
DllExport ScreenSize __stdcall GetScreenSize(bool ignoreScale, ConsoleId console)
{
DllExport ScreenSize __stdcall GetScreenSize(bool ignoreScale, ConsoleId console)
{
return GetConsoleById(console)->GetVideoDecoder()->GetScreenSize(ignoreScale);
}
}
DllExport void __stdcall ClearCheats() { _console->GetCheatManager()->ClearCheats(); }
DllExport void __stdcall SetCheats(uint32_t codes[], uint32_t length) { _console->GetCheatManager()->SetCheats(codes, length); }
DllExport void __stdcall ClearCheats() { _console->GetCheatManager()->ClearCheats(); }
DllExport void __stdcall SetCheats(uint32_t codes[], uint32_t length)
{
_console->GetCheatManager()->SetCheats(codes, length);
}
DllExport void __stdcall WriteLogEntry(char* message) { MessageManager::Log(message); }
DllExport void __stdcall WriteLogEntry(char* message) { MessageManager::Log(message); }
DllExport void __stdcall SaveState(uint32_t stateIndex) { _console->GetSaveStateManager()->SaveState(stateIndex); }
DllExport void __stdcall LoadState(uint32_t stateIndex) { _console->GetSaveStateManager()->LoadState(stateIndex); }
DllExport void __stdcall SaveStateFile(char* filepath) { _console->GetSaveStateManager()->SaveState(filepath); }
DllExport void __stdcall LoadStateFile(char* filepath) { _console->GetSaveStateManager()->LoadState(filepath); }
DllExport void __stdcall LoadRecentGame(char* filepath, bool resetGame) { _console->GetSaveStateManager()->LoadRecentGame(filepath, resetGame); }
DllExport int32_t __stdcall GetSaveStatePreview(char* saveStatePath, uint8_t* pngData) { return _console->GetSaveStateManager()->GetSaveStatePreview(saveStatePath, pngData); }
DllExport void __stdcall SaveState(uint32_t stateIndex) { _console->GetSaveStateManager()->SaveState(stateIndex); }
DllExport void __stdcall LoadState(uint32_t stateIndex) { _console->GetSaveStateManager()->LoadState(stateIndex); }
DllExport void __stdcall SaveStateFile(char* filepath) { _console->GetSaveStateManager()->SaveState(filepath); }
DllExport void __stdcall LoadStateFile(char* filepath) { _console->GetSaveStateManager()->LoadState(filepath); }
DllExport void __stdcall LoadRecentGame(char* filepath, bool resetGame)
{
_console->GetSaveStateManager()->LoadRecentGame(filepath, resetGame);
}
DllExport void __stdcall PgoRunTest(vector<string> testRoms, bool enableDebugger)
{
DllExport int32_t __stdcall GetSaveStatePreview(char* saveStatePath, uint8_t* pngData)
{
return _console->GetSaveStateManager()->GetSaveStatePreview(saveStatePath, pngData);
}
DllExport void __stdcall PgoRunTest(vector<string> testRoms, bool enableDebugger)
{
FolderUtilities::SetHomeFolder("../PGOMesenHome");
for(size_t i = 0; i < testRoms.size(); i++) {
for (size_t i = 0; i < testRoms.size(); i++)
{
std::cout << "Running: " << testRoms[i] << std::endl;
_console.reset(new Console());
@ -309,7 +347,8 @@ extern "C" {
_console->GetSettings()->SetGameboyConfig(cfg);
_console->LoadRom((VirtualFile)testRoms[i], VirtualFile());
if(enableDebugger) {
if (enableDebugger)
{
//turn on debugger to profile the debugger's code too
_console->GetDebugger();
}
@ -318,5 +357,5 @@ extern "C" {
_console->Stop(false);
_console->Release();
}
}
}
}

View file

@ -22,16 +22,15 @@ unique_ptr<IRenderingDevice> _historyRenderer;
unique_ptr<IAudioDevice> _historySoundManager;
enum class VideoCodec;
extern "C"
extern "C" {
DllExport bool __stdcall HistoryViewerEnabled()
{
DllExport bool __stdcall HistoryViewerEnabled()
{
shared_ptr<RewindManager> rewindManager = _console->GetRewindManager();
return rewindManager ? rewindManager->HasHistory() : false;
}
}
DllExport void __stdcall HistoryViewerInitialize(void* windowHandle, void* viewerHandle)
{
DllExport void __stdcall HistoryViewerInitialize(void* windowHandle, void* viewerHandle)
{
_historyConsole.reset(new Console());
// TODO: something about initializing with settings?
_historyConsole->Initialize();
@ -45,9 +44,9 @@ extern "C"
VideoConfig config = _historyConsole->GetSettings()->GetVideoConfig();
config.VideoScale = 2;
_historyConsole->GetSettings()->SetVideoConfig(config);
// TODO
// _historyConsole->GetSettings()->SetEmulationSpeed(100);
// _historyConsole->GetSettings()->ClearFlags(EmulationFlags::InBackground | EmulationFlags::Rewind /*|EmulationFlags::ForceMaxSpeed | EmulationFlags::DebuggerWindowEnabled*/);
// TODO
// _historyConsole->GetSettings()->SetEmulationSpeed(100);
// _historyConsole->GetSettings()->ClearFlags(EmulationFlags::InBackground | EmulationFlags::Rewind /*|EmulationFlags::ForceMaxSpeed | EmulationFlags::DebuggerWindowEnabled*/);
#ifdef _WIN32
_historyRenderer.reset(new Renderer(_historyConsole, (HWND)viewerHandle, false));
@ -56,68 +55,75 @@ extern "C"
_historyRenderer.reset(new SdlRenderer(_historyConsole, viewerHandle, false));
_historySoundManager.reset(new SdlSoundManager(_historyConsole));
#endif
}
}
DllExport void __stdcall HistoryViewerRelease()
{
DllExport void __stdcall HistoryViewerRelease()
{
_historyConsole->Stop(true);
_historyConsole->Release(); // Mesen had True, "For ShutDown"
_historyRenderer.reset();
_historySoundManager.reset();
_historyConsole.reset();
}
}
DllExport uint32_t __stdcall HistoryViewerGetHistoryLength()
DllExport uint32_t __stdcall HistoryViewerGetHistoryLength()
{
if (_historyConsole)
{
if (_historyConsole) {
return _historyConsole->GetHistoryViewer()->GetHistoryLength();
}
return 0;
}
}
DllExport void __stdcall HistoryViewerGetSegments(uint32_t* segmentBuffer, uint32_t& bufferSize)
DllExport void __stdcall HistoryViewerGetSegments(uint32_t* segmentBuffer, uint32_t& bufferSize)
{
if (_historyConsole)
{
if (_historyConsole) {
_historyConsole->GetHistoryViewer()->GetHistorySegments(segmentBuffer, bufferSize);
}
}
}
DllExport bool __stdcall HistoryViewerCreateSaveState(const char* outputFile, uint32_t position)
DllExport bool __stdcall HistoryViewerCreateSaveState(const char* outputFile, uint32_t position)
{
if (_historyConsole)
{
if (_historyConsole) {
return _historyConsole->GetHistoryViewer()->CreateSaveState(outputFile, position);
}
return false;
}
}
DllExport bool __stdcall HistoryViewerSaveMovie(const char* movieFile, uint32_t startPosition, uint32_t endPosition)
DllExport bool __stdcall HistoryViewerSaveMovie(const char* movieFile, uint32_t startPosition, uint32_t endPosition)
{
if (_historyConsole)
{
if (_historyConsole) {
return _historyConsole->GetHistoryViewer()->SaveMovie(movieFile, startPosition, endPosition);
}
return false;
}
}
DllExport void __stdcall HistoryViewerResumeGameplay(uint32_t resumeAtSecond)
DllExport void __stdcall HistoryViewerResumeGameplay(uint32_t resumeAtSecond)
{
if (_historyConsole)
{
if (_historyConsole) {
_historyConsole->GetHistoryViewer()->ResumeGameplay(_console, resumeAtSecond);
}
}
}
DllExport void __stdcall HistoryViewerSetPosition(uint32_t seekPosition)
DllExport void __stdcall HistoryViewerSetPosition(uint32_t seekPosition)
{
if (_historyConsole)
{
if (_historyConsole) {
_historyConsole->GetHistoryViewer()->SeekTo(seekPosition);
}
}
}
DllExport uint32_t __stdcall HistoryViewerGetPosition()
DllExport uint32_t __stdcall HistoryViewerGetPosition()
{
if (_historyConsole)
{
if (_historyConsole) {
return _historyConsole->GetHistoryViewer()->GetPosition();
}
return 0;
}
}
}

View file

@ -9,67 +9,74 @@ extern shared_ptr<Console> _console;
static string _returnString;
extern "C"
extern "C" {
DllExport void __stdcall SetMousePosition(double x, double y)
{
DllExport void __stdcall SetMousePosition(double x, double y)
{
KeyManager::SetMousePosition(_console, x, y);
}
}
DllExport void __stdcall SetMouseMovement(int16_t x, int16_t y)
{
DllExport void __stdcall SetMouseMovement(int16_t x, int16_t y)
{
KeyManager::SetMouseMovement(x, y);
}
}
DllExport void __stdcall UpdateInputDevices()
DllExport void __stdcall UpdateInputDevices()
{
if (_keyManager)
{
if(_keyManager) {
_keyManager->UpdateDevices();
}
}
}
DllExport void __stdcall GetPressedKeys(uint32_t *keyBuffer)
{
DllExport void __stdcall GetPressedKeys(uint32_t* keyBuffer)
{
vector<uint32_t> pressedKeys = KeyManager::GetPressedKeys();
for(size_t i = 0; i < pressedKeys.size() && i < 3; i++) {
for (size_t i = 0; i < pressedKeys.size() && i < 3; i++)
{
keyBuffer[i] = pressedKeys[i];
}
}
}
DllExport void __stdcall DisableAllKeys(bool disabled)
DllExport void __stdcall DisableAllKeys(bool disabled)
{
if (_keyManager)
{
if(_keyManager) {
_keyManager->SetDisabled(disabled);
}
}
}
DllExport void __stdcall SetKeyState(int32_t scanCode, bool state)
DllExport void __stdcall SetKeyState(int32_t scanCode, bool state)
{
if (_keyManager)
{
if(_keyManager) {
_keyManager->SetKeyState(scanCode, state);
_shortcutKeyHandler->ProcessKeys();
}
}
}
DllExport void __stdcall ResetKeyState()
DllExport void __stdcall ResetKeyState()
{
if (_keyManager)
{
if(_keyManager) {
_keyManager->ResetKeyState();
}
}
}
DllExport const char* __stdcall GetKeyName(uint32_t keyCode)
{
DllExport const char* __stdcall GetKeyName(uint32_t keyCode)
{
_returnString = KeyManager::GetKeyName(keyCode);
return _returnString.c_str();
}
}
DllExport uint32_t __stdcall GetKeyCode(char* keyName)
DllExport uint32_t __stdcall GetKeyCode(char* keyName)
{
if (keyName)
{
if(keyName) {
return KeyManager::GetKeyCode(keyName);
} else {
}
else
{
return 0;
}
}
}
}

View file

@ -3,7 +3,7 @@
#include "../Core/INotificationListener.h"
#include "../Core/NotificationManager.h"
typedef void(__stdcall *NotificationListenerCallback)(int, void*);
typedef void (__stdcall *NotificationListenerCallback)(int, void*);
class InteropNotificationListener : public INotificationListener
{

View file

@ -6,7 +6,7 @@
#include "../Utilities/SimpleLock.h"
#include "InteropNotificationListener.h"
typedef void(__stdcall *NotificationListenerCallback)(int, void*);
typedef void (__stdcall *NotificationListenerCallback)(int, void*);
class InteropNotificationListeners
{
@ -14,7 +14,8 @@ class InteropNotificationListeners
vector<shared_ptr<INotificationListener>> _externalNotificationListeners;
public:
INotificationListener* RegisterNotificationCallback(NotificationListenerCallback callback, shared_ptr<Console> console)
INotificationListener* RegisterNotificationCallback(NotificationListenerCallback callback,
shared_ptr<Console> console)
{
auto lock = _externalNotificationListenerLock.AcquireSafe();
auto listener = shared_ptr<INotificationListener>(new InteropNotificationListener(callback));
@ -23,7 +24,7 @@ public:
return listener.get();
}
void UnregisterNotificationCallback(INotificationListener *listener)
void UnregisterNotificationCallback(INotificationListener* listener)
{
auto lock = _externalNotificationListenerLock.AcquireSafe();
_externalNotificationListeners.erase(

View file

@ -8,43 +8,56 @@
extern shared_ptr<Console> _console;
extern "C" {
DllExport void __stdcall StartServer(uint16_t port, char* password, char* hostPlayerName) { GameServer::StartServer(_console, port, password, hostPlayerName); }
DllExport void __stdcall StopServer() { GameServer::StopServer(); }
DllExport bool __stdcall IsServerRunning() { return GameServer::Started(); }
DllExport void __stdcall StartServer(uint16_t port, char* password, char* hostPlayerName)
{
GameServer::StartServer(_console, port, password, hostPlayerName);
}
DllExport void __stdcall Connect(char* host, uint16_t port, char* password, char* playerName, bool spectator)
{
DllExport void __stdcall StopServer() { GameServer::StopServer(); }
DllExport bool __stdcall IsServerRunning() { return GameServer::Started(); }
DllExport void __stdcall Connect(char* host, uint16_t port, char* password, char* playerName, bool spectator)
{
ClientConnectionData connectionData(host, port, password, playerName, spectator);
GameClient::Connect(_console, connectionData);
}
}
DllExport void __stdcall Disconnect() { GameClient::Disconnect(); }
DllExport bool __stdcall IsConnected() { return GameClient::Connected(); }
DllExport void __stdcall Disconnect() { GameClient::Disconnect(); }
DllExport bool __stdcall IsConnected() { return GameClient::Connected(); }
DllExport int32_t __stdcall NetPlayGetAvailableControllers()
DllExport int32_t __stdcall NetPlayGetAvailableControllers()
{
if (GameServer::Started())
{
if(GameServer::Started()) {
return GameServer::GetAvailableControllers();
} else {
}
else
{
return GameClient::GetAvailableControllers();
}
}
}
DllExport void __stdcall NetPlaySelectController(int32_t port)
DllExport void __stdcall NetPlaySelectController(int32_t port)
{
if (GameServer::Started())
{
if(GameServer::Started()) {
return GameServer::SetHostControllerPort(port);
} else {
}
else
{
return GameClient::SelectController(port);
}
}
}
DllExport int32_t __stdcall NetPlayGetControllerPort()
DllExport int32_t __stdcall NetPlayGetControllerPort()
{
if (GameServer::Started())
{
if(GameServer::Started()) {
return GameServer::GetHostControllerPort();
} else {
}
else
{
return GameClient::GetControllerPort();
}
}
}
}

View file

@ -7,23 +7,26 @@
extern shared_ptr<Console> _console;
enum class VideoCodec;
extern "C"
extern "C" {
DllExport void __stdcall AviRecord(char* filename, VideoCodec codec, uint32_t compressionLevel)
{
DllExport void __stdcall AviRecord(char* filename, VideoCodec codec, uint32_t compressionLevel) { _console->GetVideoRenderer()->StartRecording(filename, codec, compressionLevel); }
DllExport void __stdcall AviStop() { _console->GetVideoRenderer()->StopRecording(); }
DllExport bool __stdcall AviIsRecording() { return _console->GetVideoRenderer()->IsRecording(); }
_console->GetVideoRenderer()->StartRecording(filename, codec, compressionLevel);
}
DllExport void __stdcall WaveRecord(char* filename) { _console->GetSoundMixer()->StartRecording(filename); }
DllExport void __stdcall WaveStop() { _console->GetSoundMixer()->StopRecording(); }
DllExport bool __stdcall WaveIsRecording() { return _console->GetSoundMixer()->IsRecording(); }
DllExport void __stdcall AviStop() { _console->GetVideoRenderer()->StopRecording(); }
DllExport bool __stdcall AviIsRecording() { return _console->GetVideoRenderer()->IsRecording(); }
DllExport void __stdcall MoviePlay(char* filename) { _console->GetMovieManager()->Play(string(filename)); }
DllExport void __stdcall MovieStop() { _console->GetMovieManager()->Stop(); }
DllExport bool __stdcall MoviePlaying() { return _console->GetMovieManager()->Playing(); }
DllExport bool __stdcall MovieRecording() { return _console->GetMovieManager()->Recording(); }
DllExport void __stdcall MovieRecord(RecordMovieOptions *options)
{
DllExport void __stdcall WaveRecord(char* filename) { _console->GetSoundMixer()->StartRecording(filename); }
DllExport void __stdcall WaveStop() { _console->GetSoundMixer()->StopRecording(); }
DllExport bool __stdcall WaveIsRecording() { return _console->GetSoundMixer()->IsRecording(); }
DllExport void __stdcall MoviePlay(char* filename) { _console->GetMovieManager()->Play(string(filename)); }
DllExport void __stdcall MovieStop() { _console->GetMovieManager()->Stop(); }
DllExport bool __stdcall MoviePlaying() { return _console->GetMovieManager()->Playing(); }
DllExport bool __stdcall MovieRecording() { return _console->GetMovieManager()->Recording(); }
DllExport void __stdcall MovieRecord(RecordMovieOptions* options)
{
RecordMovieOptions opt = *options;
_console->GetMovieManager()->Record(opt);
}
}
}

View file

@ -5,27 +5,27 @@
extern shared_ptr<Console> _console;
shared_ptr<RecordedRomTest> _recordedRomTest;
extern "C"
extern "C" {
DllExport int32_t __stdcall RunRecordedTest(char* filename, bool inBackground)
{
DllExport int32_t __stdcall RunRecordedTest(char* filename, bool inBackground)
{
shared_ptr<RecordedRomTest> romTest(new RecordedRomTest(inBackground ? nullptr : _console));
return romTest->Run(filename);
}
}
DllExport void __stdcall RomTestRecord(char* filename, bool reset)
{
DllExport void __stdcall RomTestRecord(char* filename, bool reset)
{
_recordedRomTest.reset(new RecordedRomTest(_console));
_recordedRomTest->Record(filename, reset);
}
}
DllExport void __stdcall RomTestStop()
DllExport void __stdcall RomTestStop()
{
if (_recordedRomTest)
{
if(_recordedRomTest) {
_recordedRomTest->Stop();
_recordedRomTest.reset();
}
}
DllExport bool __stdcall RomTestRecording() { return _recordedRomTest != nullptr; }
}
DllExport bool __stdcall RomTestRecording() { return _recordedRomTest != nullptr; }
}

View file

@ -6,23 +6,23 @@
#pragma once
#if _WIN32 || _WIN64
#if _WIN64
#define ENVIRONMENT64
#else
#if _WIN64
#define ENVIRONMENT64
#else
#define ENVIRONMENT32
#endif
#endif
#endif
#if __GNUC__
#if __x86_64__ || __ppc64__
#if __x86_64__ || __ppc64__
#define ENVIRONMENT64
#else
#else
#define ENVIRONMENT32
#endif
#endif
#endif
#ifdef _DEBUG
#define MESEN_LIBRARY_DEBUG_SUFFIX "Debug"
#define MESEN_LIBRARY_DEBUG_SUFFIX "Debug"
#else
#define MESEN_LIBRARY_DEBUG_SUFFIX "Release"
#endif
@ -30,18 +30,18 @@
#ifdef ENVIRONMENT32
#define MESEN_LIBRARY_SUFFIX "x86.lib"
#else
#define MESEN_LIBRARY_SUFFIX "x64.lib"
#define MESEN_LIBRARY_SUFFIX "x64.lib"
#endif
#if _WIN32 || _WIN64
//#pragma comment(lib, "Core.lib")
//#pragma comment(lib, "Utilities.lib")
//#pragma comment(lib, "Windows.lib")
//#pragma comment(lib, "SevenZip.lib")
//#pragma comment(lib, "Lua.lib")
//#pragma comment(lib, "ws2_32.lib") //Winsock Library
//#pragma comment(lib, "../Dependencies/DirectXTK." MESEN_LIBRARY_DEBUG_SUFFIX ".Static." MESEN_LIBRARY_SUFFIX)
#define DllExport __declspec(dllexport)
//#pragma comment(lib, "Core.lib")
//#pragma comment(lib, "Utilities.lib")
//#pragma comment(lib, "Windows.lib")
//#pragma comment(lib, "SevenZip.lib")
//#pragma comment(lib, "Lua.lib")
//#pragma comment(lib, "ws2_32.lib") //Winsock Library
//#pragma comment(lib, "../Dependencies/DirectXTK." MESEN_LIBRARY_DEBUG_SUFFIX ".Static." MESEN_LIBRARY_SUFFIX)
#define DllExport __declspec(dllexport)
#else
#define __stdcall
#define DllExport __attribute__((visibility("default")))