Recordings store information about which Wiimotes are actually in use. (Slight modification to a patch by Toad King.)

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7132 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
smelenchuk 2011-02-11 19:09:46 +00:00
parent b0fa0a83f8
commit caad098b69
4 changed files with 34 additions and 27 deletions

View File

@ -4,6 +4,7 @@
#include "Wiimote.h"
#include "WiimoteReal/WiimoteReal.h"
#include "WiimoteEmu/WiimoteEmu.h"
#include "OnFrame.h"
#include "ControllerInterface/ControllerInterface.h"
@ -46,6 +47,9 @@ void Initialize(void* const hwnd)
g_plugin.LoadConfig();
WiimoteReal::Initialize();
if (Frame::IsPlayingInput()) // reload Wiimotes with our settings
Frame::ChangeWiiPads();
}
// __________________________________________________________________________________________________
@ -100,7 +104,7 @@ void Update(int _number)
}
_last_number = _number;
if (WIIMOTE_SRC_EMU & g_wiimote_sources[_number])
if ((Frame::IsPlayingInput() && Frame::IsUsingWiimote(_number)) || (!Frame::IsPlayingInput() && (WIIMOTE_SRC_EMU & g_wiimote_sources[_number])))
((WiimoteEmu::Wiimote*)g_plugin.controllers[_number])->Update();
else
WiimoteReal::Update(_number);

View File

@ -22,6 +22,8 @@
#include "FileUtil.h"
#include "PowerPC/PowerPC.h"
#include "HW/SI.h"
#include "HW/Wiimote.h"
#include "IPC_HLE/WII_IPC_HLE_Device_usb.h"
#include "VideoBackendBase.h"
Common::CriticalSection cs_frameSkip;
@ -130,28 +132,27 @@ bool IsPlayingInput()
bool IsUsingPad(int controller)
{
switch (controller)
{
case 0:
return (g_numPads & 0x01) != 0;
case 1:
return (g_numPads & 0x02) != 0;
case 2:
return (g_numPads & 0x04) != 0;
case 3:
return (g_numPads & 0x08) != 0;
default:
return false;
}
return (g_numPads & (1 << controller));
}
bool IsUsingWiimote(int wiimote)
{
return (g_numPads & (1 << (wiimote + 4)));
}
void ChangePads()
{
if (Core::GetState() != Core::CORE_UNINITIALIZED) {
SerialInterface::ChangeDevice(IsUsingPad(0) ? SI_GC_CONTROLLER : SI_NONE, 0);
SerialInterface::ChangeDevice(IsUsingPad(1) ? SI_GC_CONTROLLER : SI_NONE, 1);
SerialInterface::ChangeDevice(IsUsingPad(2) ? SI_GC_CONTROLLER : SI_NONE, 2);
SerialInterface::ChangeDevice(IsUsingPad(3) ? SI_GC_CONTROLLER : SI_NONE, 3);
if (Core::GetState() != Core::CORE_UNINITIALIZED)
for (int i = 0; i < 4; i++)
SerialInterface::ChangeDevice(IsUsingPad(i) ? SI_GC_CONTROLLER : SI_NONE, i);
}
void ChangeWiiPads()
{
for (int i = 0; i < 4; i++)
{
g_wiimote_sources[i] = IsUsingWiimote(i) ? WIIMOTE_SRC_EMU : WIIMOTE_SRC_NONE;
GetUsbPointer()->AccessWiiMote(i | 0x100)->Activate(IsUsingWiimote(i));
}
}
@ -301,6 +302,7 @@ void LoadInput(const char *filename)
g_numPads = header.numControllers;
ChangePads();
ChangeWiiPads();
if (g_recordfd)
fclose(g_recordfd);

View File

@ -99,7 +99,9 @@ bool IsRecordingInput();
bool IsPlayingInput();
bool IsUsingPad(int controller);
bool IsUsingWiimote(int wiimote);
void ChangePads();
void ChangeWiiPads();
void SetFrameStepping(bool bEnabled);
void SetFrameStopping(bool bEnabled);

View File

@ -647,14 +647,13 @@ void CFrame::OnRecord(wxCommandEvent& WXUNUSED (event))
{
int controllers = 0;
if (SConfig::GetInstance().m_SIDevice[0] == SI_GC_CONTROLLER)
controllers |= 0x01;
if (SConfig::GetInstance().m_SIDevice[1] == SI_GC_CONTROLLER)
controllers |= 0x02;
if (SConfig::GetInstance().m_SIDevice[2] == SI_GC_CONTROLLER)
controllers |= 0x04;
if (SConfig::GetInstance().m_SIDevice[3] == SI_GC_CONTROLLER)
controllers |= 0x08;
for (int i = 0; i < 4; i++) {
if (SConfig::GetInstance().m_SIDevice[i] == SI_GC_CONTROLLER)
controllers |= (1 << i);
if (g_wiimote_sources[i] != WIIMOTE_SRC_NONE)
controllers |= (1 << (i + 4));
}
if(Frame::BeginRecordingInput(controllers))
BootGame(std::string(""));