1
// Copyright 2013 Dolphin Emulator Project
2
// Licensed under GPLv2
3
// Refer to the license.txt file included.
9
#include "CommonTypes.h"
13
#include <SFML/Network.hpp>
15
#include "NetPlayProto.h"
16
#include "GCPadStatus.h"
23
#include "FifoQueue.h"
29
NetPad(const SPADStatus* const);
38
virtual ~NetPlayUI() {};
40
virtual void BootGame(const std::string& filename) = 0;
41
virtual void StopGame() = 0;
43
virtual void Update() = 0;
44
virtual void AppendChat(const std::string& msg) = 0;
46
virtual void OnMsgChangeGame(const std::string& filename) = 0;
47
virtual void OnMsgStartGame() = 0;
48
virtual void OnMsgStopGame() = 0;
49
virtual bool IsRecording() = 0;
66
NetPlayClient(const std::string& address, const u16 port, NetPlayUI* dialog, const std::string& name);
69
void GetPlayerList(std::string& list, std::vector<int>& pid_list);
70
void GetPlayers(std::vector<const Player *>& player_list);
74
bool StartGame(const std::string &path);
77
bool ChangeGame(const std::string& game);
78
void SendChatMessage(const std::string& msg);
80
// Send and receive pads values
81
bool WiimoteUpdate(int _number, u8* data, const u8 size);
82
bool GetNetPads(const u8 pad_nb, const SPADStatus* const, NetPad* const netvalues);
84
u8 LocalPadToInGamePad(u8 localPad);
85
u8 InGamePadToLocalPad(u8 localPad);
87
u8 LocalWiimoteToInGameWiimote(u8 local_pad);
94
std::recursive_mutex game;
96
std::recursive_mutex players, send;
99
Common::FifoQueue<NetPad> m_pad_buffer[4];
100
Common::FifoQueue<NetWiimote> m_wiimote_buffer[4];
103
sf::SocketTCP m_socket;
104
std::thread m_thread;
105
sf::Selector<sf::SocketTCP> m_selector;
107
std::string m_selected_game;
108
volatile bool m_is_running;
109
volatile bool m_do_loop;
111
unsigned int m_target_buffer_size;
113
Player* m_local_player;
117
PadMapping m_pad_map[4];
118
PadMapping m_wiimote_map[4];
123
void UpdateDevices();
124
void SendPadState(const PadMapping in_game_pad, const NetPad& np);
125
void SendWiimoteState(const PadMapping in_game_pad, const NetWiimote& nw);
126
unsigned int OnData(sf::Packet& packet);
129
std::map<PlayerId, Player> m_players;
132
void NetPlay_Enable(NetPlayClient* const np);
133
void NetPlay_Disable();