mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-04-21 03:50:55 +00:00
Merge pull request #14517 from jordan-woyak/event-functor
CoreTiming: Change TimedCallback to a Common::MoveOnlyFunction.
This commit is contained in:
commit
67f1afeb74
@ -70,7 +70,7 @@ EventType* CoreTimingManager::RegisterEvent(const std::string& name, TimedCallba
|
||||
"during Init to avoid breaking save states.",
|
||||
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;
|
||||
event_type->name = &info.first->first;
|
||||
return event_type;
|
||||
|
||||
@ -23,6 +23,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/Functional.h"
|
||||
#include "Common/HookableEvent.h"
|
||||
#include "Common/SPSCQueue.h"
|
||||
#include "Common/Timer.h"
|
||||
@ -47,7 +48,8 @@ struct Globals
|
||||
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
|
||||
{
|
||||
|
||||
@ -228,29 +228,21 @@ void SerialInterfaceManager::DoState(PointerWrap& p)
|
||||
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()
|
||||
{
|
||||
auto& core_timing = m_system.GetCoreTiming();
|
||||
|
||||
m_event_type_change_device = core_timing.RegisterEvent("ChangeSIDevice", ChangeDeviceCallback);
|
||||
m_event_type_tranfer_pending = core_timing.RegisterEvent("SITransferPending", GlobalRunSIBuffer);
|
||||
|
||||
constexpr std::array<CoreTiming::TimedCallback, MAX_SI_CHANNELS> event_callbacks = {
|
||||
DeviceEventCallback<0>,
|
||||
DeviceEventCallback<1>,
|
||||
DeviceEventCallback<2>,
|
||||
DeviceEventCallback<3>,
|
||||
};
|
||||
for (int i = 0; i < MAX_SI_CHANNELS; ++i)
|
||||
for (u32 i = 0; i != MAX_SI_CHANNELS; ++i)
|
||||
{
|
||||
auto& channel = m_channel[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);
|
||||
static void GlobalRunSIBuffer(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
|
||||
union USIChannelOut
|
||||
|
||||
Loading…
Reference in New Issue
Block a user