to help movie sync, added some more wiimote data to savestates and disabled auto-reconnect. although I think this is basically just removing hacks and should be more correct, I don't know what side effects this could cause for normal players, so for now these changes ONLY take effect when an input movie is playing back or being recorded.

This commit is contained in:
nitsuja 2011-12-28 13:50:53 -06:00 committed by skidau
parent d19c389246
commit 108f69eaa9
3 changed files with 94 additions and 21 deletions

View File

@ -24,6 +24,7 @@
#include "WII_IPC_HLE.h"
#include "WII_IPC_HLE_Device_usb.h"
#include "../ConfigManager.h"
#include "../Movie.h"
#include "CoreTiming.h"
// The device class
@ -104,7 +105,7 @@ CWII_IPC_HLE_Device_usb_oh1_57e_305::~CWII_IPC_HLE_Device_usb_oh1_57e_305()
void CWII_IPC_HLE_Device_usb_oh1_57e_305::DoState(PointerWrap &p)
{
/*
//things that do not get saved:
//things that do not get saved: (why not?)
std::vector<CWII_IPC_HLE_WiiMote> m_WiiMotes;
@ -120,25 +121,70 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::DoState(PointerWrap &p)
p.Do(m_ScanEnable);
m_acl_pool.DoState(p);
if (p.GetMode() == PointerWrap::MODE_READ) {
m_EventQueue.clear();
}
if (p.GetMode() == PointerWrap::MODE_READ &&
SConfig::GetInstance().m_WiimoteReconnectOnLoad)
bool storeFullData = (Movie::IsRecordingInput() || Movie::IsPlayingInput());
p.Do(storeFullData);
p.DoMarker("storeFullData in CWII_IPC_HLE_Device_usb_oh1_57e_305");
if (!storeFullData)
{
// Reset the connection of all connected wiimotes
for (unsigned int i = 0; i < 4; i++)
{
if (!m_WiiMotes[i].IsInactive())
{
m_WiiMotes[i].Activate(false);
m_WiiMotes[i].Activate(true);
}
else
{
m_WiiMotes[i].Activate(false);
}
}
if (p.GetMode() == PointerWrap::MODE_READ)
{
m_EventQueue.clear();
if (SConfig::GetInstance().m_WiimoteReconnectOnLoad)
{
// Reset the connection of all connected wiimotes
for (unsigned int i = 0; i < 4; i++)
{
if (!m_WiiMotes[i].IsInactive())
{
m_WiiMotes[i].Activate(false);
m_WiiMotes[i].Activate(true);
}
else
{
m_WiiMotes[i].Activate(false);
}
}
}
}
}
else
{
// I'm not sure why these things aren't normally saved, but I think they can affect the emulation state,
// so if sync matters (e.g. if a movie is active), we really should save them.
// also, it's definitely not safe to do the above auto-reconnect hack either.
// (unless we can do it without changing anything that affects emulation state, which is not currently the case)
p.Do(m_EventQueue);
p.DoMarker("m_EventQueue");
// m_WiiMotes is kind of annoying to save. maybe this could be done in a more general way.
u32 vec_size = (u32)m_WiiMotes.size();
p.Do(vec_size);
for (u32 i = 0; i < vec_size; ++i)
{
if (i < m_WiiMotes.size())
{
CWII_IPC_HLE_WiiMote& wiimote = m_WiiMotes[i];
wiimote.DoState(p);
}
else
{
bdaddr_t tmpBD = BDADDR_ANY;
CWII_IPC_HLE_WiiMote wiimote = CWII_IPC_HLE_WiiMote(this, i, tmpBD, false);
wiimote.DoState(p);
if (p.GetMode() == PointerWrap::MODE_READ)
{
m_WiiMotes.push_back(wiimote);
_dbg_assert_(WII_IPC_WIIMOTE, m_WiiMotes.size() == i);
}
}
}
if (p.GetMode() == PointerWrap::MODE_READ)
while ((u32)m_WiiMotes.size() > vec_size)
m_WiiMotes.pop_back();
p.DoMarker("m_WiiMotes");
}
}
@ -1881,4 +1927,4 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::LOG_LinkKey(const u8* _pLinkKey)
, _pLinkKey[0], _pLinkKey[1], _pLinkKey[2], _pLinkKey[3], _pLinkKey[4], _pLinkKey[5], _pLinkKey[6], _pLinkKey[7]
, _pLinkKey[8], _pLinkKey[9], _pLinkKey[10], _pLinkKey[11], _pLinkKey[12], _pLinkKey[13], _pLinkKey[14], _pLinkKey[15]);
}
}

View File

@ -41,6 +41,12 @@ struct SQueuedEvent
}
memset(m_buffer, 0, 1024);
}
SQueuedEvent()
: m_size(0)
, m_connectionHandle(0)
{
}
};

View File

@ -53,7 +53,7 @@ CWII_IPC_HLE_WiiMote::CWII_IPC_HLE_WiiMote(CWII_IPC_HLE_Device_usb_oh1_57e_305*
m_ConnectionState = (ready) ? CONN_READY : CONN_INACTIVE;
m_ConnectionHandle = 0x100 + _Number;
memset(m_LinkKey, 0xA0 + _Number, 16);
memset(m_LinkKey, 0xA0 + _Number, HCI_KEY_SIZE);
bdaddr_t _nullBD = BDADDR_ANY;
if (memcmp(&m_BD, &_nullBD, sizeof(bdaddr_t))==0)
@ -84,7 +84,28 @@ CWII_IPC_HLE_WiiMote::CWII_IPC_HLE_WiiMote(CWII_IPC_HLE_Device_usb_oh1_57e_305*
void CWII_IPC_HLE_WiiMote::DoState(PointerWrap &p)
{
// this function is usually not called... see CWII_IPC_HLE_Device_usb_oh1_57e_305::DoState
p.Do(m_ConnectionState);
p.Do(m_HIDControlChannel_Connected);
p.Do(m_HIDControlChannel_ConnectedWait);
p.Do(m_HIDControlChannel_Config);
p.Do(m_HIDControlChannel_ConfigWait);
p.Do(m_HIDInterruptChannel_Connected);
p.Do(m_HIDInterruptChannel_ConnectedWait);
p.Do(m_HIDInterruptChannel_Config);
p.Do(m_HIDInterruptChannel_ConfigWait);
p.Do(m_BD);
p.Do(m_ConnectionHandle);
p.Do(uclass);
p.Do(features);
p.Do(lmp_version);
p.Do(m_LinkKey);
p.Do(m_Name);
p.Do(m_Channel);
}
//