NetPlay: Remove NetPlay.h / NetPlay.cpp
Now the server and client implementations are entirely separate.
This commit is contained in:
parent
9e63cebc93
commit
a3a222bf5b
|
@ -10,7 +10,6 @@ set(SRCS Src/ActionReplay.cpp
|
|||
Src/GeckoCodeConfig.cpp
|
||||
Src/GeckoCode.cpp
|
||||
Src/Movie.cpp
|
||||
Src/NetPlay.cpp
|
||||
Src/NetPlayClient.cpp
|
||||
Src/NetPlayServer.cpp
|
||||
Src/PatchEngine.cpp
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="DebugFast|Win32">
|
||||
|
@ -334,7 +334,6 @@
|
|||
<ClCompile Include="Src\IPC_HLE\WII_IPC_HLE_WiiMote.cpp" />
|
||||
<ClCompile Include="Src\x64MemTools.cpp" />
|
||||
<ClCompile Include="Src\Movie.cpp" />
|
||||
<ClCompile Include="Src\NetPlay.cpp" />
|
||||
<ClCompile Include="Src\NetPlayClient.cpp" />
|
||||
<ClCompile Include="Src\NetPlayServer.cpp" />
|
||||
<ClCompile Include="Src\PatchEngine.cpp" />
|
||||
|
@ -540,7 +539,6 @@
|
|||
<ClInclude Include="Src\IPC_HLE\WII_IPC_HLE_WiiMote.h" />
|
||||
<ClInclude Include="Src\MemTools.h" />
|
||||
<ClInclude Include="Src\Movie.h" />
|
||||
<ClInclude Include="Src\NetPlay.h" />
|
||||
<ClInclude Include="Src\PatchEngine.h" />
|
||||
<ClInclude Include="Src\DSPEmulator.h" />
|
||||
<ClInclude Include="Src\PowerPC\CPUCoreBase.h" />
|
||||
|
@ -599,4 +597,4 @@
|
|||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Src\ConfigManager.cpp" />
|
||||
|
@ -529,9 +529,6 @@
|
|||
<ClCompile Include="Src\HW\Wiimote.cpp">
|
||||
<Filter>HW %28Flipper/Hollywood%29\Wiimote</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Src\NetPlay.cpp">
|
||||
<Filter>NetPlay</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Src\NetPlayServer.cpp">
|
||||
<Filter>NetPlay</Filter>
|
||||
</ClCompile>
|
||||
|
@ -1014,9 +1011,6 @@
|
|||
<ClInclude Include="Src\PowerPC\CPUCoreBase.h">
|
||||
<Filter>PowerPC</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Src\NetPlay.h">
|
||||
<Filter>NetPlay</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Src\BootManager.h" />
|
||||
<ClInclude Include="Src\FifoPlayer\FifoDataFile.h">
|
||||
<Filter>FifoPlayer</Filter>
|
||||
|
@ -1177,9 +1171,6 @@
|
|||
<Filter Include="HW %28Flipper/Hollywood%29\Wiimote\Real">
|
||||
<UniqueIdentifier>{1c21a3e1-b791-4a23-b0d5-ed2b2c34007f}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="NetPlay">
|
||||
<UniqueIdentifier>{231ceb02-1122-402a-87a8-094a9ed768c2}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="FifoPlayer">
|
||||
<UniqueIdentifier>{ca7d56f7-4e84-4d15-9aea-7ae6fa7d6586}</UniqueIdentifier>
|
||||
</Filter>
|
||||
|
@ -1187,4 +1178,4 @@
|
|||
<UniqueIdentifier>{3e9e6e83-c1bf-45f9-aeff-231f98f60d29}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include "Host.h"
|
||||
#include "VideoBackendBase.h"
|
||||
#include "Movie.h"
|
||||
#include "NetPlay.h"
|
||||
#include "NetPlayClient.h"
|
||||
|
||||
namespace BootManager
|
||||
{
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "../ConfigManager.h"
|
||||
#include "../CoreTiming.h"
|
||||
#include "../Movie.h"
|
||||
#include "../NetPlay.h"
|
||||
#include "../NetPlayClient.h"
|
||||
|
||||
#include "SystemTimers.h"
|
||||
#include "ProcessorInterface.h"
|
||||
|
|
|
@ -1,338 +0,0 @@
|
|||
// Copyright 2013 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "NetPlay.h"
|
||||
|
||||
// for wiimote
|
||||
#include "IPC_HLE/WII_IPC_HLE_Device_usb.h"
|
||||
#include "IPC_HLE/WII_IPC_HLE_WiiMote.h"
|
||||
// for gcpad
|
||||
#include "HW/SI_DeviceGCController.h"
|
||||
#include "HW/SI_DeviceGCSteeringWheel.h"
|
||||
#include "HW/SI_DeviceDanceMat.h"
|
||||
// for gctime
|
||||
#include "HW/EXI_DeviceIPL.h"
|
||||
// for wiimote/ OSD messages
|
||||
#include "Core.h"
|
||||
#include "ConfigManager.h"
|
||||
|
||||
std::mutex crit_netplay_client;
|
||||
static NetPlayClient * netplay_client = NULL;
|
||||
NetSettings g_NetPlaySettings;
|
||||
|
||||
#define RPT_SIZE_HACK (1 << 16)
|
||||
|
||||
NetPlayClient::Player::Player()
|
||||
{
|
||||
memset(pad_map, -1, sizeof(pad_map));
|
||||
}
|
||||
|
||||
// called from ---GUI--- thread
|
||||
std::string NetPlayClient::Player::ToString() const
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss << name << '[' << (char)(pid+'0') << "] : " << revision << " |";
|
||||
for (unsigned int i=0; i<4; ++i)
|
||||
ss << (pad_map[i]>=0 ? (char)(pad_map[i]+'1') : '-');
|
||||
ss << '|';
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
NetPad::NetPad()
|
||||
{
|
||||
nHi = 0x00808080;
|
||||
nLo = 0x80800000;
|
||||
}
|
||||
|
||||
NetPad::NetPad(const SPADStatus* const pad_status)
|
||||
{
|
||||
nHi = (u32)((u8)pad_status->stickY);
|
||||
nHi |= (u32)((u8)pad_status->stickX << 8);
|
||||
nHi |= (u32)((u16)pad_status->button << 16);
|
||||
nHi |= 0x00800000;
|
||||
nLo = (u8)pad_status->triggerRight;
|
||||
nLo |= (u32)((u8)pad_status->triggerLeft << 8);
|
||||
nLo |= (u32)((u8)pad_status->substickY << 16);
|
||||
nLo |= (u32)((u8)pad_status->substickX << 24);
|
||||
}
|
||||
|
||||
// called from ---NETPLAY--- thread
|
||||
void NetPlayClient::ClearBuffers()
|
||||
{
|
||||
// clear pad buffers, Clear method isn't thread safe
|
||||
for (unsigned int i=0; i<4; ++i)
|
||||
{
|
||||
while (m_pad_buffer[i].Size())
|
||||
m_pad_buffer[i].Pop();
|
||||
|
||||
while (m_wiimote_buffer[i].Size())
|
||||
m_wiimote_buffer[i].Pop();
|
||||
|
||||
m_wiimote_input[i].clear();
|
||||
}
|
||||
}
|
||||
|
||||
// called from ---CPU--- thread
|
||||
bool NetPlayClient::GetNetPads(const u8 pad_nb, const SPADStatus* const pad_status, NetPad* const netvalues)
|
||||
{
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lkp(m_crit.players);
|
||||
|
||||
// in game mapping for this local pad
|
||||
unsigned int in_game_num = m_local_player->pad_map[pad_nb];
|
||||
|
||||
// does this local pad map in game?
|
||||
if (in_game_num < 4)
|
||||
{
|
||||
NetPad np(pad_status);
|
||||
|
||||
// adjust the buffer either up or down
|
||||
// inserting multiple padstates or dropping states
|
||||
while (m_pad_buffer[in_game_num].Size() <= m_target_buffer_size)
|
||||
{
|
||||
// add to buffer
|
||||
m_pad_buffer[in_game_num].Push(np);
|
||||
|
||||
// send
|
||||
SendPadState(pad_nb, np);
|
||||
}
|
||||
}
|
||||
|
||||
} // unlock players
|
||||
|
||||
//Common::Timer bufftimer;
|
||||
//bufftimer.Start();
|
||||
|
||||
// get padstate from buffer and send to game
|
||||
while (!m_pad_buffer[pad_nb].Pop(*netvalues))
|
||||
{
|
||||
// wait for receiving thread to push some data
|
||||
Common::SleepCurrentThread(1);
|
||||
|
||||
if (false == m_is_running)
|
||||
return false;
|
||||
|
||||
// TODO: check the time of bufftimer here,
|
||||
// if it gets pretty high, ask the user if they want to disconnect
|
||||
|
||||
}
|
||||
|
||||
//u64 hangtime = bufftimer.GetTimeElapsed();
|
||||
//if (hangtime > 10)
|
||||
//{
|
||||
// std::ostringstream ss;
|
||||
// ss << "Pad " << (int)pad_nb << ": Had to wait " << hangtime << "ms for pad data. (increase pad Buffer maybe)";
|
||||
// Core::DisplayMessage(ss.str(), 1000);
|
||||
//}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// called from ---CPU--- thread
|
||||
void NetPlayClient::WiimoteInput(int _number, u16 _channelID, const void* _pData, u32 _Size)
|
||||
{
|
||||
//// in game mapping for this local wiimote
|
||||
unsigned int in_game_num = m_local_player->pad_map[_number]; // just using gc pad_map for now
|
||||
|
||||
// does this local pad map in game?
|
||||
if (in_game_num < 4)
|
||||
{
|
||||
m_wiimote_input[_number].resize(m_wiimote_input[_number].size() + 1);
|
||||
m_wiimote_input[_number].back().assign((char*)_pData, (char*)_pData + _Size);
|
||||
m_wiimote_input[_number].back().channel = _channelID;
|
||||
}
|
||||
}
|
||||
|
||||
// called from ---CPU--- thread
|
||||
void NetPlayClient::WiimoteUpdate(int _number)
|
||||
{
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lkp(m_crit.players);
|
||||
|
||||
// in game mapping for this local wiimote
|
||||
unsigned int in_game_num = m_local_player->pad_map[_number]; // just using gc pad_map for now
|
||||
|
||||
// does this local pad map in game?
|
||||
if (in_game_num < 4)
|
||||
{
|
||||
m_wiimote_buffer[in_game_num].Push(m_wiimote_input[_number]);
|
||||
|
||||
// TODO: send it
|
||||
|
||||
m_wiimote_input[_number].clear();
|
||||
}
|
||||
|
||||
} // unlock players
|
||||
|
||||
if (0 == m_wiimote_buffer[_number].Size())
|
||||
{
|
||||
//PanicAlert("PANIC");
|
||||
return;
|
||||
}
|
||||
|
||||
NetWiimote nw;
|
||||
m_wiimote_buffer[_number].Pop(nw);
|
||||
|
||||
NetWiimote::const_iterator
|
||||
i = nw.begin(), e = nw.end();
|
||||
for ( ; i!=e; ++i)
|
||||
Core::Callback_WiimoteInterruptChannel(_number, i->channel, &(*i)[0], (u32)i->size() + RPT_SIZE_HACK);
|
||||
}
|
||||
|
||||
// called from ---GUI--- thread and ---NETPLAY--- thread (client side)
|
||||
bool NetPlayClient::StopGame()
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lkg(m_crit.game);
|
||||
|
||||
if (false == m_is_running)
|
||||
{
|
||||
PanicAlertT("Game isn't running!");
|
||||
return false;
|
||||
}
|
||||
|
||||
m_dialog->AppendChat(" -- STOPPING GAME -- ");
|
||||
|
||||
m_is_running = false;
|
||||
NetPlay_Disable();
|
||||
|
||||
// stop game
|
||||
m_dialog->StopGame();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// called from ---CPU--- thread
|
||||
u8 NetPlayClient::GetPadNum(u8 numPAD)
|
||||
{
|
||||
// TODO: i don't like that this loop is running everytime there is rumble
|
||||
unsigned int i = 0;
|
||||
for (; i<4; ++i)
|
||||
if (numPAD == m_local_player->pad_map[i])
|
||||
break;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
// stuff hacked into dolphin
|
||||
|
||||
// called from ---CPU--- thread
|
||||
// Actual Core function which is called on every frame
|
||||
bool CSIDevice_GCController::NetPlay_GetInput(u8 numPAD, SPADStatus PadStatus, u32 *PADStatus)
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(crit_netplay_client);
|
||||
|
||||
if (netplay_client)
|
||||
return netplay_client->GetNetPads(numPAD, &PadStatus, (NetPad*)PADStatus);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CSIDevice_GCSteeringWheel::NetPlay_GetInput(u8 numPAD, SPADStatus PadStatus, u32 *PADStatus)
|
||||
{
|
||||
return CSIDevice_GCController::NetPlay_GetInput(numPAD, PadStatus, PADStatus);
|
||||
}
|
||||
|
||||
bool CSIDevice_DanceMat::NetPlay_GetInput(u8 numPAD, SPADStatus PadStatus, u32 *PADStatus)
|
||||
{
|
||||
return CSIDevice_GCController::NetPlay_GetInput(numPAD, PadStatus, PADStatus);
|
||||
}
|
||||
|
||||
// called from ---CPU--- thread
|
||||
// so all players' games get the same time
|
||||
u32 CEXIIPL::NetPlay_GetGCTime()
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(crit_netplay_client);
|
||||
|
||||
if (netplay_client)
|
||||
return 1272737767; // watev
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
// called from ---CPU--- thread
|
||||
// return the local pad num that should rumble given a ingame pad num
|
||||
u8 CSIDevice_GCController::NetPlay_GetPadNum(u8 numPAD)
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(crit_netplay_client);
|
||||
|
||||
if (netplay_client)
|
||||
return netplay_client->GetPadNum(numPAD);
|
||||
else
|
||||
return numPAD;
|
||||
}
|
||||
|
||||
u8 CSIDevice_GCSteeringWheel::NetPlay_GetPadNum(u8 numPAD)
|
||||
{
|
||||
return CSIDevice_GCController::NetPlay_GetPadNum(numPAD);
|
||||
}
|
||||
|
||||
u8 CSIDevice_DanceMat::NetPlay_GetPadNum(u8 numPAD)
|
||||
{
|
||||
return CSIDevice_GCController::NetPlay_GetPadNum(numPAD);
|
||||
}
|
||||
|
||||
// called from ---CPU--- thread
|
||||
// wiimote update / used for frame counting
|
||||
//void CWII_IPC_HLE_Device_usb_oh1_57e_305::NetPlay_WiimoteUpdate(int _number)
|
||||
void CWII_IPC_HLE_Device_usb_oh1_57e_305::NetPlay_WiimoteUpdate(int)
|
||||
{
|
||||
//CritLocker crit(crit_netplay_client);
|
||||
|
||||
//if (netplay_client)
|
||||
// netplay_client->WiimoteUpdate(_number);
|
||||
}
|
||||
|
||||
// called from ---CPU--- thread
|
||||
//
|
||||
int CWII_IPC_HLE_WiiMote::NetPlay_GetWiimoteNum(int _number)
|
||||
{
|
||||
//CritLocker crit(crit_netplay_client);
|
||||
|
||||
//if (netplay_client)
|
||||
// return netplay_client->GetPadNum(_number); // just using gcpad mapping for now
|
||||
//else
|
||||
return _number;
|
||||
}
|
||||
|
||||
// called from ---CPU--- thread
|
||||
// intercept wiimote input callback
|
||||
//bool CWII_IPC_HLE_WiiMote::NetPlay_WiimoteInput(int _number, u16 _channelID, const void* _pData, u32& _Size)
|
||||
bool CWII_IPC_HLE_WiiMote::NetPlay_WiimoteInput(int, u16, const void*, u32&)
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(crit_netplay_client);
|
||||
|
||||
if (netplay_client)
|
||||
//{
|
||||
// if (_Size >= RPT_SIZE_HACK)
|
||||
// {
|
||||
// _Size -= RPT_SIZE_HACK;
|
||||
// return false;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// netplay_client->WiimoteInput(_number, _channelID, _pData, _Size);
|
||||
// // don't use this packet
|
||||
return true;
|
||||
// }
|
||||
//}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
bool NetPlay::IsNetPlayRunning()
|
||||
{
|
||||
return netplay_client != NULL;
|
||||
}
|
||||
|
||||
void NetPlay_Enable(NetPlayClient* const np)
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(crit_netplay_client);
|
||||
netplay_client = np;
|
||||
}
|
||||
|
||||
void NetPlay_Disable()
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(crit_netplay_client);
|
||||
netplay_client = NULL;
|
||||
}
|
|
@ -2,7 +2,60 @@
|
|||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "NetPlay.h"
|
||||
#include "NetPlayClient.h"
|
||||
|
||||
// for wiimote
|
||||
#include "IPC_HLE/WII_IPC_HLE_Device_usb.h"
|
||||
#include "IPC_HLE/WII_IPC_HLE_WiiMote.h"
|
||||
// for gcpad
|
||||
#include "HW/SI_DeviceGCController.h"
|
||||
#include "HW/SI_DeviceGCSteeringWheel.h"
|
||||
#include "HW/SI_DeviceDanceMat.h"
|
||||
// for gctime
|
||||
#include "HW/EXI_DeviceIPL.h"
|
||||
// for wiimote/ OSD messages
|
||||
#include "Core.h"
|
||||
#include "ConfigManager.h"
|
||||
|
||||
std::mutex crit_netplay_client;
|
||||
static NetPlayClient * netplay_client = NULL;
|
||||
NetSettings g_NetPlaySettings;
|
||||
|
||||
#define RPT_SIZE_HACK (1 << 16)
|
||||
|
||||
NetPlayClient::Player::Player()
|
||||
{
|
||||
memset(pad_map, -1, sizeof(pad_map));
|
||||
}
|
||||
|
||||
// called from ---GUI--- thread
|
||||
std::string NetPlayClient::Player::ToString() const
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss << name << '[' << (char)(pid+'0') << "] : " << revision << " |";
|
||||
for (unsigned int i=0; i<4; ++i)
|
||||
ss << (pad_map[i]>=0 ? (char)(pad_map[i]+'1') : '-');
|
||||
ss << '|';
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
NetPad::NetPad()
|
||||
{
|
||||
nHi = 0x00808080;
|
||||
nLo = 0x80800000;
|
||||
}
|
||||
|
||||
NetPad::NetPad(const SPADStatus* const pad_status)
|
||||
{
|
||||
nHi = (u32)((u8)pad_status->stickY);
|
||||
nHi |= (u32)((u8)pad_status->stickX << 8);
|
||||
nHi |= (u32)((u16)pad_status->button << 16);
|
||||
nHi |= 0x00800000;
|
||||
nLo = (u8)pad_status->triggerRight;
|
||||
nLo |= (u32)((u8)pad_status->triggerLeft << 8);
|
||||
nLo |= (u32)((u8)pad_status->substickY << 16);
|
||||
nLo |= (u32)((u8)pad_status->substickX << 24);
|
||||
}
|
||||
|
||||
// called from ---GUI--- thread
|
||||
NetPlayClient::~NetPlayClient()
|
||||
|
@ -368,3 +421,283 @@ bool NetPlayClient::ChangeGame(const std::string&)
|
|||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// called from ---NETPLAY--- thread
|
||||
void NetPlayClient::ClearBuffers()
|
||||
{
|
||||
// clear pad buffers, Clear method isn't thread safe
|
||||
for (unsigned int i=0; i<4; ++i)
|
||||
{
|
||||
while (m_pad_buffer[i].Size())
|
||||
m_pad_buffer[i].Pop();
|
||||
|
||||
while (m_wiimote_buffer[i].Size())
|
||||
m_wiimote_buffer[i].Pop();
|
||||
|
||||
m_wiimote_input[i].clear();
|
||||
}
|
||||
}
|
||||
|
||||
// called from ---CPU--- thread
|
||||
bool NetPlayClient::GetNetPads(const u8 pad_nb, const SPADStatus* const pad_status, NetPad* const netvalues)
|
||||
{
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lkp(m_crit.players);
|
||||
|
||||
// in game mapping for this local pad
|
||||
unsigned int in_game_num = m_local_player->pad_map[pad_nb];
|
||||
|
||||
// does this local pad map in game?
|
||||
if (in_game_num < 4)
|
||||
{
|
||||
NetPad np(pad_status);
|
||||
|
||||
// adjust the buffer either up or down
|
||||
// inserting multiple padstates or dropping states
|
||||
while (m_pad_buffer[in_game_num].Size() <= m_target_buffer_size)
|
||||
{
|
||||
// add to buffer
|
||||
m_pad_buffer[in_game_num].Push(np);
|
||||
|
||||
// send
|
||||
SendPadState(pad_nb, np);
|
||||
}
|
||||
}
|
||||
|
||||
} // unlock players
|
||||
|
||||
//Common::Timer bufftimer;
|
||||
//bufftimer.Start();
|
||||
|
||||
// get padstate from buffer and send to game
|
||||
while (!m_pad_buffer[pad_nb].Pop(*netvalues))
|
||||
{
|
||||
// wait for receiving thread to push some data
|
||||
Common::SleepCurrentThread(1);
|
||||
|
||||
if (false == m_is_running)
|
||||
return false;
|
||||
|
||||
// TODO: check the time of bufftimer here,
|
||||
// if it gets pretty high, ask the user if they want to disconnect
|
||||
|
||||
}
|
||||
|
||||
//u64 hangtime = bufftimer.GetTimeElapsed();
|
||||
//if (hangtime > 10)
|
||||
//{
|
||||
// std::ostringstream ss;
|
||||
// ss << "Pad " << (int)pad_nb << ": Had to wait " << hangtime << "ms for pad data. (increase pad Buffer maybe)";
|
||||
// Core::DisplayMessage(ss.str(), 1000);
|
||||
//}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// called from ---CPU--- thread
|
||||
void NetPlayClient::WiimoteInput(int _number, u16 _channelID, const void* _pData, u32 _Size)
|
||||
{
|
||||
//// in game mapping for this local wiimote
|
||||
unsigned int in_game_num = m_local_player->pad_map[_number]; // just using gc pad_map for now
|
||||
|
||||
// does this local pad map in game?
|
||||
if (in_game_num < 4)
|
||||
{
|
||||
m_wiimote_input[_number].resize(m_wiimote_input[_number].size() + 1);
|
||||
m_wiimote_input[_number].back().assign((char*)_pData, (char*)_pData + _Size);
|
||||
m_wiimote_input[_number].back().channel = _channelID;
|
||||
}
|
||||
}
|
||||
|
||||
// called from ---CPU--- thread
|
||||
void NetPlayClient::WiimoteUpdate(int _number)
|
||||
{
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lkp(m_crit.players);
|
||||
|
||||
// in game mapping for this local wiimote
|
||||
unsigned int in_game_num = m_local_player->pad_map[_number]; // just using gc pad_map for now
|
||||
|
||||
// does this local pad map in game?
|
||||
if (in_game_num < 4)
|
||||
{
|
||||
m_wiimote_buffer[in_game_num].Push(m_wiimote_input[_number]);
|
||||
|
||||
// TODO: send it
|
||||
|
||||
m_wiimote_input[_number].clear();
|
||||
}
|
||||
|
||||
} // unlock players
|
||||
|
||||
if (0 == m_wiimote_buffer[_number].Size())
|
||||
{
|
||||
//PanicAlert("PANIC");
|
||||
return;
|
||||
}
|
||||
|
||||
NetWiimote nw;
|
||||
m_wiimote_buffer[_number].Pop(nw);
|
||||
|
||||
NetWiimote::const_iterator
|
||||
i = nw.begin(), e = nw.end();
|
||||
for ( ; i!=e; ++i)
|
||||
Core::Callback_WiimoteInterruptChannel(_number, i->channel, &(*i)[0], (u32)i->size() + RPT_SIZE_HACK);
|
||||
}
|
||||
|
||||
// called from ---GUI--- thread and ---NETPLAY--- thread (client side)
|
||||
bool NetPlayClient::StopGame()
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lkg(m_crit.game);
|
||||
|
||||
if (false == m_is_running)
|
||||
{
|
||||
PanicAlertT("Game isn't running!");
|
||||
return false;
|
||||
}
|
||||
|
||||
m_dialog->AppendChat(" -- STOPPING GAME -- ");
|
||||
|
||||
m_is_running = false;
|
||||
NetPlay_Disable();
|
||||
|
||||
// stop game
|
||||
m_dialog->StopGame();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// called from ---CPU--- thread
|
||||
u8 NetPlayClient::GetPadNum(u8 numPAD)
|
||||
{
|
||||
// TODO: i don't like that this loop is running everytime there is rumble
|
||||
unsigned int i = 0;
|
||||
for (; i<4; ++i)
|
||||
if (numPAD == m_local_player->pad_map[i])
|
||||
break;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
// stuff hacked into dolphin
|
||||
|
||||
// called from ---CPU--- thread
|
||||
// Actual Core function which is called on every frame
|
||||
bool CSIDevice_GCController::NetPlay_GetInput(u8 numPAD, SPADStatus PadStatus, u32 *PADStatus)
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(crit_netplay_client);
|
||||
|
||||
if (netplay_client)
|
||||
return netplay_client->GetNetPads(numPAD, &PadStatus, (NetPad*)PADStatus);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CSIDevice_GCSteeringWheel::NetPlay_GetInput(u8 numPAD, SPADStatus PadStatus, u32 *PADStatus)
|
||||
{
|
||||
return CSIDevice_GCController::NetPlay_GetInput(numPAD, PadStatus, PADStatus);
|
||||
}
|
||||
|
||||
bool CSIDevice_DanceMat::NetPlay_GetInput(u8 numPAD, SPADStatus PadStatus, u32 *PADStatus)
|
||||
{
|
||||
return CSIDevice_GCController::NetPlay_GetInput(numPAD, PadStatus, PADStatus);
|
||||
}
|
||||
|
||||
// called from ---CPU--- thread
|
||||
// so all players' games get the same time
|
||||
u32 CEXIIPL::NetPlay_GetGCTime()
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(crit_netplay_client);
|
||||
|
||||
if (netplay_client)
|
||||
return 1272737767; // watev
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
// called from ---CPU--- thread
|
||||
// return the local pad num that should rumble given a ingame pad num
|
||||
u8 CSIDevice_GCController::NetPlay_GetPadNum(u8 numPAD)
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(crit_netplay_client);
|
||||
|
||||
if (netplay_client)
|
||||
return netplay_client->GetPadNum(numPAD);
|
||||
else
|
||||
return numPAD;
|
||||
}
|
||||
|
||||
u8 CSIDevice_GCSteeringWheel::NetPlay_GetPadNum(u8 numPAD)
|
||||
{
|
||||
return CSIDevice_GCController::NetPlay_GetPadNum(numPAD);
|
||||
}
|
||||
|
||||
u8 CSIDevice_DanceMat::NetPlay_GetPadNum(u8 numPAD)
|
||||
{
|
||||
return CSIDevice_GCController::NetPlay_GetPadNum(numPAD);
|
||||
}
|
||||
|
||||
// called from ---CPU--- thread
|
||||
// wiimote update / used for frame counting
|
||||
//void CWII_IPC_HLE_Device_usb_oh1_57e_305::NetPlay_WiimoteUpdate(int _number)
|
||||
void CWII_IPC_HLE_Device_usb_oh1_57e_305::NetPlay_WiimoteUpdate(int)
|
||||
{
|
||||
//CritLocker crit(crit_netplay_client);
|
||||
|
||||
//if (netplay_client)
|
||||
// netplay_client->WiimoteUpdate(_number);
|
||||
}
|
||||
|
||||
// called from ---CPU--- thread
|
||||
//
|
||||
int CWII_IPC_HLE_WiiMote::NetPlay_GetWiimoteNum(int _number)
|
||||
{
|
||||
//CritLocker crit(crit_netplay_client);
|
||||
|
||||
//if (netplay_client)
|
||||
// return netplay_client->GetPadNum(_number); // just using gcpad mapping for now
|
||||
//else
|
||||
return _number;
|
||||
}
|
||||
|
||||
// called from ---CPU--- thread
|
||||
// intercept wiimote input callback
|
||||
//bool CWII_IPC_HLE_WiiMote::NetPlay_WiimoteInput(int _number, u16 _channelID, const void* _pData, u32& _Size)
|
||||
bool CWII_IPC_HLE_WiiMote::NetPlay_WiimoteInput(int, u16, const void*, u32&)
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(crit_netplay_client);
|
||||
|
||||
if (netplay_client)
|
||||
//{
|
||||
// if (_Size >= RPT_SIZE_HACK)
|
||||
// {
|
||||
// _Size -= RPT_SIZE_HACK;
|
||||
// return false;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// netplay_client->WiimoteInput(_number, _channelID, _pData, _Size);
|
||||
// // don't use this packet
|
||||
return true;
|
||||
// }
|
||||
//}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
bool NetPlay::IsNetPlayRunning()
|
||||
{
|
||||
return netplay_client != NULL;
|
||||
}
|
||||
|
||||
void NetPlay_Enable(NetPlayClient* const np)
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(crit_netplay_client);
|
||||
netplay_client = np;
|
||||
}
|
||||
|
||||
void NetPlay_Disable()
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(crit_netplay_client);
|
||||
netplay_client = NULL;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include <IniFile.h>
|
||||
|
||||
#include "WxUtils.h"
|
||||
#include "NetPlay.h"
|
||||
#include "NetPlayClient.h"
|
||||
#include "NetPlayServer.h"
|
||||
#include "NetWindow.h"
|
||||
#include "Frame.h"
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#include "FifoQueue.h"
|
||||
|
||||
#include "NetPlay.h"
|
||||
#include "NetPlayClient.h"
|
||||
|
||||
enum
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue