diff --git a/GloSC/GloSC.cpp b/GloSC/GloSC.cpp
index 26f2e0a..532be47 100644
--- a/GloSC/GloSC.cpp
+++ b/GloSC/GloSC.cpp
@@ -18,6 +18,7 @@ limitations under the License.
GloSC::GloSC(QWidget *parent)
: QMainWindow(parent)
{
+ QDir::setCurrent(QCoreApplication::applicationDirPath());
ui.setupUi(this);
updateEntryList();
@@ -26,7 +27,7 @@ GloSC::GloSC(QWidget *parent)
//Launch the gamelauncher here, just to be safe
//Don't need to check if the process already exists as it does it itself
QProcess proc;
- proc.startDetached("GloSC_Gamelauncher.exe", QStringList(), QDir::toNativeSeparators(QApplication::applicationDirPath()), nullptr);
+ proc.startDetached("GloSC_Gamelauncher.exe", QStringList(), QApplication::applicationDirPath(), nullptr);
}
@@ -34,13 +35,13 @@ void GloSC::updateEntryList()
{
ui.lwInstances->clear();
- QDir dir(".\\");
- QStringList dirNames = dir.entryList(QDir::Dirs);
+ QDir dir("./targets");
+ QStringList fileNames = dir.entryList(QDir::Files);
- for (auto &dirName : dirNames)
+ for (auto &fileName : fileNames)
{
- if (dirName != "." && dirName != ".." && dirName != "platforms")
- ui.lwInstances->addItem(dirName);
+ if (fileName.endsWith(".ini"))
+ ui.lwInstances->addItem(fileName.left(fileName.length() - 4));
}
@@ -48,7 +49,7 @@ void GloSC::updateEntryList()
void GloSC::writeIni(QString entryName)
{
- QSettings settings(entryName + "\\TargetConfig.ini", QSettings::IniFormat);
+ QSettings settings("./targets/" + entryName + ".ini", QSettings::IniFormat);
settings.beginGroup("BaseConf");
@@ -64,16 +65,12 @@ void GloSC::writeIni(QString entryName)
settings.beginGroup("LaunchGame");
settings.setValue("bLaunchGame", 0 + ui.cbLaunchGame->isChecked());
- if (ui.cbLaunchGame->isChecked())
- {
- settings.setValue("Path", ui.lePath->text());
- if (ui.lePath->text().contains("\\") || ui.lePath->text().contains("/"))
- {
- settings.setValue("Type", "Win32");
- } else {
- settings.setValue("Type", "UWP");
- }
- }
+ settings.setValue("Path", ui.lePath->text());
+ settings.setValue("Args", ui.leArguments->text());
+ if (ui.lePath->text().contains("\\") || ui.lePath->text().contains("/"))
+ settings.setValue("Type", "Win32");
+ else
+ settings.setValue("Type", "UWP");
settings.setValue("bCloseWhenDone", 0 + ui.cbCloseWhenDone->isChecked());
@@ -89,17 +86,13 @@ void GloSC::updateTargetsToNewVersion()
on_lwInstances_currentRowChanged(i);
QString name = ui.leName->text();
- QSettings settings(name + "\\TargetConfig.ini", QSettings::IniFormat);
+ QSettings settings("./targets/" + name + ".ini", QSettings::IniFormat);
settings.beginGroup("BaseConf");
unsigned int version = settings.value("version").toInt();
settings.endGroup();
if (version < GLOSC_VERSION)
- {
- QFile file(name + "\\" + name + ".exe");
- file.remove();
on_pbSave_clicked();
- }
}
}
@@ -165,6 +158,7 @@ void GloSC::on_pbCreateNew_clicked()
ui.cbLaunchGame->setChecked(false);
ui.lePath->setText("");
+ ui.leArguments->setText("");
ui.cbCloseWhenDone->setChecked(false);
animate(wide_x);
@@ -182,48 +176,10 @@ void GloSC::on_pbSave_clicked()
if (temp.remove(" ") == "")
return;
- QDir dir(name);
+ QDir dir("targets");
if (!dir.exists())
dir.mkdir(".");
-#ifdef NDEBUG
- QString fileNames[] = {
- "Qt5Core.dll",
- "Qt5Gui.dll",
- "Qt5Widgets.dll",
- "sfml-system-2.dll",
- "sfml-window-2.dll",
- "sfml-graphics-2.dll",
- "ViGEmUM.dll",
- "TargetConfig.ini" };
-#else
- QString fileNames[] = {
- "Qt5Cored.dll",
- "Qt5Guid.dll",
- "Qt5Widgetsd.dll",
- "sfml-system-d-2.dll",
- "sfml-window-d-2.dll",
- "sfml-graphics-d-2.dll",
- "ViGEmUM.dll",
- "TargetConfig.ini"
-};
-#endif
-
- for (auto &fileName : fileNames)
- {
- QFile::copy(fileName, dir.path() + "\\" + fileName);
- }
- QDir platformdir(name + "\\platforms");
- if (!platformdir.exists())
- platformdir.mkdir(".");
-
- QFile file(dir.path() + "\\" + name + ".exe");
- file.remove();
-
-
- QFile::copy("platforms\\qwindows.dll", dir.path() + "\\" + "platforms\\qwindows.dll");
- QFile::copy("SteamTarget.exe", dir.path() + "\\" + name + ".exe");
-
writeIni(name);
updateEntryList();
@@ -235,19 +191,15 @@ void GloSC::on_pbSave_clicked()
void GloSC::on_pbDelete_clicked()
{
QString name = ui.leName->text();
- name.remove("\\");
- name.remove("/");
- name.remove(":");
- name.remove(".");
QString temp = name;
if (temp.remove(" ") == "")
return;
- QDir dir(name);
- if (dir.exists())
+ QFile file("./targets/" + name + ".ini");
+ if (file.exists())
{
- dir.removeRecursively();
+ file.remove();
}
updateEntryList();
@@ -290,11 +242,11 @@ void GloSC::on_pbAddToSteam_clicked()
int shortcutCount = QString(temp).toInt();
QString itemName;
- QString appDir = QDir::toNativeSeparators(QCoreApplication::applicationFilePath().mid(0, QCoreApplication::applicationFilePath().lastIndexOf("/")));
+ QDir appDir = QDir::current();
for (int i = 0; i < ui.lwInstances->count(); i++)
{
itemName = ui.lwInstances->item(i)->text();
- if (!shortcutsFileBytes.contains(QString(appDir + "\\" + itemName + "\\" + itemName + ".exe").toStdString().c_str()))
+ if (!shortcutsFileBytes.contains(("\"" + QDir::toNativeSeparators(appDir.absoluteFilePath("SteamTarget.exe")) + "\"" + " \"./targets/" + itemName + ".ini\"").toStdString().c_str()))
{
shortcutsFileBytes.chop(2); //chop of end bytes
shortcutCount++;
@@ -310,12 +262,12 @@ void GloSC::on_pbAddToSteam_clicked()
shortcutsFileBytes.append('\x01');
shortcutsFileBytes.append("exe");
shortcutsFileBytes.append('\x00');
- shortcutsFileBytes.append(QString("\"" + appDir + "\\" + itemName + "\\" + itemName + ".exe\""));
+ shortcutsFileBytes.append("\"" + QDir::toNativeSeparators(appDir.absoluteFilePath("SteamTarget.exe")) + "\"" + " \"./targets/" + itemName + ".ini\"");
shortcutsFileBytes.append('\x00');
shortcutsFileBytes.append('\x01');
shortcutsFileBytes.append("StartDir");
shortcutsFileBytes.append('\x00');
- shortcutsFileBytes.append(QString("\"" + appDir + "\\" + itemName + "\\" + "\""));
+ shortcutsFileBytes.append("\"" + QDir::toNativeSeparators(appDir.absolutePath()) + "\"");
shortcutsFileBytes.append('\x00');
shortcutsFileBytes.append('\x01');
shortcutsFileBytes.append("icon");
@@ -376,16 +328,14 @@ void GloSC::on_pbAddToSteam_clicked()
void GloSC::on_pbSearchPath_clicked()
{
QString filePath = QFileDialog::getOpenFileName(this, "Select Game", "", "*.exe");
- ui.lePath->setText(filePath);
- if (filePath.length() > 0)
+ if (!filePath.isEmpty())
{
- QString name;
- if (filePath.contains("\\"))
- name = filePath.mid(filePath.lastIndexOf("\\") + 1, -1);
- else
- name = filePath.mid(filePath.lastIndexOf("/") + 1, -1);
+ QFileInfo fileInfo(filePath);
+ ui.lePath->setText(fileInfo.filePath());
+ QString name = fileInfo.fileName();
name.chop(4);
ui.leName->setText(name);
+ ui.cbLaunchGame->setChecked(true);
}
}
@@ -488,6 +438,7 @@ void GloSC::on_pbUWP_clicked()
{
ui.lePath->setText(uwpPairs.at(selection).AppUMId);
ui.leName->setText(uwpPairs.at(selection).AppName);
+ ui.cbLaunchGame->setChecked(true);
}
}
@@ -499,7 +450,7 @@ void GloSC::on_lwInstances_currentRowChanged(int row)
QString entryName = ui.lwInstances->item(row)->text();
ui.leName->setText(entryName);
- QSettings settings(entryName + "\\TargetConfig.ini", QSettings::IniFormat);
+ QSettings settings("./targets/" + entryName + ".ini", QSettings::IniFormat);
settings.beginGroup("BaseConf");
@@ -523,10 +474,8 @@ void GloSC::on_lwInstances_currentRowChanged(int row)
settings.beginGroup("LaunchGame");
ui.cbLaunchGame->setChecked(settings.value("bLaunchGame").toBool());
- if (ui.cbLaunchGame->isChecked())
- {
- ui.lePath->setText(settings.value("Path").toString());
- }
+ ui.lePath->setText(settings.value("Path").toString());
+ ui.leArguments->setText(settings.value("Args").toString());
ui.cbCloseWhenDone->setChecked(settings.value("bCloseWhenDone").toBool());
settings.endGroup();
diff --git a/GloSC/GloSC.ui b/GloSC/GloSC.ui
index 34d2f03..f57a168 100644
--- a/GloSC/GloSC.ui
+++ b/GloSC/GloSC.ui
@@ -103,41 +103,28 @@
Config
-
-
-
- 40
- 251
- 261
- 20
-
-
-
-
+
- 344
- 250
+ 10
+ 29
41
- 23
+ 21
- UWP
+ Name:
-
+
- 300
- 250
- 41
- 23
+ 50
+ 29
+ 331
+ 21
-
- ...
-
@@ -171,11 +158,42 @@
true
+
+
+
+ 10
+ 120
+ 371
+ 41
+
+
+
+ Use Desktop-Config
+Disables hooking, per application bindings won't work
+
+
+
+
+
+ 10
+ 160
+ 371
+ 41
+
+
+
+ Hook Steam
+Enforces bindings reliably by hooking into Steam
+
+
+ true
+
+
10
- 230
+ 210
371
17
@@ -184,11 +202,11 @@
Launch game
-
+
10
- 251
+ 231
31
20
@@ -197,57 +215,64 @@
Path:
-
+
- 10
- 330
- 231
- 31
+ 40
+ 231
+ 271
+ 21
-
- font: 87 8pt "Arial Black";
+
+
+
+
+ 310
+ 230
+ 31
+ 23
+
- Save
+ ...
-
+
- 10
- 33
- 47
- 13
+ 340
+ 230
+ 41
+ 23
- Name:
+ UWP
-
+
- 50
- 30
- 331
+ 10
+ 255
+ 61
20
+
+ Arguments:
+
-
+
- 250
- 330
- 131
- 31
+ 70
+ 255
+ 310
+ 21
-
- Delete
-
@@ -263,35 +288,33 @@
(Disable for Uplay-games!)
-
+
10
- 170
- 371
- 41
+ 330
+ 231
+ 31
-
- Hook Steam
-Enforces bindings reliably by hooking into Steam
+
+ font: 87 8pt "Arial Black";
-
- true
+
+ Save
-
+
- 10
- 130
- 371
- 41
+ 250
+ 330
+ 131
+ 31
- Use Desktop-Config
-Disables hooking, per application bindings won't work
+ Delete
diff --git a/GloSC_GameLauncher/GloSC_GameLauncher.cpp b/GloSC_GameLauncher/GloSC_GameLauncher.cpp
index 23e5eaf..d54b305 100644
--- a/GloSC_GameLauncher/GloSC_GameLauncher.cpp
+++ b/GloSC_GameLauncher/GloSC_GameLauncher.cpp
@@ -75,7 +75,18 @@ void GloSC_GameLauncher::checkSharedMem()
{
if (stringList.at(i + 1) != "" && stringList.at(i + 2) != "")
{
- launchGame(stringList.at(i + 1), stringList.at(i + 2));
+ QStringList args;
+ QRegularExpression re("([^\\s\"']+)|\"([^\"]*)\"|'([^']*)'");
+ QRegularExpressionMatchIterator ri = re.globalMatch(stringList.at(i + 3));
+ while (ri.hasNext())
+ {
+ QRegularExpressionMatch match = ri.next();
+ int mi = 1;
+ while (match.captured(mi).isEmpty())
+ mi++;
+ args += match.captured(mi);
+ }
+ launchGame(stringList.at(i + 1), stringList.at(i + 2), args);
stringList = defaultSharedMemData;
}
}
@@ -117,7 +128,7 @@ void GloSC_GameLauncher::checkSharedMem()
}
}
-void GloSC_GameLauncher::launchGame(QString type, QString path)
+void GloSC_GameLauncher::launchGame(QString type, QString path, QStringList args)
{
if (type == LGT_Win32)
@@ -125,11 +136,11 @@ void GloSC_GameLauncher::launchGame(QString type, QString path)
QProcess app;
if (path.contains("\\"))
{
- app.startDetached(path, QStringList(), path.mid(0, path.lastIndexOf("\\")), &pid);
+ app.startDetached(path, args, path.mid(0, path.lastIndexOf("\\")), &pid);
}
else
{
- app.startDetached(path, QStringList(), path.mid(0, path.lastIndexOf("/")), &pid);
+ app.startDetached(path, args, path.mid(0, path.lastIndexOf("/")), &pid);
}
} else if (type == LGT_UWP) {
diff --git a/GloSC_GameLauncher/GloSC_GameLauncher.h b/GloSC_GameLauncher/GloSC_GameLauncher.h
index 5fd5d67..59bc610 100644
--- a/GloSC_GameLauncher/GloSC_GameLauncher.h
+++ b/GloSC_GameLauncher/GloSC_GameLauncher.h
@@ -28,6 +28,7 @@ limitations under the License.
#include
#include
+#include
#include
#include
@@ -36,16 +37,16 @@ limitations under the License.
class GloSC_GameLauncher : public QMainWindow
{
- Q_OBJECT
+ Q_OBJECT
public:
- GloSC_GameLauncher(QWidget *parent = Q_NULLPTR);
+ GloSC_GameLauncher(QWidget *parent = Q_NULLPTR);
public slots:
void isAboutToBeKilled();
private:
- Ui::GloSC_GameLauncherClass ui;
+ Ui::GloSC_GameLauncherClass ui;
const QString LaunchGame = "LaunchGame";
const QString LGT_UWP = "UWP";
@@ -56,6 +57,7 @@ private:
<< LaunchGame
<< ""
<< ""
+ << ""
<< LaunchedProcessFinished
<< "0"
<< IsSteamHooked
@@ -70,7 +72,7 @@ private:
bool bHookedSteam = false;
- void launchGame(QString type, QString path);
+ void launchGame(QString type, QString path, QStringList args);
HRESULT LaunchUWPApp(LPCWSTR packageFullName, PDWORD pdwProcessId);
diff --git a/SteamTarget/SteamTargetRenderer.cpp b/SteamTarget/SteamTargetRenderer.cpp
index 978d6d3..778d31f 100644
--- a/SteamTarget/SteamTargetRenderer.cpp
+++ b/SteamTarget/SteamTargetRenderer.cpp
@@ -26,7 +26,12 @@ SteamTargetRenderer::SteamTargetRenderer(int& argc, char** argv) : QApplication(
loadLogo();
SetConsoleCtrlHandler(reinterpret_cast(ConsoleCtrlCallback), true);
- QSettings settings(".\\TargetConfig.ini", QSettings::IniFormat);
+ if (this->arguments().size() == 1)
+ {
+ std::cerr << "Target configuration file must be specified" << std::endl;
+ QApplication::exit(1);
+ }
+ QSettings settings(this->arguments().at(1), QSettings::IniFormat);
settings.beginGroup("BaseConf");
const QStringList childKeys = settings.childKeys();
for (auto &childkey : childKeys)
@@ -38,7 +43,7 @@ SteamTargetRenderer::SteamTargetRenderer(int& argc, char** argv) : QApplication(
bDrawOverlay = settings.value(childkey).toBool();
} else if (childkey == "bEnableControllers") {
bEnableControllers = settings.value(childkey).toBool();
- }else if (childkey == "bHookSteam") {
+ } else if (childkey == "bHookSteam") {
bHookSteam = settings.value(childkey).toBool();
}
else if (childkey == "bUseDesktopConfig") {
@@ -126,11 +131,9 @@ void SteamTargetRenderer::RunSfWindowLoop()
bool focusSwitchNeeded = true;
if (bDrawOverlay)
- {
SetWindowPos(sfWindow.getSystemHandle(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_ASYNCWINDOWPOS);
- } else {
+ else
ShowWindow(consoleHwnd, SW_SHOW);
- }
while (sfWindow.isOpen() && bRunLoop)
@@ -287,7 +290,7 @@ void SteamTargetRenderer::hookBindings()
QProcess proc;
proc.setNativeArguments(" --inject ");
proc.setWorkingDirectory(dir);
- proc.start("..\\Injector.exe", QIODevice::ReadOnly);
+ proc.start("./Injector.exe", QIODevice::ReadOnly);
proc.waitForStarted();
proc.waitForFinished();
@@ -402,24 +405,22 @@ void SteamTargetRenderer::launchApp()
bool closeWhenDone = false;
QString type = "Win32";
QString path = "";
- QSettings settings(".\\TargetConfig.ini", QSettings::IniFormat);
+ QString args;
+ QSettings settings(this->arguments().at(1), QSettings::IniFormat);
settings.beginGroup("LaunchGame");
const QStringList childKeys = settings.childKeys();
for (auto &childkey : childKeys)
{
if (childkey == "bLaunchGame")
- {
launchGame = settings.value(childkey).toBool();
- }
- else if (childkey == "Type") {
+ else if (childkey == "Type")
type = settings.value(childkey).toString();
- }
- else if (childkey == "Path") {
+ else if (childkey == "Path")
path = settings.value(childkey).toString();
- }
- else if (childkey == "bCloseWhenDone") {
+ else if (childkey == "Args")
+ args = settings.value(childkey).toString();
+ else if (childkey == "bCloseWhenDone")
closeWhenDone = settings.value("bCloseWhenDone").toBool();
- }
}
settings.endGroup();
@@ -445,7 +446,7 @@ void SteamTargetRenderer::launchApp()
int lgt_index = stringList.indexOf(LaunchGame);
stringList.replace(lgt_index + 1, type);
stringList.replace(lgt_index + 2, path);
-
+ stringList.replace(lgt_index + 3, args);
buffer.open(QBuffer::ReadWrite);
@@ -488,16 +489,10 @@ void SteamTargetRenderer::checkSharedMem()
sharedMemInstance.unlock();
sharedMemInstance.detach();
- int close_index = stringList.indexOf(LaunchedProcessFinished)+1;
+ int close_index = stringList.indexOf(LaunchedProcessFinished) + 1;
if (close_index > 0 && stringList.at(close_index).toInt() == 1)
- {
bRunLoop = false;
- renderThread.join();
- if (controllerThread.isRunning())
- controllerThread.stop();
- exit(0);
- }
}
diff --git a/TargetConfig.ini b/TargetConfig.ini
index 6ca6d85..33d2ad9 100644
--- a/TargetConfig.ini
+++ b/TargetConfig.ini
@@ -10,4 +10,5 @@ version=288
bLaunchGame=0
Type=Win32
Path=
+Args=
bCloseWhenDone=1
\ No newline at end of file