diff --git a/Source/Core/Core/Src/HW/SystemTimers.cpp b/Source/Core/Core/Src/HW/SystemTimers.cpp index dbb58cdc7e..edfcbe4d4b 100644 --- a/Source/Core/Core/Src/HW/SystemTimers.cpp +++ b/Source/Core/Core/Src/HW/SystemTimers.cpp @@ -177,8 +177,7 @@ void IPC_HLE_UpdateCallback(u64 userdata, int cyclesLate) { if (Core::GetStartupParameter().bWii) WII_IPC_HLE_Interface::Update(); - - CoreTiming::ScheduleEvent(VideoInterface::GetTicksPerLine()-cyclesLate, et_IPC_HLE); + CoreTiming::ScheduleEvent(IPC_HLE_PERIOD - cyclesLate, et_IPC_HLE); } void VICallback(u64 userdata, int cyclesLate) @@ -253,9 +252,12 @@ void Init() DSP_PERIOD = (int)(GetTicksPerSecond() * 0.003f); // AyuanX: TO BE TWEAKED - // If this update frequency is too high, WiiMote could easily jam the IPC Bus - // but if it is too low, sometimes IPC gets overflown by CPU :~~~( - IPC_HLE_PERIOD = (int)(GetTicksPerSecond() * 0.003f); + // Now the 15000 is a pure assumption + // We need to figure out the real frequency though + // PS: When this period is tweaked, the FreqDividerMote + // in WII_IPC_HLE_Device_usb.cpp should also be tweaked accordingly + // to guarantee WiiMote updates at a fixed 100Hz + IPC_HLE_PERIOD = GetTicksPerSecond() / 15000; } else { diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp index 475fb330db..bf4b2cbd8c 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp @@ -477,7 +477,7 @@ u32 CWII_IPC_HLE_Device_usb_oh1_57e_305::Update() if (m_HCIBuffer.m_address && !WII_IPCInterface::GetAddress() && m_WiiMotes[0].IsConnected()) { m_FreqDividerSync++; - if ((m_PacketCount > 0) || (m_FreqDividerSync > 60)) // Feel free to tweak it + if ((m_PacketCount > 0) || (m_FreqDividerSync > 100)) // Feel free to tweak it { m_FreqDividerSync = 0; SendEventNumberOfCompletedPackets(m_WiiMotes[0].GetConnectionHandle(), m_PacketCount); @@ -487,16 +487,13 @@ u32 CWII_IPC_HLE_Device_usb_oh1_57e_305::Update() } */ - // AyuanX: If we let this Wiimote_Update function running freely - // it will exaust all the HLE time slots and block further CPU commands - // so we have to make sure CPU and other things get the privilege to bypass this - // Besides, decreasing its reporting frequency also brings us great FPS boost - // Now I am making it running at 1/100 frequency of IPC which is already fast enough for human input - // + // The Real Wiimote sends report at a fixed frequency of 100Hz + // So let's make it also 100Hz here + // Calculation: 15000Hz (IPC_HLE) / 100Hz (WiiMote) = 150 if (m_ACLBuffer.m_address && !m_LastCmd && m_WiiMotes[0].IsLinked()) { m_FreqDividerMote++; - if(m_FreqDividerMote > 99) // Feel free to tweak it + if(m_FreqDividerMote >= 150) { m_FreqDividerMote = 0; CPluginManager::GetInstance().GetWiimote(0)->Wiimote_Update(); diff --git a/Source/Plugins/Plugin_Wiimote/Src/main.cpp b/Source/Plugins/Plugin_Wiimote/Src/main.cpp index 326ed4ee49..80a5ca6c21 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/main.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/main.cpp @@ -313,10 +313,10 @@ void Wiimote_InterruptChannel(u16 _channelID, const void* _pData, u32 _Size) } // Decice where to send the message - //if (!g_RealWiiMotePresent) + if (!g_Config.bUseRealWiimote || !g_RealWiiMotePresent) WiiMoteEmu::InterruptChannel(_channelID, _pData, _Size); #if HAVE_WIIUSE - if (g_RealWiiMotePresent) + else if (g_RealWiiMotePresent) WiiMoteReal::InterruptChannel(_channelID, _pData, _Size); #endif } @@ -348,10 +348,10 @@ void Wiimote_ControlChannel(u16 _channelID, const void* _pData, u32 _Size) DEBUG_LOG(WIIMOTE, " Data: %s", Temp.c_str()); } - //if (!g_RealWiiMotePresent) + if (!g_Config.bUseRealWiimote || !g_RealWiiMotePresent) WiiMoteEmu::ControlChannel(_channelID, _pData, _Size); #if HAVE_WIIUSE - if (g_RealWiiMotePresent) + else if (g_RealWiiMotePresent) WiiMoteReal::ControlChannel(_channelID, _pData, _Size); #endif }