Merge pull request #14517 from jordan-woyak/event-functor
CoreTiming: Change TimedCallback to a Common::MoveOnlyFunction.
This commit is contained in:
@@ -70,7 +70,7 @@ EventType* CoreTimingManager::RegisterEvent(const std::string& name, TimedCallba
|
|||||||
"during Init to avoid breaking save states.",
|
"during Init to avoid breaking save states.",
|
||||||
name);
|
name);
|
||||||
|
|
||||||
auto info = m_event_types.emplace(name, EventType{callback, nullptr});
|
auto info = m_event_types.emplace(name, EventType{std::move(callback), nullptr});
|
||||||
EventType* event_type = &info.first->second;
|
EventType* event_type = &info.first->second;
|
||||||
event_type->name = &info.first->first;
|
event_type->name = &info.first->first;
|
||||||
return event_type;
|
return event_type;
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
|
#include "Common/Functional.h"
|
||||||
#include "Common/HookableEvent.h"
|
#include "Common/HookableEvent.h"
|
||||||
#include "Common/SPSCQueue.h"
|
#include "Common/SPSCQueue.h"
|
||||||
#include "Common/Timer.h"
|
#include "Common/Timer.h"
|
||||||
@@ -47,7 +48,8 @@ struct Globals
|
|||||||
float last_OC_factor_inverted = 0.0f;
|
float last_OC_factor_inverted = 0.0f;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef void (*TimedCallback)(Core::System& system, u64 userdata, s64 cyclesLate);
|
using TimedCallback =
|
||||||
|
Common::MoveOnlyFunction<void(Core::System& system, u64 userdata, s64 cyclesLate)>;
|
||||||
|
|
||||||
struct EventType
|
struct EventType
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -228,29 +228,21 @@ void SerialInterfaceManager::DoState(PointerWrap& p)
|
|||||||
p.Do(m_si_buffer);
|
p.Do(m_si_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int device_number>
|
|
||||||
void SerialInterfaceManager::DeviceEventCallback(Core::System& system, u64 userdata, s64 cyclesLate)
|
|
||||||
{
|
|
||||||
const auto& si = system.GetSerialInterface();
|
|
||||||
si.m_channel[device_number].device->OnEvent(userdata, cyclesLate);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SerialInterfaceManager::RegisterEvents()
|
void SerialInterfaceManager::RegisterEvents()
|
||||||
{
|
{
|
||||||
auto& core_timing = m_system.GetCoreTiming();
|
auto& core_timing = m_system.GetCoreTiming();
|
||||||
|
|
||||||
m_event_type_change_device = core_timing.RegisterEvent("ChangeSIDevice", ChangeDeviceCallback);
|
m_event_type_change_device = core_timing.RegisterEvent("ChangeSIDevice", ChangeDeviceCallback);
|
||||||
m_event_type_tranfer_pending = core_timing.RegisterEvent("SITransferPending", GlobalRunSIBuffer);
|
m_event_type_tranfer_pending = core_timing.RegisterEvent("SITransferPending", GlobalRunSIBuffer);
|
||||||
|
|
||||||
constexpr std::array<CoreTiming::TimedCallback, MAX_SI_CHANNELS> event_callbacks = {
|
for (u32 i = 0; i != MAX_SI_CHANNELS; ++i)
|
||||||
DeviceEventCallback<0>,
|
|
||||||
DeviceEventCallback<1>,
|
|
||||||
DeviceEventCallback<2>,
|
|
||||||
DeviceEventCallback<3>,
|
|
||||||
};
|
|
||||||
for (int i = 0; i < MAX_SI_CHANNELS; ++i)
|
|
||||||
{
|
{
|
||||||
|
auto& channel = m_channel[i];
|
||||||
m_event_types_device[i] =
|
m_event_types_device[i] =
|
||||||
core_timing.RegisterEvent(fmt::format("SIEventChannel{}", i), event_callbacks[i]);
|
core_timing.RegisterEvent(fmt::format("SIEventChannel{}", i),
|
||||||
|
[&channel](Core::System&, u64 user_data, s64 cycles_late) {
|
||||||
|
channel.device->OnEvent(user_data, cycles_late);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -88,8 +88,6 @@ private:
|
|||||||
void RunSIBuffer(u64 user_data, s64 cycles_late);
|
void RunSIBuffer(u64 user_data, s64 cycles_late);
|
||||||
static void GlobalRunSIBuffer(Core::System& system, u64 user_data, s64 cycles_late);
|
static void GlobalRunSIBuffer(Core::System& system, u64 user_data, s64 cycles_late);
|
||||||
static void ChangeDeviceCallback(Core::System& system, u64 user_data, s64 cycles_late);
|
static void ChangeDeviceCallback(Core::System& system, u64 user_data, s64 cycles_late);
|
||||||
template <int device_number>
|
|
||||||
static void DeviceEventCallback(Core::System& system, u64 userdata, s64 cyclesLate);
|
|
||||||
|
|
||||||
// SI Channel Output
|
// SI Channel Output
|
||||||
union USIChannelOut
|
union USIChannelOut
|
||||||
|
|||||||
Reference in New Issue
Block a user