diff --git a/Source/Core/Core/Src/HW/Wiimote.cpp b/Source/Core/Core/Src/HW/Wiimote.cpp index 2b79974e49..a81dd5298d 100644 --- a/Source/Core/Core/Src/HW/Wiimote.cpp +++ b/Source/Core/Core/Src/HW/Wiimote.cpp @@ -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); diff --git a/Source/Core/Core/Src/OnFrame.cpp b/Source/Core/Core/Src/OnFrame.cpp index 622e326f09..ee33536bc7 100644 --- a/Source/Core/Core/Src/OnFrame.cpp +++ b/Source/Core/Core/Src/OnFrame.cpp @@ -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); diff --git a/Source/Core/Core/Src/OnFrame.h b/Source/Core/Core/Src/OnFrame.h index 82a6969ea5..feefe821c4 100644 --- a/Source/Core/Core/Src/OnFrame.h +++ b/Source/Core/Core/Src/OnFrame.h @@ -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); diff --git a/Source/Core/DolphinWX/Src/FrameTools.cpp b/Source/Core/DolphinWX/Src/FrameTools.cpp index b3cc5271af..4e2aa1b754 100644 --- a/Source/Core/DolphinWX/Src/FrameTools.cpp +++ b/Source/Core/DolphinWX/Src/FrameTools.cpp @@ -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(""));