Rework the wizard APK downloading, install directly instead of telling the user to use ADB. Add setting to choose which game to start automatically.
This commit is contained in:
+1
-2
@@ -45,8 +45,6 @@ option(WIVRN_OPENXR_INSTALL_ABSOLUTE_RUNTIME_PATH OFF)
|
||||
|
||||
option(ENABLE_COLOURED_OUTPUT "Always produce ANSI-coloured output (GNU/Clang only)." ON)
|
||||
|
||||
set(WIVRN_CLIENT_URL "https://github.com/WiVRn/WiVRn/releases/latest/download/WiVRn-standard-release.apk" CACHE STRING "URL used to download the client in the GUI")
|
||||
|
||||
if(ENABLE_COLOURED_OUTPUT)
|
||||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
add_compile_options(-fdiagnostics-color=always)
|
||||
@@ -150,6 +148,7 @@ endif()
|
||||
|
||||
if (WIVRN_BUILD_DASHBOARD)
|
||||
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets DBus Network LinguistTools)
|
||||
find_package(nlohmann_json REQUIRED)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
|
||||
@@ -5,6 +5,12 @@ execute_process(
|
||||
ERROR_QUIET
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
||||
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
|
||||
OUTPUT_VARIABLE GIT_COMMIT
|
||||
ERROR_QUIET
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
||||
|
||||
if (GIT_DESC)
|
||||
string(STRIP ${GIT_DESC} GIT_DESC)
|
||||
message(STATUS "Setting version to ${GIT_DESC} from git")
|
||||
@@ -13,4 +19,12 @@ else()
|
||||
message(STATUS "Setting version to ${GIT_DESC} from CMakeLists")
|
||||
endif()
|
||||
|
||||
if (GIT_COMMIT)
|
||||
string(STRIP ${GIT_COMMIT} GIT_COMMIT)
|
||||
message(STATUS "Setting commit to ${GIT_COMMIT}")
|
||||
else()
|
||||
set(GIT_COMMIT "")
|
||||
message(STATUS "Not setting commit")
|
||||
endif()
|
||||
|
||||
configure_file(${INPUT_FILE} ${OUTPUT_FILE})
|
||||
|
||||
@@ -21,4 +21,7 @@ namespace wivrn
|
||||
{
|
||||
extern const char git_version[];
|
||||
const char git_version[] = "@GIT_DESC@";
|
||||
|
||||
extern const char git_commit[];
|
||||
const char git_commit[] = "@GIT_COMMIT@";
|
||||
}
|
||||
|
||||
@@ -8,5 +8,6 @@ namespace wivrn
|
||||
using protocol = std::variant<from_headset::packets, to_headset::packets>;
|
||||
|
||||
extern const char git_version[];
|
||||
extern const char git_commit[];
|
||||
static inline const constinit auto protocol_version = serialization_type_hash<protocol>();
|
||||
} // namespace wivrn
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
|
||||
if (GIT_DESC)
|
||||
configure_file(version.cpp.in version.cpp)
|
||||
else ()
|
||||
add_custom_target(wivrn-dashboard-version ALL
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-D GIT_EXECUTABLE=${GIT_EXECUTABLE}
|
||||
-D INPUT_FILE=${CMAKE_CURRENT_SOURCE_DIR}/version.cpp.in
|
||||
-D OUTPUT_FILE=${CMAKE_CURRENT_BINARY_DIR}/version.cpp
|
||||
-D CMAKE_PROJECT_VERSION=${CMAKE_PROJECT_VERSION}
|
||||
-P ${CMAKE_SOURCE_DIR}/cmake/GitVersion.cmake
|
||||
BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/version.cpp
|
||||
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/version.cpp.in
|
||||
)
|
||||
endif()
|
||||
|
||||
qt_add_executable(wivrn-dashboard
|
||||
main.cpp
|
||||
main_window.cpp
|
||||
@@ -13,8 +29,12 @@ qt_add_executable(wivrn-dashboard
|
||||
wizard.ui
|
||||
rectangle_partitionner.cpp
|
||||
rectangle_partitionner.h
|
||||
steam_app.cpp
|
||||
steam_app.h
|
||||
adb.cpp
|
||||
adb.h
|
||||
../wivrn-dashboard.qrc
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../common/version.cpp
|
||||
${CMAKE_CURRENT_BINARY_DIR}/version.cpp
|
||||
)
|
||||
|
||||
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/../dbus/io.github.wivrn.Server.xml PROPERTIES INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/wivrn_qdbus_types.h")
|
||||
@@ -28,12 +48,12 @@ configure_file(gui_config.h.in gui_config.h)
|
||||
configure_file(io.github.wivrn.wivrn.desktop.in io.github.wivrn.wivrn.desktop)
|
||||
|
||||
target_link_libraries(wivrn-dashboard PRIVATE
|
||||
wivrn-common
|
||||
Qt6::Core
|
||||
Qt6::Gui
|
||||
Qt6::Widgets
|
||||
Qt6::DBus
|
||||
Qt6::Network
|
||||
nlohmann_json
|
||||
)
|
||||
|
||||
file(GLOB TRANSLATION_FILES ${CMAKE_CURRENT_SOURCE_DIR}/wivrn_*.ts)
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2024 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "adb.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QProcess>
|
||||
#include <QPromise>
|
||||
#include <exception>
|
||||
#include <memory>
|
||||
|
||||
template <typename... Args>
|
||||
std::unique_ptr<QProcess> escape_sandbox(const std::string & executable, Args &&... args_orig)
|
||||
{
|
||||
auto process = std::make_unique<QProcess>();
|
||||
QStringList args;
|
||||
|
||||
if (std::filesystem::exists("/.flatpak-info"))
|
||||
{
|
||||
process->setProgram("flatpak-spawn");
|
||||
args.push_back("--host");
|
||||
args.push_back(QString::fromStdString(executable));
|
||||
}
|
||||
else
|
||||
{
|
||||
process->setProgram(QString::fromStdString(executable));
|
||||
}
|
||||
|
||||
(args.push_back(QString::fromStdString(args_orig)), ...);
|
||||
|
||||
process->setArguments(args);
|
||||
|
||||
return process;
|
||||
}
|
||||
|
||||
std::shared_ptr<QPromise<std::vector<adb::device>>> adb::devices()
|
||||
{
|
||||
auto process = escape_sandbox("adb", "devices", "-l");
|
||||
|
||||
process->start();
|
||||
|
||||
auto promise = std::make_shared<QPromise<std::vector<adb::device>>>();
|
||||
|
||||
auto p = process.get();
|
||||
|
||||
QObject::connect(p, &QProcess::finished, [p = std::move(process), promise](int exitCode, QProcess::ExitStatus exitStatus) {
|
||||
try
|
||||
{
|
||||
if (exitCode != 0 or exitStatus != QProcess::NormalExit)
|
||||
{
|
||||
qDebug() << "adb devices exited with code" << exitCode << ", status" << exitStatus;
|
||||
|
||||
QString out = p->readAllStandardOutput();
|
||||
qDebug() << "stdout:" << out;
|
||||
|
||||
QString err = p->readAllStandardError();
|
||||
qDebug() << "stderr:" << err;
|
||||
|
||||
throw std::runtime_error("adb devices failed");
|
||||
}
|
||||
else
|
||||
{
|
||||
auto out = p->readAllStandardOutput();
|
||||
auto lines = QString{out}.split('\n');
|
||||
|
||||
if (not lines.empty())
|
||||
lines.pop_front();
|
||||
|
||||
std::vector<adb::device> devs;
|
||||
for (auto & line: lines)
|
||||
{
|
||||
auto words = line.split(' ', Qt::SkipEmptyParts);
|
||||
device dev;
|
||||
|
||||
if (words.empty())
|
||||
continue;
|
||||
dev._serial = words.front().toStdString();
|
||||
words.pop_front();
|
||||
|
||||
if (words.empty())
|
||||
continue;
|
||||
dev._state = words.front().toStdString();
|
||||
words.pop_front();
|
||||
|
||||
for (auto & word: words)
|
||||
{
|
||||
auto idx = word.indexOf(':');
|
||||
if (idx >= 0)
|
||||
{
|
||||
dev._properties[word.left(idx).toStdString()] = word.mid(idx + 1).toStdString();
|
||||
}
|
||||
}
|
||||
|
||||
devs.push_back(dev);
|
||||
}
|
||||
|
||||
promise->addResult(std::move(devs));
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
promise->setException(std::current_exception());
|
||||
}
|
||||
|
||||
promise->finish();
|
||||
});
|
||||
|
||||
return promise;
|
||||
}
|
||||
|
||||
std::unique_ptr<QProcess> adb::device::install(const std::filesystem::path & path)
|
||||
{
|
||||
return escape_sandbox("adb", "-s", _serial, "install", "-r", path);
|
||||
}
|
||||
|
||||
std::unique_ptr<QProcess> adb::device::uninstall(const std::string & app)
|
||||
{
|
||||
return escape_sandbox("adb", "-s", _serial, "uninstall", app);
|
||||
}
|
||||
|
||||
// void adb::device::start(const std::string& app)
|
||||
// {
|
||||
// auto process = escape_sandbox("adb", "-s", _serial, "shell", "am", "start", app);
|
||||
// process->start();
|
||||
// process->waitForFinished();
|
||||
// }
|
||||
//
|
||||
// void adb::device::stop(const std::string& app)
|
||||
// {
|
||||
// auto process = escape_sandbox("adb", "-s", _serial, "shell", "am", "force-stop", app);
|
||||
// process->start();
|
||||
// process->waitForFinished();
|
||||
// }
|
||||
//
|
||||
// void adb::device::start(const std::string& app, const std::string& action, const std::string& uri)
|
||||
// {
|
||||
// // action: "android.intent.action.VIEW" or "android.intent.action.MAIN"
|
||||
// auto process = escape_sandbox("adb", "-s", _serial, "shell", "am", "start", "-a", action, "-d", uri, app);
|
||||
// process->start();
|
||||
// process->waitForFinished();
|
||||
// }
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2024 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QFuture>
|
||||
#include <filesystem>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class QProcess;
|
||||
|
||||
class adb
|
||||
{
|
||||
public:
|
||||
class device
|
||||
{
|
||||
std::string _serial;
|
||||
std::string _state;
|
||||
std::map<std::string, std::string> _properties;
|
||||
|
||||
friend class adb;
|
||||
|
||||
public:
|
||||
device() = default;
|
||||
device(const device &) = default;
|
||||
device(device &&) = default;
|
||||
device & operator=(const device &) = default;
|
||||
device & operator=(device &&) = default;
|
||||
|
||||
const auto & serial() const
|
||||
{
|
||||
return _serial;
|
||||
};
|
||||
|
||||
const auto & state() const
|
||||
{
|
||||
return _state;
|
||||
};
|
||||
|
||||
const auto & properties() const
|
||||
{
|
||||
return _properties;
|
||||
};
|
||||
|
||||
bool operator==(const device & other) const
|
||||
{
|
||||
return _serial == other._serial;
|
||||
}
|
||||
|
||||
std::unique_ptr<QProcess> install(const std::filesystem::path & path);
|
||||
std::unique_ptr<QProcess> uninstall(const std::string & app);
|
||||
// void start(const std::string& app);
|
||||
// void stop(const std::string& app);
|
||||
// void start(const std::string& app, const std::string& action, const std::string& uri);
|
||||
};
|
||||
|
||||
std::shared_ptr<QPromise<std::vector<adb::device>>> devices();
|
||||
};
|
||||
+3
-7
@@ -25,13 +25,9 @@
|
||||
#include <QTranslator>
|
||||
|
||||
#include "main_window.h"
|
||||
#include "version.h"
|
||||
#include "wizard.h"
|
||||
|
||||
namespace wivrn
|
||||
{
|
||||
extern const char git_version[];
|
||||
}
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
@@ -63,13 +59,13 @@ int main(int argc, char * argv[])
|
||||
auto main = std::make_unique<main_window>();
|
||||
|
||||
QSettings settings;
|
||||
if (settings.value("first_run", true).toBool())
|
||||
if (settings.value("wizard/first_run", true).toBool())
|
||||
{
|
||||
wizard_window.reset(new wizard);
|
||||
wizard_window->show();
|
||||
|
||||
QObject::connect(wizard_window.get(), &QWizard::finished, [&](int value) {
|
||||
settings.setValue("first_run", false);
|
||||
settings.setValue("wizard/first_run", false);
|
||||
|
||||
wizard_window.release()->deleteLater();
|
||||
main->show();
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include <chrono>
|
||||
#include <cmath>
|
||||
|
||||
#include "exit_codes.h"
|
||||
#include "settings.h"
|
||||
#include "ui_main_window.h"
|
||||
#include "wivrn_server.h"
|
||||
@@ -372,19 +371,19 @@ void main_window::on_server_finished(int exit_code, QProcess::ExitStatus status)
|
||||
QString error_message = tr("Unknown error (%1), check logs").arg(exit_code);
|
||||
switch (exit_code)
|
||||
{
|
||||
case wivrn_exit_code::cannot_connect_to_avahi:
|
||||
error_message = tr("Cannot connect to avahi, make sure avahi-daemon service is started");
|
||||
case EXIT_SUCCESS:
|
||||
case EXIT_FAILURE:
|
||||
break;
|
||||
case wivrn_exit_code::cannot_create_pipe:
|
||||
case wivrn_exit_code::cannot_create_socketpair:
|
||||
case 2:
|
||||
case 3:
|
||||
error_message = tr("Insufficient system resources");
|
||||
break;
|
||||
case wivrn_exit_code::success:
|
||||
case wivrn_exit_code::unknown_error:
|
||||
case 4:
|
||||
error_message = tr("Cannot connect to avahi, make sure avahi-daemon service is started");
|
||||
break;
|
||||
}
|
||||
|
||||
QMessageBox msgbox /*(this)*/;
|
||||
QMessageBox msgbox;
|
||||
msgbox.setIcon(QMessageBox::Critical);
|
||||
msgbox.setText(tr("Server crashed:\n%1").arg(error_message));
|
||||
msgbox.setStandardButtons(QMessageBox::Close);
|
||||
|
||||
+272
-129
@@ -19,11 +19,12 @@
|
||||
#include "settings.h"
|
||||
|
||||
#include "rectangle_partitionner.h"
|
||||
#include "steam_app.h"
|
||||
#include "ui_settings.h"
|
||||
#include "wivrn_server.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QJsonObject>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QPainter>
|
||||
#include <QPushButton>
|
||||
@@ -31,7 +32,6 @@
|
||||
#include <QStandardPaths>
|
||||
#include <QToolTip>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
@@ -123,108 +123,18 @@ settings::settings(wivrn_server * server_interface) :
|
||||
ui = new Ui::Settings;
|
||||
ui->setupUi(this);
|
||||
|
||||
QJsonParseError error;
|
||||
json_doc = QJsonDocument::fromJson(server_interface->jsonConfiguration().toUtf8(), &error);
|
||||
|
||||
std::vector<QRectF> rectangles;
|
||||
std::vector<QVariant> encoder_config;
|
||||
|
||||
if (error.error)
|
||||
{
|
||||
std::cout << "Cannot read configuration: " << error.errorString().toStdString() << ", offset " << error.offset << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto encoders = json_doc.object().find("encoders");
|
||||
|
||||
if (encoders->isArray())
|
||||
{
|
||||
ui->radio_auto_encoder->setChecked(false);
|
||||
ui->radio_manual_encoder->setChecked(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->radio_auto_encoder->setChecked(true);
|
||||
ui->radio_manual_encoder->setChecked(false);
|
||||
|
||||
encoders = json_doc.object().find("encoders.disabled");
|
||||
}
|
||||
|
||||
if (encoders->isArray())
|
||||
{
|
||||
for (QJsonValue i: encoders->toArray())
|
||||
{
|
||||
int encoder = encoder_id_from_string(i["encoder"].toString("auto").toLower().toStdString());
|
||||
int codec = codec_id_from_string(i["codec"].toString("auto").toLower().toStdString());
|
||||
double width = i["width"].toDouble(1);
|
||||
double height = i["height"].toDouble(1);
|
||||
double offset_x = i["offset_x"].toDouble(0);
|
||||
double offset_y = i["offset_y"].toDouble(0);
|
||||
int group = i["group"].toInt(0); // TODO: handle groups
|
||||
|
||||
rectangles.push_back(QRectF(offset_x, offset_y, width, height));
|
||||
encoder_config.push_back(QVariant::fromValue(std::pair(encoder, codec)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rectangles.empty())
|
||||
{
|
||||
rectangles.push_back(QRectF(0, 0, 1, 1));
|
||||
std::pair<int, int> config{0, 0};
|
||||
encoder_config.push_back(QVariant::fromValue(config));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
ui->partitionner->set_rectangles(rectangles);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
QMessageBox msgbox{QMessageBox::Information, tr("Invalid settings"), tr("The encoder configuration is invalid, the default values will be restored."), QMessageBox::Close, this};
|
||||
msgbox.exec();
|
||||
|
||||
ui->radio_auto_encoder->setChecked(true);
|
||||
ui->radio_manual_encoder->setChecked(false);
|
||||
|
||||
rectangles.clear();
|
||||
encoder_config.clear();
|
||||
|
||||
rectangles.push_back(QRectF(0, 0, 1, 1));
|
||||
ui->partitionner->set_rectangles(rectangles);
|
||||
|
||||
std::pair<int, int> config{0, 0};
|
||||
encoder_config.push_back(QVariant::fromValue(config));
|
||||
}
|
||||
|
||||
ui->partitionner->set_rectangles_data(encoder_config);
|
||||
ui->partitionner->set_selected_index(0);
|
||||
|
||||
if (json_doc["scale"].isDouble())
|
||||
{
|
||||
ui->slider_foveation->setValue(std::round((1 - json_doc["scale"].toDouble(1)) * 100));
|
||||
ui->spin_foveation->setValue(std::round((1 - json_doc["scale"].toDouble(1)) * 100));
|
||||
ui->radio_auto_foveation->setChecked(false);
|
||||
ui->radio_manual_foveation->setChecked(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->radio_auto_foveation->setChecked(true);
|
||||
ui->radio_manual_foveation->setChecked(false);
|
||||
}
|
||||
ui->bitrate->setValue(json_doc["bitrate"].toDouble(50'000'000) / 1'000'000);
|
||||
|
||||
selected_rectangle_changed(0);
|
||||
connect(ui->combo_select_game, &QComboBox::currentIndexChanged, this, &settings::on_selected_game_changed);
|
||||
connect(ui->button_game_browse, &QPushButton::clicked, this, &settings::on_browse_game);
|
||||
|
||||
connect(ui->partitionner, &rectangle_partitionner::selected_index_change, this, &settings::selected_rectangle_changed);
|
||||
// connect(ui->partitionner, &rectangle_partitionner::rectangles_change, this, [](){});
|
||||
|
||||
connect(ui->encoder, &QComboBox::currentIndexChanged, this, &settings::on_encoder_changed);
|
||||
connect(ui->encoder, &QComboBox::currentIndexChanged, this, &settings::on_settings_changed);
|
||||
connect(ui->codec, &QComboBox::currentIndexChanged, this, &settings::on_settings_changed);
|
||||
connect(ui->bitrate, &QDoubleSpinBox::valueChanged, this, &settings::on_settings_changed);
|
||||
connect(ui->slider_foveation, &QSlider::valueChanged, this, &settings::on_settings_changed);
|
||||
connect(ui->spin_foveation, &QSpinBox::valueChanged, this, &settings::on_settings_changed);
|
||||
connect(ui->encoder, &QComboBox::currentIndexChanged, this, &settings::on_selected_encoder_changed);
|
||||
connect(ui->encoder, &QComboBox::currentIndexChanged, this, &settings::on_encoder_settings_changed);
|
||||
connect(ui->codec, &QComboBox::currentIndexChanged, this, &settings::on_encoder_settings_changed);
|
||||
connect(ui->bitrate, &QDoubleSpinBox::valueChanged, this, &settings::on_encoder_settings_changed);
|
||||
connect(ui->slider_foveation, &QSlider::valueChanged, this, &settings::on_encoder_settings_changed);
|
||||
connect(ui->spin_foveation, &QSpinBox::valueChanged, this, &settings::on_encoder_settings_changed);
|
||||
|
||||
// connect(ui->foveation_info, &QPushButton::clicked, this, [&]() { QToolTip::showText(ui->radio_manual_foveation->pos(), ui->radio_manual_foveation->toolTip(), ui->radio_manual_foveation); });
|
||||
|
||||
@@ -264,13 +174,9 @@ settings::settings(wivrn_server * server_interface) :
|
||||
painter.setFont(font);
|
||||
});
|
||||
|
||||
// Update the compatible codecs
|
||||
on_encoder_changed();
|
||||
|
||||
// Update the status text
|
||||
on_settings_changed();
|
||||
|
||||
setWindowModality(Qt::WindowModality::ApplicationModal);
|
||||
|
||||
load_settings();
|
||||
}
|
||||
|
||||
settings::~settings()
|
||||
@@ -279,7 +185,7 @@ settings::~settings()
|
||||
ui = nullptr;
|
||||
}
|
||||
|
||||
void settings::on_encoder_changed()
|
||||
void settings::on_selected_encoder_changed()
|
||||
{
|
||||
int encoder = ui->encoder->currentIndex();
|
||||
|
||||
@@ -302,7 +208,7 @@ void settings::on_encoder_changed()
|
||||
}
|
||||
}
|
||||
|
||||
void settings::on_settings_changed()
|
||||
void settings::on_encoder_settings_changed()
|
||||
{
|
||||
QString status;
|
||||
|
||||
@@ -343,6 +249,45 @@ void settings::on_settings_changed()
|
||||
ui->message->setText(status);
|
||||
}
|
||||
|
||||
void settings::on_selected_game_changed(int index)
|
||||
{
|
||||
if (index == 0) // No game selected
|
||||
{
|
||||
ui->edit_game_path->setEnabled(false);
|
||||
ui->button_game_browse->setEnabled(false);
|
||||
}
|
||||
else if (index == 1) // Custom path
|
||||
{
|
||||
ui->edit_game_path->setEnabled(true);
|
||||
ui->button_game_browse->setEnabled(true);
|
||||
}
|
||||
else // From Steam vrmanifest
|
||||
{
|
||||
ui->edit_game_path->setEnabled(false);
|
||||
ui->button_game_browse->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
void settings::on_browse_game()
|
||||
{
|
||||
QFileInfo info(ui->edit_game_path->text());
|
||||
|
||||
QFileDialog dlg(this, tr("Select game"));
|
||||
dlg.setFilter(QDir::Executable | QDir::Files);
|
||||
dlg.setFileMode(QFileDialog::ExistingFile);
|
||||
dlg.setDirectory(info.dir());
|
||||
|
||||
if (not dlg.exec())
|
||||
return;
|
||||
|
||||
auto files = dlg.selectedFiles();
|
||||
|
||||
if (files.empty())
|
||||
return;
|
||||
|
||||
ui->edit_game_path->setText(files.front());
|
||||
}
|
||||
|
||||
void settings::selected_rectangle_changed(int index)
|
||||
{
|
||||
auto [encoder, codec] = ui->partitionner->rectangles_data(index).value<std::pair<int, int>>();
|
||||
@@ -367,44 +312,223 @@ void settings::restore_defaults()
|
||||
ui->partitionner->set_rectangles(rectangles);
|
||||
ui->partitionner->set_rectangles_data(encoder_config);
|
||||
ui->partitionner->set_selected_index(0);
|
||||
|
||||
ui->combo_select_game->setCurrentIndex(0);
|
||||
ui->edit_game_path->setText("");
|
||||
}
|
||||
|
||||
void settings::load_settings()
|
||||
{
|
||||
std::vector<QRectF> rectangles;
|
||||
std::vector<QVariant> encoder_config;
|
||||
|
||||
// Encoders configuration
|
||||
try
|
||||
{
|
||||
json_doc = nlohmann::json::parse(server_interface->jsonConfiguration().toUtf8());
|
||||
}
|
||||
catch (std::exception & e)
|
||||
{
|
||||
qWarning() << "Cannot read configuration: " << e.what();
|
||||
restore_defaults();
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
nlohmann::json encoders;
|
||||
|
||||
if (json_doc.contains("encoders"))
|
||||
{
|
||||
encoders = json_doc["encoders"];
|
||||
ui->radio_auto_encoder->setChecked(false);
|
||||
ui->radio_manual_encoder->setChecked(true);
|
||||
}
|
||||
else if (json_doc.contains("encoders.disabled"))
|
||||
{
|
||||
encoders = json_doc["encoders.disabled"];
|
||||
ui->radio_auto_encoder->setChecked(true);
|
||||
ui->radio_manual_encoder->setChecked(false);
|
||||
ui->layout_encoder_config->setVisible(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->radio_auto_encoder->setChecked(true);
|
||||
ui->radio_manual_encoder->setChecked(false);
|
||||
ui->layout_encoder_config->setVisible(false);
|
||||
}
|
||||
|
||||
for (auto & i: encoders)
|
||||
{
|
||||
int encoder = encoder_id_from_string(i.value("encoder", "auto"));
|
||||
int codec = codec_id_from_string(i.value("codec", "auto"));
|
||||
double width = i.value("width", 1.0);
|
||||
double height = i.value("height", 1.0);
|
||||
double offset_x = i.value("offset_x", 0.0);
|
||||
double offset_y = i.value("offset_y", 0.0);
|
||||
int group = i.value("group", 0); // TODO: handle groups
|
||||
|
||||
rectangles.push_back(QRectF(offset_x, offset_y, width, height));
|
||||
encoder_config.push_back(QVariant::fromValue(std::pair(encoder, codec)));
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
QMessageBox msgbox{QMessageBox::Information, tr("Invalid settings"), tr("The encoder configuration is invalid, the default values will be restored."), QMessageBox::Close, this};
|
||||
msgbox.exec();
|
||||
|
||||
rectangles.clear();
|
||||
encoder_config.clear();
|
||||
}
|
||||
|
||||
if (rectangles.empty())
|
||||
{
|
||||
ui->radio_auto_encoder->setChecked(true);
|
||||
ui->radio_manual_encoder->setChecked(false);
|
||||
ui->layout_encoder_config->setVisible(false);
|
||||
|
||||
rectangles.push_back(QRectF(0, 0, 1, 1));
|
||||
std::pair<int, int> config{0, 0};
|
||||
encoder_config.push_back(QVariant::fromValue(config));
|
||||
}
|
||||
|
||||
ui->partitionner->set_rectangles(rectangles);
|
||||
ui->partitionner->set_rectangles_data(encoder_config);
|
||||
ui->partitionner->set_selected_index(0);
|
||||
|
||||
// Foveation
|
||||
try
|
||||
{
|
||||
if (json_doc.contains("scale"))
|
||||
{
|
||||
ui->slider_foveation->setValue(std::round((1 - json_doc.value("scale", 1.0)) * 100));
|
||||
ui->spin_foveation->setValue(std::round((1 - json_doc.value("scale", 1.0)) * 100));
|
||||
ui->radio_auto_foveation->setChecked(false);
|
||||
ui->radio_manual_foveation->setChecked(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->radio_auto_foveation->setChecked(true);
|
||||
ui->radio_manual_foveation->setChecked(false);
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
ui->radio_auto_foveation->setChecked(true);
|
||||
ui->radio_manual_foveation->setChecked(false);
|
||||
}
|
||||
|
||||
// Bitrate
|
||||
ui->bitrate->setValue(json_doc.value("bitrate", 50'000'000.0) / 1'000'000);
|
||||
|
||||
// Automatically started application
|
||||
std::vector<std::string> application;
|
||||
|
||||
if (json_doc["application"].is_array())
|
||||
application = json_doc.value<std::vector<std::string>>("application", {});
|
||||
else if (json_doc["application"].is_string())
|
||||
application.push_back(json_doc["application"]);
|
||||
|
||||
ui->combo_select_game->clear();
|
||||
ui->combo_select_game->addItem(tr("None", "Game selection combo box"));
|
||||
ui->combo_select_game->addItem(tr("Custom...", "Game selection combo box"));
|
||||
|
||||
auto apps = steam_apps();
|
||||
for (auto & app: apps)
|
||||
{
|
||||
ui->combo_select_game->addItem(QString::fromUtf8(app.name), QVariant::fromValue(app));
|
||||
|
||||
if (application.size() == 2 and application[0] == "steam" and application[1] == app.url)
|
||||
{
|
||||
ui->combo_select_game->setCurrentIndex(ui->combo_select_game->count() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (application.size() == 1 and ui->combo_select_game->currentIndex() == 0)
|
||||
{
|
||||
ui->combo_select_game->setCurrentIndex(1);
|
||||
ui->edit_game_path->setText(QString::fromUtf8(application.front()));
|
||||
}
|
||||
selected_rectangle_changed(0);
|
||||
|
||||
ui->partitionner->set_paint([&](QPainter & painter, QRect rect, const QVariant & data, int index, bool selected) {
|
||||
if (selected)
|
||||
{
|
||||
painter.fillRect(rect.adjusted(1, 1, 0, 0), QColorConstants::Cyan);
|
||||
}
|
||||
|
||||
auto [encoder_id, codec_id] = data.value<std::pair<int, int>>();
|
||||
|
||||
QString codec = ui->codec->itemText(codec_id);
|
||||
QString encoder = ui->encoder->itemText(encoder_id);
|
||||
|
||||
QFont font = painter.font();
|
||||
QFont font2 = font;
|
||||
|
||||
font2.setPixelSize(24);
|
||||
|
||||
QString text = QString("%1\n%2").arg(encoder, codec);
|
||||
|
||||
QFontMetrics metrics{font2};
|
||||
QSize size = metrics.size(0, text);
|
||||
|
||||
if (double ratio = std::max((double)size.width() / rect.width(), (double)size.height() / rect.height()); ratio > 1)
|
||||
{
|
||||
int pixel_size = font2.pixelSize() / ratio;
|
||||
if (pixel_size > 0)
|
||||
font2.setPixelSize(pixel_size);
|
||||
}
|
||||
|
||||
painter.setFont(font2);
|
||||
painter.drawText(rect, Qt::AlignCenter, text);
|
||||
painter.setFont(font);
|
||||
});
|
||||
|
||||
// Update the compatible codecs
|
||||
on_selected_encoder_changed();
|
||||
|
||||
// Update the status text
|
||||
on_encoder_settings_changed();
|
||||
}
|
||||
|
||||
void settings::save_settings()
|
||||
{
|
||||
QJsonObject json = json_doc.object();
|
||||
|
||||
// Remove all optional keys that might not be overwritten
|
||||
auto it = json.find("scale");
|
||||
if (it != json.end())
|
||||
json.erase(it);
|
||||
auto it = json_doc.find("scale");
|
||||
if (it != json_doc.end())
|
||||
json_doc.erase(it);
|
||||
|
||||
it = json.find("encoders.disabled");
|
||||
if (it != json.end())
|
||||
json.erase(it);
|
||||
it = json_doc.find("encoders.disabled");
|
||||
if (it != json_doc.end())
|
||||
json_doc.erase(it);
|
||||
|
||||
it = json.find("encoders");
|
||||
if (it != json.end())
|
||||
json.erase(it);
|
||||
it = json_doc.find("encoders");
|
||||
if (it != json_doc.end())
|
||||
json_doc.erase(it);
|
||||
|
||||
it = json_doc.find("application");
|
||||
if (it != json_doc.end())
|
||||
json_doc.erase(it);
|
||||
|
||||
if (not ui->radio_auto_foveation->isChecked())
|
||||
json["scale"] = 1 - ui->slider_foveation->value() / 100.0;
|
||||
json_doc["scale"] = 1 - ui->slider_foveation->value() / 100.0;
|
||||
|
||||
json["bitrate"] = ui->bitrate->value() * 1'000'000;
|
||||
json_doc["bitrate"] = ui->bitrate->value() * 1'000'000;
|
||||
|
||||
QJsonArray encoders;
|
||||
nlohmann::json encoders;
|
||||
|
||||
const auto & rect = ui->partitionner->rectangles();
|
||||
const auto & data = ui->partitionner->rectangles_data();
|
||||
|
||||
for (int i = 0, n = rect.size(); i < n; i++)
|
||||
{
|
||||
QJsonObject encoder;
|
||||
nlohmann::json encoder;
|
||||
auto [encoder_id, codec_id] = data[i].value<std::pair<int, int>>();
|
||||
|
||||
if (auto value = QString::fromLatin1(encoder_from_id(encoder_id)); value != "auto")
|
||||
if (auto value = encoder_from_id(encoder_id); value != "auto")
|
||||
encoder["encoder"] = value;
|
||||
|
||||
if (auto value = QString::fromLatin1(codec_from_id(codec_id)); value != "auto")
|
||||
if (auto value = codec_from_id(codec_id); value != "auto")
|
||||
encoder["codec"] = value;
|
||||
|
||||
encoder["width"] = rect[i].width();
|
||||
@@ -418,15 +542,34 @@ void settings::save_settings()
|
||||
}
|
||||
|
||||
// If there is only one automatic encoder, don't save it'
|
||||
if (encoders.size() != 1 or encoders[0].toObject().contains("codec") or encoders[0].toObject().contains("encoder"))
|
||||
if (encoders.size() != 1 or encoders[0].contains("codec") or encoders[0].contains("encoder"))
|
||||
{
|
||||
if (ui->radio_manual_encoder->isChecked())
|
||||
json["encoders"] = encoders;
|
||||
json_doc["encoders"] = encoders;
|
||||
else
|
||||
json["encoders.disabled"] = encoders;
|
||||
json_doc["encoders.disabled"] = encoders;
|
||||
}
|
||||
|
||||
server_interface->setJsonConfiguration(QString::fromUtf8(QJsonDocument(json).toJson()));
|
||||
if (ui->combo_select_game->currentIndex() == 0)
|
||||
{
|
||||
}
|
||||
else if (ui->combo_select_game->currentIndex() == 1)
|
||||
{
|
||||
nlohmann::json application;
|
||||
application.push_back(ui->edit_game_path->text().toStdString());
|
||||
json_doc["application"] = application;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto app = qvariant_cast<steam_app>(ui->combo_select_game->currentData());
|
||||
|
||||
nlohmann::json application;
|
||||
application.push_back("steam");
|
||||
application.push_back(app.url);
|
||||
json_doc["application"] = application;
|
||||
}
|
||||
|
||||
server_interface->setJsonConfiguration(QString::fromStdString(json_doc.dump(2)));
|
||||
}
|
||||
|
||||
#include "moc_settings.cpp"
|
||||
|
||||
@@ -19,8 +19,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
@@ -35,7 +34,7 @@ class settings : public QDialog
|
||||
Ui::Settings * ui;
|
||||
wivrn_server * server_interface;
|
||||
|
||||
QJsonDocument json_doc;
|
||||
nlohmann::json json_doc;
|
||||
|
||||
void selected_rectangle_changed(int);
|
||||
|
||||
@@ -43,8 +42,12 @@ public:
|
||||
settings(wivrn_server * server_interface = nullptr);
|
||||
~settings();
|
||||
|
||||
void on_settings_changed();
|
||||
void on_encoder_changed();
|
||||
private:
|
||||
void on_encoder_settings_changed();
|
||||
void on_selected_encoder_changed();
|
||||
void on_selected_game_changed(int index);
|
||||
void on_browse_game();
|
||||
void load_settings();
|
||||
void save_settings();
|
||||
void restore_defaults();
|
||||
};
|
||||
|
||||
+577
-487
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2024 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "steam_app.h"
|
||||
#include <QProcess>
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
namespace
|
||||
{
|
||||
std::string read_vr_manifest()
|
||||
{
|
||||
const char * home = getenv("HOME");
|
||||
|
||||
std::filesystem::path vrmanifest = std::string{home ? home : ""} + "/.steam/steam/config/steamapps.vrmanifest";
|
||||
|
||||
if (std::filesystem::exists("/.flatpak-info"))
|
||||
{
|
||||
QProcess flatpak_spawn;
|
||||
flatpak_spawn.start("flatpak-spawn", {"--host", "cat", QString::fromStdString(vrmanifest)});
|
||||
flatpak_spawn.waitForFinished();
|
||||
return flatpak_spawn.readAllStandardOutput().toStdString();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::ifstream f(vrmanifest);
|
||||
std::istreambuf_iterator<char> begin{f}, end;
|
||||
|
||||
return {begin, end};
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
std::vector<steam_app> steam_apps(const std::string & locale)
|
||||
{
|
||||
std::vector<steam_app> apps;
|
||||
|
||||
nlohmann::json json = nlohmann::json::parse(read_vr_manifest());
|
||||
|
||||
for (auto & i: json["applications"])
|
||||
{
|
||||
try
|
||||
{
|
||||
steam_app app;
|
||||
|
||||
app.image_path = i.value("image_path", "");
|
||||
app.name = i["strings"]["en_us"]["name"];
|
||||
|
||||
if (i["launch_type"] == "url")
|
||||
{
|
||||
app.url = i["url"];
|
||||
}
|
||||
else if (i["launch_type"] == "binary")
|
||||
{
|
||||
std::string app_key = i["app_key"];
|
||||
|
||||
const char prefix[] = "steam.app.";
|
||||
if (app_key.starts_with(prefix))
|
||||
app.url = "steam://rungameid/" + app_key.substr(strlen(prefix));
|
||||
}
|
||||
|
||||
if (app.url != "")
|
||||
apps.push_back(app);
|
||||
}
|
||||
catch (std::exception & e)
|
||||
{
|
||||
std::cerr << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
std::ranges::sort(apps, [](const steam_app & a, const steam_app & b) {
|
||||
return a.name < b.name;
|
||||
});
|
||||
|
||||
return apps;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2024 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
struct steam_app
|
||||
{
|
||||
std::string name;
|
||||
std::string image_path;
|
||||
std::string url;
|
||||
};
|
||||
|
||||
std::vector<steam_app> steam_apps(const std::string & locale = "en_us");
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2022 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
* Copyright (C) 2022 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "version.h"
|
||||
|
||||
namespace wivrn
|
||||
{
|
||||
const char git_version[] = "@GIT_DESC@";
|
||||
const char git_commit[] = "@GIT_COMMIT@";
|
||||
} // namespace wivrn
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2022 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
* Copyright (C) 2022 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace wivrn
|
||||
{
|
||||
extern const char git_version[];
|
||||
extern const char git_commit[];
|
||||
} // namespace wivrn
|
||||
+330
-49
@@ -26,22 +26,30 @@
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
#include <QNetworkRequest>
|
||||
#include <QProcess>
|
||||
#include <QSaveFile>
|
||||
#include <QScrollBar>
|
||||
#include <QStandardPaths>
|
||||
#include <QUrl>
|
||||
#include <QWizard>
|
||||
#include <algorithm>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include "ui_wizard.h"
|
||||
|
||||
#include "wivrn_server.h"
|
||||
|
||||
#include "adb.h"
|
||||
#include "gui_config.h"
|
||||
#include "ui_wizard.h"
|
||||
#include "version.h"
|
||||
#include "wivrn_server.h"
|
||||
#include <filesystem>
|
||||
#include <regex>
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
|
||||
enum class wizard_page
|
||||
{
|
||||
select_headset_model,
|
||||
sideload_download,
|
||||
sideload_devmode,
|
||||
sideload_install,
|
||||
connect_hmd,
|
||||
start_game
|
||||
@@ -71,9 +79,30 @@ static constexpr int role_devmode_url = Qt::UserRole + 1;
|
||||
static constexpr int role_store_name = Qt::UserRole + 2;
|
||||
static constexpr int role_store_url = Qt::UserRole + 3;
|
||||
|
||||
// #define TEST 1 // Not in the WiVRn-APK repo
|
||||
// #define TEST 2 // In the WiVRn-APK repo, not a tagged version
|
||||
// #define TEST 3 // Current version
|
||||
// #define TEST 4 // Old version
|
||||
|
||||
#if !defined(TEST) || TEST == 0 // Normal case
|
||||
static const std::string git_version = wivrn::git_version;
|
||||
static const std::string git_commit = wivrn::git_commit;
|
||||
#elif TEST == 1
|
||||
static const std::string git_version = "v0.19.1-60-g66ce2c5";
|
||||
static const std::string git_commit = "66ce2c547dedf9b320af677ed42f32f361b32832";
|
||||
#elif TEST == 2
|
||||
static const std::string git_version = "v0.19.1-59-g0d62929";
|
||||
static const std::string git_commit = "554c0f7ad647d9cd66e380f567f2e842fff6a27a";
|
||||
#elif TEST == 3
|
||||
static const std::string git_version = "v0.19.1";
|
||||
static const std::string git_commit = "bcffadcd4e043d7bacd700b1331c2e98f96ca178";
|
||||
#elif TEST == 4
|
||||
static const std::string git_version = "v0.19";
|
||||
static const std::string git_commit = "d0014823480bc0e54594b74d2475882554ed5829";
|
||||
#endif
|
||||
|
||||
wizard::wizard() :
|
||||
server(new wivrn_server(this)),
|
||||
apk_file(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/wivrn.apk")
|
||||
server(new wivrn_server(this))
|
||||
{
|
||||
ui = new Ui::Wizard;
|
||||
ui->setupUi(this);
|
||||
@@ -87,10 +116,6 @@ wizard::wizard() :
|
||||
QGuiApplication::clipboard()->setText(ui->label_steam_command->text());
|
||||
});
|
||||
|
||||
connect(ui->copy_adb_command, &QPushButton::clicked, this, [&]() {
|
||||
QGuiApplication::clipboard()->setText(ui->label_adb_install->text());
|
||||
});
|
||||
|
||||
connect(server, &wivrn_server::headsetConnectedChanged, this, &wizard::on_headset_connected_changed);
|
||||
|
||||
connect(ui->button_cancel_download, &QPushButton::clicked, this, &wizard::cancel_download);
|
||||
@@ -101,10 +126,6 @@ wizard::wizard() :
|
||||
ui->label_steam_command->setText(server->steamCommand());
|
||||
|
||||
setPixmap(WatermarkPixmap, QPixmap(":/images/wivrn.svg"));
|
||||
|
||||
ui->label_adb_install->setText("adb install -r " + apk_file.fileName());
|
||||
apk_downloaded = QFileInfo(apk_file).exists() and (settings.value("client_apk_url").toString() == WIVRN_CLIENT_URL);
|
||||
|
||||
for (const headset & i: headsets_info)
|
||||
{
|
||||
auto item = new QStandardItem(i.name);
|
||||
@@ -119,14 +140,168 @@ wizard::wizard() :
|
||||
|
||||
ui->combo_hmd_model->setModel(&headsets);
|
||||
ui->combo_hmd_model->setCurrentIndex(-1);
|
||||
connect(ui->combo_hmd_model, &QComboBox::currentIndexChanged, this, &wizard::on_headset_model_changed);
|
||||
connect(ui->check_sideload, &QCheckBox::clicked, this, &wizard::on_headset_model_changed);
|
||||
connect(ui->combo_hmd_model, &QComboBox::currentIndexChanged, this, &wizard::update_welcome_page);
|
||||
connect(ui->check_sideload, &QCheckBox::clicked, this, &wizard::update_welcome_page);
|
||||
|
||||
setWindowModality(Qt::WindowModality::ApplicationModal);
|
||||
|
||||
if (std::regex_match(git_version, std::regex(".*-g[0-9a-f]+")))
|
||||
{
|
||||
apk_file.setFileName(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/wivrn-" + QString::fromStdString(git_commit) + ".apk");
|
||||
|
||||
qDebug() << "Not a tagged version" << git_version.c_str();
|
||||
|
||||
ui->label_release_info->setText(
|
||||
tr("This is not a tagged release.") +
|
||||
"\n" +
|
||||
tr("If you install the headset app from the store, it might not be compatible with this server.") +
|
||||
"\n" +
|
||||
tr("If you install the headset app manually, this wizard will download the version that matches the dashboard."));
|
||||
|
||||
std::string url = "https://api.github.com/repos/WiVRn/WiVRn-APK/releases/tags/apk-" + git_commit;
|
||||
qDebug() << "Downloading metadata from" << url.c_str();
|
||||
|
||||
apk_release_reply = manager.get(QNetworkRequest{QUrl{url.c_str()}});
|
||||
connect(apk_release_reply, &QNetworkReply::finished, this, &wizard::on_apk_release_finished);
|
||||
}
|
||||
else
|
||||
{
|
||||
apk_file.setFileName(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/wivrn-" + QString::fromStdString(git_version) + ".apk");
|
||||
|
||||
qDebug() << "Tagged version" << git_version.c_str();
|
||||
|
||||
// Get the current release information
|
||||
std::string url = "https://api.github.com/repos/WiVRn/WiVRn/releases/tags/" + git_version;
|
||||
qDebug() << "Downloading metadata from" << url.c_str();
|
||||
apk_release_reply = manager.get(QNetworkRequest{QUrl{url.c_str()}});
|
||||
connect(apk_release_reply, &QNetworkReply::finished, this, &wizard::on_apk_release_finished);
|
||||
|
||||
// Get the latest release information
|
||||
latest_release_reply = manager.get(QNetworkRequest{QUrl{"https://api.github.com/repos/WiVRn/WiVRn/releases/latest"}});
|
||||
connect(latest_release_reply, &QNetworkReply::finished, this, &wizard::on_latest_release_finished);
|
||||
}
|
||||
|
||||
// Detect connected android devices
|
||||
poll_devices_timer.setInterval(std::chrono::milliseconds(500));
|
||||
connect(&poll_devices_timer, &QTimer::timeout, this, [this]() {
|
||||
if (android_devices_future.isFinished())
|
||||
{
|
||||
android_devices_promise = adb{}.devices();
|
||||
android_devices_future = android_devices_promise->future();
|
||||
android_devices_future_watcher.setFuture(android_devices_future);
|
||||
}
|
||||
});
|
||||
poll_devices_timer.start();
|
||||
connect(&android_devices_future_watcher, &QFutureWatcher<std::vector<adb::device>>::finished, this, &wizard::on_android_devices_future_finished);
|
||||
}
|
||||
|
||||
void wizard::on_headset_model_changed()
|
||||
void wizard::on_latest_release_finished()
|
||||
{
|
||||
disconnect(latest_release_reply, &QNetworkReply::finished, this, &wizard::on_latest_release_finished);
|
||||
|
||||
// By default, assume this is the latest release
|
||||
latest_release = git_version;
|
||||
|
||||
try
|
||||
{
|
||||
if (latest_release_reply->error())
|
||||
throw std::runtime_error(latest_release_reply->errorString().toStdString());
|
||||
|
||||
auto json = nlohmann::json::parse(latest_release_reply->readAll());
|
||||
|
||||
latest_release = json["tag_name"];
|
||||
|
||||
if (latest_release == git_version)
|
||||
{
|
||||
// This is already the latest release
|
||||
ui->label_release_info->setText("This is the latest WiVRn release.");
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->label_release_info->setText(
|
||||
tr("A new release is available (%1 → %2).").arg(QString::fromLatin1(git_version)).arg(QString::fromLatin1(latest_release)) +
|
||||
"\n" +
|
||||
tr("If you install the headset app from the store, it might not be compatible with this server.") +
|
||||
"\n" +
|
||||
tr("If you install the headset app manually, this wizard will download the version that matches the dashboard."));
|
||||
}
|
||||
}
|
||||
catch (std::exception & e)
|
||||
{
|
||||
qWarning() << "Cannot get latest release: " << e.what();
|
||||
ui->label_release_info->setText(tr("Cannot get latest release: %1").arg(e.what()));
|
||||
}
|
||||
|
||||
latest_release_reply->deleteLater();
|
||||
latest_release_reply = nullptr;
|
||||
update_welcome_page();
|
||||
}
|
||||
|
||||
void wizard::on_apk_release_finished()
|
||||
{
|
||||
disconnect(apk_release_reply, &QNetworkReply::finished, this, &wizard::on_apk_release_finished);
|
||||
|
||||
try
|
||||
{
|
||||
auto error = apk_release_reply->error();
|
||||
|
||||
if (error == QNetworkReply::NetworkError::ContentNotFoundError)
|
||||
{
|
||||
ui->label_release_info->setText(
|
||||
"<html><head/><body><p>" +
|
||||
tr("There is no precompiled APK for this version.") +
|
||||
"</p>\n<p>" +
|
||||
tr("Follow the <a href=\"https://github.com/WiVRn/WiVRn/blob/master/docs/building.md#client-headset\"><span style=\"text-decoration: underline; color:#2980b9;\">documentation</span></a> to build your own client.") +
|
||||
"</p></body></html>");
|
||||
|
||||
ui->combo_hmd_model->setEnabled(false);
|
||||
ui->combo_hmd_model->setCurrentIndex(-1);
|
||||
ui->check_sideload->setEnabled(false);
|
||||
}
|
||||
else if (error != QNetworkReply::NetworkError::NoError)
|
||||
{
|
||||
throw std::runtime_error(apk_release_reply->errorString().toStdString());
|
||||
}
|
||||
else
|
||||
{
|
||||
auto json = nlohmann::json::parse(apk_release_reply->readAll());
|
||||
|
||||
for (auto & i: json["assets"])
|
||||
{
|
||||
std::string name = i["name"];
|
||||
|
||||
if (name.ends_with("-standard-release.apk"))
|
||||
{
|
||||
apk_url = i["browser_download_url"];
|
||||
qDebug() << "Using APK URL" << apk_url.c_str();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
apk_downloaded = QFileInfo(apk_file).exists();
|
||||
}
|
||||
}
|
||||
catch (std::exception & e)
|
||||
{
|
||||
qWarning() << "Cannot get APK information: " << e.what();
|
||||
ui->label_release_info->setText(tr("Cannot get APK information: %1").arg(e.what()));
|
||||
}
|
||||
|
||||
apk_release_reply->deleteLater();
|
||||
apk_release_reply = nullptr;
|
||||
update_welcome_page();
|
||||
}
|
||||
|
||||
void wizard::update_welcome_page()
|
||||
{
|
||||
if (latest_release == "")
|
||||
{
|
||||
// We don't have the latest release information yet
|
||||
ui->widget_store->setVisible(false);
|
||||
ui->check_sideload->setVisible(false);
|
||||
button(NextButton)->setEnabled(false);
|
||||
}
|
||||
|
||||
auto devmode_url = ui->combo_hmd_model->currentData(role_devmode_url).toString();
|
||||
auto store_name = ui->combo_hmd_model->currentData(role_store_name).toString();
|
||||
auto store_url = ui->combo_hmd_model->currentData(role_store_url).toString();
|
||||
@@ -136,26 +311,29 @@ void wizard::on_headset_model_changed()
|
||||
|
||||
if (ui->combo_hmd_model->currentIndex() < 0)
|
||||
{
|
||||
// No headset selected
|
||||
ui->widget_store->setVisible(false);
|
||||
ui->check_sideload->setVisible(false);
|
||||
button(NextButton)->setEnabled(false);
|
||||
}
|
||||
else if (store_name != "")
|
||||
{
|
||||
// Headset with a link to a store
|
||||
ui->widget_store->setVisible(not ui->check_sideload->isChecked());
|
||||
ui->check_sideload->setVisible(true);
|
||||
button(NextButton)->setEnabled(true);
|
||||
button(NextButton)->setEnabled(apk_url != "" or nextId() != (int)wizard_page::sideload_download);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Headset without store
|
||||
ui->widget_store->setVisible(false);
|
||||
ui->check_sideload->setVisible(false);
|
||||
button(NextButton)->setEnabled(true);
|
||||
button(NextButton)->setEnabled(apk_url != "");
|
||||
}
|
||||
|
||||
ui->label_devmode_url->setVisible(devmode_url != "");
|
||||
|
||||
if (nextId() == (int)wizard_page::sideload_download and ui->combo_hmd_model->currentIndex() >= 0)
|
||||
if (nextId() == (int)wizard_page::sideload_download and ui->combo_hmd_model->currentIndex() >= 0 and apk_url != "")
|
||||
button(NextButton)->setText(tr("Download"));
|
||||
else
|
||||
button(NextButton)->setText(QWizard::tr("&Next >", "do not translate, the QWizard translation will be used"));
|
||||
@@ -175,6 +353,9 @@ void wizard::on_custom_button_clicked(int which)
|
||||
case wizard_page::sideload_download:
|
||||
return;
|
||||
|
||||
case wizard_page::sideload_devmode:
|
||||
return;
|
||||
|
||||
case wizard_page::sideload_install:
|
||||
return;
|
||||
|
||||
@@ -197,7 +378,7 @@ void wizard::on_page_changed(int id)
|
||||
button(WizardButton::CustomButton2)->setText(tr("Skip"));
|
||||
|
||||
setButtonLayout({QWizard::Stretch, QWizard::BackButton, QWizard::NextButton, QWizard::CustomButton2, QWizard::CancelButton});
|
||||
on_headset_model_changed();
|
||||
update_welcome_page();
|
||||
return;
|
||||
|
||||
case wizard_page::sideload_download:
|
||||
@@ -209,8 +390,16 @@ void wizard::on_page_changed(int id)
|
||||
button(NextButton)->setEnabled(false);
|
||||
return;
|
||||
|
||||
case wizard_page::sideload_install:
|
||||
case wizard_page::sideload_devmode:
|
||||
setButtonLayout({QWizard::Stretch, QWizard::BackButton, QWizard::NextButton, QWizard::CancelButton});
|
||||
on_adb_device_list_changed();
|
||||
return;
|
||||
|
||||
case wizard_page::sideload_install:
|
||||
start_install();
|
||||
setButtonLayout({QWizard::Stretch, QWizard::BackButton, QWizard::NextButton, QWizard::CancelButton});
|
||||
button(BackButton)->setEnabled(false);
|
||||
button(NextButton)->setEnabled(false);
|
||||
return;
|
||||
|
||||
case wizard_page::connect_hmd:
|
||||
@@ -248,7 +437,7 @@ int wizard::nextId() const
|
||||
if (ui->combo_hmd_model->currentData(role_store_name).toString() != "" and not ui->check_sideload->isChecked())
|
||||
return (int)wizard_page::connect_hmd;
|
||||
else if (apk_downloaded)
|
||||
return (int)wizard_page::sideload_install;
|
||||
return (int)wizard_page::sideload_devmode;
|
||||
else
|
||||
return (int)wizard_page::sideload_download;
|
||||
|
||||
@@ -277,9 +466,9 @@ void wizard::start_download()
|
||||
{
|
||||
ui->button_cancel_download->setEnabled(true);
|
||||
|
||||
QUrl url(WIVRN_CLIENT_URL);
|
||||
QUrl url(apk_url.c_str());
|
||||
|
||||
qDebug() << "Downloading from " << url.toString();
|
||||
qDebug() << "Downloading from" << url.toString();
|
||||
|
||||
auto apk_dir = std::filesystem::path(apk_file.fileName().toStdString()).parent_path();
|
||||
std::filesystem::create_directories(apk_dir);
|
||||
@@ -288,20 +477,20 @@ void wizard::start_download()
|
||||
|
||||
QNetworkRequest request(url);
|
||||
|
||||
if (reply)
|
||||
if (apk_reply)
|
||||
{
|
||||
disconnect(reply, &QNetworkReply::downloadProgress, this, &wizard::on_download_progress);
|
||||
disconnect(reply, &QNetworkReply::errorOccurred, this, &wizard::on_download_error);
|
||||
disconnect(reply, &QNetworkReply::finished, this, &wizard::on_download_finished);
|
||||
reply->abort();
|
||||
reply->deleteLater();
|
||||
disconnect(apk_reply, &QNetworkReply::downloadProgress, this, &wizard::on_download_progress);
|
||||
disconnect(apk_reply, &QNetworkReply::errorOccurred, this, &wizard::on_download_error);
|
||||
disconnect(apk_reply, &QNetworkReply::finished, this, &wizard::on_download_finished);
|
||||
apk_reply->abort();
|
||||
apk_reply->deleteLater();
|
||||
}
|
||||
|
||||
reply = manager.get(request);
|
||||
apk_reply = manager.get(request);
|
||||
|
||||
connect(reply, &QNetworkReply::downloadProgress, this, &wizard::on_download_progress);
|
||||
connect(reply, &QNetworkReply::errorOccurred, this, &wizard::on_download_error);
|
||||
connect(reply, &QNetworkReply::finished, this, &wizard::on_download_finished);
|
||||
connect(apk_reply, &QNetworkReply::downloadProgress, this, &wizard::on_download_progress);
|
||||
connect(apk_reply, &QNetworkReply::errorOccurred, this, &wizard::on_download_error);
|
||||
connect(apk_reply, &QNetworkReply::finished, this, &wizard::on_download_finished);
|
||||
|
||||
ui->progress_download->setValue(0);
|
||||
}
|
||||
@@ -310,12 +499,12 @@ void wizard::cancel_download()
|
||||
{
|
||||
assert(reply);
|
||||
|
||||
disconnect(reply, &QNetworkReply::downloadProgress, this, &wizard::on_download_progress);
|
||||
disconnect(reply, &QNetworkReply::errorOccurred, this, &wizard::on_download_error);
|
||||
disconnect(reply, &QNetworkReply::finished, this, &wizard::on_download_finished);
|
||||
reply->abort();
|
||||
reply->deleteLater();
|
||||
reply = nullptr;
|
||||
disconnect(apk_reply, &QNetworkReply::downloadProgress, this, &wizard::on_download_progress);
|
||||
disconnect(apk_reply, &QNetworkReply::errorOccurred, this, &wizard::on_download_error);
|
||||
disconnect(apk_reply, &QNetworkReply::finished, this, &wizard::on_download_finished);
|
||||
apk_reply->abort();
|
||||
apk_reply->deleteLater();
|
||||
apk_reply = nullptr;
|
||||
|
||||
// Cancel and commit to close without saving the already written data, so that it can be reopened
|
||||
apk_file.cancelWriting();
|
||||
@@ -328,12 +517,12 @@ void wizard::on_download_progress(qint64 bytesReceived, qint64 bytesTotal)
|
||||
{
|
||||
assert(reply);
|
||||
|
||||
if (not reply->error())
|
||||
if (not apk_reply->error())
|
||||
{
|
||||
if (bytesTotal > 0)
|
||||
ui->progress_download->setValue(bytesReceived * 100 / bytesTotal);
|
||||
|
||||
apk_file.write(reply->readAll());
|
||||
apk_file.write(apk_reply->readAll());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -347,7 +536,7 @@ void wizard::on_download_error(QNetworkReply::NetworkError code)
|
||||
|
||||
QMessageBox msgbox /*(this)*/;
|
||||
msgbox.setIcon(QMessageBox::Critical);
|
||||
msgbox.setText(tr("Error downloading the client:\n%1").arg(QMetaEnum::fromType<QNetworkReply::NetworkError>().valueToKey(code)));
|
||||
msgbox.setText(tr("Error downloading the client:\n%1").arg(apk_reply->errorString()));
|
||||
msgbox.setStandardButtons(QMessageBox::Retry | QMessageBox::Cancel);
|
||||
|
||||
#ifdef WORKAROUND_QTBUG_90005
|
||||
@@ -374,18 +563,110 @@ void wizard::on_download_finished()
|
||||
{
|
||||
assert(reply);
|
||||
|
||||
if (not reply->error())
|
||||
if (not apk_reply->error())
|
||||
{
|
||||
reply->deleteLater();
|
||||
reply = nullptr;
|
||||
auto last_modified = apk_reply->header(QNetworkRequest::LastModifiedHeader).value<QDateTime>();
|
||||
apk_file.setFileTime(last_modified, QFileDevice::FileModificationTime);
|
||||
|
||||
apk_reply->deleteLater();
|
||||
apk_reply = nullptr;
|
||||
|
||||
ui->button_cancel_download->setEnabled(false);
|
||||
apk_file.commit();
|
||||
apk_downloaded = true;
|
||||
settings.setValue("client_apk_url", WIVRN_CLIENT_URL);
|
||||
|
||||
back(); // Remove current page from history before going to the install page
|
||||
setCurrentId((int)wizard_page::sideload_install);
|
||||
setCurrentId((int)wizard_page::sideload_devmode);
|
||||
}
|
||||
}
|
||||
|
||||
void wizard::on_android_devices_future_finished()
|
||||
{
|
||||
auto old_devs = android_devices;
|
||||
android_devices = android_devices_future.result();
|
||||
|
||||
bool changed = false;
|
||||
for (auto & i: android_devices)
|
||||
{
|
||||
if (i.state() != "device")
|
||||
continue;
|
||||
|
||||
if (std::ranges::find(old_devs, i) == old_devs.end())
|
||||
changed = true;
|
||||
}
|
||||
|
||||
for (auto & i: old_devs)
|
||||
{
|
||||
if (i.state() != "device")
|
||||
continue;
|
||||
|
||||
if (std::ranges::find(android_devices, i) == android_devices.end())
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (changed)
|
||||
on_adb_device_list_changed();
|
||||
}
|
||||
|
||||
void wizard::on_adb_device_list_changed()
|
||||
{
|
||||
if (android_devices.empty())
|
||||
{
|
||||
ui->label_device_detected->setText(tr("No device detected."));
|
||||
|
||||
if (currentId() == (int)wizard_page::sideload_devmode)
|
||||
button(NextButton)->setEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->label_device_detected->setText(tr("%n device(s) detected.", nullptr, android_devices.size()));
|
||||
|
||||
if (currentId() == (int)wizard_page::sideload_devmode)
|
||||
button(NextButton)->setEnabled(true);
|
||||
}
|
||||
|
||||
// TODO show device list
|
||||
}
|
||||
|
||||
void wizard::start_install()
|
||||
{
|
||||
if (android_devices.empty())
|
||||
{
|
||||
back();
|
||||
return;
|
||||
}
|
||||
|
||||
auto dev = android_devices.back(); // TODO choose device from device list
|
||||
process_adb_install = dev.install(apk_file.fileName().toStdString());
|
||||
|
||||
connect(process_adb_install.get(), &QProcess::finished, this, &wizard::on_install_finished);
|
||||
connect(process_adb_install.get(), &QProcess::readyReadStandardOutput, this, &wizard::on_install_stdout);
|
||||
connect(process_adb_install.get(), &QProcess::readyReadStandardError, this, &wizard::on_install_stderr);
|
||||
process_adb_install->setParent(this);
|
||||
process_adb_install->start();
|
||||
ui->adb_install_logs->setPlainText("");
|
||||
}
|
||||
|
||||
void wizard::on_install_stdout()
|
||||
{
|
||||
ui->adb_install_logs->appendPlainText(process_adb_install->readAllStandardOutput());
|
||||
ui->adb_install_logs->verticalScrollBar()->setValue(ui->adb_install_logs->verticalScrollBar()->maximum());
|
||||
}
|
||||
|
||||
void wizard::on_install_stderr()
|
||||
{
|
||||
ui->adb_install_logs->appendPlainText(process_adb_install->readAllStandardError());
|
||||
ui->adb_install_logs->verticalScrollBar()->setValue(ui->adb_install_logs->verticalScrollBar()->maximum());
|
||||
}
|
||||
|
||||
void wizard::on_install_finished(int exit_code, QProcess::ExitStatus exit_status)
|
||||
{
|
||||
if (exit_code == 0 and exit_status == QProcess::NormalExit)
|
||||
{
|
||||
// back(); // Remove current page from history before going to the connect page
|
||||
// setCurrentId((int)wizard_page::connect_hmd);
|
||||
|
||||
button(NextButton)->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+40
-2
@@ -18,12 +18,18 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "adb.h"
|
||||
#include <QFutureWatcher>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
#include <QProcess>
|
||||
#include <QSaveFile>
|
||||
#include <QSettings>
|
||||
#include <QStandardItemModel>
|
||||
#include <QTimer>
|
||||
#include <QWizard>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
@@ -43,10 +49,31 @@ class wizard : public QWizard
|
||||
|
||||
QSettings settings;
|
||||
QNetworkAccessManager manager;
|
||||
QNetworkReply * reply = nullptr;
|
||||
|
||||
// Used to download the APK
|
||||
QNetworkReply * apk_reply = nullptr;
|
||||
|
||||
// Used to query the latest release on github
|
||||
QNetworkReply * latest_release_reply = nullptr;
|
||||
|
||||
// Used to get the info about the current version on github, either from the WiVRn or the WiVRn-APK repo
|
||||
QNetworkReply * apk_release_reply = nullptr;
|
||||
|
||||
QSaveFile apk_file;
|
||||
std::string apk_url;
|
||||
bool apk_downloaded = false;
|
||||
|
||||
std::string latest_release;
|
||||
|
||||
std::shared_ptr<QPromise<std::vector<adb::device>>> android_devices_promise;
|
||||
QFuture<std::vector<adb::device>> android_devices_future;
|
||||
QFutureWatcher<std::vector<adb::device>> android_devices_future_watcher;
|
||||
|
||||
std::vector<adb::device> android_devices;
|
||||
QTimer poll_devices_timer;
|
||||
// std::unique_ptr<QProcess> process_adb_devices;
|
||||
std::unique_ptr<QProcess> process_adb_install;
|
||||
|
||||
public:
|
||||
wizard();
|
||||
~wizard();
|
||||
@@ -64,7 +91,18 @@ public:
|
||||
void on_download_error(QNetworkReply::NetworkError code);
|
||||
void on_download_finished();
|
||||
|
||||
void on_headset_model_changed();
|
||||
void on_android_devices_future_finished();
|
||||
void on_adb_device_list_changed();
|
||||
|
||||
void start_install();
|
||||
void on_install_finished(int exit_code, QProcess::ExitStatus exit_status);
|
||||
void on_install_stdout();
|
||||
void on_install_stderr();
|
||||
|
||||
void on_latest_release_finished();
|
||||
void on_apk_release_finished();
|
||||
|
||||
void update_welcome_page();
|
||||
void on_headset_connected_changed(bool);
|
||||
void on_custom_button_clicked(int which);
|
||||
};
|
||||
|
||||
+80
-59
@@ -23,9 +23,6 @@
|
||||
<property name="subTitle">
|
||||
<string/>
|
||||
</property>
|
||||
<attribute name="pageId">
|
||||
<string notr="true">0</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
@@ -80,6 +77,19 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_release_info">
|
||||
<property name="text">
|
||||
<string>Getting latest release information...</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="check_sideload">
|
||||
<property name="text">
|
||||
@@ -151,9 +161,6 @@
|
||||
<property name="subTitle">
|
||||
<string/>
|
||||
</property>
|
||||
<attribute name="pageId">
|
||||
<string notr="true">1</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<spacer name="verticalSpacer_8">
|
||||
@@ -211,16 +218,13 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWizardPage" name="page_3_sideload_install">
|
||||
<widget class="QWizardPage" name="page_3_sideload_devmode">
|
||||
<property name="title">
|
||||
<string>Install the WiVRn app on your headset</string>
|
||||
</property>
|
||||
<property name="subTitle">
|
||||
<string/>
|
||||
</property>
|
||||
<attribute name="pageId">
|
||||
<string notr="true">2</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<spacer name="verticalSpacer_10">
|
||||
@@ -266,52 +270,30 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Run the following command to install the client:</string>
|
||||
<spacer name="verticalSpacer_12">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Policy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_device_detected">
|
||||
<property name="text">
|
||||
<string notr="true">label_device_detected</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,1">
|
||||
<item>
|
||||
<widget class="QPushButton" name="copy_adb_command">
|
||||
<property name="toolTip">
|
||||
<string>Copy to clipboard</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="edit-copy-symbolic"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_adb_install">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Noto Sans Mono</family>
|
||||
</font>
|
||||
</property>
|
||||
<property name="cursor">
|
||||
<cursorShape>IBeamCursor</cursorShape>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">adb install wivrn.apk</string>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextInteractionFlag::TextSelectableByKeyboard|Qt::TextInteractionFlag::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_11">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
@@ -325,16 +307,58 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWizardPage" name="page_4_connect_hmd">
|
||||
<widget class="QWizardPage" name="page_4_sideload_install">
|
||||
<property name="title">
|
||||
<string>Install the WiVRn app on your headset</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||
<item>
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Policy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Installing...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="adb_install_logs">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Noto Sans Mono</family>
|
||||
</font>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="plainText">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWizardPage" name="page_5_connect_hmd">
|
||||
<property name="title">
|
||||
<string>Start the WiVRn app and connect to this computer</string>
|
||||
</property>
|
||||
<property name="subTitle">
|
||||
<string/>
|
||||
</property>
|
||||
<attribute name="pageId">
|
||||
<string notr="true">3</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_9">
|
||||
<item>
|
||||
<spacer name="verticalSpacer_14">
|
||||
@@ -422,16 +446,13 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWizardPage" name="page_5_start_game">
|
||||
<widget class="QWizardPage" name="page_6_start_game">
|
||||
<property name="title">
|
||||
<string>Finished</string>
|
||||
</property>
|
||||
<property name="subTitle">
|
||||
<string/>
|
||||
</property>
|
||||
<attribute name="pageId">
|
||||
<string notr="true">4</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<item>
|
||||
<spacer name="verticalSpacer_16">
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# kate: syntax yaml
|
||||
id: io.github.wivrn.wivrn
|
||||
runtime: org.kde.Platform
|
||||
runtime-version: '6.7'
|
||||
@@ -28,6 +29,8 @@ finish-args:
|
||||
- --own-name=io.github.wivrn.Server
|
||||
# QSystemTrayIcon
|
||||
- --talk-name=org.kde.StatusNotifierWatcher
|
||||
# Run processes outside of sandbox
|
||||
- --talk-name=org.freedesktop.Flatpak
|
||||
|
||||
cleanup:
|
||||
- /lib/pkgconfig
|
||||
@@ -152,11 +155,11 @@ modules:
|
||||
- -DWIVRN_USE_X264=ON
|
||||
- -DWIVRN_USE_NVENC=ON
|
||||
- -DWIVRN_USE_PULSEAUDIO=OFF
|
||||
- -DWIVRN_CLIENT_URL=https://github.com/WiVRn/WiVRn/releases/latest/download/WiVRn-standard-release.apk
|
||||
- -DWIVRN_WERROR=ON
|
||||
- -DFETCHCONTENT_FULLY_DISCONNECTED=ON
|
||||
- -DFETCHCONTENT_BASE_DIR=deps
|
||||
- -DGIT_DESC=WIVRN_GIT_DESC
|
||||
- -DGIT_COMMIT=WIVRN_GIT_COMMIT
|
||||
- -Wno-dev
|
||||
sources:
|
||||
- WIVRN_SRC1
|
||||
@@ -217,4 +220,3 @@ modules:
|
||||
- trap cleanup EXIT INT TERM HUP
|
||||
-
|
||||
- wivrn-dashboard
|
||||
|
||||
|
||||
+1
-1
@@ -574,7 +574,7 @@ void on_name_acquired(GDBusConnection * connection, const gchar * name, gpointer
|
||||
on_headset_info_packet({});
|
||||
|
||||
std::ifstream file(configuration::get_config_file());
|
||||
std::string config{std::istream_iterator<char>(file), std::istream_iterator<char>()};
|
||||
std::string config{std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>()};
|
||||
|
||||
wivrn_server_set_json_configuration(dbus_server, config.c_str());
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
|
||||
#include "driver/configuration.h"
|
||||
|
||||
#include <filesystem>
|
||||
#include <iomanip>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <vector>
|
||||
@@ -230,13 +232,39 @@ int wivrn::exec_application(configuration config)
|
||||
if (config.application.empty())
|
||||
return 0;
|
||||
|
||||
std::vector<char *> argv;
|
||||
argv.reserve(config.application.size() + 1);
|
||||
std::string executable;
|
||||
std::vector<std::string> args;
|
||||
|
||||
if (std::filesystem::exists("/.flatpak-info"))
|
||||
{
|
||||
executable = "flatpak-spawn";
|
||||
args.push_back("flatpak-spawn");
|
||||
args.push_back("--host");
|
||||
}
|
||||
else
|
||||
{
|
||||
executable = config.application.front();
|
||||
}
|
||||
|
||||
for (auto & arg: config.application)
|
||||
argv.push_back(arg.data());
|
||||
args.push_back(arg.data());
|
||||
|
||||
std::vector<char *> argv;
|
||||
argv.reserve(args.size());
|
||||
|
||||
for (auto & i: args)
|
||||
argv.push_back(i.data());
|
||||
argv.push_back(nullptr);
|
||||
|
||||
execvp(config.application.front().c_str(), argv.data());
|
||||
std::cerr << "Launching " << executable << std::endl;
|
||||
std::cerr << "With args:" << std::endl;
|
||||
for (auto & i: argv)
|
||||
{
|
||||
if (i)
|
||||
std::cerr << " " << std::quoted(i) << std::endl;
|
||||
}
|
||||
|
||||
execvp(executable.c_str(), argv.data());
|
||||
|
||||
perror("Cannot start application");
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
@@ -32,13 +32,6 @@ MONADO_COMMIT=$(grep -zo "FetchContent_Declare(monado[^)]*)" ../CMakeLists.txt |
|
||||
BOOSTPFR_URL=$(grep -zo "FetchContent_Declare(boostpfr[^)]*)" ../CMakeLists.txt | sed -ze "s/^.*URL *\([^ )]*\).*$/\1/" | tr -d '\0')
|
||||
BOOSTPFR_SHA256=$(curl --silent --location $BOOSTPFR_URL | sha256sum | cut -f1 -d' ')
|
||||
|
||||
if [ -z "$GIT_TAG" ]
|
||||
then
|
||||
WIVRN_CLIENT_URL=https://github.com/WiVRn/WiVRn-APK/releases/download/apk-${GIT_SHA}/org.meumeu.wivrn-standard-release.apk
|
||||
else
|
||||
WIVRN_CLIENT_URL=https://github.com/WiVRn/WiVRn/releases/download/${GIT_TAG}/WiVRn-standard-release.apk
|
||||
fi
|
||||
|
||||
if [ $WIVRN_SRC_TYPE = git ]
|
||||
then
|
||||
WIVRN_SRC1="type: git"
|
||||
@@ -57,17 +50,16 @@ fi
|
||||
|
||||
echo "Git commit: $GIT_COMMIT" >&2
|
||||
echo "Git tag: $GIT_DESC" >&2
|
||||
echo "Client URL: $WIVRN_CLIENT_URL" >&2
|
||||
echo "Monado commit: $MONADO_COMMIT" >&2
|
||||
echo "Boost.PFR URL: $BOOSTPFR_URL" >&2
|
||||
echo "Boost.PFR SHA256: $BOOSTPFR_SHA256" >&2
|
||||
|
||||
cat ../flatpak/io.github.wivrn.wivrn.yml.in | sed \
|
||||
-e s,WIVRN_SRC1,"$WIVRN_SRC1", \
|
||||
-e s,WIVRN_SRC2,"$WIVRN_SRC2", \
|
||||
-e s,WIVRN_SRC3,"$WIVRN_SRC3", \
|
||||
-e s,WIVRN_SRC1,"$WIVRN_SRC1", \
|
||||
-e s,WIVRN_SRC2,"$WIVRN_SRC2", \
|
||||
-e s,WIVRN_SRC3,"$WIVRN_SRC3", \
|
||||
-e s,WIVRN_GIT_DESC,$GIT_DESC, \
|
||||
-e s,WIVRN_CLIENT_URL=.*,WIVRN_CLIENT_URL=$WIVRN_CLIENT_URL, \
|
||||
-e s,WIVRN_GIT_COMMIT,$GIT_COMMIT, \
|
||||
-e s,BOOSTPFR_URL,$BOOSTPFR_URL, \
|
||||
-e s,BOOSTPFR_SHA256,$BOOSTPFR_SHA256, \
|
||||
-e s,MONADO_COMMIT,$MONADO_COMMIT,
|
||||
|
||||
Reference in New Issue
Block a user