1 // Copyright 2018 Citra Emulator Project 2 // Licensed under GPLv2 or any later version 3 // Refer to the license.txt file included. 4 5 #pragma once 6 7 #include <memory> 8 #include <shared_mutex> 9 #include <vector> 10 #include "common/common_types.h" 11 12 namespace Core { 13 class System; 14 struct TimingEventType; 15 } // namespace Core 16 17 namespace CoreTiming { 18 struct EventType; 19 } 20 21 namespace Cheats { 22 23 class CheatBase; 24 25 class CheatEngine { 26 public: 27 explicit CheatEngine(Core::System& system); 28 ~CheatEngine(); 29 void Connect(); 30 std::vector<std::shared_ptr<CheatBase>> GetCheats() const; 31 void AddCheat(const std::shared_ptr<CheatBase>& cheat); 32 void RemoveCheat(int index); 33 void UpdateCheat(int index, const std::shared_ptr<CheatBase>& new_cheat); 34 void SaveCheatFile() const; 35 36 private: 37 void LoadCheatFile(); 38 void RunCallback(u64 userdata, s64 cycles_late); 39 std::vector<std::shared_ptr<CheatBase>> cheats_list; 40 mutable std::shared_mutex cheats_list_mutex; 41 Core::TimingEventType* event; 42 Core::System& system; 43 }; 44 } // namespace Cheats 45