diff options
author | Morph <39850852+Morph1984@users.noreply.github.com> | 2021-09-26 05:14:49 +0200 |
---|---|---|
committer | Morph <39850852+Morph1984@users.noreply.github.com> | 2021-10-02 05:39:54 +0200 |
commit | d8467ca6c0eff0ea0fc619043893abb0a2cebf9f (patch) | |
tree | a41258ebddf8f93e8e3c3259157584af1ac0781f | |
parent | Merge pull request #7102 from Morph1984/remove-boxcat (diff) | |
download | yuzu-d8467ca6c0eff0ea0fc619043893abb0a2cebf9f.tar yuzu-d8467ca6c0eff0ea0fc619043893abb0a2cebf9f.tar.gz yuzu-d8467ca6c0eff0ea0fc619043893abb0a2cebf9f.tar.bz2 yuzu-d8467ca6c0eff0ea0fc619043893abb0a2cebf9f.tar.lz yuzu-d8467ca6c0eff0ea0fc619043893abb0a2cebf9f.tar.xz yuzu-d8467ca6c0eff0ea0fc619043893abb0a2cebf9f.tar.zst yuzu-d8467ca6c0eff0ea0fc619043893abb0a2cebf9f.zip |
-rw-r--r-- | src/core/core.cpp | 13 | ||||
-rw-r--r-- | src/core/core.h | 12 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp index 50d5dab4b..bb268a319 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -421,6 +421,7 @@ struct System::Impl { bool is_async_gpu{}; ExecuteProgramCallback execute_program_callback; + ExitCallback exit_callback; std::array<u64, Core::Hardware::NUM_CPU_CORES> dynarmic_ticks{}; std::array<MicroProfileToken, Core::Hardware::NUM_CPU_CORES> microprofile_dynarmic{}; @@ -798,6 +799,18 @@ void System::ExecuteProgram(std::size_t program_index) { } } +void System::RegisterExitCallback(ExitCallback&& callback) { + impl->exit_callback = std::move(callback); +} + +void System::Exit() { + if (impl->exit_callback) { + impl->exit_callback(); + } else { + LOG_CRITICAL(Core, "exit_callback must be initialized by the frontend"); + } +} + void System::ApplySettings() { if (IsPoweredOn()) { Renderer().RefreshBaseSettings(); diff --git a/src/core/core.h b/src/core/core.h index 715ab88e7..a796472b2 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -387,6 +387,18 @@ public: */ void ExecuteProgram(std::size_t program_index); + /// Type used for the frontend to designate a callback for System to exit the application. + using ExitCallback = std::function<void()>; + + /** + * Registers a callback from the frontend for System to exit the application. + * @param callback Callback from the frontend to exit the application. + */ + void RegisterExitCallback(ExitCallback&& callback); + + /// Instructs the frontend to exit the application. + void Exit(); + /// Applies any changes to settings to this core instance. void ApplySettings(); |