From b999eaa4c9c3dc703f30edccb071effa445f1469 Mon Sep 17 00:00:00 2001 From: Sean O'Neil Date: Thu, 28 Jul 2022 14:56:55 -0700 Subject: [PATCH] Update uwp_main.cpp (#14239) Added launch protocol arg 'forceExit' so a frontend can tell an already-running RetroArch UWP instance to quit. --- uwp/uwp_main.cpp | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/uwp/uwp_main.cpp b/uwp/uwp_main.cpp index d65a5a2564..4d66034871 100644 --- a/uwp/uwp_main.cpp +++ b/uwp/uwp_main.cpp @@ -405,17 +405,17 @@ void App::Uninitialize() void App::OnActivated(CoreApplicationView^ applicationView, IActivatedEventArgs^ args) { + int argc = NULL; + std::vector argv; + std::vector argvTmp; //using std::string as temp buf instead of char* array to avoid manual char allocations + ParseProtocolArgs(args, &argc, &argv, &argvTmp); + //start only if not already initialized. If there is a game in progress, just return if (m_initialized == true) { return; } - int argc = NULL; - std::vector argv; - std::vector argvTmp; //using std::string as temp buf instead of char* array to avoid manual char allocations - ParseProtocolArgs(args, &argc, &argv, &argvTmp); - int ret = rarch_main(argc, argv.data(), NULL); if (ret != 0) { @@ -705,7 +705,12 @@ void App::ParseProtocolArgs(Windows::ApplicationModel::Activation::IActivatedEve IWwwFormUrlDecoderEntry^ arg = query->GetAt(i); //parse RetroArch command line string - if (arg->Name == "cmd") + if (arg->Name == "forceExit") + { + //this allows a frotend to quit RetroArch, which in turn allows it to launch a different game. + CoreApplication::Exit(); + } + else if (arg->Name == "cmd" && m_initalized == false) { std::wstring wsValue(arg->Value->ToString()->Data()); std::string strValue(wsValue.begin(), wsValue.end()); @@ -725,14 +730,17 @@ void App::ParseProtocolArgs(Windows::ApplicationModel::Activation::IActivatedEve } } } - - (*argc) = argvTmp->size(); - //convert to char* array compatible with argv - for (int i = 0; i < argvTmp->size(); i++) + + if (m_initialized == false) { - argv->push_back((char*)(argvTmp->at(i)).c_str()); + (*argc) = argvTmp->size(); + //convert to char* array compatible with argv + for (int i = 0; i < argvTmp->size(); i++) + { + argv->push_back((char*)(argvTmp->at(i)).c_str()); + } + argv->push_back(nullptr); } - argv->push_back(nullptr); } /* Implement UWP equivalents of various win32_* functions */