Add dialog/functionality to inform user on "SteamController_XBoxSupport"

pull/179/head
Peter Repukat 2 years ago
parent 40390b568d
commit 7208d7e036

@ -137,6 +137,7 @@
<ClCompile Include="UIModel.cpp" />
<None Include=".clang-format" />
<None Include="GetAUMIDs.ps1" />
<None Include="qml\SteamInputXboxDisabledDialog.qml" />
<None Include="qml\AddSelectTypeDialog.qml" />
<None Include="qml\FluentTextInput.qml" />
<None Include="qml\InfoDialog.qml" />

@ -68,6 +68,9 @@
<None Include="qml\SteamNotFoundDialog.qml">
<Filter>qml</Filter>
</None>
<None Include="qml\SteamInputXboxDisabledDialog.qml">
<Filter>qml</Filter>
</None>
</ItemGroup>
<ItemGroup>
<QtMoc Include="UIModel.h">

@ -51,8 +51,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,0,8,102000500230
PRODUCTVERSION 0,0,8,102000500230
FILEVERSION 0,0,8,105004039005
PRODUCTVERSION 0,0,8,105004039005
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -69,12 +69,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Peter Repukat - FlatspotSoftware"
VALUE "FileDescription", "GlosSI - Config"
VALUE "FileVersion", "0.0.8.1-2-gc5fc23d"
VALUE "FileVersion", "0.0.8.1-5-g40390b5"
VALUE "InternalName", "GlosSIConfig"
VALUE "LegalCopyright", "Copyright (C) 2021 Peter Repukat - FlatspotSoftware"
VALUE "OriginalFilename", "GlosSIConfig.exe"
VALUE "ProductName", "GlosSI"
VALUE "ProductVersion", "0.0.8.1-2-gc5fc23d"
VALUE "ProductVersion", "0.0.8.1-5-g40390b5"
END
END
BLOCK "VarFileInfo"
@ -800,6 +800,78 @@ IDI_ICON1 ICON "..\GloSC_Icon.ico"

@ -237,6 +237,46 @@ QVariantMap UIModel::manualProps(QVariant shortcut)
return res;
}
void UIModel::enableSteamInputXboxSupport()
{
if (foundSteam()) {
const std::filesystem::path config_path = std::wstring(getSteamPath()) + user_data_path_.toStdWString() + getSteamUserId() + user_config_file_.toStdWString();
if (!std::filesystem::exists(config_path)) {
qDebug() << "localconfig.vdf does not exist.";
}
QFile file(config_path);
if (file.open(QIODevice::Text | QIODevice::ReadOnly)) {
QTextStream in(&file);
QStringList lines;
QString line = in.readLine();
// simple approach is enough...
while (!in.atEnd()) {
if (line.contains("SteamController_XBoxSupport")) {
if (line.contains("1")) {
qDebug() << "\"SteamController_XBoxSupport\" is already enabled! aborting write...";
file.close();
return;
}
qDebug() << "found \"SteamController_XBoxSupport\" line, replacing value...";
line.replace("0", "1");
}
lines.push_back(line);
line = in.readLine();
}
file.close();
QFile updatedFile(config_path);
if (updatedFile.open(QFile::WriteOnly | QFile::Truncate | QFile::Text)) {
qDebug() << "writing localconfig.vdf...";
QTextStream out(&updatedFile);
for (const auto& l : lines) {
out << l << "\n";
}
}
updatedFile.close();
}
}
}
#ifdef _WIN32
QVariantList UIModel::uwpApps()
{
@ -436,3 +476,39 @@ void UIModel::parseShortcutVDF()
qDebug() << "Error parsing VDF: " << e.what();
}
}
bool UIModel::isSteamInputXboxSupportEnabled() const
{
// return true as default to not bug the user in error cases.
if (foundSteam()) {
const std::filesystem::path config_path = std::wstring(getSteamPath()) + user_data_path_.toStdWString() + getSteamUserId() + user_config_file_.toStdWString();
if (!std::filesystem::exists(config_path)) {
qDebug() << "localconfig.vdf does not exist.";
return true;
}
QFile file(config_path);
if (file.open(QIODevice::Text | QIODevice::ReadOnly)) {
QTextStream in(&file);
QString line = in.readLine();
// simple, regex approach should be enough...
while (!in.atEnd()) {
if (line.contains("SteamController_XBoxSupport")) {
file.close();
if (line.contains("1")) {
qDebug() << "\"SteamController_XBoxSupport\" is enabled!";
return true;
}
qDebug() << "\"SteamController_XBoxSupport\" is disabled!";
return false;
}
line = in.readLine();
}
qDebug() << "couldn't find \"SteamController_XBoxSupport\" in localconfig.vdf";
file.close();
}
else {
qDebug() << "could not open localconfig.vdf";
}
}
return true;
}

