Dashboard GUI update: add button to start pairing, add banner warning about missing monado layers
This commit is contained in:
committed by
Patrick Nicolas
parent
ad7beaf80f
commit
6209d5e6d5
@@ -26,6 +26,7 @@ configure_file(wivrn_config.h.in wivrn_config.h)
|
||||
add_library(wivrn-common-base STATIC
|
||||
utils/xdg_base_directory.cpp
|
||||
utils/flatpak.cpp
|
||||
utils/strings.cpp
|
||||
${CMAKE_CURRENT_BINARY_DIR}/version.cpp
|
||||
)
|
||||
|
||||
@@ -34,6 +35,7 @@ add_library(wivrn-common STATIC
|
||||
secrets.cpp
|
||||
wivrn_sockets.cpp
|
||||
utils/xdg_base_directory.cpp
|
||||
utils/strings.cpp
|
||||
vk/allocation.cpp
|
||||
vk/error_category.cpp
|
||||
vk/vk_allocator.cpp
|
||||
|
||||
@@ -17,27 +17,74 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "strings.h"
|
||||
#include <cstdlib>
|
||||
#include <filesystem>
|
||||
|
||||
std::filesystem::path xdg_config_home()
|
||||
{
|
||||
const char * xdg_config_home = std::getenv("XDG_CONFIG_HOME");
|
||||
if (xdg_config_home)
|
||||
if (const char * xdg_config_home = std::getenv("XDG_CONFIG_HOME"))
|
||||
return xdg_config_home;
|
||||
const char * home = std::getenv("HOME");
|
||||
if (home)
|
||||
|
||||
if (const char * home = std::getenv("HOME"))
|
||||
return std::filesystem::path(home) / ".config";
|
||||
|
||||
return ".";
|
||||
}
|
||||
|
||||
std::filesystem::path xdg_cache_home()
|
||||
{
|
||||
const char * xdg_cache_home = std::getenv("XDG_CACHE_HOME");
|
||||
if (xdg_cache_home)
|
||||
if (const char * xdg_cache_home = std::getenv("XDG_CACHE_HOME"))
|
||||
return xdg_cache_home;
|
||||
const char * home = std::getenv("HOME");
|
||||
if (home)
|
||||
|
||||
if (const char * home = std::getenv("HOME"))
|
||||
return std::filesystem::path(home) / ".cache";
|
||||
|
||||
return ".";
|
||||
}
|
||||
|
||||
std::filesystem::path xdg_data_home()
|
||||
{
|
||||
if (const char * xdg_data_home = std::getenv("XDG_DATA_HOME"))
|
||||
return xdg_data_home;
|
||||
|
||||
if (const char * home = std::getenv("HOME"))
|
||||
return std::filesystem::path(home) / ".local/share";
|
||||
|
||||
return ".";
|
||||
}
|
||||
|
||||
std::vector<std::filesystem::path> xdg_config_dirs()
|
||||
{
|
||||
std::vector<std::filesystem::path> paths;
|
||||
|
||||
if (const char * xdg_config_dirs = std::getenv("XDG_CONFIG_DIRS"))
|
||||
{
|
||||
for (const auto & path: utils::split(xdg_config_dirs, ":"))
|
||||
paths.push_back(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
paths.push_back("/etc/xdg");
|
||||
}
|
||||
|
||||
return paths;
|
||||
}
|
||||
|
||||
std::vector<std::filesystem::path> xdg_data_dirs()
|
||||
{
|
||||
std::vector<std::filesystem::path> paths;
|
||||
|
||||
if (const char * xdg_config_dirs = std::getenv("XDG_DATA_DIRS"))
|
||||
{
|
||||
for (const auto & path: utils::split(xdg_config_dirs, ":"))
|
||||
paths.push_back(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
paths.push_back("/usr/local/share");
|
||||
paths.push_back("/usr/share");
|
||||
}
|
||||
|
||||
return paths;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <vector>
|
||||
|
||||
std::filesystem::path xdg_config_home();
|
||||
std::filesystem::path xdg_cache_home();
|
||||
std::filesystem::path xdg_data_home();
|
||||
std::vector<std::filesystem::path> xdg_config_dirs();
|
||||
std::vector<std::filesystem::path> xdg_data_dirs();
|
||||
|
||||
@@ -66,6 +66,7 @@ target_link_libraries(wivrn-dashboard PRIVATE
|
||||
Qt6::Network
|
||||
nlohmann_json
|
||||
wivrn-common-base
|
||||
Vulkan::Vulkan
|
||||
)
|
||||
|
||||
target_compile_definitions(wivrn-dashboard PRIVATE JSON_DIAGNOSTICS=1)
|
||||
|
||||
+138
-5
@@ -27,11 +27,15 @@
|
||||
|
||||
#include <chrono>
|
||||
#include <cmath>
|
||||
#include <fstream>
|
||||
|
||||
#include "adb.h"
|
||||
#include "gui_config.h"
|
||||
#include "settings.h"
|
||||
#include "ui_main_window.h"
|
||||
#include "utils/flatpak.h"
|
||||
#include "utils/strings.h"
|
||||
#include "utils/xdg_base_directory.h"
|
||||
#include "wivrn_server.h"
|
||||
#include "wizard.h"
|
||||
|
||||
@@ -39,6 +43,9 @@
|
||||
#include <sys/capability.h>
|
||||
#endif
|
||||
|
||||
#include <vulkan/vulkan.hpp>
|
||||
#include <vulkan/vulkan_raii.hpp>
|
||||
|
||||
Q_LOGGING_CATEGORY(wivrn_log_category, "wivrn")
|
||||
|
||||
enum class server_state
|
||||
@@ -74,6 +81,121 @@ static bool server_has_cap_sys_nice()
|
||||
}
|
||||
#endif
|
||||
|
||||
std::vector<std::filesystem::path> layer_dirs()
|
||||
{
|
||||
// See https://vulkan.lunarg.com/doc/view/latest/linux/loader_and_layer_interface.html#user-content-linux-layer-discovery
|
||||
std::vector<std::filesystem::path> dirs;
|
||||
|
||||
dirs.push_back(xdg_config_home() / "vulkan/implicit_layer.d");
|
||||
|
||||
for (auto dir: xdg_config_dirs())
|
||||
dirs.push_back(dir / "vulkan/implicit_layer.d");
|
||||
|
||||
dirs.push_back("/etc/vulkan/implicit_layer.d");
|
||||
|
||||
dirs.push_back(xdg_data_home() / "vulkan/implicit_layer.d");
|
||||
|
||||
for (auto dir: xdg_data_dirs())
|
||||
dirs.push_back(dir / "vulkan/implicit_layer.d");
|
||||
|
||||
return dirs;
|
||||
}
|
||||
|
||||
static std::string read_file(const std::filesystem::path & path)
|
||||
{
|
||||
if (wivrn::flatpak_key(wivrn::flatpak::section::session_bus_policy, "org.freedesktop.Flatpak") == "talk")
|
||||
{
|
||||
QProcess flatpak_spawn;
|
||||
flatpak_spawn.start("flatpak-spawn", {"--host", "cat", QString::fromStdString(path)});
|
||||
flatpak_spawn.waitForFinished();
|
||||
return flatpak_spawn.readAllStandardOutput().toStdString();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::ifstream f(path);
|
||||
std::istreambuf_iterator<char> begin{f}, end;
|
||||
|
||||
return {begin, end};
|
||||
}
|
||||
}
|
||||
|
||||
static std::vector<std::filesystem::path> list_files(const std::vector<std::filesystem::path> & dirs)
|
||||
{
|
||||
std::vector<std::filesystem::path> files;
|
||||
|
||||
if (wivrn::flatpak_key(wivrn::flatpak::section::session_bus_policy, "org.freedesktop.Flatpak") == "talk")
|
||||
{
|
||||
QProcess flatpak_spawn;
|
||||
QStringList args{"--host", "find"};
|
||||
for (const std::filesystem::path & dir: dirs)
|
||||
args.push_back(QString::fromStdString(dir));
|
||||
args.push_back("-name");
|
||||
args.push_back("*.json");
|
||||
|
||||
flatpak_spawn.start("flatpak-spawn", args);
|
||||
flatpak_spawn.waitForFinished();
|
||||
|
||||
qDebug() << args;
|
||||
|
||||
for (const std::string & file: utils::split(flatpak_spawn.readAllStandardOutput().toStdString()))
|
||||
{
|
||||
if (file != "")
|
||||
files.push_back(file);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (const std::filesystem::path & dir: dirs)
|
||||
{
|
||||
try
|
||||
{
|
||||
for (auto const & dir_entry: std::filesystem::directory_iterator{dir})
|
||||
{
|
||||
if (dir_entry.path().extension() != ".json")
|
||||
continue;
|
||||
|
||||
files.push_back(dir / dir_entry.path());
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
// Ignore non existing directories
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
static bool nvidia_layer_missing()
|
||||
{
|
||||
vk::raii::Context context;
|
||||
|
||||
vk::ApplicationInfo app_info{"WiVRn dashboard", 1, "No engine", 1, VK_API_VERSION_1_0};
|
||||
vk::InstanceCreateInfo instance_info{vk::InstanceCreateFlags{0}, &app_info};
|
||||
vk::raii::Instance vulkan{context, instance_info};
|
||||
|
||||
// Check if an nvidia GPU is present
|
||||
if (not std::ranges::any_of(vulkan.enumeratePhysicalDevices(), [](vk::raii::PhysicalDevice & device) { return device.getProperties().vendorID == 0x10de; }))
|
||||
return false;
|
||||
|
||||
// Check if the monado vulkan layer is present
|
||||
for (auto file: list_files(layer_dirs()))
|
||||
{
|
||||
try
|
||||
{
|
||||
nlohmann::json json = nlohmann::json::parse(read_file(file));
|
||||
if (json["layer"]["name"] == "VK_LAYER_MND_enable_timeline_semaphore")
|
||||
return false;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
main_window::main_window()
|
||||
{
|
||||
ui = new Ui::MainWindow;
|
||||
@@ -138,9 +260,15 @@ main_window::main_window()
|
||||
connect(server_interface, &wivrn_server::supportedCodecsChanged, this, &main_window::on_supported_codecs_changed);
|
||||
connect(server_interface, &wivrn_server::steamCommandChanged, this, &main_window::on_steam_command_changed);
|
||||
|
||||
connect(server_interface, &wivrn_server::encryptionEnabledChanged, ui->widget_authentication, &QWidget::setVisible);
|
||||
connect(server_interface, &wivrn_server::pinChanged, this, &main_window::on_pin_changed);
|
||||
on_pin_changed(server_interface->pin());
|
||||
|
||||
connect(server_interface, &wivrn_server::enrollEnabledChanged, ui->button_cancel_pairing, &QWidget::setVisible);
|
||||
connect(server_interface, &wivrn_server::enrollEnabledChanged, ui->button_pair_headset, &QWidget::setHidden);
|
||||
connect(ui->button_cancel_pairing, &QPushButton::clicked, server_interface, &wivrn_server::disable_enroll_headset);
|
||||
connect(ui->button_pair_headset, &QPushButton::clicked, server_interface, &wivrn_server::enroll_headset);
|
||||
|
||||
connect(ui->button_start, &QPushButton::clicked, this, &main_window::start_server);
|
||||
connect(ui->button_stop, &QPushButton::clicked, this, &main_window::stop_server);
|
||||
connect(ui->button_settings, &QPushButton::clicked, this, &main_window::on_action_settings);
|
||||
@@ -161,8 +289,7 @@ main_window::main_window()
|
||||
on_android_device_list_changed(adb_service.devices());
|
||||
|
||||
#if WIVRN_CHECK_CAPSYSNICE
|
||||
QIcon icon = QIcon::fromTheme("dialog-information");
|
||||
ui->banner_capsysnice_icon->setPixmap(icon.pixmap(ui->banner_capsysnice_dismiss->height()));
|
||||
ui->banner_capsysnice_icon->setPixmap(QIcon::fromTheme("dialog-information").pixmap(ui->banner_capsysnice_dismiss->height()));
|
||||
connect(ui->banner_capsysnice_text, &QLabel::linkActivated, this, &main_window::on_banner_capsysnice);
|
||||
|
||||
if (server_has_cap_sys_nice())
|
||||
@@ -171,6 +298,10 @@ main_window::main_window()
|
||||
ui->banner_capsysnice->hide();
|
||||
#endif
|
||||
|
||||
ui->banner_nvidia_layer_icon->setPixmap(QIcon::fromTheme("dialog-information").pixmap(ui->banner_nvidia_layer_dismiss->height()));
|
||||
if (not nvidia_layer_missing())
|
||||
ui->banner_nvidia_layer->hide();
|
||||
|
||||
// TODO implement this
|
||||
ui->button_known_headsets->hide();
|
||||
|
||||
@@ -536,8 +667,10 @@ void main_window::on_steam_command_changed(QString value)
|
||||
|
||||
void main_window::on_pin_changed(QString value)
|
||||
{
|
||||
ui->widget_authentication->setVisible(value != "");
|
||||
ui->label_pin->setText(value);
|
||||
if (value == "")
|
||||
ui->label_pin->setText("");
|
||||
else
|
||||
ui->label_pin->setText(tr("To pair your headset use the following PIN: %1").arg(value));
|
||||
}
|
||||
|
||||
void main_window::on_server_finished(int exit_code, QProcess::ExitStatus status)
|
||||
@@ -563,7 +696,7 @@ void main_window::on_server_finished(int exit_code, QProcess::ExitStatus status)
|
||||
error_message = tr("Insufficient system resources");
|
||||
break;
|
||||
case 4:
|
||||
error_message = tr("Cannot connect to avahi, make sure avahi-daemon service is started");
|
||||
error_message = tr("Cannot connect to avahi, make sure avahi-daemon service is started with \"disable-user-service-publishing\" set to no");
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
+114
-58
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>898</width>
|
||||
<height>757</height>
|
||||
<width>895</width>
|
||||
<height>842</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -18,11 +18,11 @@
|
||||
<normaloff>:/images/wivrn.svg</normaloff>:/images/wivrn.svg</iconset>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,0,0,1,0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QFrame" name="banner_capsysnice">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">#banner_capsysnice
|
||||
<string notr="true">.QFrame
|
||||
{
|
||||
background-color: rgb(255, 170, 127);
|
||||
border: 1px solid rgb(255, 127, 127);
|
||||
@@ -57,6 +57,44 @@ border-radius: 5px;
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="banner_nvidia_layer">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">.QFrame
|
||||
{
|
||||
background-color: rgb(255, 170, 127);
|
||||
border: 1px solid rgb(255, 127, 127);
|
||||
border-radius: 5px;
|
||||
}</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Shape::Box</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_10" stretch="0,1,0">
|
||||
<item>
|
||||
<widget class="QLabel" name="banner_nvidia_layer_icon">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="banner_nvidia_layer_text">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p>The Monado NVIDIA layer is not installed.</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="banner_nvidia_layer_dismiss">
|
||||
<property name="icon">
|
||||
<iconset theme="window-close"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="group_server">
|
||||
<property name="title">
|
||||
@@ -179,56 +217,7 @@ border-radius: 5px;
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_authentication" stretch=""/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_authentication" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_8" stretch="0,1,0">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_16">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>14</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PIN:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_pin">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>14</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">000000</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="button_known_headsets">
|
||||
<property name="text">
|
||||
<string>Known headsets</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" name="layout_authentication"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
@@ -360,6 +349,57 @@ border-radius: 5px;
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_authentication" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_8" stretch="1,0,0,0">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_pin">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>14</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">label_pin</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="button_pair_headset">
|
||||
<property name="text">
|
||||
<string>Pair headset</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="button_cancel_pairing">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="button_known_headsets">
|
||||
<property name="text">
|
||||
<string>Known headsets</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_how_to_connect">
|
||||
<property name="text">
|
||||
@@ -613,12 +653,28 @@ border-radius: 5px;
|
||||
<slot>hide()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>837</x>
|
||||
<y>31</y>
|
||||
<x>881</x>
|
||||
<y>44</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>799</x>
|
||||
<y>54</y>
|
||||
<x>805</x>
|
||||
<y>51</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>banner_nvidia_layer_dismiss</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>banner_nvidia_layer</receiver>
|
||||
<slot>hide()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>869</x>
|
||||
<y>82</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>852</x>
|
||||
<y>102</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
|
||||
Reference in New Issue
Block a user