From f9c993dc500c69fbaa376c2bcf51db54442ee50f Mon Sep 17 00:00:00 2001 From: Peter Repukat Date: Fri, 7 Oct 2022 13:08:55 +0200 Subject: [PATCH] GlosSITarget: Add cli-switches: -disableuwpoverlay -disablewatchdog --- GlosSITarget/Settings.h | 38 +++++++++++++++++++++++++++--------- GlosSITarget/SteamTarget.cpp | 25 ++++++++++++------------ GlosSITarget/main.cpp | 5 +++-- 3 files changed, 44 insertions(+), 24 deletions(-) diff --git a/GlosSITarget/Settings.h b/GlosSITarget/Settings.h index eaef719..374b93a 100644 --- a/GlosSITarget/Settings.h +++ b/GlosSITarget/Settings.h @@ -59,6 +59,11 @@ inline struct Controller { bool emulateDS4 = false; } controller; +inline struct Cli { + bool no_uwp_overlay = false; + bool disable_watchdog = false; +} cli; + inline bool extendedLogging = false; inline std::filesystem::path settings_path_ = ""; @@ -114,14 +119,29 @@ inline void checkWinVer() } #endif -inline void Parse(std::wstring arg1) +inline void Parse(const std::vector& args) { - const auto config_specified = !std::views::filter(arg1, [](const auto& ch) { - return ch != ' '; - }).empty(); - if (config_specified) { - if (!arg1.ends_with(L".json")) { - arg1 += L".json"; + std::wstring configName; + for (const auto& arg : args) { + if (arg.empty()) { + continue; + } + if (arg[0] != L'-') { + configName = std::wstring(arg.begin(), arg.end()); + } + if (arg[0] == L'-') { + if (arg == L"-disableuwpoverlay") { + cli.no_uwp_overlay = true; + } + if (arg == L"-disablewatchdog") { + cli.disable_watchdog = true; + } + } + } + + if (!configName.empty()) { + if (!configName.ends_with(L".json")) { + configName += L".json"; } } wchar_t* localAppDataFolder; @@ -135,9 +155,9 @@ inline void Parse(std::wstring arg1) path /= "Roaming"; path /= "GlosSI"; - if (config_specified) { + if (!configName.empty()) { path /= "Targets"; - path /= arg1; + path /= configName; } else { spdlog::info("No config file specified, using default"); diff --git a/GlosSITarget/SteamTarget.cpp b/GlosSITarget/SteamTarget.cpp index 6fff749..0192256 100644 --- a/GlosSITarget/SteamTarget.cpp +++ b/GlosSITarget/SteamTarget.cpp @@ -48,14 +48,11 @@ SteamTarget::SteamTarget() { target_window_handle_ = window_.getSystemHandle(); #ifdef _WIN32 - //if (Settings::launch.isUWP) { - // UWPOverlayEnabler::EnableUwpOverlay(); - //} - //else { - // UWPOverlayEnabler::AddUwpOverlayOvWidget(); - //} - UWPOverlayEnabler::EnableUwpOverlay(); - + if (Settings::cli.no_uwp_overlay) { + UWPOverlayEnabler::AddUwpOverlayOvWidget(); + } else { + UWPOverlayEnabler::EnableUwpOverlay(); + } #endif } @@ -78,12 +75,14 @@ Application will not function!"); steam_overlay_present_ = true; #ifdef WIN32 - wchar_t buff[MAX_PATH]; - GetModuleFileName(GetModuleHandle(NULL), buff, MAX_PATH); - std::wstring watchDogPath(buff); - watchDogPath = watchDogPath.substr(0, 1 + watchDogPath.find_last_of(L'\\')) + L"GlosSIWatchdog.dll"; + if (!Settings::cli.disable_watchdog) { + wchar_t buff[MAX_PATH]; + GetModuleFileName(GetModuleHandle(NULL), buff, MAX_PATH); + std::wstring watchDogPath(buff); + watchDogPath = watchDogPath.substr(0, 1 + watchDogPath.find_last_of(L'\\')) + L"GlosSIWatchdog.dll"; - DllInjector::injectDllInto(watchDogPath, L"explorer.exe"); + DllInjector::injectDllInto(watchDogPath, L"explorer.exe"); + } #endif } getXBCRebindingEnabled(); diff --git a/GlosSITarget/main.cpp b/GlosSITarget/main.cpp index 6ce5a1e..620eb4f 100644 --- a/GlosSITarget/main.cpp +++ b/GlosSITarget/main.cpp @@ -164,10 +164,11 @@ int main(int argc, char* argv[]) #ifdef _WIN32 int numArgs; LPWSTR* args = CommandLineToArgvW(GetCommandLine(), &numArgs); - std::wstring argsv = L""; + std::vector argsv; + argsv.reserve(numArgs); if (numArgs > 1) { for (int i = 1; i < numArgs; i++) - argsv += i == 1 ? args[i] : std::wstring(L" ") + args[i]; + argsv.emplace_back(args[i]); } Settings::Parse(argsv); Settings::checkWinVer();