diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml
index 5c847e25..8803ed51 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.yml
+++ b/.github/ISSUE_TEMPLATE/bug_report.yml
@@ -9,7 +9,10 @@ body:
attributes:
label: Describe the bug
description: A clear and concise description of what the bug is.
- placeholder: Please describe the bug here...
+ placeholder: |
+ Please describe the bug here...
+ *** Do NOT use AI to generate a bug report ***
+ Write down what is wrong, attach logs and screenshots when relevant.
validations:
required: true
@@ -22,12 +25,6 @@ body:
2. Click on '...'
3. See error
- - type: input
- attributes:
- label: Expected behavior
- description: A clear and concise description of what you expected to happen.
- placeholder: Please describe what you expected to happen.
-
- type: input
attributes:
label: WiVRn Version
@@ -42,20 +39,6 @@ body:
description: Describe how WiVRn and OpenComposite/xrizer were installed
placeholder: flatpak --user, flatpak, AUR, Gentoo/Guru, built from sources...
- - type: textarea
- attributes:
- label: Server Config
- description: |
- Provide the content of `config.json` for the server.
- Located in `${XDG_CONFIG_HOME-${HOME}/.config}/wivrn/config.json`
- or `~/.var/app/io.github.wivrn.wivrn/config/wivrn/config.json` for the flatpak version
- placeholder: |
- {
- "encoders": [
- {"codec": "h264"}
- ]
- }
-
- type: textarea
attributes:
label: Server Logs
@@ -64,18 +47,6 @@ body:
Add the output of the wivrn-server here.
If more than a few lines, prefer file attachment.
- - type: dropdown
- id: gpu
- attributes:
- label: What GPU did the bug occur on?
- options:
- - NVIDIA
- - AMD
- - Intel
- - Other
- validations:
- required: true
-
- type: textarea
attributes:
label: Vulkan Info
@@ -107,5 +78,5 @@ body:
attributes:
label: ADB Logs
description: Provide the output of `adb logcat` command.
- render: plain
+ render: text
placeholder: Attach the output of adb logcat as a file.
diff --git a/.github/workflows/APK-Release.yml b/.github/workflows/APK-Release.yml
index c3284951..d7a607ac 100644
--- a/.github/workflows/APK-Release.yml
+++ b/.github/workflows/APK-Release.yml
@@ -25,16 +25,18 @@ jobs:
ref: ${{ github.sha }}
fetch-depth: 0
- - name: Prepare Vulkan SDK
- uses: humbletim/setup-vulkan-sdk@v1.2.1
+ # Gradle distribution and the Android plugin's dependencies.
+ - uses: actions/cache@v5
with:
- vulkan-query-version: 1.3.296.0
- vulkan-components: Glslang, SPIRV-Tools
- vulkan-use-cache: true
+ key: gradle-android-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties', 'build.gradle') }}
+ path: |
+ ~/.gradle/caches
+ ~/.gradle/wrapper
+ restore-keys: gradle-android-
- name: Install dependencies
run: |
- sudo apt-get update && sudo apt-get install glslang-tools librsvg2-bin gettext npm
+ sudo apt-get update && sudo apt-get install glslang-tools spirv-tools librsvg2-bin gettext npm
wget https://github.com/KhronosGroup/KTX-Software/releases/download/v4.4.0/KTX-Software-4.4.0-Linux-x86_64.deb
sudo dpkg --install KTX-Software-4.4.0-Linux-x86_64.deb
npm install --global @gltf-transform/cli@4.1.1
diff --git a/.github/workflows/Build.yml b/.github/workflows/Build.yml
index da376320..7e561ad1 100644
--- a/.github/workflows/Build.yml
+++ b/.github/workflows/Build.yml
@@ -30,7 +30,6 @@ jobs:
# Perfetto SDK glue don't bitrot (WIVRN_TRACE_MONADO needs percetto, not packaged in CI)
- preset: 'server-tracing'
packages: libboost-all-dev libsystemd-dev
- perfetto: true
- preset: 'server-no-systemd'
packages: libboost-all-dev
- preset: 'server-no-system-boost'
@@ -42,7 +41,7 @@ jobs:
- name: Apt dependencies
uses: awalsh128/cache-apt-pkgs-action@v1.6.1
with:
- packages: ccache ${{matrix.config.packages}} ${{ startsWith(matrix.config.preset, 'server') && env.SERVER_DEPS || ''}}
+ packages: ccache libvulkan-dev glslang-tools spirv-tools libwayland-dev libxrandr-dev ${{matrix.config.packages}} ${{ startsWith(matrix.config.preset, 'server') && env.SERVER_DEPS || ''}}
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2.23
@@ -69,15 +68,8 @@ jobs:
sudo dpkg --install KTX-Software-4.4.2-Linux-x86_64.deb
npm install --global @gltf-transform/cli@4.1.1
- - name: Prepare Vulkan SDK
- uses: humbletim/setup-vulkan-sdk@v1.2.1
- with:
- vulkan-query-version: 1.3.296.0
- vulkan-components: Vulkan-Headers, Vulkan-Loader, Glslang, SPIRV-Reflect, SPIRV-Tools
- vulkan-use-cache: true
-
- name: Fetch Perfetto SDK
- if: ${{ matrix.config.perfetto }}
+ if: ${{ matrix.config.preset == 'server-tracing' }}
# The amalgamated SDK is two files; install them where server/CMakeLists.txt looks.
env:
PERFETTO_TAG: v51.0
@@ -130,7 +122,8 @@ jobs:
runs-on: ubuntu-24.04
if: ${{ vars.APK_ONLY == '' }}
container:
- image: ghcr.io/flathub-infra/flatpak-github-actions:kde-6.9
+ # Tag matches runtime-version in the manifest.
+ image: ghcr.io/flathub-infra/flatpak-github-actions:kde-6.10
options: --privileged
steps:
@@ -192,13 +185,6 @@ jobs:
with:
fetch-depth: 0
- - name: Prepare Vulkan SDK
- uses: humbletim/setup-vulkan-sdk@v1.2.1
- with:
- vulkan-query-version: 1.3.296.0
- vulkan-components: Glslang, SPIRV-Tools
- vulkan-use-cache: true
-
- uses: actions/cache@v5
with:
key: cmake-android-${{matrix.buildtype}}
@@ -210,9 +196,18 @@ jobs:
${{github.workspace}}/cmake-fetch/*.tgz
restore-keys: cmake-android-
+ # Gradle distribution and the Android plugin's dependencies.
+ - uses: actions/cache@v5
+ with:
+ key: gradle-android-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties', 'build.gradle') }}
+ path: |
+ ~/.gradle/caches
+ ~/.gradle/wrapper
+ restore-keys: gradle-android-
+
- name: Install dependencies
run: |
- sudo apt-get update && sudo apt-get install glslang-tools librsvg2-bin gettext
+ sudo apt-get update && sudo apt-get install glslang-tools spirv-tools librsvg2-bin gettext
wget https://github.com/KhronosGroup/KTX-Software/releases/download/v4.3.2/KTX-Software-4.3.2-Linux-x86_64.deb
sudo dpkg --install KTX-Software-4.3.2-Linux-x86_64.deb
npm install --global @gltf-transform/cli
diff --git a/.github/workflows/Locales.yml b/.github/workflows/Locales.yml
index 772a4db4..2c0878e9 100644
--- a/.github/workflows/Locales.yml
+++ b/.github/workflows/Locales.yml
@@ -8,15 +8,25 @@ jobs:
steps:
- uses: actions/checkout@v6
+ - name: Apt dependencies
+ uses: awalsh128/cache-apt-pkgs-action@v1.6.1
+ with:
+ packages: gettext
+
- name: Install dependencies
run: |
- sudo apt-get update && sudo apt-get install gettext
pip install polib PyGithub
- name: Check that .po files are up to date
+ env:
+ GH_TOKEN: ${{ github.token }}
run: |
if [[ "${{github.ref}}" == 'refs/heads/master' ]] ; then
tools/check_po.py --manage-issues --github-repository "${{ github.repository }}" --github-token "${{ github.token }}"
+ elif [[ "${{github.base_ref}}" != "" ]] ; then
+ FILES=$(gh api repos/${{github.repository}}/pulls/${{github.event.pull_request.number}}/files | jq --raw-output '[.[].filename | select(. | startswith("locale/"))] | join(",")')
+ echo "Locale files changed by pull request: ${FILES}"
+ tools/check_po.py --fail-on "${FILES}"
else
tools/check_po.py
fi
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index e53a7388..a2441b0c 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -30,6 +30,7 @@
+
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8ddb7d23..285d2a74 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -35,7 +35,6 @@ option(WIVRN_USE_SYSTEM_FREETYPE "Use system FreeType" ON)
option(WIVRN_USE_SYSTEM_BOOST "Use system Boost headers" ON)
option(WIVRN_USE_SYSTEM_OPENXR "Use system OpenXR headers" ON)
option(WIVRN_USE_SYSTEM_LIBKTX "Use system KTX-Software library" ON)
-option(WIVRN_USE_SYSTEMD "Use libsystemd" ON)
option(WIVRN_COMPRESS_GLB "Compress textures in GLB files with gltf-transform" OFF)
option(WIVRN_USE_ANDROID_VALIDATION_LAYER "Download the android version of the Vulkan validation layer" OFF)
option(WIVRN_USE_ANDROID_BIN_LIBKTX "Download the prebuilt libktx for android" OFF)
@@ -49,6 +48,7 @@ option(WIVRN_BUILD_TEST "Build test binaries" OFF)
option(WIVRN_WERROR "Treat warnings as errors" OFF)
option(WIVRN_OPTIMIZE_SHADERS "Run spirv-opt on compiled shaders" ON)
option(WIVRN_DEBUG_SHADERS "Compile shaders with debug information" OFF)
+option(WIVRN_ADDRESS_SANITIZER "Use address sanitizer" OFF)
if(WIVRN_OPTIMIZE_SHADERS AND WIVRN_DEBUG_SHADERS)
message(FATAL_ERROR "WIVRN_OPTIMIZE_SHADERS and WIVRN_DEBUG_SHADERS are incompatible")
@@ -123,8 +123,8 @@ endif()
if (WIVRN_BUILD_SERVER)
find_program(GDBUS_CODEGEN gdbus-codegen REQUIRED)
- if (Vulkan_VERSION VERSION_LESS "1.3.261")
- message(FATAL_ERROR "Vulkan version must be at least 1.3.261, found ${Vulkan_VERSION}")
+ if (Vulkan_VERSION VERSION_LESS "1.4.304")
+ message(FATAL_ERROR "Vulkan version must be at least 1.4.304, found ${Vulkan_VERSION}")
endif()
if (NOT WIVRN_USE_NVENC AND NOT WIVRN_USE_VAAPI AND NOT WIVRN_USE_X264 AND NOT WIVRN_USE_VULKAN_ENCODE)
@@ -136,20 +136,10 @@ if (WIVRN_BUILD_SERVER)
pkg_check_modules(LIBDRM REQUIRED IMPORTED_TARGET libdrm)
endif()
- if (WIVRN_USE_VULKAN_ENCODE)
- if (Vulkan_VERSION VERSION_LESS 1.3.283)
- message(FATAL_ERROR "Vulkan video encode requires 1.3.283, found ${Vulkan_VERSION}")
- endif()
- endif()
-
if (WIVRN_USE_X264)
pkg_check_modules(X264 REQUIRED IMPORTED_TARGET x264)
endif()
- if (WIVRN_USE_SYSTEMD)
- pkg_check_modules(SYSTEMD REQUIRED IMPORTED_TARGET libsystemd)
- endif()
-
if (WIVRN_USE_PIPEWIRE)
pkg_check_modules(libpipewire REQUIRED IMPORTED_TARGET libpipewire-0.3)
endif()
@@ -259,17 +249,17 @@ set(KTX_VERSION_FULL "v${KTX_VERSION}")
FetchContent_Declare(libktx EXCLUDE_FROM_ALL SYSTEM URL https://github.com/KhronosGroup/KTX-Software/archive/refs/tags/${KTX_VERSION_FULL}.tar.gz
URL_HASH SHA256=9412cb45045a503005acd47d98f9e8b47154634a50b4df21e17a1dfa8971d323
)
-FetchContent_Declare(implot EXCLUDE_FROM_ALL SYSTEM URL https://github.com/epezent/implot/archive/3da8bd34299965d3b0ab124df743fe3e076fa222.zip
- URL_HASH SHA256=e9b439a94aa6f09fcf12ed9c2cd784efe5e99e96242122aa683e690b29f7a59f)
+FetchContent_Declare(implot EXCLUDE_FROM_ALL SYSTEM URL https://github.com/epezent/implot/releases/download/v1.0/implot-v1.0.tar.gz
+ URL_HASH SHA256=20ca14d5a46f36a650746096c74eba8bea99c9432cd3c877343b96b17a6ae566)
file(GLOB IMGUI_PATCHES CONFIGURE_DEPENDS patches/imgui/*)
-FetchContent_Declare(imgui EXCLUDE_FROM_ALL SYSTEM URL https://github.com/ocornut/imgui/archive/refs/tags/v1.92.5.tar.gz
- URL_HASH SHA256=0eb50fe9aeba1a51f96b5843c7f630a32ed2e9362d693c61b87e4fa870cf826d
+FetchContent_Declare(imgui EXCLUDE_FROM_ALL SYSTEM URL https://github.com/ocornut/imgui/archive/refs/tags/v1.92.9.tar.gz
+ URL_HASH SHA256=af97ed649182c39314320514a672b82008ab462b9293fe23d37b30bfa5d05519
PATCH_COMMAND ${CMAKE_CURRENT_LIST_DIR}/patches/apply.sh ${IMGUI_PATCHES}
)
FetchContent_Declare(uni-algo EXCLUDE_FROM_ALL SYSTEM URL https://github.com/uni-algo/uni-algo/archive/v1.2.0.tar.gz
URL_HASH SHA256=f2a1539cd8635bc6088d05144a73ecfe7b4d74ee0361fabed6f87f9f19e74ca9)
-FetchContent_Declare(entt EXCLUDE_FROM_ALL SYSTEM URL https://github.com/skypjack/entt/archive/refs/tags/v3.16.0.tar.gz
- URL_HASH SHA256=7d7b4037b737992342049ffab14f22fa10243e01664f8c3a0657aa247ac52f71)
+FetchContent_Declare(entt EXCLUDE_FROM_ALL SYSTEM URL https://github.com/skypjack/entt/archive/refs/tags/v4.0.0.tar.gz
+ URL_HASH SHA256=32a2ff2c72cb047dfd57306006ef238820b70da7c6ce4e7e8a507ac63365212e)
FetchContent_Declare(curl EXCLUDE_FROM_ALL SYSTEM URL https://github.com/curl/curl/releases/download/curl-8_17_0/curl-8.17.0.tar.xz
URL_HASH SHA256=955f6e729ad6b3566260e8fef68620e76ba3c31acf0a18524416a185acf77992)
FetchContent_Declare(spirv-reflect EXCLUDE_FROM_ALL SYSTEM URL https://github.com/KhronosGroup/SPIRV-Reflect/archive/refs/tags/vulkan-sdk-1.4.328.1.tar.gz
@@ -312,6 +302,7 @@ if (WIVRN_BUILD_CLIENT)
endif()
if (WIVRN_BUILD_SERVER OR WIVRN_BUILD_SERVER_LIBRARY)
+ find_package(Python3 REQUIRED Interpreter)
add_subdirectory(server)
if (WIVRN_BUILD_SERVER)
@@ -323,9 +314,6 @@ if (WIVRN_BUILD_SERVER OR WIVRN_BUILD_SERVER_LIBRARY)
message(STATUS "")
message(STATUS "Audio backends:")
message(STATUS "\tPipewire : ${WIVRN_USE_PIPEWIRE}")
- message(STATUS "")
- message(STATUS "Optional features:")
- message(STATUS "\tsystemd: ${WIVRN_USE_SYSTEMD}")
endif()
endif()
@@ -355,5 +343,10 @@ foreach(TARGET_NAME wivrn wivrn-server wivrn-dashboard wivrn-common wivrn-dissec
target_compile_options(${TARGET_NAME} PRIVATE -Werror)
endif()
+ if (WIVRN_ADDRESS_SANITIZER AND NOT ${TARGET_NAME} STREQUAL wivrn-dissector)
+ target_compile_options(${TARGET_NAME} PRIVATE -fsanitize=address -fno-omit-frame-pointer)
+ target_link_options(${TARGET_NAME} PRIVATE -fsanitize=address)
+ endif()
+
endif()
endforeach()
diff --git a/README.md b/README.md
index 0de9c77a..f4070337 100644
--- a/README.md
+++ b/README.md
@@ -43,6 +43,7 @@ We recommend using native packages if available for your distribution:
- [Fedora](https://packages.fedoraproject.org/pkgs/wivrn/wivrn/)
- [Gentoo Guru](https://gitweb.gentoo.org/repo/proj/guru.git/tree/media-libs/wivrn)
- [NixOS](https://search.nixos.org/packages?show=wivrn)
+- [Ubuntu PPA](https://launchpad.net/~lvra/+archive/ubuntu/wivrn)
For OpenVR and Steam compatibility, you also need a compatibility library such as [xrizer](https://github.com/Supreeeme/xrizer/) or [OpenComposite](https://gitlab.com/znixian/OpenOVR/).
@@ -78,7 +79,7 @@ Avahi must be running:
systemctl enable --now avahi-daemon
```
-On SteamOS, the Avahi configuration needs to be modified to allow user services such as WiVRn to publish services on the network; see https://github.com/WiVRn/WiVRn/issues/1001#issuecomment-4940906113 for instructions on how to do so.
+On SteamOS, the Avahi configuration needs to be modified to allow user services such as WiVRn to publish services on the network; see https://github.com/WiVRn/WiVRn/issues/1001#issuecomment-4940906113 for instructions on how to do so.
- If a firewall is installed, open port 5353/UDP for Avahi and ports 9757/UDP+TCP for WiVRn.
- For example, if using UFW run `ufw allow 5353/udp` and `ufw allow 9757`.
@@ -169,9 +170,10 @@ If the server list is empty in the headset app:
How do I see server logs when using the dashboard?
-- Click Troubleshoot > Open server logs, or
-- Navigate to `${XDG_STATE_HOME}/wivrn/wivrn-dashboard` (with fallback to `${HOME}/.local/state` for `${XDG_STATE_HOME}`, or
-- For flatpak, navigate to `${HOME}/.var/app/io.github.wivrn.wivrn/.local/state/wivrn/wivrn-dashboard`.
+- Click **Troubleshoot > Open server logs**
+- Or, navigate to `${XDG_STATE_HOME}/wivrn/wivrn-dashboard`
+ - In other words, on common setups, the dashboard writes logs to `~/.local/state/wivrn/wivrn-dashboard`
+ - For WiVRn Flatpak, the dashboard writes logs to `~/.var/app/io.github.wivrn.wivrn/.local/state/wivrn/wivrn-dashboard`
My NVIDIA GPU P-State is limited to P2 instead of reaching the highest P0 while using the NVIDIA NVENC encoder
diff --git a/assets/Font Awesome 6 Free-Regular-400.otf b/assets/Font Awesome 6 Free-Regular-400.otf
deleted file mode 100644
index 2edf2b2f..00000000
Binary files a/assets/Font Awesome 6 Free-Regular-400.otf and /dev/null differ
diff --git a/assets/Font Awesome 6 Free-Solid-900.otf b/assets/Font Awesome 6 Free-Solid-900.otf
deleted file mode 100644
index 6bd19b13..00000000
Binary files a/assets/Font Awesome 6 Free-Solid-900.otf and /dev/null differ
diff --git a/assets/Font Awesome 7 Brands-Regular-400.otf b/assets/Font Awesome 7 Brands-Regular-400.otf
new file mode 100644
index 00000000..addd48ad
Binary files /dev/null and b/assets/Font Awesome 7 Brands-Regular-400.otf differ
diff --git a/assets/Font Awesome 7 Free-Regular-400.otf b/assets/Font Awesome 7 Free-Regular-400.otf
new file mode 100644
index 00000000..2ca9963b
Binary files /dev/null and b/assets/Font Awesome 7 Free-Regular-400.otf differ
diff --git a/assets/Font Awesome 7 Free-Solid-900.otf b/assets/Font Awesome 7 Free-Solid-900.otf
new file mode 100644
index 00000000..af3b5782
Binary files /dev/null and b/assets/Font Awesome 7 Free-Solid-900.otf differ
diff --git a/build.gradle b/build.gradle
index 6d8b0470..1161658d 100644
--- a/build.gradle
+++ b/build.gradle
@@ -92,7 +92,7 @@ tasks.register("generatePngs", GeneratePngsTask) {
}
}
-
+def use_asan = project.hasProperty('wivrn_address_sanitizer') && wivrn_address_sanitizer == 'ON'
android {
namespace = "org.meumeu.wivrn"
@@ -117,16 +117,20 @@ android {
def compressGlb = project.hasProperty('wivrn_compress_glb') ? wivrn_compress_glb : 'OFF'
def fetchcontentBaseDir = project.hasProperty('fetchcontent_base_dir') ? ['-DFETCHCONTENT_BASE_DIR=' + fetchcontent_base_dir] : []
+ def asan = use_asan ? 'ON': 'OFF'
+ def stl = use_asan ? 'c++_shared' : "c++_static"
+
externalNativeBuild {
def css = project.hasProperty('wivrn_css') ? project.wivrn_css: "images/wivrn-local.css"
cmake {
arguments = ['-DANDROID_TOOLCHAIN=clang',
- '-DANDROID_STL=c++_static',
+ '-DANDROID_STL=' + stl,
'-DCMAKE_ANDROID_NDK_VERSION=' + ndkVersion,
'-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON',
'-DCMAKE_EXPORT_COMPILE_COMMANDS=ON',
'-DCMAKE_ANDROID_ASSETS_DIRECTORIES=' + layout.buildDirectory.dir("assets").get().asFile,
+ '-DRESOURCES_DIRECTORIES=' + layout.buildDirectory.dir("resources").get().asFile,
'-DWIVRN_USE_SYSTEM_BOOST=OFF',
'-DWIVRN_USE_SYSTEM_FREETYPE=OFF',
'-DWIVRN_USE_ANDROID_BIN_LIBKTX=ON',
@@ -139,13 +143,20 @@ android {
'-DWIVRN_SHOW_IMGUI_DEMO_WINDOW=' + showImguiDemo,
'-DWIVRN_CLIENT_DEBUG_MENU=' + showDebugMenu,
'-DWIVRN_CSS=' + css,
- '-DWIVRN_COMPRESS_GLB=' + compressGlb] +
+ '-DWIVRN_COMPRESS_GLB=' + compressGlb,
+ '-DWIVRN_ADDRESS_SANITIZER=' + asan,
+ ] +
fetchcontentBaseDir
resValue "string", "app_name", project.hasProperty('wivrn_app_name') ? project.wivrn_app_name : "WiVRn Local"
abiFilters 'arm64-v8a'//, 'x86_64'
}
}
+ packaging {
+ jniLibs {
+ useLegacyPackaging = use_asan
+ }
+ }
}
signingConfigs {
@@ -226,6 +237,7 @@ android {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['client/java']
res.srcDirs = [ 'resources', layout.buildDirectory.dir('generated_resources') ]
+ resources.srcDirs = [layout.buildDirectory.dir('resources')]
assets.srcDirs = ['assets', layout.buildDirectory.dir("assets")]
}
@@ -243,5 +255,6 @@ android {
applicationVariants.all { variant ->
// It probably works with merge${variant.name.capitalize()}Assets too
tasks["generate${variant.name.capitalize()}Assets"].dependsOn "externalNativeBuild${variant.name.capitalize()}"
+ tasks["merge${variant.name.capitalize()}Resources"].dependsOn "externalNativeBuild${variant.name.capitalize()}"
}
}
diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt
index 8a497705..53df0645 100644
--- a/client/CMakeLists.txt
+++ b/client/CMakeLists.txt
@@ -38,6 +38,7 @@ add_library(stb INTERFACE)
target_include_directories(stb INTERFACE ${stb_SOURCE_DIR})
if(ANDROID)
+ file(REMOVE_RECURSE ${RESOURCES_DIRECTORIES}/lib ${ANDROID_LIB_DIRECTORIES})
add_library(wivrn MODULE)
find_library(ANDROID_LIBRARY NAMES android REQUIRED)
@@ -80,6 +81,23 @@ if(ANDROID)
"decoder/android/*.cpp"
)
target_sources(wivrn PRIVATE ${PLATFORM_SOURCE})
+
+ if (WIVRN_ADDRESS_SANITIZER)
+ file(MAKE_DIRECTORY
+ ${RESOURCES_DIRECTORIES}/lib/${CMAKE_ANDROID_ARCH_ABI}
+ ${ANDROID_LIB_DIRECTORIES}/${CMAKE_ANDROID_ARCH_ABI})
+ file(GLOB _asan_location
+ ${ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64/lib/clang/*/lib/linux/libclang_rt.asan-${CMAKE_SYSTEM_PROCESSOR}-android.so
+ )
+ file(COPY
+ ${_asan_location}
+ DESTINATION ${ANDROID_LIB_DIRECTORIES}/${CMAKE_ANDROID_ARCH_ABI}
+ )
+ file(COPY_FILE
+ ${ANDROID_NDK}/wrap.sh/asan.sh
+ ${RESOURCES_DIRECTORIES}/lib/${CMAKE_ANDROID_ARCH_ABI}/wrap.sh
+ )
+ endif()
else()
add_executable(wivrn)
@@ -106,8 +124,6 @@ endif()
#
target_compile_definitions(wivrn PRIVATE "XR_USE_TIMESPEC=1")
-set_target_properties(wivrn PROPERTIES CXX_VISIBILITY_PRESET hidden)
-
file(GLOB LOCAL_SOURCE CONFIGURE_DEPENDS
"*.cpp"
"decoder/*.cpp"
@@ -144,6 +160,7 @@ target_link_libraries(wivrn
target_compile_definitions(wivrn PRIVATE -DXR_USE_GRAPHICS_API_VULKAN)
target_compile_definitions(wivrn PRIVATE -DVMA_STATS_STRING_ENABLED=0)
target_compile_definitions(wivrn PRIVATE -DGLM_ENABLE_EXPERIMENTAL)
+target_compile_definitions(wivrn PRIVATE IMGUI_DEFINE_MATH_OPERATORS)
target_include_directories(wivrn PRIVATE .)
@@ -214,9 +231,6 @@ if(WIVRN_USE_ANDROID_VALIDATION_LAYER)
file(COPY
${FETCHCONTENT_BASE_DIR}/Vulkan-ValidationLayer/android-binaries-${VVL_VERSION}/${CMAKE_ANDROID_ARCH_ABI}
DESTINATION ${ANDROID_LIB_DIRECTORIES})
-else()
- # silence "Manually-specified variables were not used by the project" warning
- set(_unused ${ANDROID_LIB_DIRECTORIES})
endif()
diff --git a/client/android/battery.cpp b/client/android/battery.cpp
index c21612df..959ea440 100644
--- a/client/android/battery.cpp
+++ b/client/android/battery.cpp
@@ -35,7 +35,7 @@ battery_status get_battery_status()
return last_status;
}
-extern "C" __attribute__((visibility("default"))) void Java_org_meumeu_wivrn_BroadcastReceiver_onReceive(JNIEnv * env, jobject instance, jobject ctxt_obj, jobject intent_obj)
+extern "C" void Java_org_meumeu_wivrn_BroadcastReceiver_onReceive(JNIEnv * env, jobject instance, jobject ctxt_obj, jobject intent_obj)
{
jni::jni_thread::setup_thread(env);
jni::object<"android/content/Intent"> intent{intent_obj};
diff --git a/client/android/exported_symbols.txt b/client/android/exported_symbols.txt
index 42904ba3..f52eaeed 100644
--- a/client/android/exported_symbols.txt
+++ b/client/android/exported_symbols.txt
@@ -2,10 +2,7 @@ LIBAPP {
global:
ANativeActivity_onCreate;
android_main;
- Java_org_meumeu_wivrn_BroadcastReceiver_onReceive;
- Java_org_meumeu_wivrn_MainActivity_onRequestPermissionsResult;
- Java_org_meumeu_wivrn_MainActivity_onActivityResult;
- Java_org_meumeu_wivrn_MainActivity_onNewIntent;
+ Java_org_meumeu_wivrn*;
local:
*;
};
diff --git a/client/android/intent.cpp b/client/android/intent.cpp
index c6f6d848..d884e6d4 100644
--- a/client/android/intent.cpp
+++ b/client/android/intent.cpp
@@ -59,7 +59,7 @@ jni::object<"android/net/Uri"> intent::get_uri()
return obj.call>("getData");
}
-extern "C" __attribute__((visibility("default"))) void Java_org_meumeu_wivrn_MainActivity_onActivityResult(JNIEnv * env, jobject instance, int request_code, int result_code, jobject data_obj)
+extern "C" void Java_org_meumeu_wivrn_MainActivity_onActivityResult(JNIEnv * env, jobject instance, int request_code, int result_code, jobject data_obj)
{
auto it = callbacks.find(request_code);
if (it == callbacks.end())
diff --git a/client/android/jnipp.h b/client/android/jnipp.h
index 4c0ed55d..64680dc3 100644
--- a/client/android/jnipp.h
+++ b/client/android/jnipp.h
@@ -89,6 +89,7 @@ struct Void
struct Int
{
constexpr static auto static_field = &_JNIEnv::GetStaticIntField;
+ constexpr static auto obj_field = &_JNIEnv::GetIntField;
constexpr static const auto call_method = &_JNIEnv::CallIntMethod;
constexpr static const auto call_static_method = &_JNIEnv::CallStaticIntMethod;
@@ -277,6 +278,7 @@ struct object
}
std::unique_ptr, details::deleter> self;
+ constexpr static auto obj_field = &_JNIEnv::GetObjectField;
constexpr static const auto call_method = &_JNIEnv::CallObjectMethod;
constexpr static const auto call_static_method = &_JNIEnv::CallStaticObjectMethod;
@@ -335,6 +337,14 @@ struct object
handles));
}
+ template
+ T field(const std::string & name)
+ {
+ auto & env = jni_thread::env();
+ jfieldID id = env.GetFieldID(klass(), name.c_str(), T::type().c_str());
+ return T((env.*T::obj_field)(*this, id));
+ }
+
jobject handle() const
{
return *this;
@@ -374,6 +384,7 @@ struct string : public string_t
{
using string_t::type;
constexpr static auto static_field = &_JNIEnv::GetStaticObjectField;
+ constexpr static auto obj_field = &_JNIEnv::GetObjectField;
operator jstring()
{
diff --git a/client/android/permissions.cpp b/client/android/permissions.cpp
index 9a5725ba..4fe0ddcb 100644
--- a/client/android/permissions.cpp
+++ b/client/android/permissions.cpp
@@ -93,7 +93,7 @@ void request_permission(const char * permission, std::function callb
}
}
-extern "C" __attribute__((visibility("default"))) void Java_org_meumeu_wivrn_MainActivity_onRequestPermissionsResult(
+extern "C" void Java_org_meumeu_wivrn_MainActivity_onRequestPermissionsResult(
JNIEnv * env,
jobject instance,
int requestCode,
diff --git a/client/android/usb.cpp b/client/android/usb.cpp
new file mode 100644
index 00000000..b83c1108
--- /dev/null
+++ b/client/android/usb.cpp
@@ -0,0 +1,61 @@
+/*
+ * WiVRn VR streaming
+ * Copyright (C) 2026 Patrick Nicolas
+ *
+ * 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 .
+ */
+
+#include "application.h"
+#include "jni.h"
+
+#include
+#include
+
+std::atomic_bool link_properties_changed = false;
+
+extern "C" void Java_org_meumeu_wivrn_NetworkInfoCallback_onAvailable(JNIEnv * env, jobject instance, jobject network)
+{
+ spdlog::info("NetworkInfoCallback_onAvailable");
+}
+extern "C" void Java_org_meumeu_wivrn_NetworkInfoCallback_onBlockedStatusChanged(JNIEnv * env, jobject instance, jobject network, jboolean blocked)
+{
+ spdlog::info("NetworkInfoCallback_onBlockedStatusChanged");
+}
+extern "C" void Java_org_meumeu_wivrn_NetworkInfoCallback_onCapabilitiesChanged(JNIEnv * env, jobject instance, jobject network, jobject caps)
+{
+ spdlog::info("NetworkInfoCallback_onCapabitilitiesChanged");
+}
+extern "C" void Java_org_meumeu_wivrn_NetworkInfoCallback_onLinkPropertiesChanged(JNIEnv * env, jobject instance, jobject network, jobject jprops)
+{
+ link_properties_changed = true;
+}
+extern "C" void Java_org_meumeu_wivrn_NetworkInfoCallback_onLosing(JNIEnv * env, jobject instance, jobject network, jint ms)
+{
+ spdlog::info("NetworkInfoCallback_onLosing");
+}
+extern "C" void Java_org_meumeu_wivrn_NetworkInfoCallback_onLost(JNIEnv * env, jobject instance, jobject network)
+{
+ spdlog::info("NetworkInfoCallback_onLost");
+ link_properties_changed = true;
+}
+extern "C" void Java_org_meumeu_wivrn_NetworkInfoCallback_onUnavailable(JNIEnv * env, jobject instance)
+{
+ spdlog::info("NetworkInfoCallback_onUnavailable");
+ application::get_config().usb_network = false;
+}
+
+bool usb_link_properties_changed()
+{
+ return link_properties_changed.exchange(false);
+}
diff --git a/client/android/usb.h b/client/android/usb.h
new file mode 100644
index 00000000..60626ff9
--- /dev/null
+++ b/client/android/usb.h
@@ -0,0 +1,19 @@
+/*
+ * WiVRn VR streaming
+ * Copyright (C) 2026 Patrick Nicolas
+ *
+ * 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 .
+ */
+
+bool usb_link_properties_changed();
diff --git a/client/application.cpp b/client/application.cpp
index a3071274..cf46e87f 100644
--- a/client/application.cpp
+++ b/client/application.cpp
@@ -1404,7 +1404,12 @@ void application::initialize()
spaces[size_t(xr::spaces::view)] = xr_session.create_reference_space(XR_REFERENCE_SPACE_TYPE_VIEW);
spaces[size_t(xr::spaces::world)] = xr_session.create_reference_space(XR_REFERENCE_SPACE_TYPE_STAGE);
- config.emplace(xr_system_id, xr_session);
+ config.emplace(xr_system_id, xr_session, application::get_config_path() / "client.json");
+ default_config.emplace(xr_system_id, xr_session);
+
+#ifdef __ANDROID__
+ set_usb_networking(config->usb_network);
+#endif
// HTC face tracker fails if created later
// we can destroy it right away, it actually stores static handles
@@ -1486,7 +1491,7 @@ std::pair application::get_action(std::string_view reque
}
#ifdef __ANDROID__
-extern "C" __attribute__((visibility("default"))) void Java_org_meumeu_wivrn_MainActivity_onNewIntent(JNIEnv * env, jobject instance, jobject intent_obj)
+extern "C" void Java_org_meumeu_wivrn_MainActivity_onNewIntent(JNIEnv * env, jobject instance, jobject intent_obj)
{
jni::jni_thread::setup_thread(env);
jni::object<"android/content/Intent"> intent{intent_obj};
@@ -1676,6 +1681,9 @@ void application::cleanup()
#ifdef __ANDROID__
jni::jni_thread::detach();
+ app_info.native_app->onAppCmd = nullptr;
+ app_info.native_app->onInputEvent = nullptr;
+ app_info.native_app->userData = nullptr;
#endif
}
@@ -1826,6 +1834,38 @@ void application::push_scene(std::shared_ptr s)
instance().scene_stack.push_back(std::move(s));
}
+#ifdef __ANDROID__
+void application::set_usb_networking(bool enabled)
+{
+ jni::object<""> act(app_info.native_app->activity->clazz);
+ auto app = act.call>("getApplication");
+ auto ctx = app.call>("getApplicationContext");
+ auto system_service = ctx.call>("getSystemService", jni::string("connectivity"));
+
+ auto cb = act.field>("netcb");
+ try
+ {
+ if (enabled)
+ {
+ auto req = jni::new_object<"android/net/NetworkRequest$Builder">()
+ .call>("removeCapability", jni::Int(12) /*NET_CAPABILITY_INTERNET*/)
+ .call>("removeCapability", jni::Int(14) /*NET_CAPABILITY_TRUSTED*/)
+ .call>("addTransportType", jni::Int(8) /*TRANSPORT_USB*/)
+ .call>("build");
+
+ // system_service.call("requestNetwork", req, jni::new_object<"org/meumeu/wivrn/NetworkInfoCallback">());
+ system_service.call("requestNetwork", req, cb);
+ }
+ else
+ {
+ system_service.call("unregisterNetworkCallback", cb);
+ }
+ }
+ catch (...)
+ {}
+}
+#endif
+
void application::poll_actions()
{
std::array action_sets{
diff --git a/client/application.h b/client/application.h
index edd7c1e5..f872b557 100644
--- a/client/application.h
+++ b/client/application.h
@@ -55,7 +55,7 @@
class scene;
#ifdef __ANDROID__
-extern "C" __attribute__((visibility("default"))) void Java_org_meumeu_wivrn_MainActivity_onNewIntent(JNIEnv * env, jobject instance, jobject intent_obj);
+extern "C" void Java_org_meumeu_wivrn_MainActivity_onNewIntent(JNIEnv * env, jobject instance, jobject intent_obj);
#endif
struct application_info
@@ -77,7 +77,7 @@ class application : public singleton
private:
#ifdef __ANDROID__
- friend __attribute__((visibility("default"))) void Java_org_meumeu_wivrn_MainActivity_onNewIntent(JNIEnv * env, jobject instance, jobject intent_obj);
+ friend void Java_org_meumeu_wivrn_MainActivity_onNewIntent(JNIEnv * env, jobject instance, jobject intent_obj);
#endif
application_info app_info;
@@ -156,6 +156,7 @@ private:
std::chrono::nanoseconds last_scene_cpu_time;
std::optional config;
+ std::optional default_config;
boost::locale::generator gen;
boost::locale::gnu_gettext::messages_info messages_info;
@@ -311,6 +312,10 @@ public:
return *instance().wifi;
}
+#ifdef __ANDROID__
+ void set_usb_networking(bool enabled);
+#endif
+
static void ignore_debug_reports_for(void * object)
{
#ifndef NDEBUG
@@ -330,8 +335,9 @@ public:
template
static void set_debug_reports_name(const T & object, std::string name)
{
- // #ifndef NDEBUG
- // if (instance().debug_utils_found)
+ if (not vk_allocator::instance().has_debug_utils)
+ return;
+
const vk::DebugUtilsObjectNameInfoEXT name_info{
.objectType = T::objectType,
.objectHandle = (uint64_t)(typename T::NativeType)object,
@@ -339,10 +345,6 @@ public:
};
instance().vk_device.setDebugUtilsObjectNameEXT(name_info);
-
- // printf("set_debug_reports_name %p, %s\n", object, name.c_str());
- // instance().debug_report_object_name[(uint64_t)object] = std::move(name);
- // #endif
}
static thread_safe & get_queue()
@@ -432,6 +434,12 @@ public:
return *instance().config;
}
+ static configuration & get_default_config()
+ {
+ assert(instance().default_config);
+ return *instance().default_config;
+ }
+
static XrSessionState get_session_state()
{
return instance().session_state;
diff --git a/client/configuration.cpp b/client/configuration.cpp
index 99fea686..3d31fa47 100644
--- a/client/configuration.cpp
+++ b/client/configuration.cpp
@@ -24,7 +24,11 @@
#include "wivrn_packets.h"
#include
+#include
#include
+#include
+#include
+#include
#ifdef __ANDROID__
#include "android/permissions.h"
@@ -33,6 +37,121 @@
// If no refresh rate is configured, don't select a too high one
static const float max_default_rate = 100;
+// key <-> member serialization descriptor for scalar settings (see config_fields()).
+// The few settings that aren't scalars are handled explicitly in save()/load().
+struct config_field
+{
+ std::function save;
+ std::function load;
+};
+
+namespace
+{
+template
+inline constexpr bool is_optional_v = false;
+template
+inline constexpr bool is_optional_v> = true;
+
+template
+struct remove_optional
+{
+ using type = T;
+};
+template
+struct remove_optional>
+{
+ using type = T;
+};
+
+std::ostream & operator<<(std::ostream & stream, feature f)
+{
+ return stream << "\"" << magic_enum::enum_name(f) << "\"";
+}
+
+template
+void write_value(std::ostream & json, const T & value)
+{
+ if constexpr (std::is_same_v)
+ json << std::boolalpha << value;
+ else if constexpr (std::is_same_v)
+ json << json_string(value);
+ else if constexpr (std::is_enum_v)
+ json << json_string(magic_enum::enum_name(value));
+ else if constexpr (std::is_integral_v)
+ json << (uint64_t)value;
+ else // floating point
+ json << value;
+}
+
+template
+std::optional read_value(simdjson::simdjson_result val)
+{
+ if constexpr (std::is_same_v)
+ {
+ if (val.is_bool())
+ return val.get_bool();
+ }
+ else if constexpr (std::is_same_v)
+ {
+ if (val.is_string())
+ return std::string(std::string_view(val.get_string().value()));
+ }
+ else if constexpr (std::is_enum_v)
+ {
+ if (val.is_string())
+ {
+ auto name = val.get_string().value();
+ for (const auto & [e, n]: magic_enum::enum_entries())
+ if (name == n)
+ return e;
+ }
+ }
+ else if constexpr (std::is_integral_v)
+ {
+ if (val.is_uint64())
+ return (T)val.get_uint64();
+ if (val.is_int64() and int64_t(val.get_int64()) >= 0)
+ return (T)val.get_int64();
+ }
+ else // floating point
+ {
+ if (val.is_double())
+ return (T)val.get_double();
+ if (val.is_int64())
+ return (T)val.get_int64();
+ if (val.is_uint64())
+ return (T)val.get_uint64();
+ }
+ return std::nullopt;
+}
+
+// build a field for a plain member: bool / float / integral / std::string / enum,
+// optionally wrapped in std::optional (only written when set)
+template
+config_field scalar(const char * key, T configuration::* member)
+{
+ return {
+ .save = [key, member](std::ostream & json, const configuration & c) {
+ if constexpr (is_optional_v)
+ {
+ if (c.*member)
+ {
+ json << ",\"" << key << "\":";
+ write_value(json, *(c.*member));
+ }
+ }
+ else
+ {
+ json << ",\"" << key << "\":";
+ write_value(json, c.*member);
+ } },
+ .load = [key, member](simdjson::dom::element root, configuration & c) {
+ if (auto v = read_value::type>(root[key]))
+ c.*member = *v; },
+ };
+}
+} // namespace
+
bool configuration::check_feature(feature f) const
{
{
@@ -105,17 +224,22 @@ configuration::configuration(xr::system & system, xr::session & session)
features[feature::hand_tracking] = system.hand_tracking_supported();
const auto & rates = session.get_refresh_rates();
+ preferred_refresh_rate = rates.empty() ? 0 : rates[0];
for (auto rate: rates)
{
if (rate >= max_default_rate)
break;
preferred_refresh_rate = rate;
}
+}
+configuration::configuration(xr::system & system, xr::session & session, const std::filesystem::path & config_path) :
+ configuration(system, session)
+{
try
{
simdjson::dom::parser parser;
- simdjson::dom::element root = parser.load((application::get_config_path() / "client.json").native());
+ simdjson::dom::element root = parser.load(config_path.native());
for (simdjson::dom::object i: simdjson::dom::array(root["servers"]))
{
server_data data{
@@ -134,60 +258,15 @@ configuration::configuration(xr::system & system, xr::session & session)
servers.emplace(data.service.txt["cookie"], data);
}
- if (auto val = root["preferred_refresh_rate"]; val.is_double())
- {
- float f = val.get_double();
- if (f == 0 or utils::contains(rates, f))
- preferred_refresh_rate = f;
- }
+ float default_refresh_rate = preferred_refresh_rate;
- if (auto val = root["minimum_refresh_rate"]; val.is_double())
- minimum_refresh_rate = val.get_double();
+ for (const auto & f: config_fields())
+ f.load(root, *this);
- if (auto val = root["resolution_scale"]; val.is_double())
- resolution_scale = val.get_double();
-
- if (auto val = root["stream_scale"]; val.is_double())
- stream_scale = val.get_double();
-
- if (auto val = root["codec"]; val.is_string())
- {
- const auto codec_str = val.get_string().value();
- for (const auto & [c, name]: magic_enum::enum_entries())
- {
- if (codec_str == name)
- {
- codec = c;
- }
- }
- }
-
- if (auto val = root["bit_depth"]; val.is_uint64())
- bit_depth = val.get_uint64();
-
- if (auto val = root["bitrate_bps"]; val.is_number())
- bitrate_bps = val.get_uint64();
-
- if (auto val = root["enable_stream_gui"]; val.is_bool())
- enable_stream_gui = val.get_bool();
-
- if (auto val = root["openxr_post_processing"]; val.is_object())
- parse_openxr_post_processing_options(val.get_object());
-
- if (auto val = root["passthrough_enabled"]; val.is_bool())
- passthrough_enabled = val.get_bool();
-
- if (auto val = root["mic_unprocessed_audio"]; val.is_bool())
- mic_unprocessed_audio = val.get_bool();
-
- if (auto val = root["forward_keyboard"]; val.is_bool())
- forward_keyboard = val.get_bool();
-
- if (auto val = root["forward_mouse"]; val.is_bool())
- forward_mouse = val.get_bool();
-
- if (auto val = root["forward_gamepad"]; val.is_bool())
- forward_gamepad = val.get_bool();
+ // refresh rate must be supported by this headset, otherwise fall back to the default
+ const auto & rates = session.get_refresh_rates();
+ if (preferred_refresh_rate != 0 and not utils::contains(rates, preferred_refresh_rate))
+ preferred_refresh_rate = default_refresh_rate;
if (auto val = root["body_parts"]; val.is_object())
{
@@ -208,44 +287,24 @@ configuration::configuration(xr::system & system, xr::session & session)
}
}
- if (auto val = root["virtual_keyboard_layout"]; val.is_string())
- virtual_keyboard_layout = val.get_string().value();
-
- for (const auto & [i, name]: magic_enum::enum_entries())
+ // nested object
+ if (auto val = root["openxr_post_processing"]; val.is_object())
{
- if (auto val = root[name]; val.is_bool())
- features[i] = val.get_bool();
+ auto obj = val.get_object();
+ openxr_post_processing = {};
+ if (auto v = obj["super_sampling"]; v.is_int64())
+ openxr_post_processing.super_sampling = v.get_int64();
+ if (auto v = obj["sharpening"]; v.is_int64())
+ openxr_post_processing.sharpening = v.get_int64();
}
+ // feature flags, keyed by enum name
+ for (const auto & [f, name]: magic_enum::enum_entries())
+ if (auto val = root[name]; val.is_bool())
+ features[f] = val.get_bool();
+
if (system.passthrough_supported() == xr::passthrough_type::none)
passthrough_enabled = false;
-
- if (auto val = root["override_foveation_enable"]; val.is_bool())
- override_foveation_enable = val.get_bool();
-
- if (auto val = root["override_foveation_pitch"]; val.is_double())
- override_foveation_pitch = val.get_double();
-
- if (auto val = root["override_foveation_distance"]; val.is_double())
- override_foveation_distance = val.get_double();
-
- if (auto val = root["first_run"]; val.is_bool())
- first_run = val.get_bool();
-
- if (auto val = root["locale"]; val.is_string())
- locale = val.get_string().value();
-
- if (auto val = root["environment_model"]; val.is_string())
- environment_model = (std::string_view)val.get_string();
-
- if (auto val = root["high_power_mode"]; val.is_bool())
- high_power_mode = val.get_bool();
-
- if (auto val = root["fps_divider"]; val.is_uint64())
- fps_divider = (uint32_t)val.get_uint64();
-
- if (auto val = root["extended_config"]; val.is_bool())
- extended_config = val.get_bool();
}
catch (std::exception & e)
{
@@ -253,27 +312,43 @@ configuration::configuration(xr::system & system, xr::session & session)
}
}
-void configuration::parse_openxr_post_processing_options(simdjson::simdjson_result openxr_post_processing_root)
+const std::vector & configuration::config_fields()
{
- openxr_post_processing = {};
- if (auto val = openxr_post_processing_root["super_sampling"]; val.is_int64())
- openxr_post_processing.super_sampling = val.get_int64();
-
- if (auto val = openxr_post_processing_root["sharpening"]; val.is_int64())
- openxr_post_processing.sharpening = val.get_int64();
-}
-
-static std::ostream & operator<<(std::ostream & stream, feature f)
-{
- return stream << "\"" << magic_enum::enum_name(f) << "\"";
-}
-
-static std::ostream & write_openxr_post_processing(std::ofstream & stream, const configuration::openxr_post_processing_settings & openxr_post_processing)
-{
- stream << "{\"super_sampling\":" << openxr_post_processing.super_sampling;
- stream << ",\"sharpening\":" << openxr_post_processing.sharpening;
- stream << "}";
- return stream;
+ static const std::vector fields = {
+ scalar("resolution_scale", &configuration::resolution_scale),
+ scalar("bitrate_bps", &configuration::bitrate_bps),
+ scalar("enable_stream_gui", &configuration::enable_stream_gui),
+ scalar("app_list_view", &configuration::app_list_view),
+ scalar("app_icon_size", &configuration::app_icon_size),
+ scalar("theme_preset", &configuration::theme_preset),
+ scalar("theme_accent", &configuration::theme_accent),
+ scalar("theme_rounding", &configuration::theme_rounding),
+ scalar("theme_card_rounding", &configuration::theme_card_rounding),
+ scalar("theme_font_scale", &configuration::theme_font_scale),
+ scalar("theme_background_alpha", &configuration::theme_background_alpha),
+ scalar("passthrough_enabled", &configuration::passthrough_enabled),
+ scalar("mic_unprocessed_audio", &configuration::mic_unprocessed_audio),
+ scalar("forward_keyboard", &configuration::forward_keyboard),
+ scalar("forward_mouse", &configuration::forward_mouse),
+ scalar("forward_gamepad", &configuration::forward_gamepad),
+ scalar("virtual_keyboard_layout", &configuration::virtual_keyboard_layout),
+ scalar("override_foveation_enable", &configuration::override_foveation_enable),
+ scalar("override_foveation_pitch", &configuration::override_foveation_pitch),
+ scalar("override_foveation_distance", &configuration::override_foveation_distance),
+ scalar("first_run", &configuration::first_run),
+ scalar("locale", &configuration::locale),
+ scalar("environment_model", &configuration::environment_model),
+ scalar("high_power_mode", &configuration::high_power_mode),
+ scalar("fps_divider", &configuration::fps_divider),
+ scalar("extended_config", &configuration::extended_config),
+ scalar("preferred_refresh_rate", &configuration::preferred_refresh_rate),
+ scalar("minimum_refresh_rate", &configuration::minimum_refresh_rate),
+ scalar("stream_scale", &configuration::stream_scale),
+ scalar("codec", &configuration::codec),
+ scalar("bit_depth", &configuration::bit_depth),
+ scalar("usb_network", &configuration::usb_network),
+ };
+ return fields;
}
void configuration::save()
@@ -305,51 +380,18 @@ void configuration::save()
std::ofstream json(application::get_config_path() / "client.json");
json << "{\"servers\":[" << servers_str << "]";
- json << ",\"preferred_refresh_rate\":" << preferred_refresh_rate;
- if (minimum_refresh_rate)
- json << ",\"minimum_refresh_rate\":" << *minimum_refresh_rate;
- json << ",\"resolution_scale\":" << resolution_scale;
- if (stream_scale)
- json << ",\"stream_scale\":" << *stream_scale;
- if (codec)
- json << ",\"codec\":" << json_string(magic_enum::enum_name(*codec));
- json << ",\"bit_depth\":" << (uint64_t)bit_depth;
- json << ",\"bitrate_bps\":" << bitrate_bps;
- json << ",\"openxr_post_processing\":";
- write_openxr_post_processing(json, openxr_post_processing);
- json << ",\"passthrough_enabled\":" << std::boolalpha << passthrough_enabled;
- json << ",\"mic_unprocessed_audio\":" << std::boolalpha << mic_unprocessed_audio;
- json << ",\"forward_keyboard\":" << std::boolalpha << forward_keyboard;
- json << ",\"forward_mouse\":" << std::boolalpha << forward_mouse;
- json << ",\"forward_gamepad\":" << std::boolalpha << forward_gamepad;
- std::stringstream body_part_ss;
- for (const auto & [b, name]: magic_enum::enum_entries())
- {
- bool enabled = (body_part_mask & std::to_underlying(b)) != 0;
- body_part_ss << "\"" << name << "\":" << std::boolalpha << enabled << ",";
- }
+ for (const auto & f: config_fields())
+ f.save(json, *this);
- std::string body_parts_str = body_part_ss.str();
- if (!body_parts_str.empty())
- {
- body_parts_str.pop_back(); // Remove last comma
- json << ",\"body_parts\":{" << body_parts_str << "}";
- }
+ // nested object
+ json << ",\"openxr_post_processing\":{\"super_sampling\":" << openxr_post_processing.super_sampling;
+ json << ",\"sharpening\":" << openxr_post_processing.sharpening << "}";
- json << ",\"enable_stream_gui\":" << std::boolalpha << enable_stream_gui;
+ // feature flags, keyed by enum name
for (auto & [key, value]: features)
json << "," << key << ":" << std::boolalpha << value;
- json << ",\"virtual_keyboard_layout\":" << json_string(virtual_keyboard_layout);
- json << ",\"override_foveation_enable\":" << std::boolalpha << override_foveation_enable;
- json << ",\"override_foveation_pitch\":" << override_foveation_pitch;
- json << ",\"override_foveation_distance\":" << override_foveation_distance;
- json << ",\"first_run\":" << std::boolalpha << first_run;
- json << ",\"locale\":" << json_string(locale);
- json << ",\"environment_model\":" << json_string(environment_model);
- json << ",\"high_power_mode\":" << std::boolalpha << high_power_mode;
- json << ",\"fps_divider\":" << fps_divider;
- json << ",\"extended_config\":" << std::boolalpha << extended_config;
+
json << "}";
}
@@ -362,6 +404,11 @@ float configuration::get_stream_scale() const
{
if (stream_scale)
return *stream_scale;
+ return get_default_stream_scale();
+}
+
+float configuration::get_default_stream_scale() const
+{
if (check_feature(feature::eye_gaze))
return 0.3;
return 0.5;
diff --git a/client/configuration.h b/client/configuration.h
index 431d1e94..2d11de7c 100644
--- a/client/configuration.h
+++ b/client/configuration.h
@@ -22,12 +22,14 @@
#include "wivrn_discover.h"
#include "wivrn_packets.h"
+#include
#include