diff --git a/GloSC/GloSC.cpp b/GloSC/GloSC.cpp index 7bd1ef6..26f2e0a 100644 --- a/GloSC/GloSC.cpp +++ b/GloSC/GloSC.cpp @@ -54,6 +54,7 @@ void GloSC::writeIni(QString entryName) settings.setValue("bEnableOverlay", 0 + ui.cbOverlay->isChecked()); settings.setValue("bEnableControllers", 0 + ui.cbControllers->isChecked()); + settings.setValue("bUseDesktopConfig", 0 + ui.cbUseDesktop->isChecked()); settings.setValue("bHookSteam", 0 + ui.cbHookSteam->isChecked()); settings.setValue("version", GLOSC_VERSION); @@ -148,6 +149,12 @@ void GloSC::animate(int to) anim->start(QPropertyAnimation::DeleteWhenStopped); } +void GloSC::on_cbUseDesktop_toggled(bool checked) +{ + ui.cbHookSteam->setEnabled(!checked); + ui.cbHookSteam->setChecked(!checked); +} + void GloSC::on_pbCreateNew_clicked() { ui.leName->setText(""); @@ -498,7 +505,17 @@ void GloSC::on_lwInstances_currentRowChanged(int row) ui.cbOverlay->setChecked(settings.value("bEnableOverlay").toBool()); ui.cbControllers->setChecked(settings.value("bEnableControllers").toBool()); - ui.cbHookSteam->setChecked(settings.value("bHookSteam").toBool()); + ui.cbUseDesktop->setChecked(settings.value("bUseDesktopConfig").toBool()); + if (ui.cbUseDesktop->isChecked()) + { + ui.cbHookSteam->setChecked(false); + ui.cbHookSteam->setEnabled(false); + } + else + { + ui.cbHookSteam->setEnabled(true); + ui.cbHookSteam->setChecked(settings.value("bHookSteam").toBool()); + } settings.endGroup(); diff --git a/GloSC/GloSC.h b/GloSC/GloSC.h index d791608..a66f35c 100644 --- a/GloSC/GloSC.h +++ b/GloSC/GloSC.h @@ -53,7 +53,7 @@ private: QList uwpPairs; - const unsigned int GLOSC_VERSION = 0x00000113; + const unsigned int GLOSC_VERSION = 0x00000114; int wide_x = 711; int small_x = 302; @@ -66,6 +66,7 @@ private: void animate(int to); private slots: + void on_cbUseDesktop_toggled(bool checked); void on_pbCreateNew_clicked(); void on_pbSave_clicked(); void on_pbDelete_clicked(); diff --git a/GloSC/GloSC.ui b/GloSC/GloSC.ui index 2ed586b..34d2f03 100644 --- a/GloSC/GloSC.ui +++ b/GloSC/GloSC.ui @@ -107,7 +107,7 @@ 40 - 231 + 251 261 20 @@ -117,7 +117,7 @@ 344 - 230 + 250 41 23 @@ -130,7 +130,7 @@ 300 - 230 + 250 41 23 @@ -143,7 +143,7 @@ 10 - 70 + 60 371 17 @@ -159,7 +159,7 @@ 10 - 100 + 90 371 17 @@ -175,7 +175,7 @@ 10 - 210 + 230 371 17 @@ -188,7 +188,7 @@ 10 - 231 + 251 31 20 @@ -253,9 +253,9 @@ 10 - 260 + 280 371 - 51 + 41 @@ -267,24 +267,34 @@ 10 - 140 + 170 371 - 51 + 41 Hook Steam -Enforces bindings reliably by hooking into Steam - +Enforces bindings reliably by hooking into Steam true + + + + 10 + 130 + 371 + 41 + + + + Use Desktop-Config +Disables hooking, per application bindings won't work + + - groupBox - configBox - verticalGroupBox diff --git a/SteamTarget/SteamTargetRenderer.cpp b/SteamTarget/SteamTargetRenderer.cpp index 5aeaa54..9e11952 100644 --- a/SteamTarget/SteamTargetRenderer.cpp +++ b/SteamTarget/SteamTargetRenderer.cpp @@ -38,6 +38,9 @@ SteamTargetRenderer::SteamTargetRenderer(int& argc, char** argv) : QApplication( }else if (childkey == "bHookSteam") { bHookSteam = settings.value(childkey).toBool(); } + else if (childkey == "bUseDesktopConfig") { + bUseDesktopConfig = settings.value(childkey).toBool(); + } } settings.endGroup(); @@ -57,7 +60,7 @@ SteamTargetRenderer::SteamTargetRenderer(int& argc, char** argv) : QApplication( consoleHwnd = GetConsoleWindow(); //We need a console for a dirty hack to make sure we stay in game bindings //QT Windows cause trouble with the overlay, so we cannot use them - ShowWindow(consoleHwnd, SW_HIDE); + //ShowWindow(consoleHwnd, SW_HIDE); if (bEnableControllers) controllerThread.run(); @@ -70,6 +73,19 @@ SteamTargetRenderer::SteamTargetRenderer(int& argc, char** argv) : QApplication( //Steam Posts a Message with 0x14FA / 0x14F7 when the overlay gets opened / closed hook = SetWindowsHookEx(WH_GETMESSAGE, HookCallback, nullptr, GetCurrentThreadId()); } + + + if (bUseDesktopConfig) + { + bHookSteam = false; + QTimer::singleShot(1000, this, []() + { + HWND taskbar = FindWindow(L"Shell_TrayWnd", nullptr); + SetFocus(taskbar); + SetForegroundWindow(taskbar); + }); + } + } SteamTargetRenderer::~SteamTargetRenderer() @@ -128,6 +144,7 @@ void SteamTargetRenderer::RunSfWindowLoop() if (bDrawDebugEdges) drawDebugEdges(); + //This ensures that we stay in game binding, even if focused application changes! (Why does this work? Well, i dunno... ask Valve...) //Only works with a console window //Causes trouble as soon as there is more than the consoleWindow and the overlayWindow @@ -142,11 +159,14 @@ void SteamTargetRenderer::RunSfWindowLoop() hookBindings(); //cleanup - unhooking / unloading of dll is managed by the GloSC gamelauncher rather than here focusSwitchNeeded = false; - SetFocus(consoleHwnd); - sf::Clock clock; - while (!SetForegroundWindow(consoleHwnd) && clock.getElapsedTime().asMilliseconds() < 1000) //try to forcefully set foreground window + if (!bUseDesktopConfig) { - Sleep(1); + SetFocus(consoleHwnd); + sf::Clock clock; + while (!SetForegroundWindow(consoleHwnd) && clock.getElapsedTime().asMilliseconds() < 1000) //try to forcefully set foreground window + { + Sleep(1); + } } } @@ -169,12 +189,16 @@ void SteamTargetRenderer::RunSfWindowLoop() //Actually activate the overlaywindow SetFocus(sfWindow.getSystemHandle()); - //by activating the consolewindow **and bringing it to the foreground** we can trick steam so the controller stays in game bindings - SetFocus(consoleHwnd); - sf::Clock clock; - while (!SetForegroundWindow(consoleHwnd) && clock.getElapsedTime().asMilliseconds() < 1000) //try to forcefully set foreground window + + if (!bUseDesktopConfig) { - Sleep(1); + //by activating the consolewindow **and bringing it to the foreground** we can trick steam so the controller stays in game bindings + SetFocus(consoleHwnd); + sf::Clock clock; + while (!SetForegroundWindow(consoleHwnd) && clock.getElapsedTime().asMilliseconds() < 1000) //try to forcefully set foreground window + { + Sleep(1); + } } //Move the mouse cursor inside the overlaywindow diff --git a/SteamTarget/SteamTargetRenderer.h b/SteamTarget/SteamTargetRenderer.h index 307bc3a..38110be 100644 --- a/SteamTarget/SteamTargetRenderer.h +++ b/SteamTarget/SteamTargetRenderer.h @@ -62,6 +62,7 @@ private: std::atomic bRunLoop = true; + bool bUseDesktopConfig = false; bool bDrawDebugEdges = false; bool bDrawOverlay = true; bool bVsync = false; diff --git a/TargetConfig.ini b/TargetConfig.ini index 81eb61c..b904367 100644 --- a/TargetConfig.ini +++ b/TargetConfig.ini @@ -2,6 +2,7 @@ bDrawDebugEdges=0 bEnableOverlay=1 bEnableControllers=1 +bUseDesktopConfig=0 bHookSteam=1 version=275