mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-04 14:01:25 +12:00
rename rpcs3_app to headless_application
This commit is contained in:
parent
0dc7841d0f
commit
503d43889d
7 changed files with 70 additions and 68 deletions
65
rpcs3/headless_application.cpp
Normal file
65
rpcs3/headless_application.cpp
Normal file
|
@ -0,0 +1,65 @@
|
|||
#include "headless_application.h"
|
||||
|
||||
#include "Emu/System.h"
|
||||
|
||||
#include "Emu/RSX/GSRender.h"
|
||||
|
||||
// For now, a trivial constructor/destructor. May add command line usage later.
|
||||
headless_application::headless_application(int& argc, char** argv) : QCoreApplication(argc, argv)
|
||||
{
|
||||
}
|
||||
|
||||
void headless_application::Init()
|
||||
{
|
||||
// Force init the emulator
|
||||
InitializeEmulator("1", true); // TODO: get user from cli args if possible
|
||||
|
||||
// Create callbacks from the emulator, which reference the handlers.
|
||||
InitializeCallbacks();
|
||||
|
||||
// Create connects to propagate events throughout Gui.
|
||||
InitializeConnects();
|
||||
}
|
||||
|
||||
void headless_application::InitializeConnects()
|
||||
{
|
||||
qRegisterMetaType<std::function<void()>>("std::function<void()>");
|
||||
connect(this, &headless_application::RequestCallAfter, this, &headless_application::HandleCallAfter);
|
||||
}
|
||||
|
||||
/** RPCS3 emulator has functions it desires to call from the GUI at times. Initialize them in here. */
|
||||
void headless_application::InitializeCallbacks()
|
||||
{
|
||||
EmuCallbacks callbacks = CreateCallbacks();
|
||||
|
||||
callbacks.exit = [this]()
|
||||
{
|
||||
quit();
|
||||
};
|
||||
callbacks.call_after = [=](std::function<void()> func)
|
||||
{
|
||||
RequestCallAfter(std::move(func));
|
||||
};
|
||||
|
||||
callbacks.get_gs_frame = []() -> std::unique_ptr<GSFrameBase> { return std::unique_ptr<GSFrameBase>(); };
|
||||
callbacks.get_msg_dialog = []() -> std::shared_ptr<MsgDialogBase> { return std::shared_ptr<MsgDialogBase>(); };
|
||||
callbacks.get_osk_dialog = []() -> std::shared_ptr<OskDialogBase> { return std::shared_ptr<OskDialogBase>(); };
|
||||
callbacks.get_save_dialog = []() -> std::unique_ptr<SaveDialogBase> { return std::unique_ptr<SaveDialogBase>(); };
|
||||
callbacks.get_trophy_notification_dialog = []() -> std::unique_ptr<TrophyNotificationBase> { return std::unique_ptr<TrophyNotificationBase>(); };
|
||||
|
||||
callbacks.on_run = []() {};
|
||||
callbacks.on_pause = []() {};
|
||||
callbacks.on_resume = []() {};
|
||||
callbacks.on_stop = []() {};
|
||||
callbacks.on_ready = []() {};
|
||||
|
||||
Emu.SetCallbacks(std::move(callbacks));
|
||||
}
|
||||
|
||||
/**
|
||||
* Using connects avoids timers being unable to be used in a non-qt thread. So, even if this looks stupid to just call func, it's succinct.
|
||||
*/
|
||||
void headless_application::HandleCallAfter(const std::function<void()>& func)
|
||||
{
|
||||
func();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue