Reformat InteropDll (Resharper)
This commit is contained in:
parent
3764af908f
commit
f3f15a32fe
10 changed files with 564 additions and 495 deletions
|
@ -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;
|
||||
}
|
||||
|
@ -87,18 +91,21 @@ extern "C" {
|
|||
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) {
|
||||
if (!noVideo)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
_renderer.reset(new Renderer(_console, (HWND)_viewerHandle, true));
|
||||
#else
|
||||
|
@ -106,7 +113,8 @@ extern "C" {
|
|||
#endif
|
||||
}
|
||||
|
||||
if(!noAudio) {
|
||||
if (!noAudio)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
_soundManager.reset(new SoundManager(_console, (HWND)_windowHandle));
|
||||
#else
|
||||
|
@ -114,7 +122,8 @@ extern "C" {
|
|||
#endif
|
||||
}
|
||||
|
||||
if(!noInput) {
|
||||
if (!noInput)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
_keyManager.reset(new WindowsKeyManager(_console, (HWND)_windowHandle));
|
||||
#else
|
||||
|
@ -126,22 +135,26 @@ extern "C" {
|
|||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -158,7 +171,8 @@ extern "C" {
|
|||
{
|
||||
RomInfo romInfo = {};
|
||||
string sha1;
|
||||
if(_console->GetCartridge()) {
|
||||
if (_console->GetCartridge())
|
||||
{
|
||||
romInfo = _console->GetCartridge()->GetRomInfo();
|
||||
sha1 = _console->GetCartridge()->GetSha1Hash();
|
||||
}
|
||||
|
@ -176,11 +190,14 @@ extern "C" {
|
|||
|
||||
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 << "[!|!]";
|
||||
}
|
||||
}
|
||||
|
@ -201,14 +218,16 @@ extern "C" {
|
|||
|
||||
DllExport void __stdcall Pause(ConsoleId consoleId)
|
||||
{
|
||||
if(!GameClient::Connected()) {
|
||||
if (!GameClient::Connected())
|
||||
{
|
||||
GetConsoleById(consoleId)->Pause();
|
||||
}
|
||||
}
|
||||
|
||||
DllExport void __stdcall Resume(ConsoleId consoleId)
|
||||
{
|
||||
if(!GameClient::Connected()) {
|
||||
if (!GameClient::Connected())
|
||||
{
|
||||
GetConsoleById(consoleId)->Resume();
|
||||
}
|
||||
}
|
||||
|
@ -216,7 +235,8 @@ extern "C" {
|
|||
DllExport bool __stdcall IsPaused(ConsoleId consoleId)
|
||||
{
|
||||
shared_ptr<Console> console = GetConsoleById(consoleId);
|
||||
if(console) {
|
||||
if (console)
|
||||
{
|
||||
return console->IsPaused();
|
||||
}
|
||||
return true;
|
||||
|
@ -224,21 +244,24 @@ extern "C" {
|
|||
|
||||
DllExport void __stdcall Reset()
|
||||
{
|
||||
if(!GameClient::Connected()) {
|
||||
if (!GameClient::Connected())
|
||||
{
|
||||
_console->GetControlManager()->GetSystemActionManager()->Reset();
|
||||
}
|
||||
}
|
||||
|
||||
DllExport void __stdcall PowerCycle()
|
||||
{
|
||||
if(!GameClient::Connected()) {
|
||||
if (!GameClient::Connected())
|
||||
{
|
||||
_console->GetControlManager()->GetSystemActionManager()->PowerCycle();
|
||||
}
|
||||
}
|
||||
|
||||
DllExport void __stdcall ReloadRom()
|
||||
{
|
||||
if(!GameClient::Connected()) {
|
||||
if (!GameClient::Connected())
|
||||
{
|
||||
_console->ReloadRom(false);
|
||||
}
|
||||
}
|
||||
|
@ -270,7 +293,11 @@ extern "C" {
|
|||
_listeners.UnregisterNotificationCallback(listener);
|
||||
}
|
||||
|
||||
DllExport void __stdcall DisplayMessage(char* title, char* message, char* param1) { MessageManager::DisplayMessage(title, message, param1 ? param1 : ""); }
|
||||
DllExport void __stdcall DisplayMessage(char* title, char* message, char* param1)
|
||||
{
|
||||
MessageManager::DisplayMessage(title, message, param1 ? param1 : "");
|
||||
}
|
||||
|
||||
DllExport const char* __stdcall GetLog()
|
||||
{
|
||||
_logString = MessageManager::GetLog();
|
||||
|
@ -283,7 +310,10 @@ extern "C" {
|
|||
}
|
||||
|
||||
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 SetCheats(uint32_t codes[], uint32_t length)
|
||||
{
|
||||
_console->GetCheatManager()->SetCheats(codes, length);
|
||||
}
|
||||
|
||||
DllExport void __stdcall WriteLogEntry(char* message) { MessageManager::Log(message); }
|
||||
|
||||
|
@ -291,14 +321,22 @@ extern "C" {
|
|||
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 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 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();
|
||||
}
|
||||
|
|
|
@ -22,8 +22,7 @@ unique_ptr<IRenderingDevice> _historyRenderer;
|
|||
unique_ptr<IAudioDevice> _historySoundManager;
|
||||
enum class VideoCodec;
|
||||
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
DllExport bool __stdcall HistoryViewerEnabled()
|
||||
{
|
||||
shared_ptr<RewindManager> rewindManager = _console->GetRewindManager();
|
||||
|
@ -69,7 +68,8 @@ extern "C"
|
|||
|
||||
DllExport uint32_t __stdcall HistoryViewerGetHistoryLength()
|
||||
{
|
||||
if (_historyConsole) {
|
||||
if (_historyConsole)
|
||||
{
|
||||
return _historyConsole->GetHistoryViewer()->GetHistoryLength();
|
||||
}
|
||||
return 0;
|
||||
|
@ -77,14 +77,16 @@ extern "C"
|
|||
|
||||
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)
|
||||
{
|
||||
if (_historyConsole) {
|
||||
if (_historyConsole)
|
||||
{
|
||||
return _historyConsole->GetHistoryViewer()->CreateSaveState(outputFile, position);
|
||||
}
|
||||
return false;
|
||||
|
@ -92,7 +94,8 @@ extern "C"
|
|||
|
||||
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;
|
||||
|
@ -100,21 +103,24 @@ extern "C"
|
|||
|
||||
DllExport void __stdcall HistoryViewerResumeGameplay(uint32_t resumeAtSecond)
|
||||
{
|
||||
if (_historyConsole) {
|
||||
if (_historyConsole)
|
||||
{
|
||||
_historyConsole->GetHistoryViewer()->ResumeGameplay(_console, resumeAtSecond);
|
||||
}
|
||||
}
|
||||
|
||||
DllExport void __stdcall HistoryViewerSetPosition(uint32_t seekPosition)
|
||||
{
|
||||
if (_historyConsole) {
|
||||
if (_historyConsole)
|
||||
{
|
||||
_historyConsole->GetHistoryViewer()->SeekTo(seekPosition);
|
||||
}
|
||||
}
|
||||
|
||||
DllExport uint32_t __stdcall HistoryViewerGetPosition()
|
||||
{
|
||||
if (_historyConsole) {
|
||||
if (_historyConsole)
|
||||
{
|
||||
return _historyConsole->GetHistoryViewer()->GetPosition();
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -9,8 +9,7 @@ extern shared_ptr<Console> _console;
|
|||
|
||||
static string _returnString;
|
||||
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
DllExport void __stdcall SetMousePosition(double x, double y)
|
||||
{
|
||||
KeyManager::SetMousePosition(_console, x, y);
|
||||
|
@ -23,7 +22,8 @@ extern "C"
|
|||
|
||||
DllExport void __stdcall UpdateInputDevices()
|
||||
{
|
||||
if(_keyManager) {
|
||||
if (_keyManager)
|
||||
{
|
||||
_keyManager->UpdateDevices();
|
||||
}
|
||||
}
|
||||
|
@ -31,21 +31,24 @@ extern "C"
|
|||
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)
|
||||
{
|
||||
if(_keyManager) {
|
||||
if (_keyManager)
|
||||
{
|
||||
_keyManager->SetDisabled(disabled);
|
||||
}
|
||||
}
|
||||
|
||||
DllExport void __stdcall SetKeyState(int32_t scanCode, bool state)
|
||||
{
|
||||
if(_keyManager) {
|
||||
if (_keyManager)
|
||||
{
|
||||
_keyManager->SetKeyState(scanCode, state);
|
||||
_shortcutKeyHandler->ProcessKeys();
|
||||
}
|
||||
|
@ -53,7 +56,8 @@ extern "C"
|
|||
|
||||
DllExport void __stdcall ResetKeyState()
|
||||
{
|
||||
if(_keyManager) {
|
||||
if (_keyManager)
|
||||
{
|
||||
_keyManager->ResetKeyState();
|
||||
}
|
||||
}
|
||||
|
@ -66,9 +70,12 @@ extern "C"
|
|||
|
||||
DllExport uint32_t __stdcall GetKeyCode(char* keyName)
|
||||
{
|
||||
if(keyName) {
|
||||
if (keyName)
|
||||
{
|
||||
return KeyManager::GetKeyCode(keyName);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -8,7 +8,11 @@
|
|||
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 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(); }
|
||||
|
||||
|
@ -23,27 +27,36 @@ extern "C" {
|
|||
|
||||
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)
|
||||
{
|
||||
if(GameServer::Started()) {
|
||||
if (GameServer::Started())
|
||||
{
|
||||
return GameServer::SetHostControllerPort(port);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return GameClient::SelectController(port);
|
||||
}
|
||||
}
|
||||
|
||||
DllExport int32_t __stdcall NetPlayGetControllerPort()
|
||||
{
|
||||
if(GameServer::Started()) {
|
||||
if (GameServer::Started())
|
||||
{
|
||||
return GameServer::GetHostControllerPort();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return GameClient::GetControllerPort();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,9 +7,12 @@
|
|||
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); }
|
||||
_console->GetVideoRenderer()->StartRecording(filename, codec, compressionLevel);
|
||||
}
|
||||
|
||||
DllExport void __stdcall AviStop() { _console->GetVideoRenderer()->StopRecording(); }
|
||||
DllExport bool __stdcall AviIsRecording() { return _console->GetVideoRenderer()->IsRecording(); }
|
||||
|
||||
|
|
|
@ -5,8 +5,7 @@
|
|||
extern shared_ptr<Console> _console;
|
||||
shared_ptr<RecordedRomTest> _recordedRomTest;
|
||||
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
DllExport int32_t __stdcall RunRecordedTest(char* filename, bool inBackground)
|
||||
{
|
||||
shared_ptr<RecordedRomTest> romTest(new RecordedRomTest(inBackground ? nullptr : _console));
|
||||
|
@ -21,7 +20,8 @@ extern "C"
|
|||
|
||||
DllExport void __stdcall RomTestStop()
|
||||
{
|
||||
if(_recordedRomTest) {
|
||||
if (_recordedRomTest)
|
||||
{
|
||||
_recordedRomTest->Stop();
|
||||
_recordedRomTest.reset();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue