2
0
mirror of https://github.com/Thracky/GlosSI.git synced 2024-11-03 09:40:18 +00:00

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
This commit is contained in:
Peter Repukat 2017-02-15 04:04:27 +01:00
parent 79ced09dcf
commit 209126ea17
6 changed files with 82 additions and 28 deletions

View File

@ -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();

View File

@ -53,7 +53,7 @@ private:
QList<UWPPair> 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();

View File

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

View File

@ -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

View File

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

View File

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