forked from SourMesen/Mesen-S
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNetplayApiWrapper.cpp
50 lines (43 loc) · 1.53 KB
/
NetplayApiWrapper.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "stdafx.h"
#include "../Core/Console.h"
#include "../Core/ClientConnectionData.h"
#include "../Core/GameServer.h"
#include "../Core/GameClient.h"
#include "../Core/EmuSettings.h"
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 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 int32_t __stdcall NetPlayGetAvailableControllers()
{
if(GameServer::Started()) {
return GameServer::GetAvailableControllers();
} else {
return GameClient::GetAvailableControllers();
}
}
DllExport void __stdcall NetPlaySelectController(int32_t port)
{
if(GameServer::Started()) {
return GameServer::SetHostControllerPort(port);
} else {
return GameClient::SelectController(port);
}
}
DllExport int32_t __stdcall NetPlayGetControllerPort()
{
if(GameServer::Started()) {
return GameServer::GetHostControllerPort();
} else {
return GameClient::GetControllerPort();
}
}
}