Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Vindicus999
2025-08-04 11:15:24 +00:00
9 changed files with 342 additions and 135 deletions
+11 -1
View File
@@ -440,7 +440,17 @@ void scenes::lobby::gui_connected()
if (std::chrono::steady_clock::now() - t0 > 10ms) if (std::chrono::steady_clock::now() - t0 > 10ms)
return default_icon; return default_icon;
it = app_icons.emplace(app.id, imgui_ctx->load_texture(app.image)).first; try
{
it = app_icons.emplace(app.id, imgui_ctx->load_texture(app.image)).first;
}
catch (std::exception & e)
{
spdlog::warn("Unable to load icon for \"{}\": {}", app.id, e.what());
app.image.clear();
return default_icon;
}
} }
return it->second; return it->second;
} }
+28 -20
View File
@@ -116,7 +116,7 @@ std::vector<std::byte> load_steam_icon(const std::filesystem::path & root, int a
return {}; return {};
} }
void read_steam_vr_apps(std::unordered_map<std::string, application> & res) void read_steam_vr_apps(std::unordered_map<std::string, application> & res, bool load_icons)
{ {
auto [command, root] = find_steam(); auto [command, root] = find_steam();
if (not root) if (not root)
@@ -166,17 +166,20 @@ void read_steam_vr_apps(std::unordered_map<std::string, application> & res)
} }
} }
try if (load_icons)
{ {
const char prefix[] = "steam.app."; try
if (app_key.starts_with(prefix)) {
const char prefix[] = "steam.app.";
if (app_key.starts_with(prefix))
{
uint32_t app_id = stoll(app_key.substr(strlen(prefix)));
app.image = load_steam_icon(*root, app_id, info);
}
}
catch (...)
{ {
uint32_t app_id = stoll(app_key.substr(strlen(prefix)));
app.image = load_steam_icon(*root, app_id, info);
} }
}
catch (...)
{
} }
if (not app.exec.empty()) if (not app.exec.empty())
@@ -278,7 +281,7 @@ bool contains(std::string_view entries, std::string_view val, char sep = ';')
return false; return false;
} }
std::optional<application> do_desktop_entry(const std::filesystem::path & filename) std::optional<application> do_desktop_entry(const std::filesystem::path & filename, bool load_icons)
{ {
auto data = read_file(filename); auto data = read_file(filename);
std::optional<application> res; std::optional<application> res;
@@ -320,10 +323,15 @@ std::optional<application> do_desktop_entry(const std::filesystem::path & filena
res->exec = unescape(item.value); res->exec = unescape(item.value);
if (item.key == "Path") if (item.key == "Path")
res->path = unescape(item.value); res->path = unescape(item.value);
if (item.key == "Icon") if (item.key == "Icon" and load_icons)
{ {
if (auto filename = xdg_icon_lookup(std::string{item.value}, 256)) try
res->image = load_icon(*filename, 256); {
if (auto filename = xdg_icon_lookup(std::string{item.value}, 256))
res->image = load_icon(*filename, 256);
}
catch (...)
{}
} }
} }
@@ -333,7 +341,7 @@ std::optional<application> do_desktop_entry(const std::filesystem::path & filena
return res; return res;
} }
void do_data_dir(std::filesystem::path dir, std::unordered_map<std::string, application> & res) void do_data_dir(std::filesystem::path dir, std::unordered_map<std::string, application> & res, bool load_icons)
{ {
dir = dir / "applications"; dir = dir / "applications";
if (not std::filesystem::is_directory(dir)) if (not std::filesystem::is_directory(dir))
@@ -356,29 +364,29 @@ void do_data_dir(std::filesystem::path dir, std::unordered_map<std::string, appl
if (res.contains(file_id)) if (res.contains(file_id))
continue; continue;
auto app = do_desktop_entry(entry.path()); auto app = do_desktop_entry(entry.path(), load_icons);
if (app) if (app)
res.emplace(std::move(file_id), std::move(*app)); res.emplace(std::move(file_id), std::move(*app));
} }
} }
} // namespace } // namespace
std::unordered_map<std::string, application> list_applications(bool include_steam) std::unordered_map<std::string, application> list_applications(bool include_steam, bool load_icons)
{ {
std::unordered_map<std::string, application> res; std::unordered_map<std::string, application> res;
if (include_steam) if (include_steam)
read_steam_vr_apps(res); read_steam_vr_apps(res, load_icons);
do_data_dir(xdg_data_home(), res); do_data_dir(xdg_data_home(), res, load_icons);
for (auto && dir: xdg_data_dirs()) for (auto && dir: xdg_data_dirs())
do_data_dir(std::move(dir), res); do_data_dir(std::move(dir), res, load_icons);
if (wivrn::is_flatpak()) if (wivrn::is_flatpak())
{ {
// Try to guess host data dirs // Try to guess host data dirs
do_data_dir("/run/host/usr/share", res); do_data_dir("/run/host/usr/share", res, load_icons);
} }
return res; return res;
+1 -1
View File
@@ -35,5 +35,5 @@ struct application
std::optional<std::string> path; std::optional<std::string> path;
}; };
std::unordered_map<std::string, application> list_applications(bool include_steam = true); std::unordered_map<std::string, application> list_applications(bool include_steam = true, bool load_icons = true);
} // namespace wivrn } // namespace wivrn
+204 -69
View File
@@ -61,13 +61,15 @@ T read(std::span<std::byte> & buffer)
return value; return value;
} }
std::span<std::byte> read(std::span<std::byte> & buffer, size_t size) template <typename T>
requires std::is_integral_v<T>
std::span<T> read(std::span<std::byte> & buffer, size_t count)
{ {
if (size > buffer.size()) if (count * sizeof(T) > buffer.size())
throw std::runtime_error{"File truncated"}; throw std::runtime_error{"File truncated"};
std::span<std::byte> value{buffer.data(), size}; std::span<T> value{reinterpret_cast<T *>(buffer.data()), count};
buffer = buffer.subspan(size); buffer = buffer.subspan(count * sizeof(T));
return value; return value;
} }
@@ -160,41 +162,40 @@ struct ico_file_entry
std::span<std::byte> data; std::span<std::byte> data;
}; };
int rowstride(int width, int bpp) constexpr int rowstride(int width, int bpp)
{ {
switch (bpp) int words_per_line = (width * bpp + 31) / 32;
{ return words_per_line * 4;
case 1:
if ((width % 32) == 0)
return width / 8;
else
return 4 * (width / 32 + 1);
// case 4:
// if ((width % 8) == 0)
// return width / 2;
// else
// return 4 * (width / 8 + 1);
//
// case 8:
// if ((width % 4) == 0)
// return width;
// else
// return 4 * (width / 4 + 1);
case 24:
if (((width * 3) % 4) == 0)
return width * 3;
else
return 4 * (width * 3 / 4 + 1);
case 32:
return width * 4;
default:
return 0;
}
} }
static_assert(rowstride(1, 1) == 4);
static_assert(rowstride(8, 1) == 4);
static_assert(rowstride(16, 1) == 4);
static_assert(rowstride(32, 1) == 4);
static_assert(rowstride(33, 1) == 8);
static_assert(rowstride(1, 4) == 4);
static_assert(rowstride(8, 4) == 4);
static_assert(rowstride(16, 4) == 8);
static_assert(rowstride(32, 4) == 16);
static_assert(rowstride(33, 4) == 20);
static_assert(rowstride(1, 8) == 4);
static_assert(rowstride(8, 8) == 8);
static_assert(rowstride(16, 8) == 16);
static_assert(rowstride(32, 8) == 32);
static_assert(rowstride(33, 8) == 36);
static_assert(rowstride(1, 24) == 4);
static_assert(rowstride(8, 24) == 24);
static_assert(rowstride(16, 24) == 48);
static_assert(rowstride(32, 24) == 96);
static_assert(rowstride(33, 24) == 100);
static_assert(rowstride(1, 32) == 4);
static_assert(rowstride(8, 32) == 32);
static_assert(rowstride(16, 32) == 64);
static_assert(rowstride(32, 32) == 128);
static_assert(rowstride(33, 32) == 132);
std::vector<std::byte> load_ico(const std::filesystem::path & filename, int size, int index = -1) std::vector<std::byte> load_ico(const std::filesystem::path & filename, int size, int index = -1)
{ {
@@ -228,8 +229,10 @@ std::vector<std::byte> load_ico(const std::filesystem::path & filename, int size
auto size = read<uint32_t>(header); auto size = read<uint32_t>(header);
auto offset = read<uint32_t>(header); auto offset = read<uint32_t>(header);
entry.data = std::span{ico}.subspan(offset, size); if (offset + size > ico.size())
return {};
entry.data = std::span{ico}.subspan(offset, size);
if (entry.width == 0) if (entry.width == 0)
entry.width = 256; entry.width = 256;
if (entry.height == 0) if (entry.height == 0)
@@ -239,17 +242,13 @@ std::vector<std::byte> load_ico(const std::filesystem::path & filename, int size
if (planes != 0 and planes != 1) if (planes != 0 and planes != 1)
return {}; return {};
// Ignore 16bpp and less
if (entry.bpp < 24)
continue;
entries.push_back(entry); entries.push_back(entry);
max_bpp = std::max(max_bpp, entry.bpp); max_bpp = std::max(max_bpp, entry.bpp);
} }
const ico_file_entry & best_entry = index >= 0 ? entries.at(index) : [&]() { const ico_file_entry * best_entry = index >= 0 ? &entries.at(index) : [&]() {
const ico_file_entry * best_entry; const ico_file_entry * best_entry = nullptr;
// Look for the smallest multiple of the requested size // Look for the smallest multiple of the requested size
int criterion = std::numeric_limits<int>::max(); int criterion = std::numeric_limits<int>::max();
@@ -269,7 +268,7 @@ std::vector<std::byte> load_ico(const std::filesystem::path & filename, int size
} }
} }
if (best_entry) if (best_entry)
return *best_entry; return best_entry;
// No multiple found: pick the largest icon // No multiple found: pick the largest icon
criterion = 0; criterion = 0;
@@ -285,17 +284,41 @@ std::vector<std::byte> load_ico(const std::filesystem::path & filename, int size
best_entry = &entry; best_entry = &entry;
} }
} }
return *best_entry; return best_entry;
}(); }();
auto data = best_entry.data; if (not best_entry)
return {};
auto data = best_entry->data;
auto magic = read<uint32_t>(data); auto magic = read<uint32_t>(data);
if (magic == ICO_PNG_MAGIC) if (magic == ICO_PNG_MAGIC)
{ {
// PNG file // PNG file
std::vector<std::byte> png_data; std::vector<std::byte> png_data;
png_data.insert(png_data.end(), data.begin(), data.end());
// The PNG magic has already been consumed, put it back
png_data.insert(png_data.end(), data.begin() - 4, data.end());
// Check if the PNG is valid
std::vector<uint8_t> pixels;
png_image png_ref{
.version = PNG_IMAGE_VERSION,
.format = PNG_FORMAT_BGRA,
};
if (not png_image_begin_read_from_memory(&png_ref, png_data.data(), png_data.size()))
return {};
pixels.resize(PNG_IMAGE_SIZE(png_ref));
if (!png_image_finish_read(&png_ref, nullptr, pixels.data(), 0, nullptr))
{
png_image_free(&png_ref);
return {};
}
png_image_free(&png_ref);
return png_data; return png_data;
} }
else if (magic == 40) else if (magic == 40)
@@ -325,44 +348,45 @@ std::vector<std::byte> load_ico(const std::filesystem::path & filename, int size
auto w = width; auto w = width;
auto h = height / 2; auto h = height / 2;
// Don't bother supporting paletted icons std::span<uint8_t> palette; // BGRX
// std::vector<uint32_t> palette;
// if (bpp <= 16)
// if (bpp <= 8) {
// { // Load the palette
// // Load the palette if (used_colors == 0)
// if (used_colors == 0) used_colors = 1 << bpp;
// used_colors = 1 << bpp;
// palette = read<uint8_t>(data, used_colors * 4);
// palette.resize(used_colors); }
// for (int i = 0; i < palette.size(); i++)
// palette[i] = read<uint32_t>(data);
// }
size_t xor_stride = rowstride(w, bpp); size_t xor_stride = rowstride(w, bpp);
size_t and_stride = rowstride(w, 1); size_t and_stride = rowstride(w, 1);
size_t dst_stride = 4 * w; size_t dst_stride = 4 * w;
std::span<std::byte> xor_map = read(data, xor_stride * h); std::span<uint8_t> xor_map = read<uint8_t>(data, xor_stride * h);
std::span<std::byte> and_map = read(data, and_stride * h); std::span<uint8_t> and_map = read<uint8_t>(data, and_stride * h);
std::vector<uint8_t> dest_buffer; std::vector<uint8_t> dest_buffer;
dest_buffer.resize(h * dst_stride); dest_buffer.resize(h * dst_stride);
switch (bpp) switch (bpp)
{ {
case 24: case 1:
for (int y = 0; y < h; y++) for (int y = 0; y < h; y++)
{ {
uint8_t * src_xor_row = (uint8_t *)xor_map.data() + xor_stride * y; uint8_t * src_xor_row = xor_map.data() + xor_stride * y;
uint8_t * src_and_row = (uint8_t *)and_map.data() + and_stride * y; uint8_t * src_and_row = and_map.data() + and_stride * y;
uint8_t * dst_row = dest_buffer.data() + dst_stride * (h - 1 - y); uint8_t * dst_row = dest_buffer.data() + dst_stride * (h - 1 - y);
for (int x = 0, i = 0; x < w; x++) for (int x = 0, i = 0; x < w; x++)
{ {
uint8_t b = *src_xor_row++; // Red int colour = (src_xor_row[x / 8] >> (7 - (x % 8))) & 0x1;
uint8_t g = *src_xor_row++; // Green if (colour >= used_colors)
uint8_t r = *src_xor_row++; // Blue return {};
uint8_t b = palette[4 * colour + 0]; // Blue
uint8_t g = palette[4 * colour + 1]; // Green
uint8_t r = palette[4 * colour + 2]; // Red
// Get alpha from AND mask (0: opaque => 0xff, 1: transparent => 0) // Get alpha from AND mask (0: opaque => 0xff, 1: transparent => 0)
uint8_t a = src_and_row[x / 8] & (1 << (7 - x % 8)) ? 0 : 0xff; uint8_t a = src_and_row[x / 8] & (1 << (7 - x % 8)) ? 0 : 0xff;
@@ -373,6 +397,117 @@ std::vector<std::byte> load_ico(const std::filesystem::path & filename, int size
*dst_row++ = a; *dst_row++ = a;
} }
} }
break;
case 4:
for (int y = 0; y < h; y++)
{
uint8_t * src_xor_row = xor_map.data() + xor_stride * y;
uint8_t * src_and_row = and_map.data() + and_stride * y;
uint8_t * dst_row = dest_buffer.data() + dst_stride * (h - 1 - y);
for (int x = 0, i = 0; x < w; x++)
{
int colour = (src_xor_row[x / 2] >> (4 - 4 * (x % 2))) & 0xf;
if (colour >= used_colors)
return {};
uint8_t b = palette[4 * colour + 0]; // Blue
uint8_t g = palette[4 * colour + 1]; // Green
uint8_t r = palette[4 * colour + 2]; // Red
// Get alpha from AND mask (0: opaque => 0xff, 1: transparent => 0)
uint8_t a = src_and_row[x / 8] & (1 << (7 - x % 8)) ? 0 : 0xff;
*dst_row++ = b;
*dst_row++ = g;
*dst_row++ = r;
*dst_row++ = a;
}
}
break;
case 8:
for (int y = 0; y < h; y++)
{
uint8_t * src_xor_row = xor_map.data() + xor_stride * y;
uint8_t * src_and_row = and_map.data() + and_stride * y;
uint8_t * dst_row = dest_buffer.data() + dst_stride * (h - 1 - y);
for (int x = 0, i = 0; x < w; x++)
{
int colour = *src_xor_row++;
if (colour >= used_colors)
return {};
uint8_t b = palette[4 * colour + 0]; // Blue
uint8_t g = palette[4 * colour + 1]; // Green
uint8_t r = palette[4 * colour + 2]; // Red
// Get alpha from AND mask (0: opaque => 0xff, 1: transparent => 0)
uint8_t a = src_and_row[x / 8] & (1 << (7 - x % 8)) ? 0 : 0xff;
*dst_row++ = b;
*dst_row++ = g;
*dst_row++ = r;
*dst_row++ = a;
}
}
break;
case 16:
for (int y = 0; y < h; y++)
{
uint8_t * src_xor_row = xor_map.data() + xor_stride * y;
uint8_t * src_and_row = and_map.data() + and_stride * y;
uint8_t * dst_row = dest_buffer.data() + dst_stride * (h - 1 - y);
for (int x = 0, i = 0; x < w; x++)
{
int colour = (src_xor_row[1] << 8) | src_xor_row[0];
src_xor_row += 2;
if (colour >= used_colors)
return {};
uint8_t b = palette[4 * colour + 0]; // Blue
uint8_t g = palette[4 * colour + 1]; // Green
uint8_t r = palette[4 * colour + 2]; // Red
// Get alpha from AND mask (0: opaque => 0xff, 1: transparent => 0)
uint8_t a = src_and_row[x / 8] & (1 << (7 - x % 8)) ? 0 : 0xff;
*dst_row++ = b;
*dst_row++ = g;
*dst_row++ = r;
*dst_row++ = a;
}
}
break;
case 24:
for (int y = 0; y < h; y++)
{
uint8_t * src_xor_row = xor_map.data() + xor_stride * y;
uint8_t * src_and_row = and_map.data() + and_stride * y;
uint8_t * dst_row = dest_buffer.data() + dst_stride * (h - 1 - y);
for (int x = 0, i = 0; x < w; x++)
{
uint8_t b = *src_xor_row++; // Blue
uint8_t g = *src_xor_row++; // Green
uint8_t r = *src_xor_row++; // Red
// Get alpha from AND mask (0: opaque => 0xff, 1: transparent => 0)
uint8_t a = src_and_row[x / 8] & (1 << (7 - x % 8)) ? 0 : 0xff;
*dst_row++ = b;
*dst_row++ = g;
*dst_row++ = r;
*dst_row++ = a;
}
}
break;
case 32: case 32:
for (int y = 0; y < h; y++) for (int y = 0; y < h; y++)
+42 -14
View File
@@ -28,6 +28,7 @@
#include <cstddef> #include <cstddef>
#include <cstdint> #include <cstdint>
#include <cstring> #include <cstring>
#include <limits>
#include <optional> #include <optional>
#include <span> #include <span>
#include <stdexcept> #include <stdexcept>
@@ -124,6 +125,13 @@ public:
std::runtime_error("Deserialization error\n" + hexdump(raw_data)) {} std::runtime_error("Deserialization error\n" + hexdump(raw_data)) {}
}; };
class serialization_error : public std::runtime_error
{
public:
serialization_error() :
std::runtime_error("Serialization error") {}
};
class serialization_packet class serialization_packet
{ {
std::vector<uint8_t> buffer; std::vector<uint8_t> buffer;
@@ -547,6 +555,8 @@ struct serialization_traits<T, std::enable_if_t<std::is_aggregate_v<T> && !is_st
template <> template <>
struct serialization_traits<std::string> struct serialization_traits<std::string>
{ {
using size_type = uint16_t;
static constexpr void type_hash(details::hash_context & h) static constexpr void type_hash(details::hash_context & h)
{ {
h.feed("string"); h.feed("string");
@@ -554,14 +564,17 @@ struct serialization_traits<std::string>
static void serialize(const std::string & value, serialization_packet & packet) static void serialize(const std::string & value, serialization_packet & packet)
{ {
packet.serialize<uint16_t>(value.size()); if (value.size() > std::numeric_limits<size_type>::max())
throw serialization_error{};
packet.serialize<size_type>(value.size());
packet.write(value.data(), value.size()); packet.write(value.data(), value.size());
} }
static std::string deserialize(deserialization_packet & packet) static std::string deserialize(deserialization_packet & packet)
{ {
std::string value; std::string value;
size_t size = packet.deserialize<uint16_t>(); size_t size = packet.deserialize<size_type>();
packet.check_remaining_size(size); packet.check_remaining_size(size);
@@ -576,13 +589,15 @@ struct serialization_traits<std::string>
} }
static size_t size(const std::string & value) static size_t size(const std::string & value)
{ {
return sizeof(uint16_t) + value.size(); return sizeof(size_type) + value.size();
} }
}; };
template <typename T> template <typename T>
struct serialization_traits<std::vector<T>> struct serialization_traits<std::vector<T>>
{ {
using size_type = uint16_t;
static constexpr void type_hash(details::hash_context & h) static constexpr void type_hash(details::hash_context & h)
{ {
h.feed("vector<"); h.feed("vector<");
@@ -592,7 +607,10 @@ struct serialization_traits<std::vector<T>>
static void serialize(const std::vector<T> & value, serialization_packet & packet) static void serialize(const std::vector<T> & value, serialization_packet & packet)
{ {
packet.serialize<uint16_t>(value.size()); if (value.size() > std::numeric_limits<size_type>::max())
throw serialization_error{};
packet.serialize<size_type>(value.size());
if constexpr (serialization_traits<T>::is_trivially_serializable()) if constexpr (serialization_traits<T>::is_trivially_serializable())
{ {
@@ -608,7 +626,7 @@ struct serialization_traits<std::vector<T>>
static std::vector<T> deserialize(deserialization_packet & packet) static std::vector<T> deserialize(deserialization_packet & packet)
{ {
std::vector<T> value; std::vector<T> value;
size_t size = packet.deserialize<uint16_t>(); size_t size = packet.deserialize<size_type>();
if constexpr (serialization_traits<T>::is_trivially_serializable()) if constexpr (serialization_traits<T>::is_trivially_serializable())
{ {
@@ -635,10 +653,10 @@ struct serialization_traits<std::vector<T>>
static size_t size(const std::vector<T> & value) static size_t size(const std::vector<T> & value)
{ {
if constexpr (is_trivially_serializable()) if constexpr (is_trivially_serializable())
return sizeof(uint16_t) + value.size() * sizeof(T); return sizeof(size_type) + value.size() * sizeof(T);
else else
{ {
size_t res = sizeof(uint16_t); size_t res = sizeof(size_type);
for (const auto & item: value) for (const auto & item: value)
res += serialized_size(item); res += serialized_size(item);
return res; return res;
@@ -756,6 +774,9 @@ struct serialization_traits<std::array<T, N>>
template <typename... T> template <typename... T>
struct serialization_traits<std::variant<T...>> struct serialization_traits<std::variant<T...>>
{ {
using size_type = uint8_t;
static_assert(sizeof...(T) <= std::numeric_limits<size_type>::max() + 1);
template <typename U, typename... V> template <typename U, typename... V>
static constexpr void type_list_hash(details::hash_context & h) static constexpr void type_list_hash(details::hash_context & h)
{ {
@@ -777,7 +798,7 @@ struct serialization_traits<std::variant<T...>>
static void serialize(const std::variant<T...> & value, serialization_packet & packet) static void serialize(const std::variant<T...> & value, serialization_packet & packet)
{ {
packet.serialize<uint8_t>(value.index()); packet.serialize<size_type>(value.index());
std::visit([&](const auto & x) { packet.serialize(x); }, value); std::visit([&](const auto & x) { packet.serialize(x); }, value);
} }
@@ -794,7 +815,7 @@ struct serialization_traits<std::variant<T...>>
static std::variant<T...> deserialize(deserialization_packet & packet) static std::variant<T...> deserialize(deserialization_packet & packet)
{ {
uint8_t type_index = packet.deserialize<uint8_t>(); size_type type_index = packet.deserialize<size_type>();
if (type_index >= sizeof...(T)) if (type_index >= sizeof...(T))
throw deserialization_error(packet.initial_buffer); throw deserialization_error(packet.initial_buffer);
@@ -807,7 +828,7 @@ struct serialization_traits<std::variant<T...>>
static size_t size(const std::variant<T...> & value) static size_t size(const std::variant<T...> & value)
{ {
return 1 + std::visit([](const auto & x) { return serialized_size(x); }, value); return sizeof(size_type) + std::visit([](const auto & x) { return serialized_size(x); }, value);
} }
}; };
@@ -850,6 +871,8 @@ struct serialization_traits<std::chrono::duration<Rep, Period>>
template <> template <>
struct serialization_traits<std::span<uint8_t>> struct serialization_traits<std::span<uint8_t>>
{ {
using size_type = uint16_t;
static constexpr void type_hash(details::hash_context & h) static constexpr void type_hash(details::hash_context & h)
{ {
h.feed("span<uint8_t>"); h.feed("span<uint8_t>");
@@ -857,22 +880,27 @@ struct serialization_traits<std::span<uint8_t>>
static void serialize(const std::span<uint8_t> & value, serialization_packet & packet) static void serialize(const std::span<uint8_t> & value, serialization_packet & packet)
{ {
packet.serialize<uint16_t>(value.size()); if (value.size() > std::numeric_limits<size_type>::max())
throw serialization_error{};
packet.serialize<size_type>(value.size());
packet.write(value); packet.write(value);
} }
static std::span<uint8_t> deserialize(deserialization_packet & packet) static std::span<uint8_t> deserialize(deserialization_packet & packet)
{ {
size_t size = packet.deserialize<uint16_t>(); size_t size = packet.deserialize<size_type>();
return packet.read_span(size); return packet.read_span(size);
} }
static bool consteval is_trivially_serializable() static bool consteval is_trivially_serializable()
{ {
return false; return false;
} }
static size_t size(const std::span<uint8_t> & x) static size_t size(const std::span<uint8_t> & x)
{ {
return 1 + x.size_bytes(); return sizeof(size_type) + x.size_bytes();
} }
}; };
@@ -929,7 +957,7 @@ struct serialization_traits<crypto::bignum>
static size_t size(const crypto::bignum & value) static size_t size(const crypto::bignum & value)
{ {
return 2 + value.data_size(); return sizeof(serialization_traits<std::string>::size_type) + value.data_size();
} }
}; };
+1 -1
View File
@@ -25,7 +25,7 @@
Apps::Apps(QObject * parent) Apps::Apps(QObject * parent)
{ {
auto apps = wivrn::list_applications(); auto apps = wivrn::list_applications(true /* Include steam apps */, false /* Don't load icons */);
for (const auto & [id, app]: apps) for (const auto & [id, app]: apps)
{ {
+12
View File
@@ -74,6 +74,10 @@ Kirigami.ApplicationWindow {
// root.pageStack.push(Qt.resolvedUrl("HeadsetStatsPage.qml")); // root.pageStack.push(Qt.resolvedUrl("HeadsetStatsPage.qml"));
// } // }
// } // }
function onJsonConfigurationChanged() {
config.load(WivrnServer);
}
} }
Component.onCompleted: { Component.onCompleted: {
@@ -153,6 +157,14 @@ Kirigami.ApplicationWindow {
visible: VulkanInfo.driverId == "AmdProprietary" || VulkanInfo.driverId == "AmdOpenSource" visible: VulkanInfo.driverId == "AmdProprietary" || VulkanInfo.driverId == "AmdOpenSource"
} }
Kirigami.InlineMessage {
Layout.fillWidth: true
text: i18n("No OpenVR compatibility detected, Steam games won't be able to load VR.\nInstall xrizer or OpenComposite.")
type: Kirigami.MessageType.Warning
showCloseButton: true
visible: WivrnServer.openVRCompat.length == 0 && config.openvr == ""
}
Kirigami.InlineMessage { Kirigami.InlineMessage {
id: message_failed_to_start id: message_failed_to_start
Layout.fillWidth: true Layout.fillWidth: true
+4
View File
@@ -243,6 +243,10 @@ void Settings::load(const wivrn_server * server)
else else
set_openvr(QString::fromStdString(*it)); set_openvr(QString::fromStdString(*it));
} }
else
{
set_openvr("");
}
} }
catch (...) catch (...)
{ {
+39 -29
View File
@@ -5,8 +5,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: WiVRn-dashboard\n" "Project-Id-Version: WiVRn-dashboard\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-06-18 21:11+0200\n" "POT-Creation-Date: 2025-08-04 09:40+0200\n"
"PO-Revision-Date: 2025-06-18 21:12+0200\n" "PO-Revision-Date: 2025-08-04 09:41+0200\n"
"Last-Translator: Guillaume Meunier <guillaume.meunier@centraliens.net>\n" "Last-Translator: Guillaume Meunier <guillaume.meunier@centraliens.net>\n"
"Language-Team: French <>\n" "Language-Team: French <>\n"
"Language: French\n" "Language: French\n"
@@ -14,7 +14,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n"
"X-Generator: Gtranslator 47.1\n" "X-Generator: Gtranslator 48.0\n"
#: dashboard/apk_installer.cpp:167 #: dashboard/apk_installer.cpp:167
#, kde-format #, kde-format
@@ -82,8 +82,8 @@ msgstr "Vérification de la dernière version..."
msgid "No precompiled APK is available for this version." msgid "No precompiled APK is available for this version."
msgstr "Aucun APK précompilé n'est disponible pour cette version." msgstr "Aucun APK précompilé n'est disponible pour cette version."
#: dashboard/qml/ApkInstallPage.qml:45 dashboard/qml/Main.qml:247 #: dashboard/qml/ApkInstallPage.qml:45 dashboard/qml/Main.qml:259
#: dashboard/qml/Main.qml:329 #: dashboard/qml/Main.qml:341
#, kde-format #, kde-format
msgid "ADB is not installed." msgid "ADB is not installed."
msgstr "ADB n'est pas installé." msgstr "ADB n'est pas installé."
@@ -132,7 +132,7 @@ msgstr "Réinstaller WiVRn"
msgid "Install WiVRn" msgid "Install WiVRn"
msgstr "Installer WiVRn" msgstr "Installer WiVRn"
#: dashboard/qml/HeadsetsPage.qml:12 dashboard/qml/Main.qml:342 #: dashboard/qml/HeadsetsPage.qml:12 dashboard/qml/Main.qml:354
#, kde-format #, kde-format
msgid "Headsets" msgid "Headsets"
msgstr "Casques" msgstr "Casques"
@@ -229,29 +229,29 @@ msgstr "Appairer un nouveau casque"
msgid "Headset statistics" msgid "Headset statistics"
msgstr "Statistiques" msgstr "Statistiques"
#: dashboard/qml/Main.qml:103 #: dashboard/qml/Main.qml:107
#, kde-format #, kde-format
msgid "The server does not have CAP_SYS_NICE capabilities." msgid "The server does not have CAP_SYS_NICE capabilities."
msgstr "Le serveur n'a pas la capacité CAP_SYS_NICE" msgstr "Le serveur n'a pas la capacité CAP_SYS_NICE"
#: dashboard/qml/Main.qml:110 #: dashboard/qml/Main.qml:114
#, kde-format #, kde-format
msgid "Fix it" msgid "Fix it"
msgstr "Corriger" msgstr "Corriger"
#: dashboard/qml/Main.qml:119 #: dashboard/qml/Main.qml:123
#, kde-format #, kde-format
msgid "The CAP_SYS_NICE capability will be used when the server is restarted." msgid "The CAP_SYS_NICE capability will be used when the server is restarted."
msgstr "" msgstr ""
"La capacité CAP_SYS_NICE sera utilisée quand le serveur sera redémarré." "La capacité CAP_SYS_NICE sera utilisée quand le serveur sera redémarré."
#: dashboard/qml/Main.qml:125 #: dashboard/qml/Main.qml:129
#, kde-format #, kde-format
msgctxt "restart the server" msgctxt "restart the server"
msgid "Restart now" msgid "Restart now"
msgstr "Redémarrer" msgstr "Redémarrer"
#: dashboard/qml/Main.qml:136 #: dashboard/qml/Main.qml:140
#, kde-format #, kde-format
msgid "" msgid ""
"NVIDIA GPUs require at least driver version 565.77, current version is %1" "NVIDIA GPUs require at least driver version 565.77, current version is %1"
@@ -259,12 +259,12 @@ msgstr ""
"Les GPUs NVIDIA nécessitent au moins le driver 565.77, la version actuelle " "Les GPUs NVIDIA nécessitent au moins le driver 565.77, la version actuelle "
"est %1." "est %1."
#: dashboard/qml/Main.qml:142 #: dashboard/qml/Main.qml:146
#, kde-format #, kde-format
msgid "More info" msgid "More info"
msgstr "Plus d'infos" msgstr "Plus d'infos"
#: dashboard/qml/Main.qml:150 #: dashboard/qml/Main.qml:154
#, kde-format #, kde-format
msgid "" msgid ""
"Use the Mesa (radv) driver for AMD GPUs\n" "Use the Mesa (radv) driver for AMD GPUs\n"
@@ -273,75 +273,85 @@ msgstr ""
"Utilisez le driver Mesa (redv) pour les GPUs AMD\n" "Utilisez le driver Mesa (redv) pour les GPUs AMD\n"
"L'encodage matériel avec vaapi ne fonctionne pas avec AMDVLK et AMDGPU-PRO" "L'encodage matériel avec vaapi ne fonctionne pas avec AMDVLK et AMDGPU-PRO"
#: dashboard/qml/Main.qml:159 #: dashboard/qml/Main.qml:162
#, kde-format
msgid ""
"No OpenVR compatibility detected, Steam games won't be able to load VR.\n"
"Install xrizer or OpenComposite."
msgstr ""
"Aucune bibliothèque de compatibilité OpenVR trouvée, les jeux Steam ne "
"pourront pas charger le mode VR.\n"
"Veuillez installer xrizer ou OpenComposite."
#: dashboard/qml/Main.qml:171
#, kde-format #, kde-format
msgid "Server failed to start" msgid "Server failed to start"
msgstr "Le serveur n'a pas pu démarrer" msgstr "Le serveur n'a pas pu démarrer"
#: dashboard/qml/Main.qml:165 dashboard/qml/TroubleshootPage.qml:77 #: dashboard/qml/Main.qml:177 dashboard/qml/TroubleshootPage.qml:77
#, kde-format #, kde-format
msgid "Open server logs" msgid "Open server logs"
msgstr "Ouvrir les logs du serveur" msgstr "Ouvrir les logs du serveur"
#: dashboard/qml/Main.qml:202 #: dashboard/qml/Main.qml:214
#, kde-format #, kde-format
msgctxt "whether the server is running, displayed in front of a checkbox" msgctxt "whether the server is running, displayed in front of a checkbox"
msgid "Running" msgid "Running"
msgstr "Démarré" msgstr "Démarré"
#: dashboard/qml/Main.qml:217 #: dashboard/qml/Main.qml:229
#, kde-format #, kde-format
msgctxt "whether pairing is enabled, displayed in front of a checkbox" msgctxt "whether pairing is enabled, displayed in front of a checkbox"
msgid "Pairing" msgid "Pairing"
msgstr "Appairage" msgstr "Appairage"
#: dashboard/qml/Main.qml:230 #: dashboard/qml/Main.qml:242
#, kde-format #, kde-format
msgid "PIN: %1" msgid "PIN: %1"
msgstr "PIN : %1" msgstr "PIN : %1"
#: dashboard/qml/Main.qml:238 dashboard/qml/WizardPage.qml:373 #: dashboard/qml/Main.qml:250 dashboard/qml/WizardPage.qml:373
#, kde-format #, kde-format
msgid "Connect by USB" msgid "Connect by USB"
msgstr "Connexion par USB" msgstr "Connexion par USB"
#: dashboard/qml/Main.qml:249 #: dashboard/qml/Main.qml:261
#, kde-format #, kde-format
msgid "No headset is connected or your headset is not in developer mode." msgid "No headset is connected or your headset is not in developer mode."
msgstr "Le casque n'est pas connecté ou n'est pas en mode développeur." msgstr "Le casque n'est pas connecté ou n'est pas en mode développeur."
#: dashboard/qml/Main.qml:257 #: dashboard/qml/Main.qml:269
#, kde-format #, kde-format
msgid "Disconnect" msgid "Disconnect"
msgstr "Déconnecter" msgstr "Déconnecter"
#: dashboard/qml/Main.qml:274 #: dashboard/qml/Main.qml:286
#, kde-format #, kde-format
msgctxt "automatically started application" msgctxt "automatically started application"
msgid "Application" msgid "Application"
msgstr "Application" msgstr "Application"
#: dashboard/qml/Main.qml:295 #: dashboard/qml/Main.qml:307
#, kde-format #, kde-format
msgid "Steam information" msgid "Steam information"
msgstr "Informations pour Steam" msgstr "Informations pour Steam"
#: dashboard/qml/Main.qml:313 #: dashboard/qml/Main.qml:325
#, kde-format #, kde-format
msgid "Wizard" msgid "Wizard"
msgstr "Assistant" msgstr "Assistant"
#: dashboard/qml/Main.qml:320 #: dashboard/qml/Main.qml:332
#, kde-format #, kde-format
msgid "Install the app" msgid "Install the app"
msgstr "Installer l'appli" msgstr "Installer l'appli"
#: dashboard/qml/Main.qml:349 dashboard/qml/SettingsPage.qml:14 #: dashboard/qml/Main.qml:361 dashboard/qml/SettingsPage.qml:14
#, kde-format #, kde-format
msgid "Settings" msgid "Settings"
msgstr "Paramètres" msgstr "Paramètres"
#: dashboard/qml/Main.qml:356 dashboard/qml/TroubleshootPage.qml:10 #: dashboard/qml/Main.qml:368 dashboard/qml/TroubleshootPage.qml:10
#, kde-format #, kde-format
msgid "Troubleshoot" msgid "Troubleshoot"
msgstr "Dépannage" msgstr "Dépannage"
@@ -352,13 +362,13 @@ msgctxt "don't start an application automatically"
msgid "None" msgid "None"
msgstr "Aucune" msgstr "Aucune"
#: dashboard/qml/SelectGame.qml:21 #: dashboard/qml/SelectGame.qml:20
#, kde-format #, kde-format
msgctxt "choose a custom application to start" msgctxt "choose a custom application to start"
msgid "Custom" msgid "Custom"
msgstr "Personnalisé" msgstr "Personnalisé"
#: dashboard/qml/SelectGame.qml:79 #: dashboard/qml/SelectGame.qml:76
#, kde-format #, kde-format
msgctxt "browse a file to choose the application to start" msgctxt "browse a file to choose the application to start"
msgid "Browse" msgid "Browse"