diff --git a/src/core/core.cpp b/src/core/core.cpp index 9e3eb3795..8844285bd 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -543,6 +543,7 @@ struct System::Impl { ExecuteProgramCallback execute_program_callback; ExitCallback exit_callback; + GameLogCallback game_log_callback; std::array dynarmic_ticks{}; std::array microprofile_cpu{}; @@ -1011,6 +1012,18 @@ void System::RegisterExitCallback(ExitCallback&& callback) { impl->exit_callback = std::move(callback); } +void System::RegisterGameLogCallback(GameLogCallback&& callback) { + impl->game_log_callback = std::move(callback); +} + +void System::AppendGameMessage(std::string& text) { + if (impl->game_log_callback) { + impl->game_log_callback(text); + } else { + LOG_CRITICAL(Core, "game_log_callback must be initialized by the frontend"); + } +} + void System::Exit() { if (impl->exit_callback) { impl->exit_callback(); diff --git a/src/core/core.h b/src/core/core.h index 14b2f7785..e77ff42a8 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -462,6 +462,18 @@ public: */ void RegisterExitCallback(ExitCallback&& callback); + /// Type used for the frontend to designate a callback for System to display log output. + using GameLogCallback = std::function; + + /** + * Registers a callback from the frontend for System to display log output. + * @param callback Callback from the frontend to display log output. + */ + void RegisterGameLogCallback(GameLogCallback&& callback); + + /// Inserts a new entry on the game log ouput window + void AppendGameMessage(std::string& text); + /// Instructs the frontend to exit the application. void Exit(); diff --git a/src/core/hle/service/lm/lm.cpp b/src/core/hle/service/lm/lm.cpp index 20df00233..ae9f1277e 100644 --- a/src/core/hle/service/lm/lm.cpp +++ b/src/core/hle/service/lm/lm.cpp @@ -276,6 +276,7 @@ private: if (text_log) { output_log += fmt::format("Log Text: {}\n", *text_log); + system.AppendGameMessage(*text_log); } LOG_DEBUG(Service_LM, "LogManager {} ({}):\n{}", NameOf(entry.severity), DestinationToString(destination), output_log);