Add setting to use Desktop-Config

Add a setting to use desktop-config
If enabled, will disable hooking and deactive any focus-switch trickery
Problems with overlay may occur
UWP_Overlay-legacy
Peter Repukat 7 years ago
parent 79ced09dcf
commit 209126ea17

@ -54,6 +54,7 @@ void GloSC::writeIni(QString entryName)
settings.setValue("bEnableOverlay", 0 + ui.cbOverlay->isChecked()); settings.setValue("bEnableOverlay", 0 + ui.cbOverlay->isChecked());
settings.setValue("bEnableControllers", 0 + ui.cbControllers->isChecked()); settings.setValue("bEnableControllers", 0 + ui.cbControllers->isChecked());
settings.setValue("bUseDesktopConfig", 0 + ui.cbUseDesktop->isChecked());
settings.setValue("bHookSteam", 0 + ui.cbHookSteam->isChecked()); settings.setValue("bHookSteam", 0 + ui.cbHookSteam->isChecked());
settings.setValue("version", GLOSC_VERSION); settings.setValue("version", GLOSC_VERSION);
@ -148,6 +149,12 @@ void GloSC::animate(int to)
anim->start(QPropertyAnimation::DeleteWhenStopped); anim->start(QPropertyAnimation::DeleteWhenStopped);
} }
void GloSC::on_cbUseDesktop_toggled(bool checked)
{
ui.cbHookSteam->setEnabled(!checked);
ui.cbHookSteam->setChecked(!checked);
}
void GloSC::on_pbCreateNew_clicked() void GloSC::on_pbCreateNew_clicked()
{ {
ui.leName->setText(""); ui.leName->setText("");
@ -498,7 +505,17 @@ void GloSC::on_lwInstances_currentRowChanged(int row)
ui.cbOverlay->setChecked(settings.value("bEnableOverlay").toBool()); ui.cbOverlay->setChecked(settings.value("bEnableOverlay").toBool());
ui.cbControllers->setChecked(settings.value("bEnableControllers").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(); settings.endGroup();

@ -53,7 +53,7 @@ private:
QList<UWPPair> uwpPairs; QList<UWPPair> uwpPairs;
const unsigned int GLOSC_VERSION = 0x00000113; const unsigned int GLOSC_VERSION = 0x00000114;
int wide_x = 711; int wide_x = 711;
int small_x = 302; int small_x = 302;
@ -66,6 +66,7 @@ private:
void animate(int to); void animate(int to);
private slots: private slots:
void on_cbUseDesktop_toggled(bool checked);
void on_pbCreateNew_clicked(); void on_pbCreateNew_clicked();
void on_pbSave_clicked(); void on_pbSave_clicked();
void on_pbDelete_clicked(); void on_pbDelete_clicked();

@ -107,7 +107,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>40</x> <x>40</x>
<y>231</y> <y>251</y>
<width>261</width> <width>261</width>
<height>20</height> <height>20</height>
</rect> </rect>
@ -117,7 +117,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>344</x> <x>344</x>
<y>230</y> <y>250</y>
<width>41</width> <width>41</width>
<height>23</height> <height>23</height>
</rect> </rect>
@ -130,7 +130,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>300</x> <x>300</x>
<y>230</y> <y>250</y>
<width>41</width> <width>41</width>
<height>23</height> <height>23</height>
</rect> </rect>
@ -143,7 +143,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
<y>70</y> <y>60</y>
<width>371</width> <width>371</width>
<height>17</height> <height>17</height>
</rect> </rect>
@ -159,7 +159,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
<y>100</y> <y>90</y>
<width>371</width> <width>371</width>
<height>17</height> <height>17</height>
</rect> </rect>
@ -175,7 +175,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
<y>210</y> <y>230</y>
<width>371</width> <width>371</width>
<height>17</height> <height>17</height>
</rect> </rect>
@ -188,7 +188,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
<y>231</y> <y>251</y>
<width>31</width> <width>31</width>
<height>20</height> <height>20</height>
</rect> </rect>
@ -253,9 +253,9 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
<y>260</y> <y>280</y>
<width>371</width> <width>371</width>
<height>51</height> <height>41</height>
</rect> </rect>
</property> </property>
<property name="text"> <property name="text">
@ -267,24 +267,34 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
<y>140</y> <y>170</y>
<width>371</width> <width>371</width>
<height>51</height> <height>41</height>
</rect> </rect>
</property> </property>
<property name="text"> <property name="text">
<string>Hook Steam <string>Hook Steam
Enforces bindings reliably by hooking into Steam Enforces bindings reliably by hooking into Steam</string>
</string>
</property> </property>
<property name="checked"> <property name="checked">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
<widget class="QCheckBox" name="cbUseDesktop">
<property name="geometry">
<rect>
<x>10</x>
<y>130</y>
<width>371</width>
<height>41</height>
</rect>
</property>
<property name="text">
<string>Use Desktop-Config
Disables hooking, per application bindings won't work</string>
</property>
</widget>
</widget> </widget>
<zorder>groupBox</zorder>
<zorder>configBox</zorder>
<zorder>verticalGroupBox</zorder>
</widget> </widget>
</widget> </widget>
<layoutdefault spacing="6" margin="11"/> <layoutdefault spacing="6" margin="11"/>

@ -38,6 +38,9 @@ SteamTargetRenderer::SteamTargetRenderer(int& argc, char** argv) : QApplication(
}else if (childkey == "bHookSteam") { }else if (childkey == "bHookSteam") {
bHookSteam = settings.value(childkey).toBool(); bHookSteam = settings.value(childkey).toBool();
} }
else if (childkey == "bUseDesktopConfig") {
bUseDesktopConfig = settings.value(childkey).toBool();
}
} }
settings.endGroup(); 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 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 //QT Windows cause trouble with the overlay, so we cannot use them
ShowWindow(consoleHwnd, SW_HIDE); //ShowWindow(consoleHwnd, SW_HIDE);
if (bEnableControllers) if (bEnableControllers)
controllerThread.run(); 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 //Steam Posts a Message with 0x14FA / 0x14F7 when the overlay gets opened / closed
hook = SetWindowsHookEx(WH_GETMESSAGE, HookCallback, nullptr, GetCurrentThreadId()); 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() SteamTargetRenderer::~SteamTargetRenderer()
@ -128,6 +144,7 @@ void SteamTargetRenderer::RunSfWindowLoop()
if (bDrawDebugEdges) if (bDrawDebugEdges)
drawDebugEdges(); drawDebugEdges();
//This ensures that we stay in game binding, even if focused application changes! (Why does this work? Well, i dunno... ask Valve...) //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 //Only works with a console window
//Causes trouble as soon as there is more than the consoleWindow and the overlayWindow //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 hookBindings(); //cleanup - unhooking / unloading of dll is managed by the GloSC gamelauncher rather than here
focusSwitchNeeded = false; focusSwitchNeeded = false;
SetFocus(consoleHwnd); if (!bUseDesktopConfig)
sf::Clock clock;
while (!SetForegroundWindow(consoleHwnd) && clock.getElapsedTime().asMilliseconds() < 1000) //try to forcefully set foreground window
{ {
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 //Actually activate the overlaywindow
SetFocus(sfWindow.getSystemHandle()); 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); if (!bUseDesktopConfig)
sf::Clock clock;
while (!SetForegroundWindow(consoleHwnd) && clock.getElapsedTime().asMilliseconds() < 1000) //try to forcefully set foreground window
{ {
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 //Move the mouse cursor inside the overlaywindow

@ -62,6 +62,7 @@ private:
std::atomic<bool> bRunLoop = true; std::atomic<bool> bRunLoop = true;
bool bUseDesktopConfig = false;
bool bDrawDebugEdges = false; bool bDrawDebugEdges = false;
bool bDrawOverlay = true; bool bDrawOverlay = true;
bool bVsync = false; bool bVsync = false;

@ -2,6 +2,7 @@
bDrawDebugEdges=0 bDrawDebugEdges=0
bEnableOverlay=1 bEnableOverlay=1
bEnableControllers=1 bEnableControllers=1
bUseDesktopConfig=0
bHookSteam=1 bHookSteam=1
version=275 version=275

Loading…
Cancel
Save