@ -28,6 +28,7 @@ class UIModel : public QObject {
Q_PROPERTY(QVariantList targetList READ getTargetList NOTIFY targetListChanged)
Q_PROPERTY(QVariantList uwpList READ uwpApps CONSTANT)
Q_PROPERTY(bool foundSteam READ foundSteam CONSTANT)
Q_PROPERTY(bool steamInputXboxSupportEnabled READ isSteamInputXboxSupportEnabled CONSTANT)
public:
UIModel();
@ -42,6 +43,7 @@ class UIModel : public QObject {
bool addToSteam(const QString& name, const QString& shortcutspath, bool from_cmd = false);
Q_INVOKABLE bool removeFromSteam(const QString& name, const QString& shortcutspath, bool from_cmd = false);
Q_INVOKABLE QVariantMap manualProps(QVariant shortcut);
Q_INVOKABLE void enableSteamInputXboxSupport();
#ifdef _WIN32
Q_INVOKABLE QVariantList uwpApps();
#endif
@ -71,7 +73,11 @@ class UIModel : public QObject {
std::wstring getSteamUserId() const;
bool foundSteam() const;
void parseShortcutVDF();
bool isSteamInputXboxSupportEnabled() const;
QString shortcutsfile_ = "/config/shortcuts.vdf";
QString user_config_file_ = "/config/localconfig.vdf";
QString user_data_path_ = "/userdata/";
QVariantList targets_;

@ -16,5 +16,6 @@
<file>GloSC_Icon_small.png</file>
<file>svg/help_outline_white_24dp.svg</file>
<file>qml/SteamNotFoundDialog.qml</file>
<file>qml/SteamInputXboxDisabledDialog.qml</file>
</qresource>
</RCC>

@ -0,0 +1,111 @@
/*
Copyright 2021-2022 Peter Repukat - FlatspotSoftware
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import QtQuick 6.2
import QtQuick.Controls 6.2
import QtQuick.Layouts 6.2
import QtQuick.Controls.Material 6.2
Dialog {
id: dlg
anchors.centerIn: parent
signal confirmed(var param)
visible: false
modal: true
dim: true
parent: Overlay.overlay
Overlay.modal: Rectangle {
color: Qt.rgba(0,0,0,0.4)
opacity: backdropOpacity
Behavior on opacity {
NumberAnimation {
duration: 300
}
}
}
property real backdropOpacity: 1.0
enter: Transition {
NumberAnimation{target: content; property: "y"; from: parent.height; to: 16; duration: 300; easing.type: Easing.OutQuad }
NumberAnimation{target: background; property: "y"; from: parent.height; to: 0; duration: 300; easing.type: Easing.OutQuad }
NumberAnimation{target: dlg; property: "backdropOpacity"; from: 0; to: 1; duration: 300; easing.type: Easing.OutQuad }
}
exit: Transition {
NumberAnimation{target: content; property: "y"; from: 16; to: parent.height; duration: 300; easing.type: Easing.InQuad }
NumberAnimation{target: background; property: "y"; from: 0; to: parent.height; duration: 300; easing.type: Easing.InQuad }
NumberAnimation{target: dlg; property: "backdropOpacity"; from: 1; to: 0; duration: 300; easing.type: Easing.InQuad }
}
background: RPane {
id: background
radius: 4
Material.elevation: 64
bgOpacity: 0.97
}
contentItem: Item {
id: content
clip: true
Column {
spacing: 4
bottomPadding: 96
Label {
id: titlelabel
text: qsTr("Steam Input Xbox support disabled")
font.pixelSize: 24
font.bold: true
}
Item {
height: 32
}
Label {
text: qsTr("Please enable \"Xbox configuration support\" in Steams controller settings.\n\nGlosSI cannot function properly with this setting disabled\n\nEnable now?")
wrapMode: Text.WordWrap
width: parent.width
}
Row {
anchors.right: parent.right
anchors.topMargin: 16
anchors.rightMargin: 2
spacing: 8
Button {
id: noBtn
text: qsTr("No")
onClicked: dlg.close()
}
Button {
id: yesBtn
text: qsTr("Yes")
onClicked: function() {
uiModel.enableSteamInputXboxSupport();
dlg.close();
steamChangedDialog2.open();
}
}
}
}
InfoDialog {
id: steamChangedDialog2
titleText: qsTr("Attention!")
text: qsTr("Please restart Steam to reload your changes!")
onConfirmed: function (callback) {
callback();
}
}
}
}

@ -48,6 +48,10 @@ Window {
Component.onCompleted: function() {
if (!uiModel.foundSteam) {
steamNotFoundDialog.open();
return;
}
if (!uiModel.steamInputXboxSupportEnabled) {
steamXboxDisabledDialog.open();
}
}
@ -64,6 +68,10 @@ Window {
SteamNotFoundDialog {
id: steamNotFoundDialog
}
SteamInputXboxDisabledDialog {
id: steamXboxDisabledDialog
}
InfoDialog {
id: steamChangedDialog

Loading…
Cancel
Save