Update uwp_main.cpp (#14239)

Added launch protocol arg 'forceExit' so a frontend can tell an already-running RetroArch UWP instance to quit.
This commit is contained in:
Sean O'Neil 2022-07-28 14:56:55 -07:00 committed by GitHub
parent 6c38efb0ee
commit b999eaa4c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -405,17 +405,17 @@ void App::Uninitialize()
void App::OnActivated(CoreApplicationView^ applicationView, IActivatedEventArgs^ args)
{
int argc = NULL;
std::vector<char*> argv;
std::vector<std::string> 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<char*> argv;
std::vector<std::string> 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());
@ -726,6 +731,8 @@ void App::ParseProtocolArgs(Windows::ApplicationModel::Activation::IActivatedEve
}
}
if (m_initialized == false)
{
(*argc) = argvTmp->size();
//convert to char* array compatible with argv
for (int i = 0; i < argvTmp->size(); i++)
@ -734,6 +741,7 @@ void App::ParseProtocolArgs(Windows::ApplicationModel::Activation::IActivatedEve
}
argv->push_back(nullptr);
}
}
/* Implement UWP equivalents of various win32_* functions */
extern "C" {