diff options
| author | 2020-07-15 19:14:21 -0400 | |
|---|---|---|
| committer | 2020-07-15 19:41:22 -0400 | |
| commit | bef1844a51a37c1c8dc531e67069ef00821ffa9c (patch) | |
| tree | 2e46f404c3f0baf1b854e1bea916c19469fe424a /src/core/memory | |
| parent | core_timing: Make use of std::chrono with ScheduleEvent (diff) | |
| download | yuzu-bef1844a51a37c1c8dc531e67069ef00821ffa9c.tar.gz yuzu-bef1844a51a37c1c8dc531e67069ef00821ffa9c.tar.xz yuzu-bef1844a51a37c1c8dc531e67069ef00821ffa9c.zip | |
core_timing: Make TimedCallback take std::chrono::nanoseconds
Enforces our desired time units directly with a concrete type.
Diffstat (limited to 'src/core/memory')
| -rw-r--r-- | src/core/memory/cheat_engine.cpp | 13 | ||||
| -rw-r--r-- | src/core/memory/cheat_engine.h | 3 |
2 files changed, 9 insertions, 7 deletions
diff --git a/src/core/memory/cheat_engine.cpp b/src/core/memory/cheat_engine.cpp index 09bf8c5cf..ced41b1fe 100644 --- a/src/core/memory/cheat_engine.cpp +++ b/src/core/memory/cheat_engine.cpp | |||
| @@ -188,9 +188,11 @@ CheatEngine::~CheatEngine() { | |||
| 188 | } | 188 | } |
| 189 | 189 | ||
| 190 | void CheatEngine::Initialize() { | 190 | void CheatEngine::Initialize() { |
| 191 | event = Core::Timing::CreateEvent( | 191 | event = Core::Timing::CreateEvent("CheatEngine::FrameCallback::" + |
| 192 | "CheatEngine::FrameCallback::" + Common::HexToString(metadata.main_nso_build_id), | 192 | Common::HexToString(metadata.main_nso_build_id), |
| 193 | [this](u64 userdata, s64 ns_late) { FrameCallback(userdata, ns_late); }); | 193 | [this](u64 userdata, std::chrono::nanoseconds ns_late) { |
| 194 | FrameCallback(userdata, ns_late); | ||
| 195 | }); | ||
| 194 | core_timing.ScheduleEvent(CHEAT_ENGINE_NS, event); | 196 | core_timing.ScheduleEvent(CHEAT_ENGINE_NS, event); |
| 195 | 197 | ||
| 196 | metadata.process_id = system.CurrentProcess()->GetProcessID(); | 198 | metadata.process_id = system.CurrentProcess()->GetProcessID(); |
| @@ -217,7 +219,7 @@ void CheatEngine::Reload(std::vector<CheatEntry> cheats) { | |||
| 217 | 219 | ||
| 218 | MICROPROFILE_DEFINE(Cheat_Engine, "Add-Ons", "Cheat Engine", MP_RGB(70, 200, 70)); | 220 | MICROPROFILE_DEFINE(Cheat_Engine, "Add-Ons", "Cheat Engine", MP_RGB(70, 200, 70)); |
| 219 | 221 | ||
| 220 | void CheatEngine::FrameCallback(u64 userdata, s64 ns_late) { | 222 | void CheatEngine::FrameCallback(u64, std::chrono::nanoseconds ns_late) { |
| 221 | if (is_pending_reload.exchange(false)) { | 223 | if (is_pending_reload.exchange(false)) { |
| 222 | vm.LoadProgram(cheats); | 224 | vm.LoadProgram(cheats); |
| 223 | } | 225 | } |
| @@ -230,8 +232,7 @@ void CheatEngine::FrameCallback(u64 userdata, s64 ns_late) { | |||
| 230 | 232 | ||
| 231 | vm.Execute(metadata); | 233 | vm.Execute(metadata); |
| 232 | 234 | ||
| 233 | const auto future_ns = CHEAT_ENGINE_NS - std::chrono::nanoseconds{ns_late}; | 235 | core_timing.ScheduleEvent(CHEAT_ENGINE_NS - ns_late, event); |
| 234 | core_timing.ScheduleEvent(future_ns, event); | ||
| 235 | } | 236 | } |
| 236 | 237 | ||
| 237 | } // namespace Core::Memory | 238 | } // namespace Core::Memory |
diff --git a/src/core/memory/cheat_engine.h b/src/core/memory/cheat_engine.h index 2649423f8..d4068cf84 100644 --- a/src/core/memory/cheat_engine.h +++ b/src/core/memory/cheat_engine.h | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <atomic> | 7 | #include <atomic> |
| 8 | #include <chrono> | ||
| 8 | #include <memory> | 9 | #include <memory> |
| 9 | #include <vector> | 10 | #include <vector> |
| 10 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| @@ -71,7 +72,7 @@ public: | |||
| 71 | void Reload(std::vector<CheatEntry> cheats); | 72 | void Reload(std::vector<CheatEntry> cheats); |
| 72 | 73 | ||
| 73 | private: | 74 | private: |
| 74 | void FrameCallback(u64 userdata, s64 cycles_late); | 75 | void FrameCallback(u64 userdata, std::chrono::nanoseconds ns_late); |
| 75 | 76 | ||
| 76 | DmntCheatVm vm; | 77 | DmntCheatVm vm; |
| 77 | CheatProcessMetadata metadata; | 78 | CheatProcessMetadata metadata; |