mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
Get rid of netpad and just send the GCPadStatus in netplay.
This commit is contained in:
@ -21,24 +21,6 @@ static std::mutex crit_netplay_client;
|
||||
static NetPlayClient * netplay_client = nullptr;
|
||||
NetSettings g_NetPlaySettings;
|
||||
|
||||
NetPad::NetPad()
|
||||
{
|
||||
nHi = 0x00808080;
|
||||
nLo = 0x80800000;
|
||||
}
|
||||
|
||||
NetPad::NetPad(const GCPadStatus* 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()
|
||||
{
|
||||
@ -207,12 +189,12 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
|
||||
case NP_MSG_PAD_DATA :
|
||||
{
|
||||
PadMapping map = 0;
|
||||
NetPad np;
|
||||
packet >> map >> np.nHi >> np.nLo;
|
||||
GCPadStatus pad;
|
||||
packet >> map >> pad.button >> pad.analogA >> pad.analogB >> pad.stickX >> pad.stickY >> pad.substickX >> pad.substickY >> pad.triggerLeft >> pad.triggerRight;
|
||||
|
||||
// trusting server for good map value (>=0 && <4)
|
||||
// add to pad buffer
|
||||
m_pad_buffer[map].Push(np);
|
||||
m_pad_buffer[map].Push(pad);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -425,13 +407,13 @@ void NetPlayClient::SendChatMessage(const std::string& msg)
|
||||
}
|
||||
|
||||
// called from ---CPU--- thread
|
||||
void NetPlayClient::SendPadState(const PadMapping in_game_pad, const NetPad& np)
|
||||
void NetPlayClient::SendPadState(const PadMapping in_game_pad, const GCPadStatus& pad)
|
||||
{
|
||||
// send to server
|
||||
sf::Packet spac;
|
||||
spac << (MessageId)NP_MSG_PAD_DATA;
|
||||
spac << in_game_pad;
|
||||
spac << np.nHi << np.nLo;
|
||||
spac << pad.button << pad.analogA << pad.analogB << pad.stickX << pad.stickY << pad.substickX << pad.substickY << pad.triggerLeft << pad.triggerRight;
|
||||
|
||||
std::lock_guard<std::recursive_mutex> lks(m_crit.send);
|
||||
m_socket.Send(spac);
|
||||
@ -556,7 +538,7 @@ void NetPlayClient::ClearBuffers()
|
||||
}
|
||||
|
||||
// called from ---CPU--- thread
|
||||
bool NetPlayClient::GetNetPads(const u8 pad_nb, const GCPadStatus* const pad_status, NetPad* const netvalues)
|
||||
bool NetPlayClient::GetNetPads(const u8 pad_nb, GCPadStatus* pad_status)
|
||||
{
|
||||
// The interface for this is extremely silly.
|
||||
//
|
||||
@ -589,17 +571,15 @@ bool NetPlayClient::GetNetPads(const u8 pad_nb, const GCPadStatus* const pad_sta
|
||||
// information given.
|
||||
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);
|
||||
m_pad_buffer[in_game_num].Push(*pad_status);
|
||||
|
||||
// send
|
||||
SendPadState(in_game_num, np);
|
||||
SendPadState(in_game_num, *pad_status);
|
||||
}
|
||||
}
|
||||
|
||||
@ -607,7 +587,7 @@ bool NetPlayClient::GetNetPads(const u8 pad_nb, const GCPadStatus* const pad_sta
|
||||
// retrieved from NetPlay. This could be the value we pushed
|
||||
// above if we're configured as P1 and the code is trying
|
||||
// to retrieve data for slot 1.
|
||||
while (!m_pad_buffer[pad_nb].Pop(*netvalues))
|
||||
while (!m_pad_buffer[pad_nb].Pop(*pad_status))
|
||||
{
|
||||
if (!m_is_running)
|
||||
return false;
|
||||
@ -616,23 +596,14 @@ bool NetPlayClient::GetNetPads(const u8 pad_nb, const GCPadStatus* const pad_sta
|
||||
Common::SleepCurrentThread(1);
|
||||
}
|
||||
|
||||
GCPadStatus tmp;
|
||||
tmp.stickY = ((u8*)&netvalues->nHi)[0];
|
||||
tmp.stickX = ((u8*)&netvalues->nHi)[1];
|
||||
tmp.button = ((u16*)&netvalues->nHi)[1];
|
||||
|
||||
tmp.substickX = ((u8*)&netvalues->nLo)[3];
|
||||
tmp.substickY = ((u8*)&netvalues->nLo)[2];
|
||||
tmp.triggerLeft = ((u8*)&netvalues->nLo)[1];
|
||||
tmp.triggerRight = ((u8*)&netvalues->nLo)[0];
|
||||
if (Movie::IsRecordingInput())
|
||||
{
|
||||
Movie::RecordInput(&tmp, pad_nb);
|
||||
Movie::RecordInput(pad_status, pad_nb);
|
||||
Movie::InputUpdate();
|
||||
}
|
||||
else
|
||||
{
|
||||
Movie::CheckPadStatus(&tmp, pad_nb);
|
||||
Movie::CheckPadStatus(pad_status, pad_nb);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -844,12 +815,12 @@ u8 NetPlayClient::LocalWiimoteToInGameWiimote(u8 local_pad)
|
||||
|
||||
// called from ---CPU--- thread
|
||||
// Actual Core function which is called on every frame
|
||||
bool CSIDevice_GCController::NetPlay_GetInput(u8 numPAD, GCPadStatus PadStatus, u32 *PADStatus)
|
||||
bool CSIDevice_GCController::NetPlay_GetInput(u8 numPAD, GCPadStatus* PadStatus)
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(crit_netplay_client);
|
||||
|
||||
if (netplay_client)
|
||||
return netplay_client->GetNetPads(numPAD, &PadStatus, (NetPad*)PADStatus);
|
||||
return netplay_client->GetNetPads(numPAD, PadStatus);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
@ -864,14 +835,14 @@ bool WiimoteEmu::Wiimote::NetPlay_GetWiimoteData(int wiimote, u8* data, u8 size)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CSIDevice_GCSteeringWheel::NetPlay_GetInput(u8 numPAD, GCPadStatus PadStatus, u32 *PADStatus)
|
||||
bool CSIDevice_GCSteeringWheel::NetPlay_GetInput(u8 numPAD, GCPadStatus* PadStatus)
|
||||
{
|
||||
return CSIDevice_GCController::NetPlay_GetInput(numPAD, PadStatus, PADStatus);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CSIDevice_DanceMat::NetPlay_GetInput(u8 numPAD, GCPadStatus PadStatus, u32 *PADStatus)
|
||||
bool CSIDevice_DanceMat::NetPlay_GetInput(u8 numPAD, GCPadStatus* PadStatus)
|
||||
{
|
||||
return CSIDevice_GCController::NetPlay_GetInput(numPAD, PadStatus, PADStatus);
|
||||
return false;
|
||||
}
|
||||
|
||||
// called from ---CPU--- thread
|
||||
|
Reference in New Issue
Block a user