Skip to content
Snippets Groups Projects
Commit fbf14957 authored by Vicki Pfau's avatar Vicki Pfau
Browse files

retro: Expose cheats

parent 18899e6f
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,7 @@ using namespace Retro;
struct PyGameData;
struct PyRetroEmulator {
Retro::Emulator m_re;
int m_cheats = 0;
PyRetroEmulator(const string& rom_path) {
if (Emulator::isLoaded()) {
throw std::runtime_error("Cannot create multiple emulator instances per process");
......@@ -91,6 +92,16 @@ struct PyRetroEmulator {
}
}
void addCheat(const string& code) {
m_re.setCheat(m_cheats, true, code.c_str());
++m_cheats;
}
void clearCheats() {
m_re.clearCheats();
m_cheats = 0;
}
void configureData(PyGameData& data);
static bool loadCoreInfo(const string& json) {
return Retro::loadCoreInfo(json);
......@@ -309,6 +320,8 @@ PYBIND11_MODULE(_retro, m) {
.def("get_audio_rate", &PyRetroEmulator::getAudioRate)
.def("get_resolution", &PyRetroEmulator::getResolution)
.def("configure_data", &PyRetroEmulator::configureData)
.def("add_cheat", &PyRetroEmulator::addCheat)
.def("clear_cheats", &PyRetroEmulator::clearCheats)
.def_static("load_core_info", &PyRetroEmulator::loadCoreInfo);
py::class_<PyMemoryView>(m, "Memory")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment