HW: Poll system input from system timers

Rather than playing terrible hacks to determine the start of input
frames, just update system input periodically. Specifically, every
60th of a second.
This commit is contained in:
Jasper St. Pierre 2014-11-15 01:47:29 -08:00
parent f3b739341e
commit 854f6b8688
4 changed files with 15 additions and 18 deletions

View File

@ -64,15 +64,6 @@ void GetStatus(u8 _numPAD, GCPadStatus* _pPADStatus)
return;
}
// if we are on the next input cycle, update output and input
// if we can get a lock
static int _last_numPAD = 4;
if (_numPAD <= _last_numPAD)
{
g_controller_interface.UpdateInput();
}
_last_numPAD = _numPAD;
// get input
((GCPad*)s_config.controllers[_numPAD])->GetInput(_pPADStatus);
}

View File

@ -61,6 +61,8 @@ IPC_HLE_PERIOD: For the Wiimote this is the call schedule:
#include "Core/IPC_HLE/WII_IPC_HLE.h"
#include "Core/PowerPC/PowerPC.h"
#include "InputCommon/ControllerInterface/ControllerInterface.h"
#include "VideoCommon/CommandProcessor.h"
#include "VideoCommon/VideoBackendBase.h"
@ -79,6 +81,7 @@ static int et_DSP;
static int et_IPC_HLE;
static int et_PatchEngine; // PatchEngine updates every 1/60th of a second by default
static int et_Throttle;
static int et_UpdateInput;
// These are badly educated guesses
// Feel free to experiment. Set these in Init below.
@ -132,6 +135,14 @@ static void VICallback(u64 userdata, int cyclesLate)
CoreTiming::ScheduleEvent(VideoInterface::GetTicksPerLine() - cyclesLate, et_VI);
}
static void UpdateInputCallback(u64 userdata, int cyclesLate)
{
g_controller_interface.UpdateInput();
// Poll system input every 1/60th of a second.
CoreTiming::ScheduleEvent(SystemTimers::GetTicksPerSecond() / 60 - cyclesLate, et_UpdateInput);
}
static void SICallback(u64 userdata, int cyclesLate)
{
SerialInterface::UpdateDevices();
@ -258,6 +269,7 @@ void Init()
et_IPC_HLE = CoreTiming::RegisterEvent("IPC_HLE_UpdateCallback", IPC_HLE_UpdateCallback);
et_PatchEngine = CoreTiming::RegisterEvent("PatchEngine", PatchEngineCallback);
et_Throttle = CoreTiming::RegisterEvent("Throttle", ThrottleCallback);
et_UpdateInput = CoreTiming::RegisterEvent("UpdateInput", UpdateInputCallback);
CoreTiming::ScheduleEvent(VideoInterface::GetTicksPerLine(), et_VI);
CoreTiming::ScheduleEvent(0, et_DSP);
@ -271,6 +283,8 @@ void Init()
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bWii)
CoreTiming::ScheduleEvent(IPC_HLE_PERIOD, et_IPC_HLE);
CoreTiming::ScheduleEvent(0, et_UpdateInput);
}
void Shutdown()

View File

@ -17,7 +17,6 @@ namespace Wiimote
{
static InputConfig s_config(WIIMOTE_INI_NAME, _trans("Wiimote"), "Wiimote");
static int s_last_number = 4;
InputConfig* GetConfig()
{
@ -115,12 +114,6 @@ void Update(int _number)
// TODO: change this to a try_to_lock, and make it give empty input on failure
std::lock_guard<std::recursive_mutex> lk(s_config.controls_lock);
if (_number <= s_last_number)
{
g_controller_interface.UpdateInput();
}
s_last_number = _number;
if (WIIMOTE_SRC_EMU & g_wiimote_sources[_number])
((WiimoteEmu::Wiimote*)s_config.controllers[_number])->Update();
else
@ -153,7 +146,6 @@ void DoState(u8 **ptr, PointerWrap::Mode mode)
// TODO:
PointerWrap p(ptr, mode);
p.Do(s_last_number);
for (unsigned int i=0; i<MAX_BBMOTES; ++i)
((WiimoteEmu::Wiimote*)s_config.controllers[i])->DoState(p);
}

View File

@ -64,7 +64,7 @@ static Common::Event g_compressAndDumpStateSyncEvent;
static std::thread g_save_thread;
// Don't forget to increase this after doing changes on the savestate system
static const u32 STATE_VERSION = 36;
static const u32 STATE_VERSION = 37;
enum
{