OpenVR compat configurable in dashboard

This commit is contained in:
Patrick Nicolas
2025-04-29 19:40:36 +02:00
parent acd35e3ebd
commit e759b93d69
3 changed files with 113 additions and 1 deletions
+78 -1
View File
@@ -336,7 +336,7 @@ Kirigami.ScrollablePage {
enabled: adb_custom.checked enabled: adb_custom.checked
Controls.TextField { Controls.TextField {
id: adb_location id: adb_location
placeholderText: settings.adb placeholderText: settings.adb_location
Layout.fillWidth: true Layout.fillWidth: true
} }
Controls.Button { Controls.Button {
@@ -345,6 +345,75 @@ Kirigami.ScrollablePage {
} }
} }
ListModel {
id: openvr_libs
function init() {
openvr_libs.append({
"name": i18n("Default"),
"value": "",
"is_custom": false
});
if (config.flatpak) {
openvr_libs.append({
"name": i18n("xrizer"),
"value": "xrizer",
"is_custom": false
});
openvr_libs.append({
"name": i18n("Open Composite"),
"value": "OpenComposite",
"is_custom": false
});
}
openvr_libs.append({
"name": i18nc("set a custom OpenVR compatibility library", "Custom"),
"is_custom": true
});
openvr_libs.append({
"name": i18n("Disabled"),
"value": "-",
"is_custom": false
});
}
}
RowLayout {
Kirigami.FormData.label: i18n("OpenVR compatibility library:")
Layout.fillWidth: true
Controls.ComboBox {
id: openvr_combobox
Layout.columnSpan: 2
textRole: "name"
model: openvr_libs
function load() {
for(let i=0 ; i < openvr_libs.count; i++) {
if (openvr_libs.get(i).value == config.openvr) {
openvr_combobox.currentIndex = i;
return;
}
}
for(let i=0 ; i < openvr_libs.count; i++) {
if (openvr_libs.get(i).is_custom) {
openvr_text.text = config.openvr
openvr_combobox.currentIndex = i;
return;
}
}
}
}
Controls.TextField {
id: openvr_text
placeholderText: i18n("Library path, excluding bin/linux64/vrclient.so")
visible: !!openvr_combobox.model.get(openvr_combobox.currentIndex)?.is_custom
Layout.fillWidth: true
}
}
} }
Item { Item {
@@ -370,6 +439,7 @@ Kirigami.ScrollablePage {
} }
Component.onCompleted: { Component.onCompleted: {
openvr_libs.init()
config.load(WivrnServer); config.load(WivrnServer);
settings.load(); settings.load();
} }
@@ -378,6 +448,12 @@ Kirigami.ScrollablePage {
config.bitrate = bitrate.value * 1000000; config.bitrate = bitrate.value * 1000000;
config.scale = manual_foveation.checked ? 1 - scale_slider.value / 100.0 : -1; config.scale = manual_foveation.checked ? 1 - scale_slider.value / 100.0 : -1;
config.manualEncoders = encoder_layout.currentIndex > 0; config.manualEncoders = encoder_layout.currentIndex > 0;
let openvr = openvr_combobox.model.get(openvr_combobox.currentIndex)
if (openvr.is_custom) {
config.openvr = openvr_text.text;
} else {
config.openvr = openvr.value
}
settings.adb_custom = adb_custom.checked; settings.adb_custom = adb_custom.checked;
settings.adb_location = adb_location.text; settings.adb_location = adb_location.text;
Adb.setPath(adb_custom.checked ? adb_location.text : "adb"); Adb.setPath(adb_custom.checked ? adb_location.text : "adb");
@@ -400,6 +476,7 @@ Kirigami.ScrollablePage {
// auto_encoders.checked = true; // auto_encoders.checked = true;
encoder_layout.currentIndex = 0; encoder_layout.currentIndex = 0;
} }
openvr_combobox.load()
adb_custom.checked = settings.adb_custom; adb_custom.checked = settings.adb_custom;
adb_location.text = settings.adb_location; adb_location.text = settings.adb_location;
+29
View File
@@ -19,6 +19,7 @@
#include "settings.h" #include "settings.h"
#include "escape_string.h" #include "escape_string.h"
#include "utils/flatpak.h"
#include "wivrn_server.h" #include "wivrn_server.h"
#include <QList> #include <QList>
#include <QObject> #include <QObject>
@@ -211,6 +212,22 @@ void Settings::load(const wivrn_server * server)
{ {
set_application(""); set_application("");
} }
// OpenVR compat library
try
{
if (auto it = json_doc.find("openvr-compat-path"); it != json_doc.end())
{
if (it->is_null())
set_openvr("-");
else
set_openvr(QString::fromStdString(*it));
}
}
catch (...)
{
set_openvr("");
}
} }
void Settings::save(wivrn_server * server) void Settings::save(wivrn_server * server)
@@ -281,6 +298,13 @@ void Settings::save(wivrn_server * server)
if (application() != "") if (application() != "")
json_doc["application"] = unescape_string(application()); json_doc["application"] = unescape_string(application());
if (openvr() == "-")
json_doc["openvr-compat-path"] = nullptr;
else if (openvr() == "")
json_doc.erase("openvr-compat-path");
else
json_doc["openvr-compat-path"] = openvr().toStdString();
server->setJsonConfiguration(QString::fromStdString(json_doc.dump(2))); server->setJsonConfiguration(QString::fromStdString(json_doc.dump(2)));
} }
@@ -318,4 +342,9 @@ void Settings::set_encoder_preset(QJSValue preset)
set_encoders(encoders); set_encoders(encoders);
} }
bool Settings::flatpak() const
{
return wivrn::is_flatpak();
}
#include "moc_settings.cpp" #include "moc_settings.cpp"
+6
View File
@@ -123,6 +123,9 @@ class Settings : public QObject
Q_PROPERTY(float scale READ scale WRITE set_scale NOTIFY scaleChanged) Q_PROPERTY(float scale READ scale WRITE set_scale NOTIFY scaleChanged)
Q_PROPERTY(QString application READ application WRITE set_application NOTIFY applicationChanged) Q_PROPERTY(QString application READ application WRITE set_application NOTIFY applicationChanged)
Q_PROPERTY(bool tcpOnly READ tcpOnly WRITE set_tcpOnly NOTIFY tcpOnlyChanged) Q_PROPERTY(bool tcpOnly READ tcpOnly WRITE set_tcpOnly NOTIFY tcpOnlyChanged)
Q_PROPERTY(QString openvr READ openvr WRITE set_openvr NOTIFY openvrChanged)
Q_PROPERTY(bool flatpak READ flatpak CONSTANT)
SETTER_GETTER_NOTIFY(bool, manualEncoders) SETTER_GETTER_NOTIFY(bool, manualEncoders)
SETTER_GETTER_NOTIFY(std::vector<encoder>, encoders) SETTER_GETTER_NOTIFY(std::vector<encoder>, encoders)
@@ -131,6 +134,7 @@ class Settings : public QObject
SETTER_GETTER_NOTIFY(float, scale) SETTER_GETTER_NOTIFY(float, scale)
SETTER_GETTER_NOTIFY(QString, application) SETTER_GETTER_NOTIFY(QString, application)
SETTER_GETTER_NOTIFY(bool, tcpOnly) SETTER_GETTER_NOTIFY(bool, tcpOnly)
SETTER_GETTER_NOTIFY(QString, openvr)
public: public:
Settings(QObject * parent = nullptr) : Settings(QObject * parent = nullptr) :
@@ -141,6 +145,8 @@ public:
Q_INVOKABLE void restore_defaults(); Q_INVOKABLE void restore_defaults();
Q_INVOKABLE void set_encoder_preset(QJSValue preset); Q_INVOKABLE void set_encoder_preset(QJSValue preset);
bool flatpak() const;
static std::optional<encoder::encoder_name> encoder_id_from_string(std::string_view s); static std::optional<encoder::encoder_name> encoder_id_from_string(std::string_view s);
static std::optional<encoder::video_codec> codec_id_from_string(std::string_view s); static std::optional<encoder::video_codec> codec_id_from_string(std::string_view s);
static const std::string & encoder_from_id(std::optional<encoder::encoder_name> id); static const std::string & encoder_from_id(std::optional<encoder::encoder_name> id);