2
1
Fork 0
mirror of https://github.com/yuzu-emu/yuzu.git synced 2024-07-04 23:31:19 +01:00

core: Add Exit and ExitCallback

This allows ISelfController::Exit to stop the currently running application. This is typically used by homebrew to exit back to the homebrew menu after calling consoleExit with libnx.
This commit is contained in:
Morph 2021-09-25 23:14:49 -04:00
parent 3a33519598
commit d8467ca6c0
2 changed files with 25 additions and 0 deletions

View file

@ -421,6 +421,7 @@ struct System::Impl {
bool is_async_gpu{}; bool is_async_gpu{};
ExecuteProgramCallback execute_program_callback; ExecuteProgramCallback execute_program_callback;
ExitCallback exit_callback;
std::array<u64, Core::Hardware::NUM_CPU_CORES> dynarmic_ticks{}; std::array<u64, Core::Hardware::NUM_CPU_CORES> dynarmic_ticks{};
std::array<MicroProfileToken, Core::Hardware::NUM_CPU_CORES> microprofile_dynarmic{}; 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() { void System::ApplySettings() {
if (IsPoweredOn()) { if (IsPoweredOn()) {
Renderer().RefreshBaseSettings(); Renderer().RefreshBaseSettings();

View file

@ -387,6 +387,18 @@ public:
*/ */
void ExecuteProgram(std::size_t program_index); 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. /// Applies any changes to settings to this core instance.
void ApplySettings(); void ApplySettings();