Compare commits

..
119 Commits
Author SHA1 Message Date
Patrick Nicolas b0c05813fe Prepare v26.11 release
Release APK Only / Android (Release) (push) Failing after 37m19s
Release APK Only / Android (Debug) (push) Failing after 37m22s
Release APK Only / Android (DebugWithValidationLayer) (push) Failing after 37m23s
Release APK Only / Create APK release (push) Skipped
Build / Linux (map[packages:extra-cmake-modules libarchive-dev libboost-all-dev libkf6coreaddons-dev libkf6qqc2desktopstyle-dev libkf6iconthemes-dev libkirigami-dev librsvg2-dev nlohmann-json3-dev qcoro-qt6-dev qml6-module-org-kde-kirigamiaddons-formcard prese… (push) Waiting to run
Build / Linux (map[packages:libboost-all-dev libsystemd-dev preset:server-tracing]) (push) Waiting to run
Build / Linux (map[packages:libboost-all-dev libsystemd-dev preset:server]) (push) Waiting to run
Build / Linux (map[packages:libboost-all-dev preset:server-no-systemd]) (push) Waiting to run
Build / Linux (map[packages:libboost-all-dev wireshark-dev preset:dissector-no-system-boost]) (push) Waiting to run
Build / Linux (map[packages:libharfbuzz-dev libfreetype-dev libavcodec-dev libavutil-dev libswscale-dev librsvg2-bin gettext libcurl4-openssl-dev libfontconfig-dev libpipewire-0.3-dev preset:client-no-system-boost]) (push) Waiting to run
Build / Linux (map[packages:libsystemd-dev preset:server-no-system-boost]) (push) Waiting to run
Build / Steam Frame (push) Waiting to run
Build / Create release (push) Blocked by required conditions
Build / Sync fork downstream (push) Blocked by required conditions
Build / Linux server (flatpak) (push) Skipped
Build / Test Nix package and devshell (push) Skipped
Build / Android (Debug) (push) Skipped
Build / Android (DebugWithValidationLayer) (push) Skipped
Build / Android (Oculus) (push) Skipped
Build / Android (Release) (push) Skipped
Build / Build Ubuntu package (plucky) (push) Skipped
Format / Formatting check (client) (push) Skipped
Format / Formatting check (common) (push) Skipped
Format / Formatting check (dashboard) (push) Skipped
Format / Formatting check (server) (push) Skipped
Format / Formatting check (tools/wireshark) (push) Skipped
Format / Python lint (ruff) (push) Skipped
Locales / Locale check (push) Skipped
2026-11-28 08:57:11 +01:00
Patrick Nicolas c8e74a3430 Fix secrets initialization 2026-11-28 08:47:30 +01:00
galister 0f020f2bb6 desktop file for linux client 2026-11-28 08:45:06 +01:00
guideahon b470b13dfc Clarify full WiVRn version strings 2026-11-27 13:51:57 +01:00
guideahon c5932f6ed9 Clarify WiVRn protocol compatibility 2026-11-27 13:51:57 +01:00
Sapphire 15b5ed07e1 Support Steam appinfo v42 (sharded) format 2026-11-27 02:58:57 -05:00
ZokuTe 2529e0bfa0 Update Simplified Chinese localization & Fix non-honorific pronouns for certain individuals. close #599 2026-11-24 09:38:54 +01:00
Patrick Nicolas dd472aee25 Workaround for source_group error
CMake Error at cmake-fetch/boost-src/libs/locale/CMakeLists.txt:236 (source_group):
  source_group
  "/home/runner/work/WiVRn/WiVRn/cmake-fetch/boost-src/libs/locale/include/boost/locale"
  is not a prefix of file
  "/home/runner/work/WiVRn/WiVRn/cmake-fetch/boost-src/libs/locale/include/boost/locale.hpp"
2026-11-23 15:25:22 +01:00
schlegp 04837ba215 Add Vulkan AV1 video encoder (#1087)
Experimental support, is never automatically selected.
2026-11-16 17:24:08 +01:00
TommiTheFirst 540d95ae7e Replaced custom bitcast with std::bit_cast 2026-11-16 15:57:57 +01:00
galister 47651c00e8 v4l2_decoder: 10-bit only if p010 capture supported 2026-11-16 21:30:12 +09:00
Patrick Nicolas 63700f05fa Fix buffer overflow when creating listen socket 2026-11-15 10:04:16 +01:00
Patrick Nicolas 4d782f7370 Set higher priorities for pipewire devices 2026-11-13 19:44:09 +01:00
Sapphire ea57db02f4 Add missing #pragma once to android USB header 2026-11-12 15:25:34 -05:00
Sapphire 7bb6f7c866 Allow changing log level on Android 2026-11-12 15:25:34 -05:00
Jonathan Steffan c26740b62d Merge pull request #1206 from damaestro/ci-ccache-fixes
ci: fix ccache effectiveness for Linux and Android builds
2026-11-11 21:40:33 -07:00
Sapphire e98e28fedc Change real panel size log to debug 2026-11-11 17:39:13 -05:00
Sapphire d3d15fab4c Make sure view is scaled for GUI render resolution display 2026-11-11 17:26:49 -05:00
Sapphire 6be331fbaa Fix Android battery change log condition 2026-11-11 16:23:54 -05:00
Sapphire 64ecbdc24b Move battery handling into dedicated monitor class 2026-11-11 16:23:54 -05:00
Sapphire 2233817b59 Forward controller battery info via XR_EXT_interaction_profile_battery_state_display 2026-11-11 16:23:54 -05:00
Sapphire aba0210923 Bind Frame bumper click to trigger as well for GUI interactions 2026-11-11 16:23:54 -05:00
Sapphire 86bbb80f90 Reorder some inputs and fix comments 2026-11-11 15:56:13 -05:00
Sapphire f4358ebe85 Reuse menu ID for view button, give left system click a distinct ID 2026-11-11 15:56:13 -05:00
Sapphire 4049f2125a Remove superfluous subpaths from Frame interaction profile patch 2026-11-11 15:56:13 -05:00
Sapphire 235eac73c2 Add missing hand interaction poses for Frame left/right bindings 2026-11-11 15:56:13 -05:00
Patrick Nicolas 1540df2e6b Add -fno-finite-math-only 2026-11-11 20:22:01 +01:00
Jonathan Steffan 70282d57fd ci: fix ccache effectiveness for Linux and Android builds
- Disable CMake module scanning, which made compilations uncacheable.
- Linux: trailing "." on cache key so one preset's key is not a prefix of
  another's.
- Android: add ccache (action, CCACHE_BASEDIR, gradle compiler launcher).
- Save cache on master only; evict files unused by the job.
2026-11-11 11:19:21 -07:00
Patrick Nicolas 7f9957ae79 Fix incorrect resolution show in stream settings 2026-11-11 12:00:26 +01:00
Sapphire 869b0ce660 Fix swapped Frame dpad buttons 2026-11-05 20:21:37 -05:00
Jonathan Steffan 6adb188c15 fix(ci): use archive sources instead of git clones for flatpak 2026-11-04 09:46:36 +01:00
Patrick Nicolas bae0cc3326 reimplement pico view locate quirk
note: stream_tracking should be ported to use the same code
2026-11-04 08:17:37 +01:00
Patrick Nicolas 32d4fee95e Fix warped image when growing the swapchain 2026-11-03 21:06:40 +01:00
BlackCherryCat 49b4ab96c6 Update es locale 2026-10-28 22:16:03 +01:00
Cláudio 'Patola' Sampaio 81006f06e9 new pt-br strings + fix for grip button name 2026-10-28 15:54:05 +01:00
Patrick Nicolas 9d821cad3f FR locale 2026-10-27 23:08:12 +01:00
Patrick Nicolas 500a60b685 Only ask actual hand tracking in lobby 2026-10-27 22:08:34 +01:00
Patrick Nicolas 8c5afd9a27 Reduce calls to instance.now() 2026-10-27 22:08:23 +01:00
galister f91b68491d refactor menu_toggle 2026-10-27 22:08:23 +01:00
galister 1f8e5afcf0 refactor chord_state 2026-10-27 22:08:23 +01:00
galister 528f8e7246 frame: gamepad emulation 2026-10-27 22:08:23 +01:00
Patrick Nicolas 64ae13e293 Add quirk for FS2020 2026-10-27 18:42:28 +01:00
Reina_Sakiria 44c64ba866 fix: d-pad up and left input do not work 2026-10-26 19:01:16 +01:00
Patrick Nicolas 5d69e391e4 Fix crash when loading Steam games on flatpak 2026-10-25 23:22:33 +01:00
Patrick Nicolas 4c7d57bd6d Don't rely on steamapps.vrmanifest
The file seems to no longer be updated by Steam.
Instead, read installed games from libraryfolders.vdf, owned games from
user's localconfig.vdf and data from appinfo.vdf
2026-10-25 20:45:42 +01:00
Patrick Nicolas edb1bf25ad Don't crash on systemd unit result 2026-10-25 08:57:52 +01:00
Patrick Nicolas b6bc602c5b Add AGENTS.md 2026-10-24 11:24:45 +02:00
Patrick Nicolas 8a075da1e4 Add CONTRIBUTING.md 2026-10-24 11:21:55 +02:00
Patrick Nicolas 75e2df579c Don't log warning when x264 is selected by user 2026-10-23 19:41:14 +02:00
Patrick Nicolas 170fb06d01 Disable XR_MSFT_unbounded_reference_space 2026-10-22 21:38:58 +02:00
sunryze a74622bd78 Fix quaternion sign alignment of replaced samples 2026-10-22 20:20:02 +02:00
galister 76da2e1cb7 client: support XR_META_foveation_eye_tracked (#1123) 2026-10-22 18:52:55 +02:00
Sapphire 2e60fa75e4 flake: Update inputs 2026-10-18 20:17:10 -05:00
Sapphire cf344e8709 flake: Add ninja to native build inputs 2026-10-17 19:02:37 -05:00
Patrick Nicolas f0fa8613af Save selected virtual trackers 2026-10-17 20:49:58 +02:00
Patrick Nicolas e599b381ec Don't use CMakeLists.txt for flatpak cache entry 2026-10-16 19:45:01 +02:00
Patrick Nicolas ae3d6cffa9 Sync github action image for flatpak build 2026-10-16 19:44:43 +02:00
Patrick Nicolas 3c2e5f66a6 Flush pw streams on destroy 2026-10-16 18:30:38 +02:00
Patrick Nicolas a98410bae0 Forward hand tracking data source 2026-10-16 18:30:38 +02:00
Patrick Nicolas 7d610b2959 Skip rendering on invalid view state 2026-10-16 18:30:38 +02:00
Patrick Nicolas 85c1935849 Allow URI to be provided for Linux client
ex: wivrn wivrn://:123456@localhost
2026-10-16 18:30:38 +02:00
Patrick Nicolas 80c899efdf Disable some more Monado drivers 2026-10-16 08:03:21 +02:00
Patrick Nicolas 879c50c743 Add back unused-variable warning 2026-10-16 08:03:21 +02:00
Jonathan Steffan 650ca30874 chore: update monado to 8b259763 2026-10-15 23:00:44 +02:00
Jonathan Steffan b8e24d7677 chore: update monado to be69de9e2, handle new xrt_view_type values 2026-10-15 23:00:44 +02:00
Jonathan Steffan 61abaf44e2 chore: update monado to a6a580491, use math_quat_exp_so3 2026-10-15 23:00:44 +02:00
Jonathan Steffan 75d76f1a77 chore: update monado to f07dd1348, drop upstreamed patch 0009 2026-10-15 23:00:44 +02:00
Patrick Nicolas bc3e374b96 Fix dashboard install without setting the prefix 2026-10-11 10:11:03 +02:00
Patrick Nicolas dc14ced68f Update xrizer to 0.6 2026-10-08 22:34:26 +02:00
Philip Poloczek 640e1a5405 client: don't hold a strong stream reference while creating decoders
shard_accumulator only keeps a weak_ptr to the stream, but setup() passed
it a temporary from shared_from_this(). setup() runs on the network
thread, so if the main thread drops its reference meanwhile (e.g. while
shutting down after XR_ERROR_INSTANCE_LOST), that temporary is the last
one and ~stream runs on the network thread. It then joins
network_thread from itself: std::system_error (EDEADLK) and
std::terminate.

Pass weak_from_this() instead so no strong reference is created.
2026-10-07 13:24:15 +02:00
Patrick Nicolas ab63b0503e Fix theoretical wraparound 2026-10-07 07:54:49 +02:00
Patrick Nicolas fd33697e2b Bump ruff github action 2026-10-06 19:25:41 +02:00
Patrick Nicolas 0e0de41153 reformat for clang-format < 23 2026-10-06 19:25:41 +02:00
Patrick Nicolas c4e5f4cfd2 bump clang-format 2026-10-06 19:25:41 +02:00
Patrick Nicolas 2fc4708bc6 Rework vaapi/nvenc/x264 IDR handling
Fix race conditions with should_skip
detect if nothings goes out from decoder and issue an IDR
remove idr_received, go directly to running state
2026-10-05 22:27:15 +02:00
orange 4ea97485cc Refine Japanese posture descriptions and processing label 2026-10-05 16:33:42 +02:00
orange 0f69fc70e4 Update Japanese translations and fix misleading UI text 2026-10-05 16:33:42 +02:00
Jonathan Steffan 59e4fb075e fix(htc): stop interaction-profile flapping and fix squeeze-touch binding
Blacklist XR_EXT_hand_interaction for HTC so the runtime can't switch
/user/hand/* to ext/hand_interaction_ext mid-session, which drops
controller button input whenever that profile is briefly active.

Point the Focus3 squeeze/touch binding at XRT_INPUT_FRAME_SQUEEZE_TOUCH,
the name the device actually exposes for that slot, instead of a name
that's never set active.
2026-10-05 09:36:37 +02:00
Patrick Nicolas fc48b6155e Assume user is present on session resume 2026-10-03 14:57:22 +02:00
Patrick Nicolas 833004f18c Fix outdated docs 2026-10-03 14:26:39 +02:00
Patrick Nicolas e8c92a7202 Prevent fragmentation when adding timing info 2026-10-02 18:53:16 +02:00
Sapphire 7e0bf5efc1 flake: Remove GIT_* CMake flags set by package
Fixes error in configure when using newer nixpkgs.
2026-10-01 20:06:40 -05:00
Sapphire 3136066aa9 flake: Format with nixfmt 2026-10-01 19:49:42 -05:00
Sapphire 5f604e1fc3 flake: Only add curl and ktx-tools to buildInputs for devshell 2026-10-01 19:45:19 -05:00
konsti219 0d9e6e121a linux client: add battery reporting 2026-10-01 23:19:53 +02:00
ckaznable 1b0d13c431 Update zh_TW locale 2026-10-01 08:03:10 +02:00
Patrick Nicolas 9c51adae1d FR locale 2026-09-30 23:45:01 +02:00
BlackCherryCat 3e73d98ae2 Update es locale 2026-09-30 09:25:39 +02:00
Cláudio 'Patola' Sampaio 81d8bd13d9 Translated strings about boundary and posture to pt-br 2026-09-30 07:57:24 +02:00
moi952 85f6cb0bd9 feat(client): add per-posture player height offset setting (#1121) 2026-09-29 23:21:55 +02:00
Nova a083901bdc fix: add android manifest permission for boundary 2026-09-29 21:52:44 +02:00
Nova 25e0316792 refactor(boundary): affirmative instead of subtractive 2026-09-29 21:52:44 +02:00
Nova 66b095d164 fix: update openxr version 2026-09-29 21:52:44 +02:00
Nova d2b7cc898f feat: implement XR_META_boundary_visibility 2026-09-29 21:52:44 +02:00
BlackCherryCat 760c1d3e4f Update es locale 2026-09-29 21:38:35 +02:00
mitsuami-megane 387c785c81 update ja locale 2026-09-29 21:38:15 +02:00
galister 5e3bb10b0c client: instructions when only 1 frame rate is reported 2026-09-29 19:22:33 +02:00
galister e5923e155a linux client: only show 10-bit if supported 2026-09-29 19:22:33 +02:00
galister 9062f082e5 v4l2_decoder: prefer h265 over h264 2026-09-29 19:22:33 +02:00
galister a09a462f6d Unprocessed Audio is Android-only 2026-09-29 19:22:33 +02:00
galister e80bfac44b fix typo that breaks codec detection 2026-09-29 19:22:33 +02:00
Patrick Nicolas 1adc48e2f2 Don't build ICU support in Boost 2026-09-29 19:22:33 +02:00
Patrick Nicolas 117027c390 Remove FoV from headset info packet 2026-09-29 19:22:33 +02:00
Patrick Nicolas 3a9b40472e Set WIVRN_USE_PIPEWIRE in wivrn_config.h 2026-09-29 19:22:33 +02:00
Patrick Nicolas 07131bec85 Set WIVRN_USE_V4L2 in wivrn_config.h 2026-09-29 19:22:33 +02:00
galister 24e4eba130 build frame on 24.04 2026-09-29 19:22:33 +02:00
galister fa4cf73fe4 frame build path fix 2026-09-29 19:22:33 +02:00
Patrick Nicolas add53c7318 Build Steam Frame client on CI 2026-09-29 19:22:33 +02:00
Patrick Nicolas ae12826ccb fix linux client build on gcc 14 2026-09-29 19:22:33 +02:00
Patrick Nicolas 83744c11d8 Fix build on steamrt for the Frame 2026-09-29 19:22:33 +02:00
Patrick Nicolas 4261477840 Fix build when not under the source dir 2026-09-29 19:22:33 +02:00
Michael Lip 045b39a4e3 Add missing German translations (#1136)
* translate the strings added in the settings and lobby UI

* translate the strings added to the connection wizard

* add missing de translations for new settings strings

* add missing de translations for new settings strings
2026-09-29 10:18:54 +02:00
dime-online 754ba4f6e1 driver: fix inverted interpolation factor in history::get_at
interpolate(before, after, t) expects t = 0 at the before sample and
t = 1 at the after sample (see hand_joints_list.cpp: radius = a.radius
* (1 - t) + b.radius * t, and monado's m_space_relation_interpolate
which lerps from the predecessor with the elapsed fraction).

The factor was computed as (after - now) / (after - before), which is
1 - t: querying at the before timestamp returned the after sample,
querying at the after timestamp returned the before sample, and
queries in between returned the pose mirrored about the segment
midpoint.

Compute t from the before sample so hand and body skeleton queries
between two tracking samples interpolate along the motion instead of
against it.
2026-09-27 19:17:06 +02:00
dime-online 8e3fd29c94 client: remember the last haptics amplitude to not skip stop commands
The self-assignment in the haptics handler left the stored amplitude
at its initial value of 0, so the "skip redundant calls" guard was
true for every amplitude-0 packet and haptic_stop() was never called.
Rumbles could not be cancelled early and kept playing for their whole
duration.

Store the newly applied amplitude so the guard only skips stops when
nothing was playing.
2026-09-27 19:14:07 +02:00
galister ee0d667105 client: xrHandTrackingDataSourceExt to filter out controller-based HT 2026-09-27 17:14:33 +09:00
galister 596e661d7e add frame controller profile 2026-09-27 17:14:33 +09:00
galister ef81d500ca linux client: detect panel res via /sys/class/drm 2026-09-27 17:14:33 +09:00
galister 2191884e95 linux client: v4l2 decoder 2026-09-27 17:14:33 +09:00
galister ce4486bc61 linux client: pipewire audio 2026-09-27 17:14:33 +09:00
163 changed files with 10404 additions and 3928 deletions
-6
View File
@@ -1,6 +0,0 @@
version: "1"
rules:
- base: master
upstream: WiVRn:master
mergeMethod: hardreset
+24 -109
View File
@@ -2,16 +2,15 @@ name: Release APK Only
on:
push:
branches: [ "apk-build" ]
branches: [ "master" ]
env:
BUILD_TYPE: RelWithDebInfo
CSS: images/wivrn-${{(github.ref_type == 'tag' && 'release') || 'nightly'}}.css
jobs:
build-android-only:
name: Android
runs-on: ubuntu-24.04-full
runs-on: ubuntu-24.04
if: ${{ vars.APK_ONLY != '' }}
strategy:
@@ -19,28 +18,25 @@ jobs:
buildtype: ['Release', 'Debug', 'DebugWithValidationLayer']
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
# Checkout from upstream instead of WiVRn-APK to ensure the GIT_DESC variable is set correctly
repository: 'gitea/WiVRn'
repository: 'WiVRn/WiVRn'
ref: ${{ github.sha }}
fetch-depth: 0
- name: Install CMake
run: |
apt-get update
apt-get install -y cmake build-essential
- name: Prepare Vulkan SDK
uses: humbletim/setup-vulkan-sdk@286ed76c72de45dbf50c515779cf4ca2f6aa3944
# 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 -y 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
@@ -64,12 +60,6 @@ jobs:
echo signingKeyPassword="$APK_SIGNINGKEYPASSWORD" > gradle.properties
echo "$APK_KEYSTORE_BASE64" | base64 --decode --ignore-garbage > ks.keystore
# - name: Setup Java
# uses: actions/setup-java@v6
# with:
# distribution: temurin
# java-version: '25'
- name: Build
run: |
chmod +x gradlew
@@ -84,7 +74,7 @@ jobs:
find debug -name libopenxr_loader.so -delete
- name: Archive APK
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
with:
name: apk-${{ (github.event_name == 'pull_request' && matrix.buildtype == 'Release') && 'Release-unsigned' || matrix.buildtype }}
path: apk/*.apk
@@ -92,79 +82,12 @@ jobs:
- name: Archive debug symbols
if: ${{ matrix.buildtype != 'Release' }}
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
with:
name: symbols-${{ matrix.buildtype }}
path: debug/**/*.so
retention-days: 7
# build-steam-frame:
# name: Steam Frame
# runs-on: ubuntu-24.04-arm
# if: ${{ vars.APK_ONLY != '' }}
# container:
# image: registry.gitlab.steamos.cloud/steamrt/steamrt4/sdk/arm64:4.0.20260805.254769
# volumes:
# - ${{github.workspace}}/install:/tmp/install
#
# steps:
# - uses: actions/checkout@v6
# with:
# fetch-depth: 0
# fetch-tags: true
#
# - name: Apt dependencies
# uses: awalsh128/cache-apt-pkgs-action@v1.6.1
# with:
# packages: librsvg2-bin npm
#
# - name: ccache
# uses: hendrikmuhs/ccache-action@v1.2.23
# with:
# key: steam-frame
# job-summary: ""
#
# - uses: actions/cache@v5
# with:
# key: cmake-frame
# path: |
# ${{github.workspace}}/cmake-fetch/*-subbuild/*-populate-prefix/src/*.tar.*
# ${{github.workspace}}/cmake-fetch/*-subbuild/*-populate-prefix/src/*.zip
# ${{github.workspace}}/cmake-fetch/*.tar.*
# ${{github.workspace}}/cmake-fetch/*.tgz
# ${{github.workspace}}/cmake-fetch/*-src/.git
#
# - name: Install dependencies
# run: |
# wget https://github.com/KhronosGroup/KTX-Software/releases/download/v4.4.2/KTX-Software-4.4.2-Linux-arm64.deb
# sudo dpkg --install KTX-Software-4.4.2-Linux-arm64.deb
# npm install --global @gltf-transform/cli@4.1.1
#
# - name: Configure CMake
# run: >
# cmake -B "$GITHUB_WORKSPACE/build"
# -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
# -DWIVRN_CSS=${{env.CSS}}
# -DFETCHCONTENT_BASE_DIR="$GITHUB_WORKSPACE/cmake-fetch"
# -DCMAKE_C_COMPILER_LAUNCHER=ccache
# -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
# -DCMAKE_INSTALL_PREFIX=/usr
# --preset frame
#
# - name: Build
# run: |
# git config --global --add safe.directory "$GITHUB_WORKSPACE"
# cd "$GITHUB_WORKSPACE/build"
# DESTDIR="$GITHUB_WORKSPACE/install" ninja install
#
# - name: Archive
# uses: actions/upload-artifact@v7
# with:
# name: wivrn-frame-client.zip
# path: install/usr
# if-no-files-found: error
# retention-days: 30
release:
name: Create APK release
runs-on: ubuntu-24.04
@@ -173,22 +96,22 @@ jobs:
steps:
- name: Download APK artifacts
uses: actions/download-artifact@v4
uses: actions/download-artifact@v8
with:
path: apk
pattern: 'apk-*'
merge-multiple: true
# - name: Rename APK artifacts
# run: |
# cd apk
# for f in *.apk; do
# BASENAME=`echo ${f}|awk -F '-APK-' '{print $2}'`
# mv "${f}" "org.meumeu.wivrn-${BASENAME}"
# done
- name: Rename APK artifacts
run: |
cd apk
for f in *.apk; do
BASENAME=`echo ${f}|awk -F '-APK-' '{print $2}'`
mv "${f}" "org.meumeu.wivrn-${BASENAME}"
done
- name: Download APK debug artifacts
uses: actions/download-artifact@v4
uses: actions/download-artifact@v8
with:
path: symbols
pattern: 'symbols-*'
@@ -199,15 +122,8 @@ jobs:
cd symbols
zip -r ../debug-symbols.zip .
# - name: Download Steam Frame artifacts
# uses: actions/download-artifact@v4
# with:
# path: install/usr
# pattern: 'wivrn-frame-client.zip'
# merge-multiple: true
- name: APK Release
uses: softprops/action-gh-release@v2
uses: softprops/action-gh-release@v3
with:
token: ${{ secrets.DOWNSTREAM_GITHUB_TOKEN }}
tag_name: "apk-${{ github.sha }}"
@@ -218,4 +134,3 @@ jobs:
files: |
apk/*.apk
debug-symbols.zip
+129 -25
View File
@@ -7,6 +7,7 @@ on:
env:
BUILD_TYPE: Release
SERVER_DEPS: libx264-dev libavcodec-dev libavutil-dev libbsd-dev libavahi-client-dev libavahi-glib-dev libeigen3-dev nlohmann-json3-dev librsvg2-dev libdrm-dev libglib2.0-dev-bin libpipewire-0.3-dev libcli11-dev libnotify-dev libarchive-dev libudev-dev
CSS: images/wivrn-${{(github.ref_type == 'tag' && 'release') || 'nightly'}}.css
jobs:
build-linux:
@@ -19,7 +20,7 @@ jobs:
matrix:
config:
- preset: 'client-no-system-boost'
packages: libharfbuzz-dev libfreetype-dev libavcodec-dev libavutil-dev libswscale-dev librsvg2-bin gettext libcurl4-openssl-dev libfontconfig-dev
packages: libharfbuzz-dev libfreetype-dev libavcodec-dev libavutil-dev libswscale-dev librsvg2-bin gettext libcurl4-openssl-dev libfontconfig-dev libpipewire-0.3-dev
- preset: 'dashboard'
packages: extra-cmake-modules libarchive-dev libboost-all-dev libkf6coreaddons-dev libkf6qqc2desktopstyle-dev libkf6iconthemes-dev libkirigami-dev librsvg2-dev nlohmann-json3-dev qcoro-qt6-dev qml6-module-org-kde-kirigamiaddons-formcard
- preset: 'dissector-no-system-boost'
@@ -44,11 +45,14 @@ jobs:
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
uses: hendrikmuhs/ccache-action@v1.2.24
with:
key: linux-${{matrix.config.preset}}
job-summary: ""
restore-keys: linux-
# The trailing "." keeps one preset's key from being a prefix of another's
key: linux-${{matrix.config.preset}}.
verbose: 1
job-summary: ''
evict-old-files: job
save: ${{ github.ref == 'refs/heads/master' }}
- uses: actions/cache@v5
with:
@@ -117,13 +121,84 @@ jobs:
draft: true
files: server-build-deps.tar.xz
build-steam-frame:
name: Steam Frame
runs-on: ubuntu-24.04-arm
if: ${{ vars.APK_ONLY == '' }}
container:
image: registry.gitlab.steamos.cloud/steamrt/steamrt4/sdk/arm64:4.0.20260805.254769
volumes:
- ${{github.workspace}}/install:/tmp/install
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
fetch-tags: true
- name: Apt dependencies
uses: awalsh128/cache-apt-pkgs-action@v1.6.1
with:
packages: librsvg2-bin npm
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2.24
with:
key: steam-frame
verbose: 1
job-summary: ''
evict-old-files: job
save: ${{ github.ref == 'refs/heads/master' }}
restore-keys: steam-frame
- uses: actions/cache@v5
with:
key: cmake-frame
path: |
${{github.workspace}}/cmake-fetch/*-subbuild/*-populate-prefix/src/*.tar.*
${{github.workspace}}/cmake-fetch/*-subbuild/*-populate-prefix/src/*.zip
${{github.workspace}}/cmake-fetch/*.tar.*
${{github.workspace}}/cmake-fetch/*.tgz
${{github.workspace}}/cmake-fetch/*-src/.git
- name: Install dependencies
run: |
wget https://github.com/KhronosGroup/KTX-Software/releases/download/v4.4.2/KTX-Software-4.4.2-Linux-arm64.deb
sudo dpkg --install KTX-Software-4.4.2-Linux-arm64.deb
npm install --global @gltf-transform/cli@4.1.1
- name: Configure CMake
run: >
cmake -B "$GITHUB_WORKSPACE/build"
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
-DWIVRN_CSS=${{env.CSS}}
-DFETCHCONTENT_BASE_DIR="$GITHUB_WORKSPACE/cmake-fetch"
-DCMAKE_C_COMPILER_LAUNCHER=ccache
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
-DCMAKE_INSTALL_PREFIX=/usr
--preset frame
- name: Build
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
cd "$GITHUB_WORKSPACE/build"
DESTDIR="$GITHUB_WORKSPACE/install" ninja install
- name: Archive
uses: actions/upload-artifact@v7
with:
name: wivrn-frame-client.zip
path: install/usr
if-no-files-found: error
retention-days: 30
build-server-flatpak:
name: Linux server (flatpak)
runs-on: ubuntu-24.04
if: ${{ vars.APK_ONLY == '' }}
container:
# Tag matches runtime-version in the manifest.
image: ghcr.io/flathub-infra/flatpak-github-actions:kde-6.10
image: ghcr.io/flathub-infra/flatpak-github-actions:kde-6.11
options: --privileged
steps:
@@ -131,6 +206,16 @@ jobs:
with:
fetch-depth: 0
- uses: actions/cache/restore@v5
id: cache
with:
path: |
flatpak/monado-*.tar.gz
flatpak/xrizer-gen-src-*.json
.flatpak-builder
key: flatpak-build-${{ hashFiles('flatpak/io.github.wivrn.wivrn.yml.in', 'flatpak/ct-ng-x86_64.config', 'flatpak/ct-ng-aarch64.config', 'monado-rev') }}
restore-keys: flatpak-build-
- name: Create the flatpak manifest
run: |
git config --global --add safe.directory $(pwd)
@@ -138,15 +223,30 @@ jobs:
tools/gen_flatpak_manifest.py --gitlocal --out flatpak
cat flatpak/io.github.wivrn.wivrn.yml
- uses: flatpak/flatpak-github-actions/flatpak-builder@v6.7
- name: Update flatpak runtimes
run: |
for i in 1 2 3; do
flatpak update -y --noninteractive && exit 0
echo "flatpak update failed (attempt $i), retrying"
sleep 20
done
exit 1
- uses: flatpak/flatpak-github-actions/flatpak-builder@v6.8
with:
manifest-path: flatpak/io.github.wivrn.wivrn.yml
bundle: wivrn-server.flatpak
# The manifest is regenerated on every commit with the git hash embedded,
# so its default (manifest-hash) cache key never hits. Key on the files
# that actually define the dependency set instead, so the toolchain
# downloads and build cache persist across commits.
cache-key: flatpak-builder-${{ hashFiles('flatpak/io.github.wivrn.wivrn.yml.in', 'flatpak/ct-ng-x86_64.config', 'flatpak/ct-ng-aarch64.config', 'monado-rev', 'CMakeLists.txt') }}
restore-cache: false
save-cache: false
- uses: actions/cache/save@v5
if: success() && steps.cache.outputs.cache-hit != 'true'
with:
path: |
flatpak/monado-*.tar.gz
flatpak/xrizer-gen-src-*.json
.flatpak-builder
key: flatpak-build-${{ hashFiles('flatpak/io.github.wivrn.wivrn.yml.in', 'flatpak/ct-ng-x86_64.config', 'flatpak/ct-ng-aarch64.config', 'monado-rev') }}
- name: Debug bundle
uses: actions/upload-artifact@v7
@@ -196,6 +296,16 @@ jobs:
${{github.workspace}}/cmake-fetch/*.tgz
restore-keys: cmake-android-
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2.24
with:
# The trailing "." keeps one build type's key from being a prefix of another's
key: android-${{matrix.buildtype}}.
verbose: 1
job-summary: ''
evict-old-files: job
save: ${{ github.ref == 'refs/heads/master' }}
# Gradle distribution and the Android plugin's dependencies.
- uses: actions/cache@v5
with:
@@ -237,6 +347,9 @@ jobs:
echo "$APK_KEYSTORE_BASE64" | base64 --decode --ignore-garbage > ks.keystore
- name: Build
env:
# Paths under the workspace are hashed relative to it
CCACHE_BASEDIR: ${{github.workspace}}
run: |
VERSION=$(git describe --tags --always | sed "s/^v\([0-9]\)/\1/")
if [ ${{ matrix.buildtype }} = 'Oculus' ]
@@ -262,25 +375,19 @@ jobs:
fi
fi
if [ ${{ github.ref_type }} = 'tag' ]
then
CSS=images/wivrn-release.css
else
CSS=images/wivrn-nightly.css
fi
echo Setting version $VERSION and version code $VERSION_CODE in manifest
echo Using stylesheet $CSS and name $APPNAME
echo Using stylesheet ${{env.CSS}} and name $APPNAME
chmod +x gradlew
./gradlew \
-Pwivrn_version=$VERSION \
-Pwivrn_versionCode=$VERSION_CODE \
-Psuffix=$SUFFIX \
-Pwivrn_css=$CSS \
-Pwivrn_css=${{env.CSS}} \
-Pwivrn_app_name="$APPNAME" \
-Pwivrn_compress_glb=ON \
-Pfetchcontent_base_dir=${{github.workspace}}/cmake-fetch \
-Pcompiler_launcher=ccache \
assemble${{ matrix.buildtype }}
- name: Upload build dir
@@ -368,10 +475,7 @@ jobs:
- name: Patch monado
working-directory: wivrn/monado-src
run: >
for p in ../patches/monado/*; do
patch -p1 --fuzz=0 --forward < "$p"
done
run: ../patches/apply.sh ../patches/monado/*
- name: Download stb
run: |
+4 -4
View File
@@ -17,9 +17,9 @@ jobs:
steps:
- uses: actions/checkout@v6
- name: Run clang-format style check for C/C++/Protobuf programs.
uses: jidicula/clang-format-action@v4.16.0
uses: jidicula/clang-format-action@v4.18.0
with:
clang-format-version: '21'
clang-format-version: '22'
check-path: ${{ matrix.path }}
python-format-check:
@@ -30,12 +30,12 @@ jobs:
- uses: actions/checkout@v6
# Scope set by `include` in ruff.toml.
- name: Run ruff lint check
uses: astral-sh/ruff-action@v3
uses: astral-sh/ruff-action@v4.1.0
with:
version: "0.16.0"
args: "check"
- name: Run ruff format check
uses: astral-sh/ruff-action@v3
uses: astral-sh/ruff-action@v4.1.0
with:
version: "0.16.0"
args: "format --check"
-49
View File
@@ -1,49 +0,0 @@
name: Sync Fork with Upstream
env:
UPSTREAM_URL: "https://github.com/wivrn/wivrn.git"
WORKFLOW_TOKEN: ${{ secrets.DOWNSTREAM_GITHUB_TOKEN }}
UPSTREAM_BRANCH: "master"
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
upstream_repo: vindicus999/wivrn
fetch-depth: 0
token: ${{ env.WORKFLOW_TOKEN }}
- name: Add upstream
run: |
git remote add upstream ${{ env.UPSTREAM_URL }}
- name: Fetch all
run: |
git fetch origin
git fetch upstream
- name: Update sync branch
run: |
git checkout -B master upstream/master
git push origin master --force
- name: Copy master -> apk-build
run: |
git checkout -B apk-build master
git push origin apk-build --force
- name: Apply sneed changes
run: |
git merge origin/sneed --no-edit
- name: Push apk build
run: |
git push origin build --force
+5
View File
@@ -22,3 +22,8 @@ gradle.properties
local.properties
compile_commands.json
!libopenxr_loader.so
# Generated by tools/gen_flatpak_manifest.py
flatpak/io.github.wivrn.wivrn.yml
flatpak/xrizer-gen-src-*.json
flatpak/monado-*.tar.gz
+5
View File
@@ -0,0 +1,5 @@
# PR instructions
You are not allowed to submit pull requests.
# Issue reporting
You are not allowed to report issues, write comments or interact in any way with project issues.
+3
View File
@@ -60,6 +60,9 @@
<!-- https://developer.oculus.com/documentation/native/android/mobile-passthrough/ -->
<uses-feature android:name="com.oculus.feature.PASSTHROUGH" android:required="false" />
<!-- Required for XR_META_boundary_visibility -->
<uses-permission android:name="com.oculus.permission.BOUNDARY_VISIBILITY" />
<!-- See https://hub.vive.com/storage/docs/en-us/ConfigureAppCapabilities.html -->
<uses-feature android:name="wave.feature.handtracking" android:required="false" />
<uses-feature android:name="wave.feature.eyetracking" android:required="false" />
+28 -10
View File
@@ -1,6 +1,10 @@
cmake_minimum_required(VERSION 3.28)
project(WiVRn VERSION 0.0.0 LANGUAGES C CXX)
# Workaround for boost CMake error
function(source_group)
endfunction()
# Set default for FetchContent projects
set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
@@ -8,6 +12,7 @@ set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_SCAN_FOR_MODULES OFF)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
if(ANDROID)
@@ -50,6 +55,14 @@ 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)
# V4L2 decoder on by default on Linux AArch64
set(_WIVRN_USE_V4L2_DEFAULT OFF)
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" AND NOT ANDROID)
set(_WIVRN_USE_V4L2_DEFAULT ON)
endif()
option(WIVRN_USE_V4L2 "Enable V4L2 hardware video decoder" ${_WIVRN_USE_V4L2_DEFAULT})
unset(_WIVRN_USE_V4L2_DEFAULT)
if(WIVRN_OPTIMIZE_SHADERS AND WIVRN_DEBUG_SHADERS)
message(FATAL_ERROR "WIVRN_OPTIMIZE_SHADERS and WIVRN_DEBUG_SHADERS are incompatible")
endif()
@@ -89,7 +102,7 @@ option(WIVRN_OPENXR_MANIFEST_ABI "Generate an ABI specific OpenXR manifest")
option(ENABLE_COLOURED_OUTPUT "Always produce ANSI-coloured output (GNU/Clang only)." ON)
set(WIVRN_ENVIRONMENTS_URL "https://github.com/Vindicus999/WiVRn-environments/releases/latest/download/index.json" CACHE STRING "URL hosting the custom environments json file")
set(WIVRN_ENVIRONMENTS_URL "https://github.com/WiVRn/WiVRn-environments/releases/latest/download/index.json" CACHE STRING "URL hosting the custom environments json file")
if (WIVRN_BUILD_CLIENT OR WIVRN_BUILD_SERVER OR WIVRN_BUILD_DASHBOARD OR WIVRN_BUILD_DISSECTOR)
set(NEED_COMMON TRUE)
@@ -140,10 +153,6 @@ if (WIVRN_BUILD_SERVER)
pkg_check_modules(X264 REQUIRED IMPORTED_TARGET x264)
endif()
if (WIVRN_USE_PIPEWIRE)
pkg_check_modules(libpipewire REQUIRED IMPORTED_TARGET libpipewire-0.3)
endif()
pkg_check_modules(AVAHI REQUIRED IMPORTED_TARGET avahi-client avahi-glib)
find_package(Eigen3 REQUIRED)
find_package(nlohmann_json REQUIRED)
@@ -168,6 +177,8 @@ if (WIVRN_BUILD_DASHBOARD)
find_package(Qt6 REQUIRED COMPONENTS QmlPrivate)
endif()
# Prevent KDE cmake module from overwriting defaults
set(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT FALSE)
find_package(ECM 5.115 REQUIRED NO_MODULE)
list(APPEND CMAKE_MODULE_PATH "${ECM_MODULE_PATH}")
@@ -182,6 +193,10 @@ if (WIVRN_BUILD_CLIENT OR WIVRN_BUILD_DASHBOARD)
find_package(Gettext REQUIRED)
endif()
if (WIVRN_USE_PIPEWIRE AND (WIVRN_BUILD_SERVER OR (WIVRN_BUILD_CLIENT AND NOT ANDROID)))
pkg_check_modules(libpipewire REQUIRED IMPORTED_TARGET libpipewire-0.3)
endif()
if (WIVRN_BUILD_CLIENT)
find_program(RSVG_CONVERT rsvg-convert REQUIRED)
find_program(KTX ktx REQUIRED)
@@ -196,11 +211,13 @@ if (WIVRN_BUILD_CLIENT)
endif()
if (WIVRN_BUILD_CLIENT AND NOT ANDROID)
pkg_check_modules(LIBAV_CLIENT REQUIRED IMPORTED_TARGET libavcodec libavutil libswscale)
if(NOT WIVRN_USE_V4L2)
pkg_check_modules(LIBAV_CLIENT REQUIRED IMPORTED_TARGET libavcodec libavutil libswscale)
endif()
find_package(Fontconfig REQUIRED)
if (WIVRN_USE_SYSTEM_OPENXR)
find_package(OpenXR 1.1.58 REQUIRED)
find_package(OpenXR 1.1.59 REQUIRED)
endif()
if (WIVRN_USE_SYSTEM_LIBKTX)
@@ -238,8 +255,8 @@ FetchContent_Declare(fastgltf EXCLUDE_FROM_ALL SYSTEM URL https://github.co
URL_HASH SHA256=0bb564e127b14c22f062db50f89381dd2e0a20dbaf4987ca138a4ae8728712f9)
FetchContent_Declare(glm EXCLUDE_FROM_ALL SYSTEM URL https://github.com/g-truc/glm/releases/download/1.0.2/glm-1.0.2.zip
URL_HASH SHA256=77fff075c5ab0caf076fade41558c5458d9a242aba2b2076bb72008bdb51a35e)
FetchContent_Declare(openxr_loader EXCLUDE_FROM_ALL SYSTEM URL https://github.com/KhronosGroup/OpenXR-SDK/archive/refs/tags/release-1.1.58.tar.gz
URL_HASH SHA256=815b933219c398314366c289221526428418d799205a73a9640c97ca4242602b)
FetchContent_Declare(openxr_loader EXCLUDE_FROM_ALL SYSTEM URL https://github.com/KhronosGroup/OpenXR-SDK/archive/refs/tags/release-1.1.59.tar.gz
URL_HASH SHA256=d45d12d71cbe381a6fc510ec95ec84a88fe30724674e63bb038dfc9a481d8885)
FetchContent_Declare(spdlog EXCLUDE_FROM_ALL SYSTEM URL https://github.com/gabime/spdlog/archive/refs/tags/v1.16.0.tar.gz
URL_HASH SHA256=8741753e488a78dd0d0024c980e1fb5b5c85888447e309d9cb9d949bdb52aa3e)
FetchContent_Declare(stb EXCLUDE_FROM_ALL SYSTEM URL https://github.com/nothings/stb/archive/013ac3beddff3dbffafd5177e7972067cd2b5083.zip
@@ -290,6 +307,7 @@ add_custom_target(wivrn-version ALL
-P ${CMAKE_SOURCE_DIR}/cmake/GitVersion.cmake
BYPRODUCTS ${CMAKE_BINARY_DIR}/version.cpp ${CMAKE_BINARY_DIR}/u_git_tag.cpp
SOURCES common/version.cpp.in server/u_git_tag.cpp.in
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
add_subdirectory(external)
@@ -329,11 +347,11 @@ foreach(TARGET_NAME wivrn wivrn-server wivrn-dashboard wivrn-common wivrn-dissec
target_compile_options(${TARGET_NAME} PRIVATE
-fdiagnostics-color -Wall -Wextra -pedantic
-ffast-math
-fno-finite-math-only
-Wundef
-Wno-missing-field-initializers
-Wno-unused-parameter
-Wno-comment
-Wno-unused-variable
-Wno-sign-compare
$<$<COMPILE_LANG_AND_ID:CXX,GNU>:-Wno-volatile -Wno-array-bounds>
$<$<COMPILE_LANG_AND_ID:CXX,Clang>:-Wno-deprecated-volatile -Wno-unneeded-internal-declaration -Wno-c99-extensions -Wno-unused-private-field>
+22
View File
@@ -157,6 +157,28 @@
"cacheVariables": {
"WIVRN_USE_SYSTEM_BOOST": "OFF"
}
},
{
"name": "frame",
"generator": "Ninja",
"cacheVariables": {
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"CMAKE_INTERPROCEDURAL_OPTIMIZATION": "ON",
"CMAKE_BUILD_TYPE": "Release",
"WIVRN_BUILD_CLIENT": "ON",
"WIVRN_BUILD_SERVER": "OFF",
"WIVRN_BUILD_SERVER_LIBRARY": "OFF",
"WIVRN_BUILD_DASHBOARD": "OFF",
"WIVRN_BUILD_DISSECTOR": "OFF",
"WIVRN_BUILD_WIVRNCTL": "OFF",
"WIVRN_USE_PIPEWIRE": "ON",
"WIVRN_USE_V4L2": "ON",
"WIVRN_USE_SYSTEM_BOOST": "OFF",
"WIVRN_USE_SYSTEM_LIBKTX": "OFF",
"WIVRN_USE_SYSTEM_OPENXR": "OFF",
"WIVRN_COMPRESS_GLB": "ON",
"WIVRN_WERROR": "ON"
}
}
],
"buildPresets": [
+20
View File
@@ -0,0 +1,20 @@
# Contributing to WiVRn
WiVRn is developed by volunteers and published under GPL-3 license.
Contributions are welcome, there are few rules that should be followed:
## Setup your development environment
Instructions on how to build the project are in [docs/building.md], for translations please follow [docs/translating.md].
## Acceptable contributions
The project is developed by humans, machine generated code will not be accepted unless it is for trivial changes.
For changes to be accepted, we have to ensure that we can maintain them in the future.
This means that we will be very careful in case of big pull requests. Changes that rely on specification violation or that violate specifications (especially OpenXR and Vulkan) will not be accepted.
## Conventions
The code does not have strict conventions, there is a clang-format file for formatting. Just try to write code that is correct, concise and easy to understand. Details can be discussed in code reviews.
+2 -2
View File
@@ -62,7 +62,7 @@ Follow the wizard in the PC dashboard to install the client on your VR headset.
It should either lead you to the [Meta Store](https://www.meta.com/experiences/7959676140827574/) (for Meta Quest headsets) or to download the correct APK (for other headsets).
> [!WARNING]
> The VR client and PC server need to be on the same version of WiVRn
> The VR client and PC server must use the same WiVRn protocol. For development builds, compare the full version string, including the Git commit suffix (for example, `26.8-42-g1234afe`); the release prefix alone (for example, `26.8`) does not identify the build.
> [!TIP]
> If the headset fails to connect to the computer, see [troubleshooting](#troubleshooting).
@@ -150,7 +150,7 @@ If the server list is empty in the headset app:
<details><summary>My headset does not connect to my computer</summary>
- If you have a firewall, check that port 9757 (UDP and TCP) is open
- The server and client must be the same version.</details>
- If the app reports an incompatible server protocol, compare the full version shown in the headset app's About screen with the server's startup log. Package metadata may show only the release prefix. For development builds, use client and server built from the same source revision. If multiple builds are installed, make sure you start the intended server.</details>
<details><summary>How do I use a wired connection manually?</summary>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 856 B

After

Width:  |  Height:  |  Size: 930 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 292 B

BIN
View File
Binary file not shown.
+4 -1
View File
@@ -117,6 +117,8 @@ 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 compilerLauncher = project.hasProperty('compiler_launcher') ? ['-DCMAKE_C_COMPILER_LAUNCHER=' + compiler_launcher, '-DCMAKE_CXX_COMPILER_LAUNCHER=' + compiler_launcher] : []
def asan = use_asan ? 'ON': 'OFF'
def stl = use_asan ? 'c++_shared' : "c++_static"
@@ -146,7 +148,8 @@ android {
'-DWIVRN_COMPRESS_GLB=' + compressGlb,
'-DWIVRN_ADDRESS_SANITIZER=' + asan,
] +
fetchcontentBaseDir
fetchcontentBaseDir +
compilerLauncher
resValue "string", "app_name", project.hasProperty('wivrn_app_name') ? project.wivrn_app_name : "WiVRn Local"
abiFilters 'arm64-v8a'//, 'x86_64'
}
+35 -3
View File
@@ -108,10 +108,29 @@ else()
target_link_libraries(wivrn openxr_loader)
endif()
target_link_libraries(wivrn PkgConfig::LIBAV_CLIENT Fontconfig::Fontconfig CURL::libcurl)
target_link_libraries(wivrn Fontconfig::Fontconfig CURL::libcurl)
if(WIVRN_USE_V4L2)
file(GLOB CLIENT_V4L2_SOURCE CONFIGURE_DEPENDS
"decoder/v4l2/*.cpp")
list(APPEND PLATFORM_SOURCE ${CLIENT_V4L2_SOURCE})
else()
target_link_libraries(wivrn PkgConfig::LIBAV_CLIENT)
file(GLOB PLATFORM_SOURCE CONFIGURE_DEPENDS
"decoder/ffmpeg/*.cpp")
endif()
file(GLOB CLIENT_LINUX_SOURCE CONFIGURE_DEPENDS
"linux/*.cpp")
list(APPEND PLATFORM_SOURCE ${CLIENT_LINUX_SOURCE})
if(WIVRN_USE_PIPEWIRE)
file(GLOB CLIENT_PIPEWIRE_SOURCE CONFIGURE_DEPENDS
"audio/linux/*.cpp")
list(APPEND PLATFORM_SOURCE ${CLIENT_PIPEWIRE_SOURCE})
target_link_libraries(wivrn PkgConfig::libpipewire)
endif()
file(GLOB PLATFORM_SOURCE CONFIGURE_DEPENDS
"decoder/ffmpeg/*.cpp")
target_sources(wivrn PRIVATE ${PLATFORM_SOURCE})
file(CREATE_LINK ${CMAKE_CURRENT_BINARY_DIR}/share ${CMAKE_BINARY_DIR}/share SYMBOLIC)
@@ -165,6 +184,8 @@ target_compile_definitions(wivrn PRIVATE IMGUI_DEFINE_MATH_OPERATORS)
target_include_directories(wivrn PRIVATE .)
if(NOT ANDROID)
configure_file(io.github.wivrn.wivrn-client.desktop.in io.github.wivrn.wivrn-client.desktop)
install(TARGETS wivrn)
endif()
@@ -276,10 +297,14 @@ set(IMAGES_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../images)
set(ASSETS_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../assets-source)
wivrn_rasterize_svg(SOURCE ${IMAGES_SRC_DIR}/wivrn.svg DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/wivrn.png WIDTH 540 HEIGHT 540 CSS ${WIVRN_CSS_ABS})
wivrn_rasterize_svg(SOURCE ${IMAGES_SRC_DIR}/wivrn-pride.svg DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/wivrn-pride.png WIDTH 540 HEIGHT 540 CSS ${WIVRN_CSS_ABS})
wivrn_rasterize_svg(SOURCE ${IMAGES_SRC_DIR}/wivrn-christmas.svg DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/wivrn-christmas.png WIDTH 540 HEIGHT 540 CSS ${WIVRN_CSS_ABS})
wivrn_rasterize_svg(SOURCE ${ASSETS_SRC_DIR}/passthrough.svg DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/passthrough.png WIDTH 256 HEIGHT 256)
wivrn_rasterize_svg(SOURCE ${ASSETS_SRC_DIR}/default-environment.svg DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/default-environment.png WIDTH 256 HEIGHT 256)
wivrn_generate_ktx( SOURCE ${CMAKE_CURRENT_BINARY_DIR}/wivrn.png DESTINATION ${ASSETS_DIR}/wivrn.ktx2 TARGET wivrn)
wivrn_generate_ktx( SOURCE ${CMAKE_CURRENT_BINARY_DIR}/wivrn-pride.png DESTINATION ${ASSETS_DIR}/wivrn-pride.ktx2 TARGET wivrn)
wivrn_generate_ktx( SOURCE ${CMAKE_CURRENT_BINARY_DIR}/wivrn-christmas.png DESTINATION ${ASSETS_DIR}/wivrn-christmas.ktx2 TARGET wivrn)
wivrn_generate_ktx( SOURCE ${ASSETS_SRC_DIR}/default_icon.png DESTINATION ${ASSETS_DIR}/default_icon.ktx2 TARGET wivrn)
wivrn_generate_ktx( SOURCE ${CMAKE_CURRENT_BINARY_DIR}/passthrough.png DESTINATION ${ASSETS_DIR}/passthrough.ktx2 TARGET wivrn)
wivrn_generate_ktx( SOURCE ${CMAKE_CURRENT_BINARY_DIR}/default-environment.png DESTINATION ${ASSETS_DIR}/default-environment.ktx2 TARGET wivrn)
@@ -328,4 +353,11 @@ if(NOT ANDROID)
set_target_properties(wivrn PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
install(DIRECTORY "${ASSETS_DIR}" DESTINATION ${CMAKE_INSTALL_DATADIR}/wivrn)
install(FILES ../images/wivrn.svg
DESTINATION share/icons/hicolor/scalable/apps
RENAME io.github.wivrn.wivrn-client.svg
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/io.github.wivrn.wivrn-client.desktop
DESTINATION share/applications
)
endif()
+21 -18
View File
@@ -2,6 +2,7 @@
* WiVRn VR streaming
* Copyright (C) 2024 Guillaume Meunier <guillaume.meunier@centraliens.net>
* Copyright (C) 2024 Patrick Nicolas <patricknicolas@laposte.net>
* Copyright (C) 2026 Sapphire <imsapphire0@gmail.com>
*
* 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
@@ -19,20 +20,19 @@
#include "battery.h"
#include "android/jnipp.h"
#include "application.h"
#include <mutex>
#include <spdlog/spdlog.h>
namespace
battery::battery(xr::instance & instance, xr::session & session, jobject activity) : battery(instance, session)
{
std::mutex last_status_lock;
battery_status last_status;
} // namespace
jni::object<""> act(activity);
auto app = act.call<jni::object<"android/app/Application">>("getApplication");
auto ctx = app.call<jni::object<"android/content/Context">>("getApplicationContext");
battery_status get_battery_status()
{
std::unique_lock _{last_status_lock};
return last_status;
auto bat_receiver = act.field<jni::object<"android/content/BroadcastReceiver">>("BatteryInfoReceiver");
ctx.call<jni::object<"android/content/Intent">>("registerReceiver", bat_receiver, jni::new_object<"android/content/IntentFilter">(jni::string{"android.intent.action.BATTERY_CHANGED"}));
}
extern "C" void Java_org_meumeu_wivrn_BroadcastReceiver_onReceive(JNIEnv * env, jobject instance, jobject ctxt_obj, jobject intent_obj)
@@ -51,16 +51,19 @@ extern "C" void Java_org_meumeu_wivrn_BroadcastReceiver_onReceive(JNIEnv * env,
auto scale_jint = intent.call<jni::Int>(get_int_extra, scale_jstr, default_jint);
auto plugged_jint = intent.call<jni::Int>(get_int_extra, plugged_jstr, default_jint);
{
std::unique_lock _{last_status_lock};
if (level_jint && level_jint.value >= 0 && scale_jint && scale_jint.value >= 0)
last_status.charge = (float)(level_jint.value) / (float)(scale_jint.value);
else
last_status.charge = std::nullopt;
std::optional<float> charge{};
if (level_jint && level_jint.value >= 0 && scale_jint && scale_jint.value >= 0)
charge = (float)(level_jint.value) / (float)(scale_jint.value);
last_status.charging = plugged_jint && plugged_jint.value > 0;
}
bool charging = plugged_jint && plugged_jint.value > 0;
if (level_jint and scale_jint and plugged_jint)
spdlog::debug("Received ACTION_BATTERY_CHANGED: level {}%, plugged {}", *last_status.charge * 100, last_status.charging);
if (charge)
spdlog::debug("Received ACTION_BATTERY_CHANGED: level {}%, plugged {}", *charge * 100, charging);
application::get_battery_monitor().on_status_update(
battery::device::head,
{
.charge = charge,
.charging = charging,
});
}
+38
View File
@@ -0,0 +1,38 @@
/*
* WiVRn VR streaming
* Copyright (C) 2023 Guillaume Meunier <guillaume.meunier@centraliens.net>
* Copyright (C) 2023 Patrick Nicolas <patricknicolas@laposte.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "property.h"
#include "utils/wrap_lambda.h"
#include <sys/system_properties.h>
std::optional<std::string> get_property(const char * property)
{
auto info = __system_property_find(property);
if (not info)
return std::nullopt;
std::string result;
wrap_lambda cb = [&result](const char * name, const char * value, uint32_t serial) {
result = value;
};
__system_property_read_callback(info, cb.userdata_first(), cb);
return result;
}
@@ -1,7 +1,7 @@
/*
* WiVRn VR streaming
* Copyright (C) 2024 Guillaume Meunier <guillaume.meunier@centraliens.net>
* Copyright (C) 2024 Patrick Nicolas <patricknicolas@laposte.net>
* Copyright (C) 2023 Guillaume Meunier <guillaume.meunier@centraliens.net>
* Copyright (C) 2023 Patrick Nicolas <patricknicolas@laposte.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -20,11 +20,6 @@
#pragma once
#include <optional>
#include <string>
struct battery_status
{
std::optional<float> charge = std::nullopt;
bool charging = false;
};
battery_status get_battery_status();
std::optional<std::string> get_property(const char * property);
+2
View File
@@ -16,4 +16,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
bool usb_link_properties_changed();
+165 -1
View File
@@ -477,6 +477,68 @@ static std::vector<interaction_profile> interaction_profiles{
"/user/hand/right/input/squeeze/value",
},
},
interaction_profile{
.profile_name = "/interaction_profiles/valve/frame_controller_valve",
.required_extensions = {"XR_VALVE_frame_controller_interaction"},
.input_sources = {
"/user/hand/right/output/haptic",
"/user/hand/left/output/haptic",
"/user/hand/right/input/grip/pose",
"/user/hand/left/input/grip/pose",
"/user/hand/right/input/aim/pose",
"/user/hand/left/input/aim/pose",
"/user/hand/right/input/a/touch",
"/user/hand/right/input/a/click",
"/user/hand/right/input/b/touch",
"/user/hand/right/input/b/click",
"/user/hand/right/input/x/touch",
"/user/hand/right/input/x/click",
"/user/hand/right/input/y/touch",
"/user/hand/right/input/y/click",
"/user/hand/right/input/menu/touch",
"/user/hand/right/input/menu/click",
"/user/hand/right/input/system/touch",
"/user/hand/right/input/system/click",
"/user/hand/right/input/bumper/touch",
"/user/hand/right/input/bumper/click",
"/user/hand/right/input/squeeze/touch",
"/user/hand/right/input/squeeze/click",
"/user/hand/right/input/squeeze/value",
"/user/hand/right/input/trigger/touch",
"/user/hand/right/input/trigger/click",
"/user/hand/right/input/trigger/value",
"/user/hand/right/input/thumbstick/touch",
"/user/hand/right/input/thumbstick/click",
"/user/hand/right/input/thumbstick",
"/user/hand/left/input/dpad_up/touch",
"/user/hand/left/input/dpad_up/click",
"/user/hand/left/input/dpad_left/touch",
"/user/hand/left/input/dpad_left/click",
"/user/hand/left/input/dpad_down/touch",
"/user/hand/left/input/dpad_down/click",
"/user/hand/left/input/dpad_right/touch",
"/user/hand/left/input/dpad_right/click",
"/user/hand/left/input/view/touch",
"/user/hand/left/input/view/click",
"/user/hand/left/input/system/touch",
"/user/hand/left/input/system/click",
"/user/hand/left/input/bumper/touch",
"/user/hand/left/input/bumper/click",
"/user/hand/left/input/squeeze/touch",
"/user/hand/left/input/squeeze/click",
"/user/hand/left/input/squeeze/value",
"/user/hand/left/input/trigger/touch",
"/user/hand/left/input/trigger/click",
"/user/hand/left/input/trigger/value",
"/user/hand/left/input/thumbstick/touch",
"/user/hand/left/input/thumbstick/click",
"/user/hand/left/input/thumbstick",
},
},
interaction_profile{
.profile_name = "/interaction_profiles/yvr/touch_controller_yvr",
.input_sources = {
@@ -837,6 +899,16 @@ void application::initialize_vulkan()
optional_device_extensions.emplace(VK_IMG_FILTER_CUBIC_EXTENSION_NAME);
optional_device_extensions.emplace(VK_KHR_TIMELINE_SEMAPHORE_EXTENSION_NAME);
optional_device_extensions.emplace(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
optional_device_extensions.emplace(VK_EXT_FRAGMENT_DENSITY_MAP_2_EXTENSION_NAME);
optional_device_extensions.emplace(VK_QCOM_FRAGMENT_DENSITY_MAP_OFFSET_EXTENSION_NAME);
#if WIVRN_USE_V4L2
// V4L2 decoders expose their output through DMA-buf
optional_device_extensions.emplace(VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME);
optional_device_extensions.emplace(VK_EXT_EXTERNAL_MEMORY_DMA_BUF_EXTENSION_NAME);
optional_device_extensions.emplace(VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME);
optional_device_extensions.emplace(VK_EXT_QUEUE_FAMILY_FOREIGN_EXTENSION_NAME);
#endif
#ifdef __ANDROID__
vk_device_extensions.push_back(VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_EXTENSION_NAME);
@@ -984,7 +1056,9 @@ void application::initialize_vulkan()
vk::PhysicalDeviceMultiviewFeaturesKHR{
.multiview = true,
},
vk::PhysicalDeviceIndexTypeUint8FeaturesEXT{}};
vk::PhysicalDeviceIndexTypeUint8FeaturesEXT{},
vk::PhysicalDeviceFragmentDensityMapFeaturesEXT{},
vk::PhysicalDeviceFragmentDensityMapOffsetFeaturesQCOM{}};
auto check_feature_flag = [&](auto feature_flag, const char * extension_name) -> bool {
using FeatureStruct = class_from_member_t<decltype(feature_flag)>;
@@ -1004,6 +1078,14 @@ void application::initialize_vulkan()
check_feature_flag(&vk::PhysicalDeviceTimelineSemaphoreFeaturesKHR::timelineSemaphore, VK_KHR_TIMELINE_SEMAPHORE_EXTENSION_NAME);
check_feature_flag(&vk::PhysicalDeviceIndexTypeUint8FeaturesEXT::indexTypeUint8, VK_EXT_INDEX_TYPE_UINT8_EXTENSION_NAME);
const bool fragment_density_map_supported =
check_feature_flag(&vk::PhysicalDeviceFragmentDensityMapFeaturesEXT::fragmentDensityMap, VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
const bool fragment_density_map2_supported =
utils::contains(vk_device_extensions, VK_EXT_FRAGMENT_DENSITY_MAP_2_EXTENSION_NAME);
const bool fragment_density_map_offset_supported =
check_feature_flag(&vk::PhysicalDeviceFragmentDensityMapOffsetFeaturesQCOM::fragmentDensityMapOffset, VK_QCOM_FRAGMENT_DENSITY_MAP_OFFSET_EXTENSION_NAME);
foveation_vulkan_supported = fragment_density_map_supported and fragment_density_map2_supported and fragment_density_map_offset_supported;
spdlog::info(" Vulkan eye-tracked foveation support: {}", foveation_vulkan_supported);
vk_device = xr_system_id.create_device(vk_physical_device, device_create_info.get());
*vk_queue.lock() = vk_device.getQueue(vk_queue_family_index, 0);
@@ -1294,9 +1376,11 @@ void application::initialize()
XR_KHR_MAINTENANCE1_EXTENSION_NAME,
XR_KHR_VISIBILITY_MASK_EXTENSION_NAME,
XR_EXT_INTERACTION_PROFILE_BATTERY_STATE_DISPLAY_EXTENSION_NAME,
XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME,
XR_EXT_HAND_INTERACTION_EXTENSION_NAME,
XR_EXT_HAND_TRACKING_EXTENSION_NAME,
XR_EXT_HAND_TRACKING_DATA_SOURCE_EXTENSION_NAME,
XR_FB_HAND_TRACKING_MESH_EXTENSION_NAME,
XR_EXT_PALM_POSE_EXTENSION_NAME,
XR_EXT_PERFORMANCE_SETTINGS_EXTENSION_NAME,
@@ -1311,6 +1395,9 @@ void application::initialize()
XR_FB_COMPOSITION_LAYER_SETTINGS_EXTENSION_NAME,
XR_FB_DISPLAY_REFRESH_RATE_EXTENSION_NAME,
XR_FB_FACE_TRACKING2_EXTENSION_NAME,
XR_FB_FOVEATION_EXTENSION_NAME,
XR_FB_FOVEATION_CONFIGURATION_EXTENSION_NAME,
XR_FB_FOVEATION_VULKAN_EXTENSION_NAME,
XR_FB_PASSTHROUGH_EXTENSION_NAME,
XR_FB_SWAPCHAIN_UPDATE_STATE_EXTENSION_NAME,
@@ -1321,7 +1408,10 @@ void application::initialize()
XR_META_BODY_TRACKING_FIDELITY_EXTENSION_NAME,
XR_META_BODY_TRACKING_FULL_BODY_EXTENSION_NAME,
XR_META_FOVEATION_EYE_TRACKED_EXTENSION_NAME,
XR_META_LOCAL_DIMMING_EXTENSION_NAME,
XR_META_BOUNDARY_VISIBILITY_EXTENSION_NAME,
XR_META_VULKAN_SWAPCHAIN_CREATE_INFO_EXTENSION_NAME,
};
for (const auto & i: interaction_profiles)
@@ -1372,6 +1462,13 @@ void application::initialize()
eye_gaze_supported = eye_gaze_properties.supportsEyeGazeInteraction;
}
if (xr_instance.has_extension(XR_META_FOVEATION_EYE_TRACKED_EXTENSION_NAME))
{
XrSystemFoveationEyeTrackedPropertiesMETA foveation_properties = xr_system_id.foveation_eye_tracked_properties();
spdlog::info(" Eye tracked foveation center support: {}", (bool)foveation_properties.supportsFoveationEyeTracked);
foveation_center_supported = foveation_properties.supportsFoveationEyeTracked;
}
if (xr_instance.has_extension(XR_FB_COMPOSITION_LAYER_SETTINGS_EXTENSION_NAME))
{
spdlog::info(" OpenXR post-processing extension support: true");
@@ -1404,9 +1501,17 @@ 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);
#ifdef __ANDROID__
battery_monitor.emplace(xr_instance, xr_session, app_info.native_app->activity->clazz);
#else
battery_monitor.emplace(xr_instance, xr_session);
#endif
config.emplace(xr_system_id, xr_session, application::get_config_path() / "client.json");
default_config.emplace(xr_system_id, xr_session);
xr_session.set_passthrough_boundary_enabled(config->passthrough_boundary_enabled);
#ifdef __ANDROID__
set_usb_networking(config->usb_network);
#endif
@@ -1698,6 +1803,7 @@ application::~application()
void application::loop()
{
poll_events();
battery_monitor->poll_batteries();
auto scene = current_scene();
if (not is_session_running())
@@ -1743,6 +1849,59 @@ void application::loop()
}
}
std::optional<XrQuaternionf> application::locate_gaze(XrTime time)
{
XrSpaceLocation res{
.type = XR_TYPE_SPACE_LOCATION,
};
if (get_hmd_traits().view_locate)
{
xrLocateSpace(spaces[size_t(xr::spaces::eye_gaze)],
spaces[size_t(xr::spaces::view)],
time,
&res);
}
else
{
XrSpaceLocation tmp{
.type = XR_TYPE_SPACE_LOCATION,
};
auto xr_res = xrLocateSpace(spaces[size_t(xr::spaces::view)],
spaces[size_t(xr::spaces::world)],
time,
&tmp);
if (XR_FAILED(xr_res))
return std::nullopt;
xr_res = xrLocateSpace(spaces[size_t(xr::spaces::eye_gaze)],
spaces[size_t(xr::spaces::world)],
time,
&res);
if (XR_FAILED(xr_res))
return std::nullopt;
glm::quat target_quat(
res.pose.orientation.w,
res.pose.orientation.x,
res.pose.orientation.y,
res.pose.orientation.z);
const glm::quat view_quat(
tmp.pose.orientation.w,
tmp.pose.orientation.x,
tmp.pose.orientation.y,
tmp.pose.orientation.z);
target_quat = glm::conjugate(view_quat) * target_quat;
res.pose.orientation = {
.x = target_quat.x,
.y = target_quat.y,
.z = target_quat.z,
.w = target_quat.w};
res.locationFlags &= tmp.locationFlags;
}
if (res.locationFlags & XR_SPACE_LOCATION_ORIENTATION_VALID_BIT)
return res.pose.orientation;
return std::nullopt;
}
#ifdef __ANDROID__
void application::run()
{
@@ -2053,6 +2212,11 @@ void application::poll_events()
spdlog::info(" XR_PASSTHROUGH_STATE_CHANGED_RESTORED_ERROR_BIT_FB");
}
break;
case XR_TYPE_EVENT_DATA_BOUNDARY_VISIBILITY_CHANGED_META: {
spdlog::info("Boundary visibility changed to {}", magic_enum::enum_name(e.boundary_visibility_changed.boundaryVisibility));
xr_session.on_boundary_visibility_changed(e.boundary_visibility_changed.boundaryVisibility);
}
break;
default:
spdlog::info("Received event type {}", xr::to_string(e.header.type));
break;
+24 -2
View File
@@ -19,6 +19,7 @@
#pragma once
#include "battery.h"
#ifdef __ANDROID__
#include "android/hid.h"
#include <android_native_app_glue.h>
@@ -131,6 +132,8 @@ private:
std::vector<std::pair<XrPath, xr::space>> generic_trackers;
bool eye_gaze_supported = false;
bool foveation_center_supported = false;
bool foveation_vulkan_supported = false;
bool openxr_post_processing_supported = false;
@@ -146,6 +149,7 @@ private:
std::filesystem::path cache_path;
std::shared_ptr<wifi_lock> wifi;
std::optional<battery> battery_monitor;
std::mutex server_intent_mutex;
std::optional<wivrn_discover::service> server_intent;
@@ -187,8 +191,6 @@ private:
vk::raii::DebugReportCallbackEXT debug_report_callback = nullptr;
#endif
void set_server_uri(std::string uri);
public:
using singleton<application>::instance;
application(application_info info);
@@ -214,6 +216,8 @@ public:
}
#endif
void set_server_uri(std::string uri);
static bool is_session_running()
{
return instance().session_running;
@@ -276,6 +280,8 @@ public:
return std::make_pair(position, orientation);
}
std::optional<XrQuaternionf> locate_gaze(XrTime time);
void run();
static void push_scene(std::shared_ptr<scene>);
@@ -312,6 +318,12 @@ public:
return *instance().wifi;
}
static battery & get_battery_monitor()
{
assert(instance().battery_monitor);
return *instance().battery_monitor;
}
#ifdef __ANDROID__
void set_usb_networking(bool enabled);
#endif
@@ -407,6 +419,16 @@ public:
return instance().eye_gaze_supported;
}
static bool get_foveation_center_supported()
{
return instance().foveation_center_supported;
}
static bool get_foveation_vulkan_supported()
{
return instance().foveation_vulkan_supported;
}
static bool get_openxr_post_processing_supported()
{
return instance().openxr_post_processing_supported;
+8
View File
@@ -19,12 +19,20 @@
#pragma once
#include "wivrn_config.h"
#ifdef __ANDROID__
#include "android/audio.h"
namespace wivrn
{
using audio = ::wivrn::android::audio;
}
#elif WIVRN_USE_PIPEWIRE
#include "linux/audio.h"
namespace wivrn
{
using audio = ::wivrn::linux_audio::audio;
}
#else
#include "wivrn_client.h"
+640
View File
@@ -0,0 +1,640 @@
/*
* WiVRn VR streaming
* Copyright (C) 2026 galister <galister-dev@pm.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "audio.h"
#include "utils/named_thread.h"
#include "wivrn_client.h"
#include "xr/instance.h"
#include "spdlog/spdlog.h"
#include <pipewire/pipewire.h>
#include <spa/param/audio/format-utils.h>
#include <spa/utils/result.h>
#include <algorithm>
#include <chrono>
#include <cstring>
#include <format>
#include <memory>
#include <mutex>
#include <stdexcept>
#include <string>
#include <string_view>
#include <vector>
namespace wivrn::linux_audio
{
void pipewire_deleter::operator()(pw_main_loop * loop) const noexcept
{
pw_main_loop_destroy(loop);
}
void pipewire_deleter::operator()(pw_thread_loop * loop) const noexcept
{
pw_thread_loop_destroy(loop);
}
void pipewire_deleter::operator()(pw_stream * stream) const noexcept
{
pw_stream_destroy(stream);
}
namespace
{
constexpr uint32_t default_sample_rate = 48'000;
constexpr uint32_t target_latency_ms = 5;
void init_pipewire()
{
[[maybe_unused]] static bool done = [] {
int argc = 0;
pw_init(&argc, nullptr);
return true;
}();
}
void set_channel_positions(spa_audio_info_raw & info)
{
switch (info.channels)
{
case 1:
info.position[0] = SPA_AUDIO_CHANNEL_MONO;
break;
case 2:
info.position[0] = SPA_AUDIO_CHANNEL_FL;
info.position[1] = SPA_AUDIO_CHANNEL_FR;
break;
default:
info.flags = SPA_AUDIO_FLAG_UNPOSITIONED;
break;
}
}
struct detected_devices
{
bool pipewire = false;
bool speaker = false;
bool microphone = false;
};
struct device_probe
{
pipewire_ptr<pw_main_loop> loop;
int sync_seq = 0;
detected_devices devices;
static void global(
void * userdata,
uint32_t,
uint32_t,
const char * type,
uint32_t,
const spa_dict * props)
{
auto self = static_cast<device_probe *>(userdata);
if (not type or not props or std::string_view(type) != PW_TYPE_INTERFACE_Node)
return;
const char * media_class = spa_dict_lookup(props, PW_KEY_MEDIA_CLASS);
if (not media_class)
return;
if (std::string_view(media_class) == "Audio/Sink")
self->devices.speaker = true;
else if (std::string_view(media_class) == "Audio/Source")
self->devices.microphone = true;
}
static void done(void * userdata, uint32_t id, int seq)
{
auto self = static_cast<device_probe *>(userdata);
if (id == PW_ID_CORE and seq == self->sync_seq)
pw_main_loop_quit(self->loop.get());
}
static void error(void * userdata, uint32_t, int, int, const char *)
{
auto self = static_cast<device_probe *>(userdata);
pw_main_loop_quit(self->loop.get());
}
};
const pw_registry_events probe_registry_events{
.version = PW_VERSION_REGISTRY_EVENTS,
.global = &device_probe::global,
};
const pw_core_events probe_core_events{
.version = PW_VERSION_CORE_EVENTS,
.done = &device_probe::done,
.error = &device_probe::error,
};
detected_devices detect_devices()
{
init_pipewire();
device_probe probe;
probe.loop.reset(pw_main_loop_new(nullptr));
if (not probe.loop)
return {};
pw_context * context = pw_context_new(pw_main_loop_get_loop(probe.loop.get()), nullptr, 0);
if (not context)
return {};
pw_core * core = pw_context_connect(context, nullptr, 0);
if (not core)
{
pw_context_destroy(context);
return {};
}
probe.devices.pipewire = true;
pw_registry * registry = pw_core_get_registry(core, PW_VERSION_REGISTRY, 0);
if (not registry)
{
pw_core_disconnect(core);
pw_context_destroy(context);
return probe.devices;
}
spa_hook registry_listener{};
spa_hook core_listener{};
pw_registry_add_listener(registry, &registry_listener, &probe_registry_events, &probe);
pw_core_add_listener(core, &core_listener, &probe_core_events, &probe);
probe.sync_seq = pw_core_sync(core, PW_ID_CORE, 0);
if (probe.sync_seq >= 0)
pw_main_loop_run(probe.loop.get());
spa_hook_remove(&core_listener);
spa_hook_remove(&registry_listener);
pw_proxy_destroy(reinterpret_cast<pw_proxy *>(registry));
pw_core_disconnect(core);
pw_context_destroy(context);
return probe.devices;
}
std::string rate_string(uint32_t sample_rate)
{
return std::format("1/{}", sample_rate);
}
std::string latency_string(uint32_t sample_rate)
{
const uint32_t frames = std::max<uint32_t>(1, sample_rate * target_latency_ms / 1000);
return std::format("{}/{}", frames, sample_rate);
}
pw_properties * make_properties(
const char * category,
const char * role,
const char * node_name,
const char * description,
uint32_t sample_rate)
{
auto rate = rate_string(sample_rate);
auto latency = latency_string(sample_rate);
return pw_properties_new(
PW_KEY_MEDIA_TYPE,
"Audio",
PW_KEY_MEDIA_CATEGORY,
category,
PW_KEY_MEDIA_ROLE,
role,
PW_KEY_NODE_NAME,
node_name,
PW_KEY_NODE_DESCRIPTION,
description,
PW_KEY_NODE_RATE,
rate.c_str(),
PW_KEY_NODE_LATENCY,
latency.c_str(),
nullptr);
}
void throw_connect_error(const char * name, int result)
{
throw std::runtime_error(std::format("Failed to connect PipeWire {} stream: {}", name, spa_strerror(result)));
}
} // namespace
const pw_stream_events audio::speaker_events{
.version = PW_VERSION_STREAM_EVENTS,
.process = &audio::speaker_process,
};
const pw_stream_events audio::microphone_events{
.version = PW_VERSION_STREAM_EVENTS,
.process = &audio::microphone_process,
};
void audio::build_speaker(const to_headset::audio_stream_description::device & device)
{
speaker.reset(pw_stream_new_simple(
pw_thread_loop_get_loop(loop.get()),
"WiVRn",
make_properties(
"Playback",
"Game",
"wivrn-client-speaker",
"WiVRn headset audio",
device.sample_rate),
&speaker_events,
this));
if (not speaker)
throw std::runtime_error("Failed to create PipeWire speaker stream");
std::vector<uint8_t> buffer(1024);
spa_pod_builder builder = SPA_POD_BUILDER_INIT(buffer.data(), uint32_t(buffer.size()));
spa_audio_info_raw audio_info{
.format = SPA_AUDIO_FORMAT_S16,
.rate = device.sample_rate,
.channels = device.num_channels,
};
set_channel_positions(audio_info);
const spa_pod * params[] = {
spa_format_audio_raw_build(&builder, SPA_PARAM_EnumFormat, &audio_info),
};
const int result = pw_stream_connect(
speaker.get(),
PW_DIRECTION_OUTPUT,
PW_ID_ANY,
pw_stream_flags(PW_STREAM_FLAG_AUTOCONNECT | PW_STREAM_FLAG_MAP_BUFFERS | PW_STREAM_FLAG_RT_PROCESS),
params,
1);
if (result < 0)
throw_connect_error("speaker", result);
spdlog::info(
"PipeWire speaker stream created: {} channels at {} Hz ({} ms target latency)",
device.num_channels,
device.sample_rate,
target_latency_ms);
}
void audio::build_microphone(const to_headset::audio_stream_description::device & device)
{
microphone.reset(pw_stream_new_simple(
pw_thread_loop_get_loop(loop.get()),
"WiVRn",
make_properties(
"Capture",
"Communication",
"wivrn-client-microphone",
"WiVRn headset microphone",
device.sample_rate),
&microphone_events,
this));
if (not microphone)
throw std::runtime_error("Failed to create PipeWire microphone stream");
std::vector<uint8_t> buffer(1024);
spa_pod_builder builder = SPA_POD_BUILDER_INIT(buffer.data(), uint32_t(buffer.size()));
spa_audio_info_raw audio_info{
.format = SPA_AUDIO_FORMAT_S16,
.rate = device.sample_rate,
.channels = device.num_channels,
};
set_channel_positions(audio_info);
const spa_pod * params[] = {
spa_format_audio_raw_build(&builder, SPA_PARAM_EnumFormat, &audio_info),
};
const int result = pw_stream_connect(
microphone.get(),
PW_DIRECTION_INPUT,
PW_ID_ANY,
pw_stream_flags(PW_STREAM_FLAG_AUTOCONNECT | PW_STREAM_FLAG_INACTIVE | PW_STREAM_FLAG_MAP_BUFFERS),
params,
1);
if (result < 0)
throw_connect_error("microphone", result);
spdlog::info(
"PipeWire microphone stream created: {} channels at {} Hz ({} ms target latency)",
device.num_channels,
device.sample_rate,
target_latency_ms);
}
audio::audio(
const wivrn::to_headset::audio_stream_description & desc,
wivrn_session & session,
xr::instance & instance) :
desc(desc), session(session), instance(instance)
{
init_pipewire();
loop.reset(pw_thread_loop_new("WiVRn audio", nullptr));
if (not loop)
throw std::runtime_error("Failed to create PipeWire thread loop");
pw_thread_loop_lock(loop.get());
const int start_result = pw_thread_loop_start(loop.get());
if (start_result < 0)
{
pw_thread_loop_unlock(loop.get());
loop.reset();
throw std::runtime_error(std::format("Failed to start PipeWire thread loop: {}", spa_strerror(start_result)));
}
try
{
if (desc.speaker)
build_speaker(*desc.speaker);
if (desc.microphone)
build_microphone(*desc.microphone);
}
catch (...)
{
speaker.reset();
microphone.reset();
pw_thread_loop_unlock(loop.get());
pw_thread_loop_stop(loop.get());
loop.reset();
throw;
}
pw_thread_loop_unlock(loop.get());
if (microphone)
microphone_thread = utils::named_thread("wivrn-mic-send", &audio::microphone_sender, this);
}
audio::~audio()
{
exiting = true;
microphone_cv.notify_all();
shutdown_pipewire();
if (microphone_thread.joinable())
microphone_thread.join();
}
void audio::shutdown_pipewire()
{
if (not loop)
return;
pw_thread_loop_lock(loop.get());
speaker.reset();
microphone.reset();
pw_thread_loop_unlock(loop.get());
pw_thread_loop_stop(loop.get());
loop.reset();
}
void audio::operator()(wivrn::audio_data && data)
{
if (not desc.speaker)
return;
const auto size = data.payload.size_bytes();
speaker_buffer_size_bytes.fetch_add(size, std::memory_order_relaxed);
if (not speaker_samples.write(std::move(data)))
speaker_buffer_size_bytes.fetch_sub(size, std::memory_order_relaxed);
}
void audio::set_mic_state(bool running)
{
if (not microphone or not loop)
return;
const bool old = mic_running.exchange(running);
if (old == running)
return;
pw_thread_loop_lock(loop.get());
const int result = pw_stream_set_active(microphone.get(), running);
pw_thread_loop_unlock(loop.get());
if (result < 0)
{
mic_running = old;
spdlog::warn("Failed to {} PipeWire microphone: {}", running ? "start" : "stop", spa_strerror(result));
}
microphone_cv.notify_one();
}
void audio::speaker_process(void * userdata)
{
auto self = static_cast<audio *>(userdata);
if (not self->speaker)
return;
pw_buffer * buffer = pw_stream_dequeue_buffer(self->speaker.get());
if (not buffer)
return;
if (not buffer->buffer or buffer->buffer->n_datas == 0)
{
pw_stream_queue_buffer(self->speaker.get(), buffer);
return;
}
auto & data = buffer->buffer->datas[0];
if (not data.data or not data.chunk or not self->desc.speaker)
{
pw_stream_queue_buffer(self->speaker.get(), buffer);
return;
}
const size_t frame_size = self->desc.speaker->num_channels * sizeof(int16_t);
if (frame_size == 0)
{
pw_stream_queue_buffer(self->speaker.get(), buffer);
return;
}
size_t num_frames = data.maxsize / frame_size;
if (buffer->requested)
num_frames = std::min<size_t>(num_frames, buffer->requested);
const size_t requested_bytes = num_frames * frame_size;
auto * output = static_cast<uint8_t *>(data.data);
size_t written = 0;
while (written < requested_bytes)
{
if (self->speaker_current.payload.empty())
{
auto next = self->speaker_samples.read();
if (not next)
break;
self->speaker_current = std::move(*next);
}
const size_t count = std::min(self->speaker_current.payload.size_bytes(), requested_bytes - written);
std::memcpy(output + written, self->speaker_current.payload.data(), count);
self->speaker_current.payload = self->speaker_current.payload.subspan(count);
written += count;
self->speaker_buffer_size_bytes.fetch_sub(count, std::memory_order_relaxed);
}
if (written < requested_bytes)
std::memset(output + written, 0, requested_bytes - written);
data.chunk->offset = 0;
data.chunk->stride = frame_size;
data.chunk->size = requested_bytes;
pw_stream_queue_buffer(self->speaker.get(), buffer);
// more than 50 ms accumulated → drop queued packets until about 30 ms remain
const size_t high_watermark = frame_size * self->desc.speaker->sample_rate * 50 / 1000;
const size_t target = frame_size * self->desc.speaker->sample_rate * 30 / 1000;
if (self->speaker_buffer_size_bytes.load(std::memory_order_relaxed) > high_watermark)
{
while (self->speaker_buffer_size_bytes.load(std::memory_order_relaxed) > target and self->speaker_samples.size() > 1)
{
auto dropped = self->speaker_samples.read();
if (not dropped)
break;
self->speaker_buffer_size_bytes.fetch_sub(dropped->payload.size_bytes(), std::memory_order_relaxed);
}
}
}
void audio::microphone_process(void * userdata)
{
auto self = static_cast<audio *>(userdata);
if (not self->microphone)
return;
pw_buffer * buffer = pw_stream_dequeue_buffer(self->microphone.get());
if (not buffer)
return;
if (not buffer->buffer or buffer->buffer->n_datas == 0)
{
pw_stream_queue_buffer(self->microphone.get(), buffer);
return;
}
auto & data = buffer->buffer->datas[0];
if (data.data and data.chunk and data.chunk->size != 0 and self->desc.microphone)
{
const size_t frame_size = self->desc.microphone->num_channels * sizeof(int16_t);
const size_t offset = std::min<size_t>(data.chunk->offset, data.maxsize);
size_t size = std::min<size_t>(data.chunk->size, data.maxsize - offset);
if (frame_size != 0)
size -= size % frame_size;
if (size != 0)
{
wivrn::audio_data packet;
packet.timestamp = self->instance.now();
packet.data.c = std::make_shared_for_overwrite<uint8_t[]>(size);
packet.payload = std::span(packet.data.c.get(), size);
std::memcpy(packet.payload.data(), static_cast<uint8_t *>(data.data) + offset, size);
self->microphone_buffer_size_bytes.fetch_add(size, std::memory_order_relaxed);
if (self->microphone_samples.write(std::move(packet)))
self->microphone_cv.notify_one();
else
self->microphone_buffer_size_bytes.fetch_sub(size, std::memory_order_relaxed);
}
}
pw_stream_queue_buffer(self->microphone.get(), buffer);
}
void audio::microphone_sender()
{
const size_t frame_size = desc.microphone ? desc.microphone->num_channels * sizeof(int16_t) : 0;
const size_t high_watermark = desc.microphone ? frame_size * desc.microphone->sample_rate * 50 / 1000 : 0;
const size_t target = desc.microphone ? frame_size * desc.microphone->sample_rate * 30 / 1000 : 0;
while (not exiting)
{
if (not mic_running)
{
while (auto dropped = microphone_samples.read())
microphone_buffer_size_bytes.fetch_sub(dropped->payload.size_bytes(), std::memory_order_relaxed);
}
else if (high_watermark != 0 and microphone_buffer_size_bytes.load(std::memory_order_relaxed) > high_watermark)
{
while (microphone_buffer_size_bytes.load(std::memory_order_relaxed) > target and microphone_samples.size() > 1)
{
auto dropped = microphone_samples.read();
if (not dropped)
break;
microphone_buffer_size_bytes.fetch_sub(dropped->payload.size_bytes(), std::memory_order_relaxed);
}
}
while (mic_running)
{
auto packet = microphone_samples.read();
if (not packet)
break;
microphone_buffer_size_bytes.fetch_sub(packet->payload.size_bytes(), std::memory_order_relaxed);
try
{
session.send_control(std::move(*packet));
}
catch (const std::exception & e)
{
if (not exiting)
spdlog::debug("Failed to send microphone audio: {}", e.what());
exiting = true;
break;
}
}
std::unique_lock lock(microphone_mutex);
microphone_cv.wait_for(lock, std::chrono::milliseconds(20), [this]() {
return exiting or microphone_samples.size() != 0;
});
}
}
void audio::get_audio_description(wivrn::from_headset::headset_info_packet & info)
{
const auto devices = detect_devices();
if (not devices.pipewire)
{
spdlog::warn("PipeWire is unavailable, disabling client audio");
return;
}
if (devices.speaker)
{
info.speaker = {
.num_channels = 2,
.sample_rate = default_sample_rate,
};
}
if (devices.microphone)
{
info.microphone = {
.num_channels = 1,
.sample_rate = default_sample_rate,
};
}
}
} // namespace wivrn::linux_audio
+99
View File
@@ -0,0 +1,99 @@
/*
* WiVRn VR streaming
* Copyright (C) 2026 galister <galister-dev@pm.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include "utils/ring_buffer.h"
#include "wivrn_packets.h"
#include <atomic>
#include <condition_variable>
#include <cstddef>
#include <memory>
#include <mutex>
#include <thread>
struct pw_main_loop;
struct pw_stream;
struct pw_stream_events;
struct pw_thread_loop;
class wivrn_session;
namespace xr
{
class instance;
}
namespace wivrn::linux_audio
{
struct pipewire_deleter
{
void operator()(pw_main_loop * loop) const noexcept;
void operator()(pw_thread_loop * loop) const noexcept;
void operator()(pw_stream * stream) const noexcept;
};
template <typename T>
using pipewire_ptr = std::unique_ptr<T, pipewire_deleter>;
class audio
{
static void speaker_process(void * userdata);
static void microphone_process(void * userdata);
static const pw_stream_events speaker_events;
static const pw_stream_events microphone_events;
void build_speaker(const to_headset::audio_stream_description::device & device);
void build_microphone(const to_headset::audio_stream_description::device & device);
void microphone_sender();
void shutdown_pipewire();
to_headset::audio_stream_description desc;
wivrn_session & session;
xr::instance & instance;
pipewire_ptr<pw_thread_loop> loop;
pipewire_ptr<pw_stream> speaker;
pipewire_ptr<pw_stream> microphone;
utils::ring_buffer<wivrn::audio_data, 100> speaker_samples;
std::atomic<size_t> speaker_buffer_size_bytes = 0;
wivrn::audio_data speaker_current;
utils::ring_buffer<wivrn::audio_data, 100> microphone_samples;
std::atomic<size_t> microphone_buffer_size_bytes = 0;
std::mutex microphone_mutex;
std::condition_variable microphone_cv;
std::atomic<bool> exiting = false;
std::atomic<bool> mic_running = false;
std::thread microphone_thread;
public:
audio(const audio &) = delete;
audio & operator=(const audio &) = delete;
audio(const wivrn::to_headset::audio_stream_description &, wivrn_session &, xr::instance &);
~audio();
void operator()(wivrn::audio_data &&);
void set_mic_state(bool running);
static void get_audio_description(wivrn::from_headset::headset_info_packet & info);
};
} // namespace wivrn::linux_audio
+108
View File
@@ -0,0 +1,108 @@
/*
* WiVRn VR streaming
* Copyright (C) 2026 Sapphire <imsapphire0@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "battery.h"
#include "application.h"
#include "scene.h"
#include <chrono>
#include <magic_enum.hpp>
#include <spdlog/spdlog.h>
battery::battery(xr::instance & instance, xr::session & session) :
session(session)
{
if (instance.has_extension(XR_EXT_INTERACTION_PROFILE_BATTERY_STATE_DISPLAY_EXTENSION_NAME))
{
top_level_paths.emplace({
std::make_pair(instance.string_to_path("/user/hand/left"), device::left_controller),
std::make_pair(instance.string_to_path("/user/hand/right"), device::right_controller),
std::make_pair(instance.string_to_path("/user/gamepad"), device::gamepad),
});
}
}
void battery::poll_batteries()
{
using namespace std::chrono_literals;
auto now = std::chrono::steady_clock::now();
if (now - last_poll < 10s)
return;
last_poll = now;
spdlog::debug("Polling batteries");
std::lock_guard lock(m);
#ifndef __ANDROID__
{
battery_status status = get_hmd_battery();
if (status != statuses.at(device::head))
{
on_status_update(device::head, std::move(status));
}
}
#endif
if (top_level_paths)
{
for (auto [path, device]: *top_level_paths)
{
XrBatteryStateDisplayEXT battery_state{
.type = XR_TYPE_BATTERY_STATE_DISPLAY_EXT,
};
XrInteractionProfileState profile_state{
.type = XR_TYPE_INTERACTION_PROFILE_STATE,
.next = &battery_state,
};
try
{
CHECK_XR(xrGetCurrentInteractionProfile(session, path, &profile_state));
}
catch (std::exception & e)
{
spdlog::warn("Failed to get battery charge state for device {}: {}", magic_enum::enum_name(device), e.what());
continue;
}
std::optional<float> charge{};
if (battery_state.stateFlags & XR_BATTERY_STATE_DISPLAY_STATE_VALID_BIT_EXT)
charge = battery_state.batteryLevel;
battery_status status{
.charge = charge,
.charging = (battery_state.stateFlags & XR_BATTERY_STATE_DISPLAY_STATE_CHARGING_BIT_EXT) != 0,
};
if (status != statuses.at(device))
{
on_status_update(device, std::move(status));
}
}
}
}
void battery::on_status_update(battery::device device, battery::battery_status && new_status)
{
std::lock_guard lock(m);
if (std::shared_ptr<scene> s = application::instance().current_scene())
{
s->on_battery_update(device, new_status);
}
statuses.at(device) = std::move(new_status);
}
+87
View File
@@ -0,0 +1,87 @@
/*
* WiVRn VR streaming
* Copyright (C) 2024 Guillaume Meunier <guillaume.meunier@centraliens.net>
* Copyright (C) 2024 Patrick Nicolas <patricknicolas@laposte.net>
* Copyright (C) 2026 Sapphire <imsapphire0@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include "xr/instance.h"
#include "xr/session.h"
#ifdef __ANDROID__
#include "jni.h"
#endif
#include <chrono>
#include <inplace_vector.hpp>
#include <magic_enum_containers.hpp>
#include <mutex>
#include <optional>
class battery
{
public:
enum device : uint8_t
{
head = 0,
left_controller,
right_controller,
gamepad,
};
struct battery_status
{
std::optional<float> charge = std::nullopt;
bool charging = false;
bool operator!=(const battery_status & other) const
{
return charge != other.charge || charging != other.charging;
}
};
battery(xr::instance & instance, xr::session & session);
#ifdef __ANDROID__
battery(xr::instance & instance, xr::session & session, jobject activity);
#endif
private:
xr::session & session;
std::optional<beman::inplace_vector::inplace_vector<std::pair<XrPath, device>, 3>> top_level_paths;
std::recursive_mutex m;
magic_enum::containers::array<device, battery_status> statuses;
// we need to poll for controller batteries, there's no XR event sent when their state changes
// linux implementation also doesn't have an event-based API for battery
std::chrono::steady_clock::time_point last_poll{};
#ifndef __ANDROID__
battery_status get_hmd_battery();
#endif
public:
void poll_batteries();
// updates statuses and sends the new battery status to the focused scene
void on_status_update(device device, battery_status && new_status);
inline battery_status get_battery_status(device device)
{
std::lock_guard lock(m);
return statuses.at(device);
};
};
+42
View File
@@ -327,10 +327,12 @@ const std::vector<config_field> & configuration::config_fields()
scalar("theme_font_scale", &configuration::theme_font_scale),
scalar("theme_background_alpha", &configuration::theme_background_alpha),
scalar("passthrough_enabled", &configuration::passthrough_enabled),
scalar("passthrough_boundary_enabled", &configuration::passthrough_boundary_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("emulated_gamepad", &configuration::emulated_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),
@@ -347,6 +349,9 @@ const std::vector<config_field> & configuration::config_fields()
scalar("codec", &configuration::codec),
scalar("bit_depth", &configuration::bit_depth),
scalar("usb_network", &configuration::usb_network),
scalar("height_offset_standing", &configuration::height_offset_standing),
scalar("height_offset_seated", &configuration::height_offset_seated),
scalar("default_posture", &configuration::default_posture),
};
return fields;
}
@@ -388,6 +393,19 @@ void configuration::save()
json << ",\"openxr_post_processing\":{\"super_sampling\":" << openxr_post_processing.super_sampling;
json << ",\"sharpening\":" << openxr_post_processing.sharpening << "}";
{
bool first = true;
json << ",\"body_parts\": {";
for (const auto & [b, name]: magic_enum::enum_entries<wivrn::from_headset::body_part_mask>())
{
if (not first)
json << ",";
first = false;
json << '"' << name << "\":" << std::boolalpha << bool(body_part_mask & std::to_underlying(b));
}
json << "}";
}
// feature flags, keyed by enum name
for (auto & [key, value]: features)
json << "," << key << ":" << std::boolalpha << value;
@@ -413,3 +431,27 @@ float configuration::get_default_stream_scale() const
return 0.3;
return 0.5;
}
float configuration::get_height_offset() const
{
std::lock_guard lock(mutex);
return default_posture == posture::seated ? height_offset_seated : height_offset_standing;
}
void configuration::set_height_offset(float value)
{
std::lock_guard lock(mutex);
(default_posture == posture::seated ? height_offset_seated : height_offset_standing) = value;
}
posture configuration::get_posture() const
{
std::lock_guard lock(mutex);
return default_posture;
}
void configuration::set_posture(posture p)
{
std::lock_guard lock(mutex);
default_posture = p;
}
+21
View File
@@ -50,6 +50,12 @@ enum class feature
body_tracking,
};
enum class posture
{
standing,
seated,
};
class configuration
{
public:
@@ -72,12 +78,15 @@ public:
uint8_t bit_depth = 10;
bool passthrough_enabled = false;
// XR_META_boundary_visibility, the boundary is always shown outside passthrough
bool passthrough_boundary_enabled = false;
bool mic_unprocessed_audio = false;
// Input forwarding, per device. Off by default; only effective if the server permits it.
bool forward_keyboard = false;
bool forward_mouse = false;
bool forward_gamepad = false;
bool emulated_gamepad = false;
std::underlying_type_t<wivrn::from_headset::body_part_mask> body_part_mask = ~0;
@@ -126,10 +135,16 @@ public:
bool check_feature(feature f) const;
void set_feature(feature f, bool state);
static constexpr float default_height_offset_standing = 0;
static constexpr float default_height_offset_seated = 0.45;
private:
mutable std::mutex mutex;
std::map<feature, bool> features;
std::optional<float> stream_scale;
float height_offset_standing = default_height_offset_standing;
float height_offset_seated = default_height_offset_seated;
posture default_posture = posture::standing;
// table of scalar settings shared by save()/load(); non-scalar settings are explicit
static const std::vector<config_field> & config_fields();
@@ -144,6 +159,12 @@ public:
float get_stream_scale() const;
float get_default_stream_scale() const;
float get_height_offset() const;
void set_height_offset(float);
posture get_posture() const;
void set_posture(posture);
uint32_t max_bitrate(bool extended) const
{
return extended ? 800'000'000u : 200'000'000u;
+46 -13
View File
@@ -20,6 +20,8 @@
#ifdef __ANDROID__
#include "decoder/android/android_decoder.h"
#elif WIVRN_USE_V4L2
#include "decoder/v4l2/v4l2_decoder.h"
#else
#include "decoder/ffmpeg/ffmpeg_decoder.h"
#endif
@@ -49,14 +51,12 @@ std::shared_ptr<wivrn::decoder> wivrn::decoder::make(
stream_index,
scene,
acc);
#elif WIVRN_USE_V4L2
return std::make_shared<wivrn::v4l2::decoder>(
device, phys_dev, vk_queue_family_index, description, stream_index, scene, acc);
#else
return std::make_shared<wivrn::ffmpeg::decoder>(
device,
phys_dev,
description,
stream_index,
scene,
acc);
device, phys_dev, description, stream_index, scene, acc);
#endif
case raw:
return std::make_shared<wivrn::raw_decoder>(
@@ -71,20 +71,53 @@ std::shared_ptr<wivrn::decoder> wivrn::decoder::make(
__builtin_unreachable();
}
static std::vector<wivrn::video_codec> supported_codecs_()
static std::vector<wivrn::video_codec_capability> supported_codecs_()
{
std::vector<wivrn::video_codec> res;
std::vector<wivrn::video_codec> codecs;
#ifdef __ANDROID__
wivrn::android::decoder::supported_codecs(res);
wivrn::android::decoder::supported_codecs(codecs);
#elif WIVRN_USE_V4L2
wivrn::v4l2::decoder::supported_codecs(codecs);
#else
wivrn::ffmpeg::decoder::supported_codecs(res);
wivrn::ffmpeg::decoder::supported_codecs(codecs);
#endif
res.push_back(wivrn::video_codec::raw);
codecs.push_back(wivrn::video_codec::raw);
std::vector<wivrn::video_codec_capability> res;
res.reserve(codecs.size());
for (auto codec: codecs)
res.push_back({.codec = codec, .supports_10bit = wivrn::decoder::supports_10bit(codec)});
return res;
}
const std::vector<wivrn::video_codec> & wivrn::decoder::supported_codecs()
const std::vector<wivrn::video_codec_capability> & wivrn::decoder::supported_codecs()
{
static std::vector<wivrn::video_codec> res = supported_codecs_();
static std::vector<wivrn::video_codec_capability> res = supported_codecs_();
return res;
}
bool wivrn::decoder::supports_10bit(wivrn::video_codec codec)
{
#ifdef __ANDROID__
return codec == wivrn::video_codec::h265 or codec == wivrn::video_codec::av1;
#elif WIVRN_USE_V4L2
switch (codec)
{
case wivrn::video_codec::h265: {
static const bool supported = wivrn::v4l2::decoder::supports_10bit(codec);
return supported;
}
case wivrn::video_codec::av1: {
static const bool supported = wivrn::v4l2::decoder::supports_10bit(codec);
return supported;
}
case wivrn::video_codec::h264:
case wivrn::video_codec::raw:
return false;
}
__builtin_unreachable();
#else
// ffmpeg
return codec == wivrn::video_codec::h265 or codec == wivrn::video_codec::av1;
#endif
}
+9 -1
View File
@@ -20,6 +20,8 @@
#include "wivrn_packets.h"
#include "wivrn_config.h"
#include <cstdint>
#include <memory>
#include <span>
@@ -46,6 +48,11 @@ public:
vk::ImageLayout & current_layout;
vk::Semaphore semaphore = nullptr;
uint64_t * semaphore_val = nullptr;
#if WIVRN_USE_V4L2
// DMA-buf images from V4L2 require queue-family ownership
// transfers between Vulkan and external engine
uint32_t foreign_queue_family = vk::QueueFamilyIgnored;
#endif
};
public:
@@ -66,6 +73,7 @@ public:
virtual vk::Sampler sampler() = 0;
static const std::vector<wivrn::video_codec> & supported_codecs();
static const std::vector<wivrn::video_codec_capability> & supported_codecs();
static bool supports_10bit(wivrn::video_codec codec);
};
} // namespace wivrn
+1 -1
View File
@@ -113,7 +113,7 @@ void shard_accumulator::push_shard(video_stream_data_shard && shard)
{
assert(current.frame_index() + 1 == next.frame_index());
uint8_t frame_diff = shard.frame_idx - current.frame_index();
auto frame_diff = shard.frame_idx - current.frame_index();
if (shard.frame_idx < current.frame_index())
{
// frame is in the past, drop it
File diff suppressed because it is too large Load Diff
+183
View File
@@ -0,0 +1,183 @@
/*
* WiVRn VR streaming
* Copyright (C) 2026 galister <galister-dev@pm.me>
*
* 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.
*/
#pragma once
#include "decoder/decoder.h"
#include "wivrn_sockets.h"
#include <cstdint>
#include <deque>
#include <exception>
#include <memory>
#include <mutex>
#include <optional>
#include <span>
#include <stop_token>
#include <string>
#include <sys/mman.h>
#include <thread>
#include <vector>
#include <vulkan/vulkan_raii.hpp>
namespace scenes
{
class stream;
}
namespace wivrn
{
class shard_accumulator;
}
namespace wivrn::v4l2
{
class decoder : public wivrn::decoder
{
private:
struct v4l2_blit_handle;
struct mapped_plane
{
void * address = nullptr;
size_t length = 0;
};
struct output_buffer
{
std::vector<mapped_plane> planes;
~output_buffer()
{
for (auto & p: planes)
if (p.address && p.address != MAP_FAILED)
munmap(p.address, p.length);
}
};
struct capture_buffer
{
std::vector<size_t> plane_lengths;
vk::raii::DeviceMemory memory = nullptr;
vk::raii::Image image = nullptr;
vk::raii::ImageView image_view = nullptr;
vk::ImageLayout current_layout = vk::ImageLayout::eUndefined;
bool held_by_vulkan = false;
};
struct pending_frame
{
uint64_t timestamp = 0;
wivrn::from_headset::feedback feedback;
wivrn::to_headset::video_stream_data_shard::view_info_t view_info;
};
struct ready_output
{
uint32_t buffer_index;
size_t bytes_used;
pending_frame pending;
};
struct assembling_frame
{
uint32_t buffer_index;
size_t bytes_used;
uint64_t frame_index;
};
vk::raii::Device & device;
vk::raii::PhysicalDevice & physical_device;
vk::raii::SamplerYcbcrConversion ycbcr_conversion = nullptr;
vk::raii::Sampler ycbcr_sampler = nullptr;
vk::Format capture_vk_format = vk::Format::eUndefined;
wivrn::fd_base fd;
std::vector<output_buffer> output_buffers;
std::vector<capture_buffer> capture_buffers;
std::vector<unsigned int> free_output_buffers;
std::deque<pending_frame> pending_frames;
std::deque<ready_output> input_queue;
std::mutex input_mutex;
std::optional<assembling_frame> assembling;
std::optional<uint64_t> dropped_frame_index;
std::mutex output_mutex;
std::deque<unsigned int> recycle_capture_queue;
std::deque<unsigned int> recycle_capture_local;
std::mutex recycle_mutex;
wivrn::fd_base wake_fd;
std::jthread worker;
std::exception_ptr worker_exception;
std::mutex worker_exception_mutex;
uint64_t next_timestamp = 1;
unsigned int queued_output_count = 0;
uint32_t capture_width = 0;
uint32_t capture_height = 0;
uint32_t capture_bytesperline = 0;
uint32_t capture_sizeimage = 0;
uint32_t capture_pixelformat = 0;
uint32_t capture_num_planes = 0;
bool output_streaming = false;
bool capture_streaming = false;
std::weak_ptr<scenes::stream> weak_scene;
shard_accumulator * accumulator;
const vk::Extent2D extent;
const wivrn::video_codec codec_type;
const uint32_t vk_queue_family_index;
void setup_device(wivrn::fd_base device_fd);
void setup_output_queue();
void setup_capture_queue();
void teardown_capture_queue();
void setup_ycbcr_sampler();
void import_capture_buffer(unsigned int index, const std::vector<size_t> & plane_lengths);
void initialize_capture_ownership();
void queue_capture_buffer(unsigned int index);
void release_capture_buffer(unsigned int index);
void recycle_capture_buffers();
void handle_events();
void reclaim_output_buffers();
void drain_capture();
void queue_ready_frames();
void queue_output_buffer(const ready_output & ready);
void abandon_assembling_frame();
void worker_loop(std::stop_token stop_token);
void wake_worker();
void rethrow_worker_exception();
void submit_capture(unsigned int capture_index, uint64_t timestamp);
pending_frame take_pending(uint64_t timestamp);
public:
decoder(vk::raii::Device & device,
vk::raii::PhysicalDevice & physical_device,
uint32_t vk_queue_family_index,
const wivrn::to_headset::video_stream_description & description,
uint8_t stream_index,
std::weak_ptr<scenes::stream> scene,
shard_accumulator * accumulator);
~decoder() override;
void push_data(std::span<std::span<const uint8_t>> data, uint64_t frame_index, bool partial) override;
void frame_completed(
const wivrn::from_headset::feedback & feedback,
const wivrn::to_headset::video_stream_data_shard::view_info_t & view_info) override;
vk::Sampler sampler() override
{
return *ycbcr_sampler;
}
static bool available_for(wivrn::video_codec codec);
static bool supports_10bit(wivrn::video_codec codec);
static void supported_codecs(std::vector<wivrn::video_codec> & result);
};
} // namespace wivrn::v4l2
+474
View File
@@ -0,0 +1,474 @@
/*
* WiVRn VR streaming
* Copyright (C) 2026 galister <galister-dev@pm.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "foveation.h"
#include "application.h"
#include "xr/instance.h"
#include "xr/session.h"
#include "xr/system.h"
#include <algorithm>
#include <cassert>
#include <cmath>
#include <spdlog/spdlog.h>
#include <stdexcept>
namespace
{
float convergence_angle(float distance, float eye_x, float yaw)
{
const float target_x = distance * std::sin(yaw);
const float target_z = distance * std::cos(yaw);
return std::atan2(target_x - eye_x, target_z);
}
XrVector2f yaw_pitch(const XrQuaternionf & q)
{
const float sine_theta = std::clamp(-2.0f * (q.y * q.z - q.w * q.x), -1.0f, 1.0f);
const float pitch = std::asin(sine_theta);
if (std::abs(sine_theta) > 0.99999f)
{
const float scale = std::copysign(2.0f, sine_theta);
return {scale * std::atan2(-q.z, q.w), pitch};
}
return {
std::atan2(2.0f * (q.x * q.z + q.w * q.y),
q.w * q.w - q.x * q.x - q.y * q.y + q.z * q.z),
pitch};
}
float ndc_to_angle(float center, float a0, float a1)
{
const float u = std::clamp(center * 0.5f + 0.5f, 0.0f, 1.0f);
const float tangent = std::lerp(std::tan(a0), std::tan(a1), u);
return std::atan(tangent);
}
client_foveation::angles center_to_angles(const std::array<XrVector2f, 2> & center, std::span<const XrFovf> fovs)
{
assert(fovs.size() == 2);
client_foveation::angles result{};
for (size_t i = 0; i < result.size(); ++i)
{
result[i].x = ndc_to_angle(center[i].x, fovs[i].angleLeft, fovs[i].angleRight);
result[i].y = ndc_to_angle(center[i].y, fovs[i].angleUp, fovs[i].angleDown);
}
return result;
}
bool fov_equal(const XrFovf & a, const XrFovf & b, const float epsilon)
{
return std::abs(a.angleLeft - b.angleLeft) <= epsilon and
std::abs(a.angleRight - b.angleRight) <= epsilon and
std::abs(a.angleUp - b.angleUp) <= epsilon and
std::abs(a.angleDown - b.angleDown) <= epsilon;
}
client_foveation::angles target_angles(
float yaw,
float pitch,
float convergence_distance,
std::span<const XrView> views)
{
assert(views.size() == 2);
client_foveation::angles result{};
for (size_t i = 0; i < result.size(); ++i)
{
result[i].x = convergence_angle(convergence_distance, views[i].pose.position.x, yaw);
result[i].y = pitch;
}
return result;
}
std::optional<client_foveation::angles> eye_gaze_angles(
XrTime time,
XrViewStateFlags view_flags,
std::span<const XrView> views)
{
if (not(view_flags & XR_VIEW_STATE_POSITION_VALID_BIT))
return std::nullopt;
auto gaze_quat = application::instance().locate_gaze(time);
if (not gaze_quat)
return std::nullopt;
const XrVector2f gaze = yaw_pitch(*gaze_quat);
return target_angles(-gaze.x, gaze.y, client_foveation::default_convergence_distance, views);
}
} // namespace
namespace client_foveation
{
center::center(xr::instance & inst, xr::system & sys, xr::session & xr_session, vk::raii::Device & vk_device, vk::raii::CommandPool & vk_commandpool, thread_safe<vk::raii::Queue> & vk_queue, vk::Format format) :
instance(inst),
session(xr_session),
device(vk_device),
commandpool(vk_commandpool),
queue(vk_queue),
swapchain_format(format)
{
if (application::get_foveation_center_supported() and
application::get_foveation_vulkan_supported() and
inst.has_extension(XR_META_FOVEATION_EYE_TRACKED_EXTENSION_NAME) and
inst.has_extension(XR_FB_FOVEATION_EXTENSION_NAME) and
inst.has_extension(XR_FB_FOVEATION_CONFIGURATION_EXTENSION_NAME) and
inst.has_extension(XR_FB_FOVEATION_VULKAN_EXTENSION_NAME) and
inst.has_extension(XR_FB_SWAPCHAIN_UPDATE_STATE_EXTENSION_NAME) and
inst.has_extension(XR_META_VULKAN_SWAPCHAIN_CREATE_INFO_EXTENSION_NAME) and
sys.foveation_eye_tracked_properties().supportsFoveationEyeTracked)
{
xrCreateFoveationProfileFB = inst.get_proc<PFN_xrCreateFoveationProfileFB>("xrCreateFoveationProfileFB");
xrDestroyFoveationProfileFB = inst.get_proc<PFN_xrDestroyFoveationProfileFB>("xrDestroyFoveationProfileFB");
xrUpdateSwapchainFB = inst.get_proc<PFN_xrUpdateSwapchainFB>("xrUpdateSwapchainFB");
xrGetFoveationEyeTrackedStateMETA = inst.get_proc<PFN_xrGetFoveationEyeTrackedStateMETA>("xrGetFoveationEyeTrackedStateMETA");
if (xrCreateFoveationProfileFB and xrDestroyFoveationProfileFB and
xrUpdateSwapchainFB and xrGetFoveationEyeTrackedStateMETA)
{
XrFoveationEyeTrackedProfileCreateInfoMETA eye_tracked_info{
.type = XR_TYPE_FOVEATION_EYE_TRACKED_PROFILE_CREATE_INFO_META,
.flags = 0,
};
XrFoveationLevelProfileCreateInfoFB level_info{
.type = XR_TYPE_FOVEATION_LEVEL_PROFILE_CREATE_INFO_FB,
.next = &eye_tracked_info,
.level = XR_FOVEATION_LEVEL_LOW_FB,
.verticalOffset = 0,
.dynamic = XR_FOVEATION_DYNAMIC_DISABLED_FB,
};
XrFoveationProfileCreateInfoFB profile_info{
.type = XR_TYPE_FOVEATION_PROFILE_CREATE_INFO_FB,
.next = &level_info,
};
XrFoveationProfileFB raw_profile = XR_NULL_HANDLE;
XrResult profile_result = xrCreateFoveationProfileFB(session, &profile_info, &raw_profile);
if (XR_SUCCEEDED(profile_result))
foveation_profile.emplace(raw_profile, xrDestroyFoveationProfileFB);
}
}
if (foveation_profile.has_value())
spdlog::info("XR_META_foveation_eye_tracked will be used for this stream");
else if (application::get_eye_gaze_supported())
spdlog::info("Eye gaze tracking will be used for this stream");
else
spdlog::info("Static foveation will be used for this stream");
auto [flags, views] = session.locate_views(
XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO,
instance.now(),
application::space(xr::spaces::view));
(void)flags;
assert(views.size() == headset_fov.size());
for (size_t i = 0; i < headset_fov.size(); ++i)
headset_fov[i] = views[i].fov;
const auto & config = application::get_config();
set_manual_mode({
.enabled = config.override_foveation_enable,
.pitch = config.override_foveation_pitch,
.distance = config.override_foveation_distance,
});
}
// member order ensures swapchain is dropped before foveation profile
center::~center() = default;
bool center::supports_meta() const
{
return foveation_profile.has_value();
}
manual_override center::get_manual_mode() const
{
return *manual_mode_.lock();
}
void center::set_manual_mode(manual_override mode)
{
*manual_mode_.lock() = mode;
}
bool center::is_cropped(std::span<const XrFovf> submitted_fov, std::span<const bool> valid) const
{
assert(submitted_fov.size() == view_count and valid.size() == view_count);
for (size_t i = 0; i < view_count; ++i)
{
// generous epsilon of ~6° per-side to filter out false positives
if (valid[i] and not fov_equal(submitted_fov[i], headset_fov[i], 0.1f))
return true;
}
return false;
}
bool center::needs_swapchain_recreation(bool cropped) const
{
return supports_meta() and (not cropped_mode or *cropped_mode != cropped);
}
bool center::use_meta_swapchain(bool cropped) const
{
return supports_meta() and not cropped;
}
void center::set_cropped(bool cropped)
{
if (not cropped_mode or *cropped_mode != cropped)
spdlog::info("Stream FOV mode: {}", cropped ? "cropped" : "full");
cropped_mode = cropped;
}
void center::on_swapchain_recreated(bool cropped)
{
dummy_swapchain = {};
if (supports_meta() and cropped)
create_dummy_swapchain();
set_cropped(cropped);
}
bool center::update_meta_swapchain(XrSwapchain swapchain) const
{
if (not supports_meta() or not swapchain)
return false;
XrSwapchainStateFoveationFB swapchain_state{
.type = XR_TYPE_SWAPCHAIN_STATE_FOVEATION_FB,
.flags = 0,
.profile = *foveation_profile,
};
XrResult update_result = xrUpdateSwapchainFB(
swapchain,
reinterpret_cast<const XrSwapchainStateBaseHeaderFB *>(&swapchain_state));
return XR_SUCCEEDED(update_result);
}
std::optional<angles> center::meta_angles(XrSwapchain swapchain, std::span<const XrFovf> fov) const
{
if (not update_meta_swapchain(swapchain))
return {};
XrFoveationEyeTrackedStateMETA state{
.type = XR_TYPE_FOVEATION_EYE_TRACKED_STATE_META,
};
XrResult result = xrGetFoveationEyeTrackedStateMETA(session, &state);
if (XR_FAILED(result) or not(state.flags & XR_FOVEATION_EYE_TRACKED_STATE_VALID_BIT_META))
return {};
std::array<XrVector2f, view_count> ndc_center{state.foveationCenter[0], state.foveationCenter[1]};
return center_to_angles(ndc_center, fov);
}
void center::update(std::span<const XrFovf> submitted_fov, std::span<const bool> valid, XrSwapchain stream_swapchain, XrTime display_time)
{
assert(submitted_fov.size() == view_count and valid.size() == view_count);
layer_.reset();
packet_.reset();
XrSpace view_space = application::space(xr::spaces::view);
auto [view_flags, views] = session.locate_views(
XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO, display_time, view_space);
constexpr XrViewStateFlags layer_flags =
XR_VIEW_STATE_POSITION_VALID_BIT | XR_VIEW_STATE_ORIENTATION_VALID_BIT;
if (supports_meta() and cropped_mode.value_or(false) and dummy_swapchain and
views.size() == view_count and (view_flags & layer_flags) == layer_flags)
{
projection_layer layer{
.flags = XR_COMPOSITION_LAYER_BLEND_TEXTURE_SOURCE_ALPHA_BIT,
.space = view_space,
};
for (size_t i = 0; i < view_count; ++i)
{
layer.views[i] = {
.type = XR_TYPE_COMPOSITION_LAYER_PROJECTION_VIEW,
.pose = views[i].pose,
.fov = headset_fov[i],
.subImage = {
.swapchain = dummy_swapchain,
.imageRect = {
.offset = {0, 0},
.extent = {dummy_swapchain_size, dummy_swapchain_size},
},
.imageArrayIndex = uint32_t(i),
},
};
}
layer_ = layer;
}
if (views.size() != view_count or not(view_flags & XR_VIEW_STATE_POSITION_VALID_BIT))
return;
// dummy layer is always full FOV
std::array<XrFovf, view_count> effective_fov{};
for (size_t i = 0; i < view_count; ++i)
effective_fov[i] = valid[i] ? submitted_fov[i] : headset_fov[i];
const XrSwapchain meta_swapchain = cropped_mode.value_or(false) ? static_cast<XrSwapchain>(dummy_swapchain) : stream_swapchain;
const std::span<const XrFovf> meta_fov = cropped_mode.value_or(false) ? std::span<const XrFovf>(headset_fov) : std::span<const XrFovf>(effective_fov);
const auto manual = get_manual_mode();
std::optional<angles> angles;
if (manual.enabled)
{
if (supports_meta())
update_meta_swapchain(meta_swapchain);
angles = target_angles(0, manual.pitch, manual.distance, views);
}
else
{
if (supports_meta())
{
if (auto a = meta_angles(meta_swapchain, meta_fov))
angles = *a;
}
if (not angles and application::get_eye_gaze_supported())
{
if (auto a = eye_gaze_angles(display_time,
view_flags,
views))
angles = *a;
}
if (not angles)
angles = target_angles(0, default_foveation_pitch, default_convergence_distance, views);
}
// angles guaranteed to have a value at this point
packet_ = wivrn::from_headset::foveation{.angles = *angles};
}
std::optional<center::projection_layer> center::get_layer() const
{
return layer_;
}
std::optional<wivrn::from_headset::foveation> center::take_packet()
{
// A skipped render must not resend the previous frame's center.
auto result = packet_;
packet_.reset();
return result;
}
void center::create_dummy_swapchain()
{
device.waitIdle();
dummy_swapchain = xr::swapchain(
instance,
session,
device,
swapchain_format,
dummy_swapchain_size,
dummy_swapchain_size,
1,
view_count,
true,
true);
if (not update_meta_swapchain(dummy_swapchain))
throw std::runtime_error("Failed to apply eye-tracked foveation profile to dummy swapchain");
const int image_index = dummy_swapchain.acquire();
dummy_swapchain.wait();
auto clear_command_buffer = std::move(device.allocateCommandBuffers({
.commandPool = *commandpool,
.level = vk::CommandBufferLevel::ePrimary,
.commandBufferCount = 1,
})[0]);
auto clear_fence = device.createFence({});
clear_command_buffer.begin(vk::CommandBufferBeginInfo{
.flags = vk::CommandBufferUsageFlagBits::eOneTimeSubmit,
});
vk::ImageMemoryBarrier to_transfer{
.srcAccessMask = vk::AccessFlagBits::eNone,
.dstAccessMask = vk::AccessFlagBits::eTransferWrite,
.oldLayout = vk::ImageLayout::eUndefined,
.newLayout = vk::ImageLayout::eTransferDstOptimal,
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
.image = dummy_swapchain.image(image_index),
.subresourceRange = {
.aspectMask = vk::ImageAspectFlagBits::eColor,
.baseMipLevel = 0,
.levelCount = 1,
.baseArrayLayer = 0,
.layerCount = view_count,
},
};
clear_command_buffer.pipelineBarrier(
vk::PipelineStageFlagBits::eTopOfPipe,
vk::PipelineStageFlagBits::eTransfer,
{},
{},
{},
to_transfer);
clear_command_buffer.clearColorImage(
dummy_swapchain.image(image_index),
vk::ImageLayout::eTransferDstOptimal,
vk::ClearColorValue{std::array<float, 4>{0, 0, 0, 0}},
to_transfer.subresourceRange);
vk::ImageMemoryBarrier to_runtime{
.srcAccessMask = vk::AccessFlagBits::eTransferWrite,
.dstAccessMask = vk::AccessFlagBits::eMemoryRead,
.oldLayout = vk::ImageLayout::eTransferDstOptimal,
.newLayout = vk::ImageLayout::eColorAttachmentOptimal,
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
.image = dummy_swapchain.image(image_index),
.subresourceRange = to_transfer.subresourceRange,
};
clear_command_buffer.pipelineBarrier(
vk::PipelineStageFlagBits::eTransfer,
vk::PipelineStageFlagBits::eAllCommands,
{},
{},
{},
to_runtime);
clear_command_buffer.end();
vk::SubmitInfo submit_info;
submit_info.setCommandBuffers(*clear_command_buffer);
queue.lock()->submit(submit_info, *clear_fence);
if (device.waitForFences(*clear_fence, VK_TRUE, UINT64_MAX) == vk::Result::eTimeout)
throw std::runtime_error("Vulkan fence timeout while clearing foveation dummy swapchain");
dummy_swapchain.release();
spdlog::info(
"Created {}x{} eye-tracked foveation dummy swapchain",
dummy_swapchain_size,
dummy_swapchain_size);
}
} // namespace client_foveation
+112
View File
@@ -0,0 +1,112 @@
/*
* WiVRn VR streaming
* Copyright (C) 2026 galister <galister-dev@pm.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include "utils/handle.h"
#include "utils/thread_safe.h"
#include "wivrn_packets.h"
#include "xr/swapchain.h"
#include <array>
#include <optional>
#include <span>
#include <openxr/openxr.h>
namespace xr
{
class instance;
class session;
class system;
} // namespace xr
namespace client_foveation
{
using angles = std::array<XrVector2f, 2>;
inline constexpr float default_convergence_distance = 1.0f;
// Default foveation target is 1 m forward and 10 degrees below horizontal.
inline constexpr float default_foveation_pitch = -0.17453292519943295f; // -10 degrees
struct manual_override
{
bool enabled = false;
float pitch = default_foveation_pitch;
float distance = default_convergence_distance;
};
// Unified class for static, meta and eye-gaze based foveation.
class center
{
public:
static constexpr size_t view_count = 2;
static constexpr int32_t dummy_swapchain_size = 512;
struct projection_layer
{
XrCompositionLayerFlags flags;
XrSpace space;
std::array<XrCompositionLayerProjectionView, view_count> views;
};
center(xr::instance &, xr::system &, xr::session &, vk::raii::Device &, vk::raii::CommandPool &, thread_safe<vk::raii::Queue> &, vk::Format swapchain_format);
~center();
bool supports_meta() const;
manual_override get_manual_mode() const;
void set_manual_mode(manual_override mode);
bool is_cropped(std::span<const XrFovf> submitted_fov, std::span<const bool> valid) const;
bool needs_swapchain_recreation(bool cropped) const;
bool use_meta_swapchain(bool cropped) const;
void on_swapchain_recreated(bool cropped);
void set_cropped(bool cropped);
void update(std::span<const XrFovf> submitted_fov, std::span<const bool> valid, XrSwapchain stream_swapchain, XrTime display_time);
std::optional<projection_layer> get_layer() const;
std::optional<wivrn::from_headset::foveation> take_packet();
private:
mutable thread_safe<manual_override> manual_mode_{};
xr::instance & instance;
xr::session & session;
vk::raii::Device & device;
vk::raii::CommandPool & commandpool;
thread_safe<vk::raii::Queue> & queue;
vk::Format swapchain_format;
PFN_xrCreateFoveationProfileFB xrCreateFoveationProfileFB = nullptr;
PFN_xrDestroyFoveationProfileFB xrDestroyFoveationProfileFB = nullptr;
PFN_xrUpdateSwapchainFB xrUpdateSwapchainFB = nullptr;
PFN_xrGetFoveationEyeTrackedStateMETA xrGetFoveationEyeTrackedStateMETA = nullptr;
std::optional<utils::handle<XrFoveationProfileFB>> foveation_profile;
std::array<XrFovf, view_count> headset_fov{};
std::optional<bool> cropped_mode;
xr::swapchain dummy_swapchain;
std::optional<projection_layer> layer_;
std::optional<wivrn::from_headset::foveation> packet_;
bool update_meta_swapchain(XrSwapchain swapchain) const;
std::optional<angles> meta_angles(XrSwapchain swapchain, std::span<const XrFovf> fov) const;
void create_dummy_swapchain();
};
} // namespace client_foveation
+54 -101
View File
@@ -19,8 +19,8 @@
#include "hmd_traits.h"
#include "utils/env.h"
#include "utils/overloaded.h"
#include "utils/strings.h"
#include "xr/to_string.h"
#include <boost/pfr.hpp>
@@ -29,6 +29,7 @@
#include <cstdlib>
#include <cstring>
#include <format>
#include <fstream>
#include <glm/ext/quaternion_trigonometric.hpp>
#include <limits>
#include <optional>
@@ -37,109 +38,14 @@
#include <unordered_map>
#include <spdlog/spdlog.h>
#include <openxr/openxr.h>
#ifdef __ANDROID__
#include "utils/wrap_lambda.h"
#include <sys/system_properties.h>
static std::optional<std::string> get_property(const char * property)
{
auto info = __system_property_find(property);
if (not info)
return std::nullopt;
std::string result;
wrap_lambda cb = [&result](const char * name, const char * value, uint32_t serial) {
result = value;
};
__system_property_read_callback(info, cb.userdata_first(), cb);
return result;
}
#include "android/property.h"
#include "utils/env.h"
#include "utils/strings.h"
#endif
template <typename T>
std::optional<T> env(std::string_view name);
template <>
std::optional<std::string> env(std::string_view name)
{
#ifdef __ANDROID__
auto android_sysprop_name = std::format("debug.wivrn.{}", name);
return get_property(android_sysprop_name.c_str());
#else
std::string env_name = "WIVRN_";
env_name.reserve(env_name.size() + name.size());
for (const auto & c: name)
env_name += std::toupper(c);
const char * value = std::getenv(env_name.c_str());
if (value)
return value;
return std::nullopt;
#endif
}
template <>
std::optional<uint32_t> env(std::string_view name)
{
const auto value = env<std::string>(name);
if (not value)
return std::nullopt;
try
{
const unsigned long parsed = std::stoul(*value);
if (parsed > std::numeric_limits<uint32_t>::max())
return std::nullopt;
return static_cast<uint32_t>(parsed);
}
catch (std::runtime_error & e)
{
spdlog::warn("failed to parse {} (value: {}: {}", name, *value, e.what());
return std::nullopt;
}
}
template <>
std::optional<bool> env(std::string_view name)
{
const auto value = env<std::string>(name);
if (not value)
return std::nullopt;
if (strcmp(value->c_str(), "1") == 0 || strcasecmp(value->c_str(), "true") == 0 || strcasecmp(value->c_str(), "yes") == 0 || strcasecmp(value->c_str(), "on") == 0)
return true;
if (strcmp(value->c_str(), "0") == 0 || strcasecmp(value->c_str(), "false") == 0 || strcasecmp(value->c_str(), "no") == 0 || strcasecmp(value->c_str(), "off") == 0)
return false;
return std::nullopt;
}
template <>
std::optional<std::unordered_map<std::string, std::string>> env(std::string_view name)
{
const auto values = env<std::string>(name);
if (not values)
return std::nullopt;
std::unordered_map<std::string, std::string> map;
for (auto value: utils::split(*values, ","))
{
if (auto pos = value.find('='); pos != std::string::npos)
map.insert(std::make_pair(value.substr(0, pos), value.substr(pos + 1)));
}
return map;
}
template <>
std::optional<std::unordered_set<std::string>> env(std::string_view name)
{
const auto values = env<std::string>(name);
if (not values)
return std::nullopt;
return std::unordered_set<std::string>{std::from_range, utils::split(*values, ",")};
}
void hmd_traits::init()
{
#ifndef NDEBUG
@@ -221,11 +127,13 @@ void hmd_traits::init()
else if (manufacturer == "Play For Dream" and model == "PFDM MR")
{
blacklisted_extensions.insert(XR_META_FOVEATION_EYE_TRACKED_EXTENSION_NAME);
controller_profile = "yvr-touch-v2";
}
else if (manufacturer == "Pico")
{
blacklisted_extensions.insert(XR_META_FOVEATION_EYE_TRACKED_EXTENSION_NAME);
permissions[feature::eye_gaze] = "com.picovr.permission.EYE_TRACKING";
permissions[feature::face_tracking] = "com.picovr.permission.FACE_TRACKING";
view_locate = false;
@@ -256,6 +164,13 @@ void hmd_traits::init()
// Accepts OpenXR 1.1 but doesn't actually implement it
max_openxr_api_version = XR_API_VERSION_1_0;
// The runtime auto-switches /user/hand/* between the controller profile and
// ext/hand_interaction_ext based on its own hand-vs-controller heuristic, which
// flips repeatedly while a controller is actively held, dropping controller button
// input whenever hand interaction is briefly active. The runtime can only switch to
// a profile the app suggested bindings for, so withhold the extension entirely.
blacklisted_extensions.insert(XR_EXT_HAND_INTERACTION_EXTENSION_NAME);
// Doesn't handle additive blend, so needs specific ray model
// Fixed in XR elite firmware version 2.0
bool need_htc_ray = true;
@@ -300,6 +215,7 @@ void hmd_traits::init()
}
if (manufacturer == "samsung")
{
blacklisted_extensions.insert(XR_META_FOVEATION_EYE_TRACKED_EXTENSION_NAME);
if (model == "SM-I610") // Galaxy XR
{
panel_width_override = 3552;
@@ -309,6 +225,43 @@ void hmd_traits::init()
permissions[feature::face_tracking] = "android.permission.FACE_TRACKING";
}
}
#else // not android
for (const auto & entry: std::filesystem::directory_iterator("/sys/class/drm"))
{
std::ifstream modes(entry.path() / "modes");
if (not modes)
continue;
std::string mode;
while (std::getline(modes, mode))
{
// panel modes are reported as `2*2160x2160_120` etc.
if (not mode.starts_with("2*"))
// not a HMD
continue;
const auto x = mode.find('x', 2);
if (x == std::string::npos)
continue;
try
{
panel_width_override = std::stoul(mode.substr(2, x - 2));
spdlog::info("Detected native panel mode {}, panel width {}", mode, panel_width_override);
break;
}
catch (...)
{
spdlog::warn("Failed to parse native panel mode {}", mode);
}
}
if (panel_width_override > 0)
break;
}
// frame: always returns 0,0
blacklisted_extensions.insert(XR_META_FOVEATION_EYE_TRACKED_EXTENSION_NAME);
#endif
spdlog::info("HMD traits initialized");
@@ -388,7 +341,7 @@ static XrViewConfigurationView scale_view(XrViewConfigurationView view, uint32_t
double ratio = double(width) / view.recommendedImageRectWidth;
view.recommendedImageRectWidth = width;
view.recommendedImageRectHeight *= ratio;
spdlog::info("Using panel size: {}x{}", view.recommendedImageRectWidth, view.recommendedImageRectHeight);
spdlog::debug("Using panel size: {}x{}", view.recommendedImageRectWidth, view.recommendedImageRectHeight);
return view;
}
@@ -0,0 +1,9 @@
[Desktop Entry]
Name=WiVRn
Comment=Play your PC VR games on a standalone headset
GenericName=WiVRn client
Exec=@CMAKE_INSTALL_PREFIX@/bin/wivrn
Icon=io.github.wivrn.wivrn-client
Type=Application
Categories=Network;
Keywords=VR;Virtual reality;OpenVR;OpenXR;
+2 -4
View File
@@ -16,7 +16,7 @@ public class MainActivity extends android.app.NativeActivity
@Override
public native void onActivityResult(int requestCode, int resultCode, android.content.Intent data);
private android.content.BroadcastReceiver BatteryInfoReceiver = null;
public android.content.BroadcastReceiver BatteryInfoReceiver = null;
public android.net.ConnectivityManager.NetworkCallback netcb = null;
@Override
@@ -24,9 +24,7 @@ public class MainActivity extends android.app.NativeActivity
{
super.onCreate(savedInstanceState);
this.BatteryInfoReceiver = new BroadcastReceiver();
this.BatteryInfoReceiver = new org.meumeu.wivrn.BroadcastReceiver();
this.netcb = new org.meumeu.wivrn.NetworkInfoCallback();
this.registerReceiver(this.BatteryInfoReceiver, new android.content.IntentFilter(android.content.Intent.ACTION_BATTERY_CHANGED));
}
}
+76
View File
@@ -0,0 +1,76 @@
/*
* WiVRn VR streaming
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "battery.h"
#include <chrono>
#include <filesystem>
#include <fstream>
#include <mutex>
#include <string>
namespace
{
std::optional<std::string> read_line(const std::filesystem::path & path)
{
std::ifstream file(path);
std::string line;
if (file and std::getline(file, line))
return line;
return std::nullopt;
}
std::optional<float> read_percent(const std::filesystem::path & path)
{
std::ifstream file(path);
float percent;
if (file >> percent and percent >= 0 and percent <= 100)
return percent / 100;
return std::nullopt;
}
battery::battery_status read_battery_status(const std::filesystem::path & percent_path, const std::filesystem::path & status_path)
{
auto charge = read_percent(percent_path);
if (not charge)
return {};
auto status = read_line(status_path);
return {
.charge = charge,
.charging = status == "Charging" or status == "Full",
};
}
} // namespace
battery::battery_status battery::get_hmd_battery()
{
// SteamOS on the Steam Frame: the charger daemon's percentage is what the system UI shows
const std::filesystem::path deckard = "/run/deckardcharger";
if (auto battery = read_battery_status(deckard / "battery_percent", deckard / "battery_status"); battery.charge)
return battery;
// Generic Linux: the first battery in sysfs
std::error_code ec;
for (const auto & supply: std::filesystem::directory_iterator("/sys/class/power_supply", ec))
{
if (read_line(supply.path() / "type") != "Battery")
continue;
if (auto battery = read_battery_status(supply.path() / "capacity", supply.path() / "status"); battery.charge)
return battery;
}
return {};
}
+32 -23
View File
@@ -20,10 +20,13 @@
#include "application.h"
#include "scenes/lobby.h"
#include "spdlog/spdlog.h"
#include "utils/env.h"
#include "version.h"
#include <algorithm>
#include <arpa/inet.h>
#include <netdb.h>
#include <string>
#include <sys/socket.h>
#include <sys/types.h>
@@ -38,9 +41,31 @@
#ifdef __ANDROID__
void real_main(android_app * native_app)
#else
void real_main()
void real_main(int argc, char ** argv)
#endif
{
auto log_level = env<std::string>("loglevel");
if (log_level)
{
std::transform(log_level->begin(), log_level->end(), log_level->begin(), [](char c) { return tolower(c); });
if (log_level == "trace")
spdlog::set_level(spdlog::level::trace);
else if (log_level == "debug")
spdlog::set_level(spdlog::level::debug);
else if (log_level == "info")
spdlog::set_level(spdlog::level::info);
else if (log_level == "warning")
spdlog::set_level(spdlog::level::warn);
else if (log_level == "error")
spdlog::set_level(spdlog::level::err);
else if (log_level == "critical")
spdlog::set_level(spdlog::level::critical);
else if (log_level == "off")
spdlog::set_level(spdlog::level::off);
else
spdlog::warn("Invalid value for log level: {}", *log_level);
}
if (wivrn::is_tag)
spdlog::info("Starting WiVRn version {}", wivrn::display_version());
else
@@ -55,6 +80,11 @@ void real_main()
info.version = VK_MAKE_VERSION(1, 0, 0);
application app(info);
#ifndef __ANDROID__
if (argc == 2)
app.set_server_uri(argv[1]);
#endif
app.push_scene<scenes::lobby>();
app.run();
@@ -102,27 +132,6 @@ int main(int argc, char * argv[])
{
spdlog::set_default_logger(spdlog::stdout_color_mt("WiVRn"));
char * loglevel = getenv("WIVRN_LOGLEVEL");
if (loglevel)
{
if (!strcasecmp(loglevel, "trace"))
spdlog::set_level(spdlog::level::trace);
else if (!strcasecmp(loglevel, "debug"))
spdlog::set_level(spdlog::level::debug);
else if (!strcasecmp(loglevel, "info"))
spdlog::set_level(spdlog::level::info);
else if (!strcasecmp(loglevel, "warning"))
spdlog::set_level(spdlog::level::warn);
else if (!strcasecmp(loglevel, "error"))
spdlog::set_level(spdlog::level::err);
else if (!strcasecmp(loglevel, "critical"))
spdlog::set_level(spdlog::level::critical);
else if (!strcasecmp(loglevel, "off"))
spdlog::set_level(spdlog::level::off);
else
spdlog::warn("Invalid value for WIVRN_LOGLEVEL environment variable");
}
real_main();
real_main(argc, argv);
}
#endif
-1
View File
@@ -77,7 +77,6 @@ glm::quat cubic_spline(const glm::quat & a, const glm::quat & vb, const glm::qua
template <auto components::node::* Field>
void apply_track(entt::registry & scene, const components::animation_track_impl<Field> & track, float current_time)
{
entt::entity target = track.target;
auto interpolation = track.interpolation;
auto field = track.field;
auto & value = scene.get<components::node>(track.target).*field;
+3 -4
View File
@@ -560,7 +560,6 @@ void imgui_context::initialize_fonts()
std::vector<imgui_context::controller_state> imgui_context::read_controllers_state(XrTime display_time)
{
float scroll_scale = io.DeltaTime * constants::gui::scroll_ratio;
size_t new_focused_controller = focused_controller;
std::vector<controller_state> new_states;
new_states.resize(controllers.size());
@@ -581,10 +580,10 @@ std::vector<imgui_context::controller_state> imgui_context::read_controllers_sta
current_aim_interaction = 1;
if (ctrl.hand)
{
if (auto joints = ctrl.hand->locate(world, display_time))
if (auto hand = ctrl.hand->locate(world, display_time).joints)
{
XrHandJointLocationEXT & index_tip = (*joints)[XR_HAND_JOINT_INDEX_TIP_EXT].first;
XrHandJointLocationEXT & palm = (*joints)[XR_HAND_JOINT_PALM_EXT].first;
XrHandJointLocationEXT & index_tip = (*hand)[XR_HAND_JOINT_INDEX_TIP_EXT].first;
XrHandJointLocationEXT & palm = (*hand)[XR_HAND_JOINT_PALM_EXT].first;
if (index_tip.locationFlags & XR_SPACE_LOCATION_POSITION_VALID_BIT)
{
-5
View File
@@ -198,7 +198,6 @@ std::vector<glm::dvec4> read_vertex_attribute_aux2(const fastgltf::Asset & asset
std::vector<glm::dvec4> output;
output.resize(accessor.count);
size_t index = 0;
switch (fastgltf::getNumComponents(accessor.type))
{
case 1:
@@ -549,7 +548,6 @@ class loader_context
fastgltf::Asset & gltf;
vk::raii::PhysicalDevice physical_device;
vk::raii::Device & device;
thread_safe<vk::raii::Queue> & queue;
image_loader loader;
const std::map<std::tuple<fastgltf::Category, size_t, std::string>, std::string> & extras;
@@ -581,7 +579,6 @@ public:
gltf(gltf),
physical_device(physical_device),
device(device),
queue(queue),
loader(device, physical_device, queue, queue_family_index),
extras(extras)
{
@@ -1080,7 +1077,6 @@ public:
break;
}
size_t count = time.count;
switch (channel.path)
{
// TODO: templatize the switch
@@ -1264,7 +1260,6 @@ static void write_cache_entry(const std::filesystem::path & path, const cache_en
{
auto mtime = std::chrono::file_clock::to_sys(std::filesystem::last_write_time(entry.filename));
auto timestamp = std::chrono::duration_cast<std::chrono::seconds>(mtime.time_since_epoch()).count();
auto size = entry.size;
json << ",\"timestamp\":" << timestamp;
}
+1
View File
@@ -584,6 +584,7 @@ void scene::remove(entt::entity entity)
void scene::on_unfocused() {}
void scene::on_focused() {}
void scene::on_xr_event(const xr::event &) {}
void scene::on_battery_update(battery::device, const battery::battery_status &) {}
bool scene::on_input_key_down(uint8_t key_code)
{
+2
View File
@@ -19,6 +19,7 @@
#pragma once
#include "battery.h"
#include "render/image_loader.h"
#include "render/scene_loader.h"
#include "render/scene_renderer.h"
@@ -209,6 +210,7 @@ public:
void set_focused(bool status);
virtual void render(const XrFrameState &) = 0;
virtual void on_xr_event(const xr::event &);
virtual void on_battery_update(battery::device device, const battery::battery_status &);
virtual bool on_input_key_down(uint8_t key_code);
virtual bool on_input_key_up(uint8_t key_code);
+3 -7
View File
@@ -19,7 +19,8 @@
#include "gui_common.h"
#include "android/battery.h"
#include "application.h"
#include "battery.h"
#include "render/ui_theme.h"
#include "render/ui_widgets.h"
@@ -37,8 +38,7 @@ float toggle_width()
std::optional<battery_indicator> battery_status_indicator(XrTime now)
{
#ifdef __ANDROID__
const auto battery = get_battery_status();
const auto battery = application::get_battery_monitor().get_battery_status(battery::device::head);
if (not battery.charge)
return std::nullopt;
@@ -82,9 +82,5 @@ std::optional<battery_indicator> battery_status_indicator(XrTime now)
.label = fmt::format("{} {}%", icon, (int)std::round(*battery.charge * 100)),
.style = style,
};
#else
(void)now;
return std::nullopt;
#endif
}
} // namespace wivrn::gui
+78 -11
View File
@@ -222,15 +222,19 @@ void settings_video(const settings_context & ctx)
auto & default_config = ctx.default_config;
const std::string disconnect_tip = ctx.in_game ? _C("tooltip for disabled settings", "Disconnect to change this setting.") : std::string{};
std::vector<setting> list;
const auto rates = ctx.session.get_refresh_rates();
if (const auto rates = ctx.session.get_refresh_rates(); not rates.empty())
if (not rates.empty())
{
const auto system_managed = rates.size() < 2;
int default_rate_index = index(rates, default_config.preferred_refresh_rate).value_or(-1) + 1;
list.push_back({
.id = "##refresh",
.label = _("Refresh rate"),
.description = _("Use 'auto' to select the refresh rate based on measured application performance. May cause flicker when a change happens."),
.description = system_managed
? _("WiVRn can't directly change the refresh rate on this device. See your device's settings to change the refresh rate.")
: _("Use 'auto' to select the refresh rate based on measured application performance. May cause flicker when a change happens."),
.ui = rates.size() < 7 ? ui_kind::segmented : ui_kind::combo,
.get_int = [&config, rates] {
for (size_t i = 0; i < rates.size(); ++i)
@@ -258,12 +262,16 @@ void settings_video(const settings_context & ctx)
opts.push_back(fmt::format("{}", int(r)));
return opts; },
.default_int = default_rate_index,
.enabled = [system_managed] { return not system_managed; },
});
}
{
const auto width = ctx.recommended_width;
const auto height = ctx.recommended_height;
auto view = ctx.system.stereo_view();
view = application::get_hmd_traits().override_view(view);
const auto width = view.recommendedImageRectWidth;
const auto height = view.recommendedImageRectHeight;
list.push_back({
.id = "##resolution",
.label = _("Render resolution"),
@@ -280,7 +288,7 @@ void settings_video(const settings_context & ctx)
});
}
if (ctx.instance.has_extension(XR_FB_DISPLAY_REFRESH_RATE_EXTENSION_NAME))
if (rates.size() > 1 && ctx.instance.has_extension(XR_FB_DISPLAY_REFRESH_RATE_EXTENSION_NAME))
{
list.push_back({
.id = "##spacewarp",
@@ -345,9 +353,9 @@ void settings_streaming(const settings_context & ctx)
};
std::vector<wivrn::video_codec> codecs;
for (auto c: wivrn::decoder::supported_codecs())
if (c != wivrn::raw)
codecs.push_back(c);
for (auto capability: wivrn::decoder::supported_codecs())
if (capability.codec != wivrn::raw)
codecs.push_back(capability.codec);
list.push_back({
.id = "##codec",
@@ -370,7 +378,7 @@ void settings_streaming(const settings_context & ctx)
.disabled_tooltip = disconnect_tip,
});
if (config.codec == wivrn::h265 or config.codec == wivrn::av1)
if (config.codec && wivrn::decoder::supports_10bit(*config.codec))
{
list.push_back({
.id = "##ten_bit",
@@ -482,7 +490,7 @@ void settings_post_processing(const settings_context & ctx)
o.push_back(flag_name(f));
return o; },
.title = std::move(title),
.default_int = index(flags, config.openxr_post_processing.*member).value_or(0),
.default_int = index(flags, default_config.openxr_post_processing.*member).value_or(0),
});
};
@@ -513,6 +521,7 @@ void settings_audio(const settings_context & ctx)
.disabled_tooltip = disconnect_tip,
});
#ifdef __ANDROID__
list.push_back({
.id = "##unprocessed",
.label = _C("setting name", "Unprocessed audio"),
@@ -524,6 +533,7 @@ void settings_audio(const settings_context & ctx)
.enabled = [&ctx, &config] { return not ctx.in_game and config.check_feature(feature::microphone); },
.disabled_tooltip = disconnect_tip,
});
#endif
ui::page_header(_cS("page header title", "Audio"), _cS("page header subtitle", "Microphone streamed to the PC."));
render_settings(ctx, "##audio", list);
@@ -567,6 +577,19 @@ void settings_devices(const settings_context & ctx)
.default_bool = default_config.forward_gamepad,
});
if (ctx.instance.has_extension("XR_VALVE_frame_controller_interaction"))
{
list.push_back({
.id = "##emulated_gamepad",
.label = _C("setting name", "Emulated Gamepad"),
.description = _("Double-click both grips to start using your controllers as a gamepad."),
.ui = ui_kind::toggle,
.get_bool = [&config] { return config.emulated_gamepad; },
.set_bool = [&config](bool v) { config.emulated_gamepad = v; config.save(); },
.default_bool = default_config.emulated_gamepad,
});
}
ui::page_header(_cS("page header title", "Devices"), _cS("page header subtitle", "Forward input devices to the PC."));
render_settings(ctx, "##devices", list);
@@ -579,7 +602,37 @@ bool settings_tracking(const settings_context & ctx)
auto & config = ctx.config;
auto & default_config = ctx.default_config;
const std::string disconnect_tip = ctx.in_game ? _C("tooltip for disabled settings", "Disconnect to change this setting.") : std::string{};
std::vector<setting> list;
std::vector<setting> list, posture_items;
const posture current_posture = config.get_posture();
const bool seated = current_posture == posture::seated;
const float default_height_offset = seated ? configuration::default_height_offset_seated : configuration::default_height_offset_standing;
posture_items.push_back({
.id = "##posture",
.label = _C("setting name", "Posture"),
.description = _("Posture assumed when a stream connects."),
.ui = ui_kind::segmented,
.get_int = [seated] { return seated ? 1 : 0; },
.set_int = [&config](int v) { config.set_posture(v ? posture::seated : posture::standing); config.save(); },
.options = [] { return std::vector<std::string>{_C("posture", "Standing"), _C("posture", "Seated")}; },
.default_int = default_config.get_posture() == posture::seated ? 1 : 0,
});
posture_items.push_back({
.id = "##height_offset",
.label = _C("setting name", "Height adjustment"),
.description = seated
? _("Corrects the height reported to the PC when seated, useful for games without native seated support.")
: _("Corrects the height reported to the PC when standing, useful for a miscalibrated floor."),
.ui = ui_kind::slider,
.get_int = [&config] { return int(std::lround(config.get_height_offset() * 100)); },
.set_int = [&config](int v) { config.set_height_offset(v / 100.f); config.save(); },
.v_min = -30,
.v_max = 70,
.fmt = "%d cm",
.default_int = int(std::lround(default_height_offset * 100)),
});
auto feature_toggle = [&](const char * id, std::string label, std::string desc, feature f) {
list.push_back({
@@ -669,6 +722,7 @@ bool settings_tracking(const settings_context & ctx)
ui::page_header(_cS("page header title", "Tracking"), _cS("page header subtitle", "Body and input tracking sent to the PC."));
render_settings(ctx, "##tracking", list);
render_settings(ctx, "##posture", posture_items);
return changed;
}
@@ -757,6 +811,19 @@ void settings_system(const settings_context & ctx)
});
}
if (ctx.session.boundary_visibility_supported())
{
list.push_back({
.id = "##passthrough_boundary",
.label = _C("setting name", "Enable boundary in passthrough"),
.description = _("Shows the boundary while passthrough is on. Disable to walk freely outside of it. The boundary is always shown in VR."),
.ui = ui_kind::toggle,
.get_bool = [&config] { return config.passthrough_boundary_enabled; },
.set_bool = [&ctx, &config](bool v) { config.passthrough_boundary_enabled = v; config.save(); ctx.session.set_passthrough_boundary_enabled(v); },
.default_bool = default_config.passthrough_boundary_enabled,
});
}
bool disable_instream_gui = false;
bool disable_instream_gui_popup_open = ImGui::IsPopupOpen("confirm disable in stream gui");
list.push_back({
+2 -6
View File
@@ -19,8 +19,8 @@
#pragma once
#include <cstdint>
#include <functional>
#include <optional>
class configuration;
class imgui_context;
@@ -39,16 +39,12 @@ namespace wivrn::gui
struct settings_context
{
configuration & config;
configuration & default_config;
const configuration & default_config;
xr::instance & instance;
xr::session & session;
xr::system & system;
imgui_context & imgui_ctx;
// recommended per-eye render resolution, for the resolution description
uint32_t recommended_width = 0;
uint32_t recommended_height = 0;
// streaming: connection-time settings are disabled, in-stream controls appear
bool in_game = false;
+4 -4
View File
@@ -289,13 +289,13 @@ void hand_model::add_hand(scene & scene,
}
void hand_model::apply(entt::registry & scene,
const std::optional<std::array<xr::hand_tracker::joint, XR_HAND_JOINT_COUNT_EXT>> & left_hand,
const std::optional<std::array<xr::hand_tracker::joint, XR_HAND_JOINT_COUNT_EXT>> & right_hand)
const xr::hand_tracker::joint_array * left_hand,
const xr::hand_tracker::joint_array * right_hand)
{
for (auto && [entity, hj, node]: scene.view<components::hand_joint, components::node>().each())
{
auto f = [&](const std::optional<std::array<xr::hand_tracker::joint, XR_HAND_JOINT_COUNT_EXT>> & joints) {
if (joints.has_value())
auto f = [&](const xr::hand_tracker::joint_array * joints) {
if (joints)
{
node.visible = true;
+2 -2
View File
@@ -37,6 +37,6 @@ void add_hand(scene & scene,
uint32_t layer_mask);
void apply(entt::registry & scene,
const std::optional<std::array<xr::hand_tracker::joint, XR_HAND_JOINT_COUNT_EXT>> & left_hand,
const std::optional<std::array<xr::hand_tracker::joint, XR_HAND_JOINT_COUNT_EXT>> & right_hand);
const xr::hand_tracker::joint_array * left_hand,
const xr::hand_tracker::joint_array * right_hand);
}; // namespace hand_model
+91 -57
View File
@@ -18,6 +18,7 @@
*/
#include "lobby.h"
#include "application.h"
#include "configuration.h"
#include "constants.h"
@@ -143,6 +144,10 @@ void scenes::lobby::move_gui(glm::vec3 head_position, glm::vec3 new_gui_position
scenes::lobby::lobby() :
scene_impl<lobby>(supported_color_formats, supported_depth_formats)
{
const auto & view = system.stereo_view();
width = view.recommendedImageRectWidth;
height = view.recommendedImageRectHeight;
spdlog::info("Using formats {} and {}", vk::to_string(swapchain_format), vk::to_string(depth_format));
if (composition_layer_depth_test_supported)
@@ -437,57 +442,54 @@ void scenes::lobby::connect(const configuration::server_data & data)
std::optional<glm::vec3> scenes::lobby::check_recenter_gesture(
xr::spaces space,
const std::optional<std::array<xr::hand_tracker::joint, XR_HAND_JOINT_COUNT_EXT>> & joints,
const xr::hand_tracker::joint_array & joints,
const std::pair<glm::vec3, glm::quat> & head_pose)
{
if (recentering_context and std::get<0>(*recentering_context) != space)
return std::nullopt;
if (joints)
const auto & palm = joints[XR_HAND_JOINT_PALM_EXT].first;
const auto palm_y = glm::rotate(glm_cast(palm.pose.orientation), glm::vec3(0, 1, 0));
for (XrHandJointEXT index: {
XR_HAND_JOINT_INDEX_PROXIMAL_EXT,
XR_HAND_JOINT_INDEX_INTERMEDIATE_EXT,
XR_HAND_JOINT_INDEX_DISTAL_EXT,
XR_HAND_JOINT_MIDDLE_PROXIMAL_EXT,
XR_HAND_JOINT_MIDDLE_INTERMEDIATE_EXT,
XR_HAND_JOINT_MIDDLE_DISTAL_EXT,
XR_HAND_JOINT_RING_PROXIMAL_EXT,
XR_HAND_JOINT_RING_INTERMEDIATE_EXT,
XR_HAND_JOINT_RING_DISTAL_EXT,
XR_HAND_JOINT_LITTLE_PROXIMAL_EXT,
XR_HAND_JOINT_LITTLE_INTERMEDIATE_EXT,
XR_HAND_JOINT_LITTLE_DISTAL_EXT,
})
{
const auto & palm = (*joints)[XR_HAND_JOINT_PALM_EXT].first;
const auto palm_y = glm::rotate(glm_cast(palm.pose.orientation), glm::vec3(0, 1, 0));
const auto fingertip_y = glm::rotate(glm_cast(joints[index].first.pose.orientation), glm::vec3(0, 1, 0));
for (XrHandJointEXT index: {
XR_HAND_JOINT_INDEX_PROXIMAL_EXT,
XR_HAND_JOINT_INDEX_INTERMEDIATE_EXT,
XR_HAND_JOINT_INDEX_DISTAL_EXT,
XR_HAND_JOINT_MIDDLE_PROXIMAL_EXT,
XR_HAND_JOINT_MIDDLE_INTERMEDIATE_EXT,
XR_HAND_JOINT_MIDDLE_DISTAL_EXT,
XR_HAND_JOINT_RING_PROXIMAL_EXT,
XR_HAND_JOINT_RING_INTERMEDIATE_EXT,
XR_HAND_JOINT_RING_DISTAL_EXT,
XR_HAND_JOINT_LITTLE_PROXIMAL_EXT,
XR_HAND_JOINT_LITTLE_INTERMEDIATE_EXT,
XR_HAND_JOINT_LITTLE_DISTAL_EXT,
})
if (glm::dot(palm_y, fingertip_y) < constants::lobby::recenter_cos_fingertip_angle_max)
{
const auto fingertip_y = glm::rotate(glm_cast((*joints)[index].first.pose.orientation), glm::vec3(0, 1, 0));
if (glm::dot(palm_y, fingertip_y) < constants::lobby::recenter_cos_fingertip_angle_max)
{
recentering_context.reset();
return std::nullopt;
}
recentering_context.reset();
return std::nullopt;
}
}
const auto q = glm_cast(palm.pose.orientation);
const auto x = glm_cast(palm.pose.position);
const auto q = glm_cast(palm.pose.orientation);
const auto x = glm_cast(palm.pose.position);
// Make the up vector orthogonal to forward
const glm::vec3 forward = glm::rotate(head_pose.second, glm::vec3{0, 0, -1});
const glm::vec3 up = glm::normalize(glm::vec3{0, 1, 0} - forward * glm::dot(forward, {0, 1, 0}));
// Make the up vector orthogonal to forward
const glm::vec3 forward = glm::rotate(head_pose.second, glm::vec3{0, 0, -1});
const glm::vec3 up = glm::normalize(glm::vec3{0, 1, 0} - forward * glm::dot(forward, {0, 1, 0}));
// Y is pointing to the back of the hand
if (glm::dot(q * glm::vec3(0, -1, 0), up) > constants::lobby::recenter_cos_palm_angle_min)
{
recentering_context.emplace(space, glm::vec3{}, 0);
return x + glm::rotate(q, glm::vec3{0, -constants::lobby::recenter_distance_up, -constants::lobby::recenter_distance_front});
}
// Y is pointing to the back of the hand
if (glm::dot(q * glm::vec3(0, -1, 0), up) > constants::lobby::recenter_cos_palm_angle_min)
{
recentering_context.emplace(space, glm::vec3{}, 0);
return x + glm::rotate(q, glm::vec3{0, -constants::lobby::recenter_distance_up, -constants::lobby::recenter_distance_front});
}
recentering_context.reset();
@@ -948,11 +950,24 @@ void scenes::lobby::render(const XrFrameState & frame_state)
renderdoc_begin(*vk_instance);
#endif
XrSpace world_space = application::space(xr::spaces::world);
// Locating everything against this instead of the raw world space lets the configured
// player height offset be previewed here, the same shift a stream would apply.
if (float offset = application::get_config().get_height_offset(); not height_offset_space or offset != applied_height_offset)
{
applied_height_offset = offset;
height_offset_space = session.create_reference_space(XR_REFERENCE_SPACE_TYPE_STAGE, {{0, 0, 0, 1}, {0, -offset, 0}});
}
XrSpace world_space = height_offset_space;
auto [flags, views] = session.locate_views(viewconfig, frame_state.predictedDisplayTime, world_space);
// assert(views.size() == swapchains_lobby.size());
assert(views.size() == 2); // FIXME
if (not(flags & XR_VIEW_STATE_POSITION_VALID_BIT and flags & XR_VIEW_STATE_ORIENTATION_VALID_BIT))
{
spdlog::warn("Invalid view state, skip frame");
return;
}
bool hide_left_controller = false;
bool hide_right_controller = false;
@@ -969,27 +984,27 @@ void scenes::lobby::render(const XrFrameState & frame_state)
{
auto windows = imgui_ctx->windows();
auto left = left_hand->locate(world_space, frame_state.predictedDisplayTime);
auto left = left_hand->locate(world_space, frame_state.predictedDisplayTime).joints;
if (left)
{
stick_finger_to_gui(*left, windows);
hide_left_controller = true;
}
auto right = right_hand->locate(world_space, frame_state.predictedDisplayTime);
auto right = right_hand->locate(world_space, frame_state.predictedDisplayTime).joints;
if (right)
{
stick_finger_to_gui(*right, windows);
hide_right_controller = true;
}
hand_model::apply(world, left, right);
hand_model::apply(world, left ? &*left : nullptr, right ? &*right : nullptr);
if (not new_gui_position and head_position)
new_gui_position = check_recenter_gesture(xr::spaces::palm_left, left, *head_position);
if (not new_gui_position and head_position and left)
new_gui_position = check_recenter_gesture(xr::spaces::palm_left, *left, *head_position);
if (not new_gui_position and head_position)
new_gui_position = check_recenter_gesture(xr::spaces::palm_right, right, *head_position);
if (not new_gui_position and head_position and right)
new_gui_position = check_recenter_gesture(xr::spaces::palm_right, *right, *head_position);
}
if (head_position and new_gui_position)
@@ -1129,15 +1144,6 @@ void scenes::lobby::on_focused()
{
recenter_gui = true;
auto views = system.view_configuration_views(viewconfig);
assert(views.size() == 2); // FIXME
stream_view = application::get_hmd_traits().override_view(views[0]);
width = views[0].recommendedImageRectWidth;
height = views[0].recommendedImageRectHeight;
// assert(std::ranges::all_of(views, [width](const XrViewConfigurationView & view) { return view.recommendedImageRectWidth == width; }));
// assert(std::ranges::all_of(views, [height](const XrViewConfigurationView & view) { return view.recommendedImageRectHeight == height; }));
auto & config = application::get_config();
try
@@ -1296,7 +1302,20 @@ void scenes::lobby::on_focused()
vps,
image_cache);
about_picture = imgui_ctx->load_texture("assets://wivrn.ktx2");
auto t = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
auto tm = std::localtime(&t);
switch (tm->tm_mon)
{
case 5:
about_picture = imgui_ctx->load_texture("assets://wivrn-pride.ktx2");
break;
case 11:
about_picture = imgui_ctx->load_texture("assets://wivrn-christmas.ktx2");
break;
default:
about_picture = imgui_ctx->load_texture("assets://wivrn.ktx2");
break;
}
default_environment_screenshot = imgui_ctx->load_texture("assets://default-environment.ktx2");
@@ -1392,6 +1411,11 @@ void scenes::lobby::on_xr_event(const xr::event & event)
if (next_scene)
next_scene->on_xr_event(event);
}
void scenes::lobby::on_battery_update(battery::device device, const battery::battery_status & battery)
{
if (next_scene)
next_scene->on_battery_update(device, battery);
}
scene::meta & scenes::lobby::get_meta_scene()
{
@@ -1425,6 +1449,7 @@ scene::meta & scenes::lobby::get_meta_scene()
"/interaction_profiles/bytedance/pico4s_controller",
"/interaction_profiles/yvr/touch_controller_yvr",
"/interaction_profiles/htc/vive_focus3_controller",
"/interaction_profiles/valve/frame_controller_valve",
},
{
{"left_aim", "/user/hand/left/input/aim/pose"},
@@ -1442,6 +1467,15 @@ scene::meta & scenes::lobby::get_meta_scene()
{"recenter_right", "/user/hand/right/input/squeeze/value"},
},
},
suggested_binding{
{
"/interaction_profiles/valve/frame_controller_valve",
},
{
{"left_trigger", "/user/hand/left/input/bumper/click"},
{"right_trigger", "/user/hand/right/input/bumper/click"},
},
},
suggested_binding{
{
"/interaction_profiles/khr/simple_controller",
+7 -2
View File
@@ -81,6 +81,11 @@ class lobby : public scene_impl<lobby>
xr::face_tracker face_tracker;
// STAGE space translated by the configured player height offset, so it previews here the
// same shift a stream would apply; recreated only when the offset actually changes.
xr::space height_offset_space;
float applied_height_offset = 0;
std::string selected_item;
std::unique_ptr<utils::mapped_file> license;
@@ -90,7 +95,6 @@ class lobby : public scene_impl<lobby>
uint32_t width;
uint32_t height;
XrViewConfigurationView stream_view;
#if WIVRN_CLIENT_DEBUG_MENU
// GUI debug
@@ -252,7 +256,7 @@ class lobby : public scene_impl<lobby>
void connect(const configuration::server_data & data);
std::unique_ptr<wivrn_session> connect_to_session(wivrn_discover::service service, bool manual_connection);
std::optional<glm::vec3> check_recenter_gesture(xr::spaces space, const std::optional<std::array<xr::hand_tracker::joint, XR_HAND_JOINT_COUNT_EXT>> & joints, const std::pair<glm::vec3, glm::quat> & head_pose);
std::optional<glm::vec3> check_recenter_gesture(xr::spaces space, const xr::hand_tracker::joint_array & joints, const std::pair<glm::vec3, glm::quat> & head_pose);
std::optional<glm::vec3> check_recenter_action(XrTime predicted_display_time, glm::vec3 head_position);
std::optional<glm::vec3> check_recenter_gui(glm::vec3 head_position, glm::quat head_orientation);
@@ -266,6 +270,7 @@ public:
void on_unfocused() override;
void on_focused() override;
void on_xr_event(const xr::event &) override;
void on_battery_update(battery::device device, const battery::battery_status &) override;
static meta & get_meta_scene();
};
-4
View File
@@ -814,9 +814,6 @@ void scenes::lobby::gui_about()
ImGui::SetCursorPosX(win_width / 4);
ImGui::Image(about_picture, {win_width / 2, win_width / 2});
ImGui::PushFont(nullptr, constants::gui::font_size_large);
CenterTextH(std::string("Sneed'n'Chuck Edition"));
ImGui::PopFont();
}
void scenes::lobby::gui_first_run()
@@ -1118,7 +1115,6 @@ std::vector<std::pair<int, XrCompositionLayerQuad>> scenes::lobby::draw_gui(XrTi
ImGui::SetNextWindowSize({1400, 900});
ImGui::Begin("WiVRn", nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove);
auto & config = application::get_config();
const float TopBarH = wivrn::ui::metrics::top_bar_height;
// Top bar: logo left, feature toggles / battery / connection status right
-2
View File
@@ -642,8 +642,6 @@ libcurl::curl_handle * scenes::lobby::parse_environment_list()
void scenes::lobby::gui_customize(XrTime predicted_display_time)
{
auto & config = application::get_config();
namespace ui = wivrn::ui;
ui::page_header(_cS("page header title", "Environment"), _cS("page header subtitle", "Choose the environment your panels float in."));
+9 -11
View File
@@ -26,7 +26,7 @@
namespace
{
wivrn::gui::settings_context lobby_settings_context(xr::instance & instance, xr::session & session, xr::system & system, imgui_context & imgui_ctx, const XrViewConfigurationView & stream_view, std::optional<bool> server_hid_forwarding)
wivrn::gui::settings_context lobby_settings_context(xr::instance & instance, xr::session & session, xr::system & system, imgui_context & imgui_ctx, std::optional<bool> server_hid_forwarding)
{
return {
.config = application::get_config(),
@@ -35,8 +35,6 @@ wivrn::gui::settings_context lobby_settings_context(xr::instance & instance, xr:
.session = session,
.system = system,
.imgui_ctx = imgui_ctx,
.recommended_width = stream_view.recommendedImageRectWidth,
.recommended_height = stream_view.recommendedImageRectHeight,
.in_game = false,
.server_hid_forwarding = server_hid_forwarding,
};
@@ -45,40 +43,40 @@ wivrn::gui::settings_context lobby_settings_context(xr::instance & instance, xr:
void scenes::lobby::gui_video()
{
wivrn::gui::settings_video(lobby_settings_context(instance, session, system, *imgui_ctx, stream_view, server_hid_forwarding));
wivrn::gui::settings_video(lobby_settings_context(instance, session, system, *imgui_ctx, server_hid_forwarding));
}
void scenes::lobby::gui_streaming()
{
wivrn::gui::settings_streaming(lobby_settings_context(instance, session, system, *imgui_ctx, stream_view, server_hid_forwarding));
wivrn::gui::settings_streaming(lobby_settings_context(instance, session, system, *imgui_ctx, server_hid_forwarding));
}
void scenes::lobby::gui_post_processing()
{
wivrn::gui::settings_post_processing(lobby_settings_context(instance, session, system, *imgui_ctx, stream_view, server_hid_forwarding));
wivrn::gui::settings_post_processing(lobby_settings_context(instance, session, system, *imgui_ctx, server_hid_forwarding));
}
void scenes::lobby::gui_audio()
{
wivrn::gui::settings_audio(lobby_settings_context(instance, session, system, *imgui_ctx, stream_view, server_hid_forwarding));
wivrn::gui::settings_audio(lobby_settings_context(instance, session, system, *imgui_ctx, server_hid_forwarding));
}
void scenes::lobby::gui_devices()
{
wivrn::gui::settings_devices(lobby_settings_context(instance, session, system, *imgui_ctx, stream_view, server_hid_forwarding));
wivrn::gui::settings_devices(lobby_settings_context(instance, session, system, *imgui_ctx, server_hid_forwarding));
}
void scenes::lobby::gui_tracking()
{
wivrn::gui::settings_tracking(lobby_settings_context(instance, session, system, *imgui_ctx, stream_view, server_hid_forwarding));
wivrn::gui::settings_tracking(lobby_settings_context(instance, session, system, *imgui_ctx, server_hid_forwarding));
}
void scenes::lobby::gui_system()
{
wivrn::gui::settings_system(lobby_settings_context(instance, session, system, *imgui_ctx, stream_view, server_hid_forwarding));
wivrn::gui::settings_system(lobby_settings_context(instance, session, system, *imgui_ctx, server_hid_forwarding));
}
void scenes::lobby::gui_theme()
{
wivrn::gui::settings_theme(lobby_settings_context(instance, session, system, *imgui_ctx, stream_view, server_hid_forwarding));
wivrn::gui::settings_theme(lobby_settings_context(instance, session, system, *imgui_ctx, server_hid_forwarding));
}
-10
View File
@@ -316,17 +316,7 @@ virtual_keyboard::key_status virtual_keyboard::button_behavior(const ImRect & bb
if (mouse_down)
{
held = true;
float prev_held_duration = held_duration;
held_duration += g.IO.DeltaTime;
// if ((flags & ImGuiButtonFlags_Repeat) and held_duration > g.IO.KeyRepeatDelay)
// {
// int n1 = (prev_held_duration - g.IO.KeyRepeatDelay) / g.IO.KeyRepeatRate;
// int n2 = (held_duration - g.IO.KeyRepeatDelay) / g.IO.KeyRepeatRate;
//
// if (n2 != n1)
// pressed = true;
// }
}
else
{
+294 -118
View File
@@ -36,10 +36,12 @@
#include "decoder/shard_accumulator.h"
#include "inplace_vector.hpp"
#include "spdlog/spdlog.h"
#include "utils/i18n.h"
#include "utils/named_thread.h"
#include "utils/ranges.h"
#include "wivrn_packets.h"
#include <algorithm>
#include <cmath>
#include <mutex>
#include <ranges>
#include <thread>
@@ -55,13 +57,29 @@ using namespace beman::inplace_vector;
// clang-format off
static const std::unordered_map<std::string, device_id> device_ids = {
{"/user/hand/left/input/x/click", device_id::X_CLICK},
{"/user/hand/left/input/x/touch", device_id::X_TOUCH},
{"/user/hand/left/input/y/click", device_id::Y_CLICK},
{"/user/hand/left/input/y/touch", device_id::Y_TOUCH},
{"/user/hand/left/input/menu/click", device_id::MENU_CLICK},
{"/user/hand/left/input/dpad_up/click", device_id::DPAD_UP_CLICK},
{"/user/hand/left/input/dpad_up/touch", device_id::DPAD_UP_TOUCH},
{"/user/hand/left/input/dpad_left/click", device_id::DPAD_LEFT_CLICK},
{"/user/hand/left/input/dpad_left/touch", device_id::DPAD_LEFT_TOUCH},
{"/user/hand/left/input/dpad_down/click", device_id::LEFT_X_CLICK},
{"/user/hand/left/input/dpad_down/touch", device_id::LEFT_X_TOUCH},
{"/user/hand/left/input/dpad_right/click", device_id::LEFT_Y_CLICK},
{"/user/hand/left/input/dpad_right/touch", device_id::LEFT_Y_TOUCH},
{"/user/hand/left/input/x/click", device_id::LEFT_X_CLICK},
{"/user/hand/left/input/x/touch", device_id::LEFT_X_TOUCH},
{"/user/hand/left/input/y/click", device_id::LEFT_Y_CLICK},
{"/user/hand/left/input/y/touch", device_id::LEFT_Y_TOUCH},
{"/user/hand/left/input/view/click", device_id::LEFT_MENU_CLICK},
{"/user/hand/left/input/view/touch", device_id::LEFT_MENU_TOUCH},
{"/user/hand/left/input/menu/click", device_id::LEFT_MENU_CLICK},
{"/user/hand/left/input/menu/touch", device_id::LEFT_MENU_TOUCH},
{"/user/hand/left/input/system/click", device_id::LEFT_SYSTEM_CLICK},
{"/user/hand/left/input/system/touch", device_id::LEFT_SYSTEM_TOUCH},
{"/user/hand/left/input/bumper/click", device_id::LEFT_BUMPER_CLICK},
{"/user/hand/left/input/bumper/touch", device_id::LEFT_BUMPER_TOUCH},
{"/user/hand/left/input/squeeze/click", device_id::LEFT_SQUEEZE_CLICK},
{"/user/hand/left/input/squeeze/force", device_id::LEFT_SQUEEZE_FORCE},
{"/user/hand/left/input/squeeze/touch", device_id::LEFT_SQUEEZE_TOUCH},
{"/user/hand/left/input/squeeze/value", device_id::LEFT_SQUEEZE_VALUE},
{"/user/hand/left/input/trigger/value", device_id::LEFT_TRIGGER_VALUE},
{"/user/hand/left/input/trigger/click", device_id::LEFT_TRIGGER_CLICK},
@@ -94,9 +112,19 @@ static const std::unordered_map<std::string, device_id> device_ids = {
{"/user/hand/right/input/a/touch", device_id::A_TOUCH},
{"/user/hand/right/input/b/click", device_id::B_CLICK},
{"/user/hand/right/input/b/touch", device_id::B_TOUCH},
{"/user/hand/right/input/system/click", device_id::SYSTEM_CLICK},
{"/user/hand/right/input/x/click", device_id::RIGHT_X_CLICK},
{"/user/hand/right/input/x/touch", device_id::RIGHT_X_TOUCH},
{"/user/hand/right/input/y/click", device_id::RIGHT_Y_CLICK},
{"/user/hand/right/input/y/touch", device_id::RIGHT_Y_TOUCH},
{"/user/hand/right/input/menu/click", device_id::RIGHT_MENU_CLICK},
{"/user/hand/right/input/menu/touch", device_id::RIGHT_MENU_TOUCH},
{"/user/hand/right/input/system/click", device_id::RIGHT_SYSTEM_CLICK},
{"/user/hand/right/input/system/touch", device_id::RIGHT_SYSTEM_TOUCH},
{"/user/hand/right/input/bumper/click", device_id::RIGHT_BUMPER_CLICK},
{"/user/hand/right/input/bumper/touch", device_id::RIGHT_BUMPER_TOUCH},
{"/user/hand/right/input/squeeze/click", device_id::RIGHT_SQUEEZE_CLICK},
{"/user/hand/right/input/squeeze/force", device_id::RIGHT_SQUEEZE_FORCE},
{"/user/hand/right/input/squeeze/touch", device_id::RIGHT_SQUEEZE_TOUCH},
{"/user/hand/right/input/squeeze/value", device_id::RIGHT_SQUEEZE_VALUE},
{"/user/hand/right/input/trigger/value", device_id::RIGHT_TRIGGER_VALUE},
{"/user/hand/right/input/trigger/click", device_id::RIGHT_TRIGGER_CLICK},
@@ -175,11 +203,12 @@ static const std::array supported_depth_formats{
scenes::stream::stream(std::string server_name, scene & parent_scene) :
scene_impl<stream>(supported_color_formats, supported_depth_formats, parent_scene),
apps{*this, std::move(server_name)}
apps{*this, std::move(server_name)},
foveation_center{instance, system, session, device, commandpool, queue, swapchain_format}
{
auto views = system.view_configuration_views(viewconfig);
width = views[0].recommendedImageRectWidth;
height = views[0].recommendedImageRectHeight;
const auto & view = system.stereo_view();
width = view.recommendedImageRectWidth;
height = view.recommendedImageRectHeight;
}
static from_headset::visibility_mask_changed::masks get_visibility_mask(xr::instance & inst, xr::session & session, int view)
@@ -222,22 +251,10 @@ std::shared_ptr<scenes::stream> scenes::stream::create(std::unique_ptr<wivrn_ses
.variant = application::get_messages_info().variant,
};
{
auto [flags, views] = self->session.locate_views(
XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO,
self->instance.now(),
application::space(xr::spaces::view));
assert(views.size() == info.fov.size());
for (auto [i, j]: std::views::zip(views, info.fov))
j = i.fov;
}
const auto & config = application::get_config();
{
auto view = self->system.view_configuration_views(self->viewconfig)[0];
auto view = self->system.stereo_view();
view = application::get_hmd_traits().override_view(view);
info.render_eye_width = view.recommendedImageRectWidth * config.resolution_scale;
@@ -269,6 +286,7 @@ std::shared_ptr<scenes::stream> scenes::stream::create(std::unique_ptr<wivrn_ses
info.settings.mirror_gamepad = config.forward_gamepad;
info.settings.enabled_body_parts = config.body_part_mask;
info.battery_status = self->instance.has_extension(XR_EXT_INTERACTION_PROFILE_BATTERY_STATE_DISPLAY_EXTENSION_NAME);
info.hand_tracking = config.check_feature(feature::hand_tracking);
info.eye_gaze = config.check_feature(feature::eye_gaze);
@@ -330,7 +348,8 @@ std::shared_ptr<scenes::stream> scenes::stream::create(std::unique_ptr<wivrn_ses
if (config.codec)
{
info.supported_codecs = {*config.codec};
const bool supports_10bit = decoder::supports_10bit(*config.codec);
info.supported_codecs = {{.codec = *config.codec, .supports_10bit = supports_10bit}};
switch (*config.codec)
{
case h264:
@@ -338,11 +357,13 @@ std::shared_ptr<scenes::stream> scenes::stream::create(std::unique_ptr<wivrn_ses
break;
case h265:
case av1:
info.bit_depth = config.bit_depth;
info.bit_depth = supports_10bit ? config.bit_depth : 8;
}
}
else
{
info.supported_codecs = decoder::supported_codecs();
}
return info;
}());
@@ -371,20 +392,6 @@ std::shared_ptr<scenes::stream> scenes::stream::create(std::unique_ptr<wivrn_ses
}
}
{
const auto & config = application::get_config();
self->override_foveation_enable = config.override_foveation_enable;
self->override_foveation_pitch = config.override_foveation_pitch;
self->override_foveation_distance = config.override_foveation_distance;
if (self->override_foveation_enable)
self->network_session->send_control(from_headset::override_foveation_center{
.enabled = self->override_foveation_enable,
.pitch = self->override_foveation_pitch,
.distance = self->override_foveation_distance,
});
}
self->network_thread = utils::named_thread("network_thread", &stream::process_packets, self.get());
self->command_buffer = std::move(self->device.allocateCommandBuffers({
@@ -558,8 +565,10 @@ void scenes::stream::on_focused()
}
}
plots_toggle_1 = get_action("plots_toggle_1").first;
plots_toggle_2 = get_action("plots_toggle_2").first;
menu_chord.a = get_action("menu_toggle_1").first;
menu_chord.b = get_action("menu_toggle_2").first;
gamepad_chord.a = get_action("gamepad_mode_1").first;
gamepad_chord.b = get_action("gamepad_mode_2").first;
recenter_left = get_action("recenter_left").first;
recenter_right = get_action("recenter_right").first;
gui_distance_left = get_action("gui_distance_left").first;
@@ -876,9 +885,34 @@ void scenes::stream::render(const XrFrameState & frame_state)
}
}
session.begin_frame();
// Search for frame with desired display time on all decoders
// If no such frame exists, use the latest frame for each decoder
current_blit_handles = common_frame(frame_state.predictedDisplayTime);
std::array<XrPosef, view_count> pose;
std::array<XrFovf, view_count> fov{};
std::array<bool, view_count> valid_fov{};
std::array<wivrn::to_headset::foveation_parameter, view_count> foveation;
std::array<XrExtent2Di, view_count> extents;
int32_t max_width = 0;
int32_t max_height = 0;
for (size_t i = 0; i < view_count; ++i)
{
auto & blit_handle = current_blit_handles[i];
if (!blit_handle)
continue;
std::array<int, view_count> image_indices;
fov[i] = blit_handle->view_info.fov[i];
valid_fov[i] = true;
foveation[i] = blit_handle->view_info.foveation[i];
extents[i] = stream_defoveator::defoveated_size(foveation[i]);
max_width = std::max(max_width, extents[i].width);
max_height = std::max(max_height, extents[i].height);
}
if (max_width > 0 and max_height > 0)
ensure_swapchain(foveation_center.is_cropped(fov, valid_fov), max_width, max_height);
session.begin_frame();
#if WIVRN_FEATURE_RENDERDOC
renderdoc_begin(*vk_instance);
@@ -893,13 +927,8 @@ void scenes::stream::render(const XrFrameState & frame_state)
command_buffer.resetQueryPool(*query_pool, 0, size_gpu_timestamps);
command_buffer.writeTimestamp(vk::PipelineStageFlagBits::eTopOfPipe, *query_pool, 0);
// Search for frame with desired display time on all decoders
// If no such frame exists, use the latest frame for each decoder
current_blit_handles = common_frame(frame_state.predictedDisplayTime);
std::array<XrPosef, view_count> pose;
std::array<XrFovf, view_count> fov;
std::array<wivrn::to_headset::foveation_parameter, view_count> foveation;
bool use_alpha = false;
auto now = instance.now();
std::array<stream_defoveator::input, view_count> images;
for (size_t i = 0; i < view_count + use_alpha; ++i)
@@ -912,7 +941,7 @@ void scenes::stream::render(const XrFrameState & frame_state)
continue;
}
blit_handle->feedback.blitted = instance.now();
blit_handle->feedback.blitted = now;
if (blit_handle->feedback.blitted - blit_handle->feedback.received_from_decoder > 1'000'000'000)
set_state(state::stalled);
++blit_handle->feedback.times_displayed;
@@ -920,7 +949,37 @@ void scenes::stream::render(const XrFrameState & frame_state)
use_alpha = blit_handle->view_info.alpha;
if (blit_handle->current_layout == vk::ImageLayout::eUndefined)
#if WIVRN_USE_V4L2
if (blit_handle->foreign_queue_family != vk::QueueFamilyIgnored)
{
// decoder completed its write before handing us this image
// acquire ownership from the external media engine before sampling it
vk::ImageMemoryBarrier barrier{
.srcAccessMask = vk::AccessFlagBits::eNone,
.dstAccessMask = vk::AccessFlagBits::eShaderRead,
.oldLayout = blit_handle->current_layout,
.newLayout = vk::ImageLayout::eGeneral,
.srcQueueFamilyIndex = blit_handle->foreign_queue_family,
.dstQueueFamilyIndex = queue_family_index,
.image = blit_handle->image,
.subresourceRange = {
.aspectMask = vk::ImageAspectFlagBits::eColor,
.levelCount = 1,
.layerCount = 1,
},
};
command_buffer.pipelineBarrier(vk::PipelineStageFlagBits::eTopOfPipe,
vk::PipelineStageFlagBits::eFragmentShader,
{},
{},
{},
barrier);
blit_handle->current_layout = vk::ImageLayout::eGeneral;
}
else
#endif
if (blit_handle->current_layout == vk::ImageLayout::eUndefined)
{
vk::ImageMemoryBarrier barrier{
.srcAccessMask = vk::AccessFlagBits::eNone,
@@ -981,42 +1040,18 @@ void scenes::stream::render(const XrFrameState & frame_state)
std::ranges::any_of(current_blit_handles, [](const auto & h) { return h and h->feedback.times_displayed < 2; }) or
is_gui_interactable())
{
XrExtent2Di extents[view_count];
{
int32_t max_width = 0;
int32_t max_height = 0;
for (size_t i = 0; i < view_count; ++i)
{
extents[i] = stream_defoveator::defoveated_size(foveation[i]);
max_width = std::max(max_width, extents[i].width);
max_height = std::max(max_height, extents[i].height);
}
if (not swapchain)
setup_reprojection_swapchain(max_width, max_height);
else if (swapchain.width() < max_width or swapchain.height() < max_height)
{
// If the defoveated image is larger than the swapchain, try to reallocate one
try
{
spdlog::info("Recreating swapchain, from {}x{} to {}x{}",
swapchain.width(),
swapchain.height(),
max_width,
max_height);
setup_reprojection_swapchain(max_width, max_height);
}
catch (std::exception & e)
{
spdlog::warn("failed to increase swapchain size");
for (size_t i = 0; i < view_count; ++i)
{
extents[i].width = std::min(extents[i].width, swapchain.width());
extents[i].height = std::min(extents[i].height, swapchain.height());
}
}
}
}
assert(swapchain);
// Swapchains only recreated when switching between cropped/full
// Otherwise we clamp and resize the existing one
for (size_t i = 0; i < view_count; ++i)
{
extents[i].width = std::min(extents[i].width, swapchain.width());
extents[i].height = std::min(extents[i].height, swapchain.height());
}
foveation_center.update(fov, valid_fov, swapchain, frame_state.predictedDisplayTime);
// defoveate the image, apply scale/bias
int image_index = swapchain.acquire();
swapchain.wait();
@@ -1050,6 +1085,41 @@ void scenes::stream::render(const XrFrameState & frame_state)
{bias, bias, bias, 0.},
image_index);
#if WIVRN_USE_V4L2
// the blit handles keep CAPTURE buffers alive until this cmd buffer's fence has completed
inplace_vector<vk::ImageMemoryBarrier, decoder_count> foreign_release_barriers;
for (const auto & handle: current_blit_handles)
{
if (handle && handle->foreign_queue_family != vk::QueueFamilyIgnored)
{
foreign_release_barriers.push_back({
.srcAccessMask = vk::AccessFlagBits::eShaderRead,
.dstAccessMask = vk::AccessFlagBits::eNone,
.oldLayout = handle->current_layout,
.newLayout = vk::ImageLayout::eGeneral,
.srcQueueFamilyIndex = queue_family_index,
.dstQueueFamilyIndex = handle->foreign_queue_family,
.image = handle->image,
.subresourceRange = {
.aspectMask = vk::ImageAspectFlagBits::eColor,
.levelCount = 1,
.layerCount = 1,
},
});
handle->current_layout = vk::ImageLayout::eGeneral;
}
}
if (!foreign_release_barriers.empty())
{
command_buffer.pipelineBarrier(vk::PipelineStageFlagBits::eFragmentShader,
vk::PipelineStageFlagBits::eBottomOfPipe,
{},
{},
{},
foreign_release_barriers);
}
#endif
command_buffer.writeTimestamp(vk::PipelineStageFlagBits::eBottomOfPipe, *query_pool, 1);
command_buffer.end();
@@ -1091,6 +1161,10 @@ void scenes::stream::render(const XrFrameState & frame_state)
render_start(use_alpha, frame_state.predictedDisplayTime);
// full-FOV dummy layer for Meta foveation, used when cropping FOV
if (auto layer = foveation_center.get_layer())
add_projection_layer(layer->flags, layer->space, layer->views);
// Add the layer with the streamed content
std::array<XrCompositionLayerProjectionView, view_count> layer_view;
for (uint32_t view = 0; view < view_count; view++)
@@ -1141,7 +1215,8 @@ void scenes::stream::render(const XrFrameState & frame_state)
{
// Keep a copy of the feedback packets as they can be modified if they're encrypted
inplace_vector<from_headset::feedback, decoder_count> feedbacks;
inplace_vector<serialization_packet, decoder_count> packets;
// +1 for optional foveation packet
inplace_vector<serialization_packet, decoder_count + 1> packets;
feedbacks.reserve(current_blit_handles.size());
packets.reserve(current_blit_handles.size());
@@ -1154,6 +1229,11 @@ void scenes::stream::render(const XrFrameState & frame_state)
wivrn_session::control_socket_t::serialize(packet, feedbacks.emplace_back(handle->feedback));
}
}
if (auto foveation_packet = foveation_center.take_packet())
{
auto & packet = packets.emplace_back();
wivrn_session::control_socket_t::serialize(packet, *foveation_packet);
}
if (not packets.empty())
{
try
@@ -1167,32 +1247,49 @@ void scenes::stream::render(const XrFrameState & frame_state)
}
}
auto show_gamepad_toast = [this, now](bool enabled) {
{
auto toast = gui_toast.lock();
toast->emplace(enabled
? _("Now emulating a gamepad. Double-click both grips to go back to using VR controllers.")
: _("No longer emulating a gamepad."),
false);
}
gui_status_last_change = now;
};
if (not application::get_config().emulated_gamepad)
{
if (gamepad_mode.exchange(false))
{
scheduled_derived_pose = now;
show_gamepad_toast(false);
spdlog::info("Controller gamepad emulation disabled due to setting change");
}
gamepad_chord.reset();
}
else if (gamepad_chord.check(now))
{
const bool enabled = not gamepad_mode.load();
gamepad_mode = enabled;
if (not enabled)
scheduled_derived_pose = now;
show_gamepad_toast(enabled);
spdlog::info("Controller gamepad mode {}", enabled ? "enabled" : "disabled");
}
read_actions();
if (application::get_config().enable_stream_gui)
if (application::get_config().enable_stream_gui and menu_chord.check(now))
{
XrActionStateGetInfo get_info{
.type = XR_TYPE_ACTION_STATE_GET_INFO,
.action = plots_toggle_1,
};
XrActionStateBoolean state_1{XR_TYPE_ACTION_STATE_BOOLEAN};
CHECK_XR(xrGetActionStateBoolean(session, &get_info, &state_1));
get_info.action = plots_toggle_2;
XrActionStateBoolean state_2{XR_TYPE_ACTION_STATE_BOOLEAN};
CHECK_XR(xrGetActionStateBoolean(session, &get_info, &state_2));
if (state_1.currentState and state_2.currentState and (state_1.changedSinceLastSync or state_2.changedSinceLastSync))
{
// Arbitrary transitions can happen from network commands
// Ensure we can't have a set of 2 non interactable states
if (is_gui_interactable())
next_gui_status = stream_tab::hidden;
else if (is_interactable(stored_gui_status))
next_gui_status = stored_gui_status;
else
next_gui_status = stream_tab::applications;
}
// Arbitrary transitions can happen from network commands
// Ensure we can't have a set of 2 non interactable states
if (is_gui_interactable())
next_gui_status = stream_tab::hidden;
else if (is_interactable(stored_gui_status))
next_gui_status = stored_gui_status;
else
next_gui_status = stream_tab::applications;
}
query_pool_filled = true;
@@ -1208,6 +1305,12 @@ void scenes::stream::setup(const to_headset::video_stream_description & descript
spdlog::info("setup, refresh rate {}", description.refresh_rate);
session.set_refresh_rate(description.refresh_rate);
battery & battery_monitor = application::get_battery_monitor();
for (auto device: magic_enum::enum_values<battery::device>())
{
on_battery_update(device, battery_monitor.get_battery_status(device));
}
std::unique_lock lock(decoder_mutex);
if (video_stream_description == description)
return;
@@ -1217,7 +1320,7 @@ void scenes::stream::setup(const to_headset::video_stream_description & descript
for (const auto & [stream_index, item]: utils::enumerate(decoders))
{
item = accumulator_images{
.decoder = std::make_unique<shard_accumulator>(device, physical_device, instance, queue_family_index, description, shared_from_this(), stream_index),
.decoder = std::make_unique<shard_accumulator>(device, physical_device, instance, queue_family_index, description, weak_from_this(), stream_index),
};
}
@@ -1225,7 +1328,7 @@ void scenes::stream::setup(const to_headset::video_stream_description & descript
defoveator->reset_pipelines();
}
void scenes::stream::setup_reprojection_swapchain(uint32_t swapchain_width, uint32_t swapchain_height)
void scenes::stream::setup_reprojection_swapchain(uint32_t swapchain_width, uint32_t swapchain_height, bool foveation)
{
assert(swapchain_width);
assert(swapchain_height);
@@ -1235,8 +1338,21 @@ void scenes::stream::setup_reprojection_swapchain(uint32_t swapchain_width, uint
auto views = system.view_configuration_views(viewconfig);
swapchain = xr::swapchain(instance, session, device, swapchain_format, swapchain_width, swapchain_height, 1, views.size());
spdlog::info("Created stream swapchain: {}x{}", swapchain.width(), swapchain.height());
swapchain = xr::swapchain(
instance,
session,
device,
swapchain_format,
swapchain_width,
swapchain_height,
1,
views.size(),
foveation);
spdlog::info(
"Created stream swapchain: {}x{}{}",
swapchain.width(),
swapchain.height(),
foveation ? " with eye-tracked foveation" : "");
for (auto view: views)
{
if (swapchain.width() > view.maxImageRectWidth or swapchain.height() > view.maxImageRectHeight)
@@ -1254,6 +1370,26 @@ void scenes::stream::setup_reprojection_swapchain(uint32_t swapchain_width, uint
swapchain.format());
}
void scenes::stream::ensure_swapchain(bool cropped, uint32_t width, uint32_t height)
{
if (!swapchain or swapchain.width() < width or swapchain.height() < height or foveation_center.needs_swapchain_recreation(cropped))
{
try
{
setup_reprojection_swapchain(width, height, foveation_center.use_meta_swapchain(cropped));
foveation_center.on_swapchain_recreated(cropped);
}
catch (std::exception & e)
{
spdlog::warn("failed to create swapchain");
}
}
else
{
foveation_center.set_cropped(cropped);
}
}
scene::meta & scenes::stream::get_meta_scene()
{
static meta m{
@@ -1270,8 +1406,10 @@ scene::meta & scenes::stream::get_meta_scene()
{"right_scroll", XR_ACTION_TYPE_VECTOR2F_INPUT},
{"right_haptic", XR_ACTION_TYPE_VIBRATION_OUTPUT},
{"plots_toggle_1", XR_ACTION_TYPE_BOOLEAN_INPUT},
{"plots_toggle_2", XR_ACTION_TYPE_BOOLEAN_INPUT},
{"menu_toggle_1", XR_ACTION_TYPE_BOOLEAN_INPUT},
{"menu_toggle_2", XR_ACTION_TYPE_BOOLEAN_INPUT},
{"gamepad_mode_1", XR_ACTION_TYPE_BOOLEAN_INPUT},
{"gamepad_mode_2", XR_ACTION_TYPE_BOOLEAN_INPUT},
{"recenter_left", XR_ACTION_TYPE_BOOLEAN_INPUT},
{"recenter_right", XR_ACTION_TYPE_BOOLEAN_INPUT},
@@ -1296,6 +1434,7 @@ scene::meta & scenes::stream::get_meta_scene()
"/interaction_profiles/bytedance/pico4s_controller",
"/interaction_profiles/yvr/touch_controller_yvr",
"/interaction_profiles/htc/vive_focus3_controller",
"/interaction_profiles/valve/frame_controller_valve",
},
{
{"left_aim", "/user/hand/left/input/aim/pose"},
@@ -1318,8 +1457,20 @@ scene::meta & scenes::stream::get_meta_scene()
{"foveation_ok", "/user/hand/right/input/a/click"},
{"foveation_cancel", "/user/hand/right/input/b/click"},
{"plots_toggle_1", "/user/hand/left/input/thumbstick/click"},
{"plots_toggle_2", "/user/hand/right/input/thumbstick/click"},
{"menu_toggle_1", "/user/hand/left/input/thumbstick/click"},
{"menu_toggle_2", "/user/hand/right/input/thumbstick/click"},
},
},
suggested_binding{
{
"/interaction_profiles/valve/frame_controller_valve",
},
{
{"left_trigger", "/user/hand/left/input/bumper/click"},
{"right_trigger", "/user/hand/right/input/bumper/click"},
{"gamepad_mode_1", "/user/hand/left/input/squeeze/click"},
{"gamepad_mode_2", "/user/hand/right/input/squeeze/click"},
},
},
suggested_binding{
@@ -1391,6 +1542,31 @@ void scenes::stream::on_xr_event(const xr::event & event)
}
}
void scenes::stream::on_battery_update(battery::device device, const battery::battery_status & battery)
{
device_id id = [&] {
switch (device)
{
case battery::device::head:
return device_id::HEAD;
case battery::device::left_controller:
return device_id::LEFT_CONTROLLER;
case battery::device::right_controller:
return device_id::RIGHT_CONTROLLER;
case battery::device::gamepad:
return device_id::GAMEPAD;
default:
assert(false);
__builtin_unreachable();
}
}();
network_session->send_control(from_headset::battery{
.device = id,
.charge = battery.charge,
.charging = battery.charging,
});
}
bool scenes::stream::forward_hid_input(from_headset::hid::input_t packet, bool device_enabled)
{
// hid_forwarding is whether the server permits it; device_enabled is the headset toggle.
+38 -7
View File
@@ -20,8 +20,11 @@
#pragma once
#include "app_launcher.h"
#include "application.h"
#include "audio/audio.h"
#include "configuration.h"
#include "decoder/shard_accumulator.h"
#include "foveation.h"
#include "render/imgui_impl.h"
#include "scene.h"
#include "scenes/input_profile.h"
@@ -78,6 +81,37 @@ private:
std::thread network_thread;
thread_safe<to_headset::tracking_control> tracking_control{};
std::array<std::atomic<interaction_profile>, 3> interaction_profiles; // left hand, right hand, gamepad
std::atomic<bool> gamepad_mode = false;
struct chord_state
{
XrAction a = XR_NULL_HANDLE;
XrAction b = XR_NULL_HANDLE;
uint32_t clicks_needed = 1;
bool both_released = false;
uint32_t clicks_done = 0;
XrTime first_click_time = 0;
void reset()
{
both_released = false;
clicks_done = 0;
first_click_time = 0;
}
// Read actions a and b and determine if they were activated together clicks_needed times in a row
bool check(XrTime now);
};
chord_state menu_chord = {};
chord_state gamepad_chord = {.clicks_needed = 2};
bool using_frame_gamepad() const
{
return gamepad_mode.load() and
interaction_profiles[0].load() == interaction_profile::valve_frame_controller_valve and
interaction_profiles[1].load() == interaction_profile::valve_frame_controller_valve;
}
std::atomic<bool> interaction_profile_changed = false;
std::atomic<XrTime> scheduled_derived_pose = 0; // Tracking thread will compute derived pose when time is reached
std::atomic<bool> recenter_requested = false;
@@ -117,6 +151,7 @@ private:
state_.compare_exchange_strong(prev, new_state);
}
client_foveation::center foveation_center;
xr::swapchain swapchain;
std::optional<audio> audio_handle;
@@ -169,8 +204,6 @@ private:
thread_safe<std::queue<std::string>> stream_error_queue;
XrAction plots_toggle_1 = XR_NULL_HANDLE;
XrAction plots_toggle_2 = XR_NULL_HANDLE;
XrAction recenter_left = XR_NULL_HANDLE;
XrAction recenter_right = XR_NULL_HANDLE;
XrAction gui_distance_left = XR_NULL_HANDLE;
@@ -188,10 +221,6 @@ private:
glm::vec3 world_gui_position;
glm::quat world_gui_orientation;
bool override_foveation_enable;
float override_foveation_pitch; // The pitch is the opposite as the height displayed in the GUI
float override_foveation_distance;
// Which controller is used for recentering and position of the GUI relative to the controller, in controller axes, during recentering
std::optional<std::tuple<xr::spaces, glm::vec3, glm::quat>> recentering_context;
void update_gui_position(xr::spaces controller, float predicted_display_period);
@@ -219,6 +248,7 @@ public:
void on_focused() override;
void on_unfocused() override;
void on_xr_event(const xr::event &) override;
void on_battery_update(battery::device device, const battery::battery_status &) override;
bool on_input_key_down(uint8_t key_code) override;
bool on_input_key_up(uint8_t key_code) override;
@@ -277,7 +307,8 @@ private:
void send_derived_pose();
void setup(const to_headset::video_stream_description &);
void setup_reprojection_swapchain(uint32_t width, uint32_t height);
void setup_reprojection_swapchain(uint32_t width, uint32_t height, bool foveation);
void ensure_swapchain(bool cropped, uint32_t width, uint32_t height);
vk::raii::QueryPool query_pool = nullptr;
bool query_pool_filled = false;
+175 -5
View File
@@ -19,29 +19,170 @@
#include "application.h"
#include "stream.h"
#include <algorithm>
#include <array>
#include <optional>
#include <ranges>
#include <spdlog/spdlog.h>
namespace
{
using wivrn::device_id;
std::optional<device_id> frame_gamepad_input(device_id id)
{
switch (id)
{
case device_id::LEFT_MENU_CLICK:
return device_id::GAMEPAD_VIEW_CLICK;
case device_id::RIGHT_MENU_CLICK:
return device_id::GAMEPAD_MENU_CLICK;
case device_id::A_CLICK:
return device_id::GAMEPAD_A_CLICK;
case device_id::B_CLICK:
return device_id::GAMEPAD_B_CLICK;
case device_id::RIGHT_X_CLICK:
return device_id::GAMEPAD_X_CLICK;
case device_id::RIGHT_Y_CLICK:
return device_id::GAMEPAD_Y_CLICK;
case device_id::DPAD_UP_CLICK:
return device_id::GAMEPAD_DPAD_UP_CLICK;
case device_id::DPAD_LEFT_CLICK:
return device_id::GAMEPAD_DPAD_LEFT_CLICK;
case device_id::LEFT_X_CLICK:
return device_id::GAMEPAD_DPAD_DOWN_CLICK;
case device_id::LEFT_Y_CLICK:
return device_id::GAMEPAD_DPAD_RIGHT_CLICK;
case device_id::LEFT_BUMPER_CLICK:
return device_id::GAMEPAD_SHOULDER_LEFT_CLICK;
case device_id::RIGHT_BUMPER_CLICK:
return device_id::GAMEPAD_SHOULDER_RIGHT_CLICK;
case device_id::LEFT_THUMBSTICK_CLICK:
return device_id::GAMEPAD_THUMBSTICK_LEFT_CLICK;
case device_id::RIGHT_THUMBSTICK_CLICK:
return device_id::GAMEPAD_THUMBSTICK_RIGHT_CLICK;
case device_id::LEFT_TRIGGER_VALUE:
return device_id::GAMEPAD_TRIGGER_LEFT_VALUE;
case device_id::RIGHT_TRIGGER_VALUE:
return device_id::GAMEPAD_TRIGGER_RIGHT_VALUE;
case device_id::LEFT_THUMBSTICK_X:
return device_id::GAMEPAD_THUMBSTICK_LEFT_X;
case device_id::RIGHT_THUMBSTICK_X:
return device_id::GAMEPAD_THUMBSTICK_RIGHT_X;
default:
return std::nullopt;
}
}
constexpr std::array frame_gamepad_ids = {
device_id::GAMEPAD_MENU_CLICK,
device_id::GAMEPAD_VIEW_CLICK,
device_id::GAMEPAD_A_CLICK,
device_id::GAMEPAD_B_CLICK,
device_id::GAMEPAD_X_CLICK,
device_id::GAMEPAD_Y_CLICK,
device_id::GAMEPAD_DPAD_UP_CLICK,
device_id::GAMEPAD_DPAD_DOWN_CLICK,
device_id::GAMEPAD_DPAD_LEFT_CLICK,
device_id::GAMEPAD_DPAD_RIGHT_CLICK,
device_id::GAMEPAD_SHOULDER_LEFT_CLICK,
device_id::GAMEPAD_SHOULDER_RIGHT_CLICK,
device_id::GAMEPAD_THUMBSTICK_LEFT_CLICK,
device_id::GAMEPAD_THUMBSTICK_RIGHT_CLICK,
device_id::GAMEPAD_TRIGGER_LEFT_VALUE,
device_id::GAMEPAD_TRIGGER_RIGHT_VALUE,
device_id::GAMEPAD_THUMBSTICK_LEFT_X,
device_id::GAMEPAD_THUMBSTICK_LEFT_Y,
device_id::GAMEPAD_THUMBSTICK_RIGHT_X,
device_id::GAMEPAD_THUMBSTICK_RIGHT_Y,
};
} // namespace
bool scenes::stream::chord_state::check(XrTime now)
{
constexpr XrDuration press_tolerance = 150'000'000; // 150ms between button presses
constexpr XrDuration click_timeout = 400'000'000; // 400ms between chord clicks
auto state_1 = application::read_action_bool(a);
auto state_2 = application::read_action_bool(b);
if (not state_1 or not state_2)
{
reset();
return false;
}
if (clicks_done != 0 and now - first_click_time > click_timeout)
clicks_done = 0;
const bool down_1 = state_1->second;
const bool down_2 = state_2->second;
if (not down_1 and not down_2)
{
both_released = true;
return false;
}
// require both inputs to be released between taps
// to avoid accidental activation
if (not(down_1 and down_2) or not both_released)
return false;
// both inputs are down
both_released = false;
const XrTime press_1 = state_1->first;
const XrTime press_2 = state_2->first;
const XrDuration press_separation = press_1 >= press_2 ? press_1 - press_2 : press_2 - press_1;
// inputs were not pressed together
if (press_separation > press_tolerance)
{
clicks_done = 0;
return false;
}
if (clicks_done == 0)
first_click_time = std::max(press_1, press_2);
++clicks_done;
if (clicks_done < clicks_needed)
return false;
reset();
return true;
}
void scenes::stream::read_actions()
{
from_headset::inputs inputs;
const bool emulating_gamepad = using_frame_gamepad();
if (not is_gui_interactable())
{
for (const auto & [id, action, action_type]: input_actions)
{
device_id output_id = id;
if (emulating_gamepad)
{
auto mapped_id = frame_gamepad_input(id);
if (not mapped_id)
continue; // No VR inputs in gamepad mode
output_id = *mapped_id;
}
switch (action_type)
{
case XR_ACTION_TYPE_BOOLEAN_INPUT: {
auto value = application::read_action_bool(action);
if (value)
inputs.values.push_back({id, (float)value->second, value->first});
inputs.values.push_back({output_id, (float)value->second, value->first});
}
break;
case XR_ACTION_TYPE_FLOAT_INPUT: {
auto value = application::read_action_float(action);
if (value)
inputs.values.push_back({id, value->second, value->first});
inputs.values.push_back({output_id, value->second, value->first});
}
break;
@@ -49,8 +190,12 @@ void scenes::stream::read_actions()
auto value = application::read_action_vec2(action);
if (value)
{
inputs.values.push_back({id, value->second.x, value->first});
inputs.values.push_back({(device_id)((int)id + 1), value->second.y, value->first});
inputs.values.push_back({output_id, value->second.x, value->first});
float y = value->second.y;
if (emulating_gamepad &&
(id == device_id::LEFT_THUMBSTICK_X || id == device_id::RIGHT_THUMBSTICK_X))
y = -y;
inputs.values.push_back({(device_id)((int)output_id + 1), y, value->first});
}
}
break;
@@ -62,6 +207,15 @@ void scenes::stream::read_actions()
}
}
if (emulating_gamepad)
{
for (auto id: frame_gamepad_ids)
{
if (std::ranges::none_of(inputs.values, [id](const auto & value) { return value.id == id; }))
inputs.values.push_back({id, 0, 0});
}
}
try
{
network_session->send_stream(std::move(inputs));
@@ -74,12 +228,28 @@ void scenes::stream::read_actions()
void scenes::stream::operator()(to_headset::haptics && haptics)
{
if (using_frame_gamepad())
{
switch (haptics.id)
{
case device_id::GAMEPAD_HAPTIC_LEFT:
case device_id::GAMEPAD_HAPTIC_LEFT_TRIGGER:
haptics.id = device_id::LEFT_CONTROLLER_HAPTIC;
break;
case device_id::GAMEPAD_HAPTIC_RIGHT:
case device_id::GAMEPAD_HAPTIC_RIGHT_TRIGGER:
haptics.id = device_id::RIGHT_CONTROLLER_HAPTIC;
break;
default:
break;
}
}
auto range = haptics_actions.equal_range(haptics.id);
for (auto it = range.first; it != range.second; ++it)
{
XrAction action = it->second.action;
float old = it->second.amplitude;
it->second.amplitude = old;
it->second.amplitude = haptics.amplitude;
// Some runtimes may be slow to process actions
// Skip it if not necessary
if (old == 0 and haptics.amplitude == 0)
-2
View File
@@ -119,8 +119,6 @@ stream_defoveator::pipeline_t & stream_defoveator::ensure_pipeline(size_t view,
target.layout = vk::raii::PipelineLayout(device, pipeline_layout_info);
const auto & vk_device_extensions = application::get_vk_device_extensions();
// Vertex shader
auto vertex_shader = load_shader(device, "reprojection.vert");
+31 -32
View File
@@ -363,8 +363,6 @@ void scenes::stream::gui_performance_metrics()
void scenes::stream::gui_compact_view()
{
const auto & metrics = global_metrics[(metrics_offset + global_metrics.size() - 1) % global_metrics.size()];
if (ImGui::BeginTable("metrics", 2))
{
auto f = [&](const char * label, float value, const char * unit) {
@@ -409,21 +407,16 @@ void scenes::stream::gui_settings(float)
.session = session,
.system = system,
.imgui_ctx = *imgui_ctx,
.recommended_width = width,
.recommended_height = height,
.in_game = true,
.server_hid_forwarding = hid_forwarding_enabled(),
.on_streaming_changed = [this] { send_settings_changed_packet(session, network_session.get(), application::get_config()); },
.enter_foveation_adjust = [this] { next_gui_status = stream_tab::foveation_settings; },
.on_foveation_override_changed = [this] {
const auto & config = application::get_config();
override_foveation_enable = config.override_foveation_enable;
override_foveation_pitch = config.override_foveation_pitch;
override_foveation_distance = config.override_foveation_distance;
network_session->send_control(from_headset::override_foveation_center{
.enabled = override_foveation_enable,
.pitch = override_foveation_pitch,
.distance = override_foveation_distance,
foveation_center.set_manual_mode({
.enabled = config.override_foveation_enable,
.pitch = config.override_foveation_pitch,
.distance = config.override_foveation_distance,
}); },
};
@@ -484,11 +477,13 @@ void scenes::stream::gui_bitrate_settings(float predicted_display_period)
void scenes::stream::gui_foveation_settings(float predicted_display_period)
{
auto override = foveation_center.get_manual_mode();
ImGui::PushFont(nullptr, constants::gui::font_size_large);
ImGui::Text("%s", _S("Use the thumbsticks to move the foveation center"));
ImGui::Text("%s", _S("Press A to save or B to cancel"));
ImGui::Text("%s", fmt::format(_F("Height {:.1f} °"), -override_foveation_pitch * 180 / M_PI).c_str());
ImGui::Text("%s", fmt::format(_F("Distance {:.2f} m"), override_foveation_distance).c_str());
ImGui::Text("%s", fmt::format(_F("Height {:.1f} °"), -override.pitch * 180 / M_PI).c_str());
ImGui::Text("%s", fmt::format(_F("Distance {:.2f} m"), override.distance).c_str());
ImGui::PopFont();
// Maximum speed 1 rad/s
@@ -497,8 +492,8 @@ void scenes::stream::gui_foveation_settings(float predicted_display_period)
// Maximum speed 2m/s @ 1m
float delta_distance = std::pow(constants::stream::gui_max_foveation_speed, application::read_action_float(foveation_distance).value_or(std::pair{0, 0}).second * predicted_display_period);
override_foveation_pitch = std::clamp<float>(override_foveation_pitch + delta_pitch, constants::stream::gui_min_foveation_pitch, constants::stream::gui_max_foveation_pitch);
override_foveation_distance = std::clamp<float>(override_foveation_distance * delta_distance, constants::stream::gui_min_foveation_distance, constants::stream::gui_max_foveation_distance);
override.pitch = std::clamp<float>(override.pitch + delta_pitch, constants::stream::gui_min_foveation_pitch, constants::stream::gui_max_foveation_pitch);
override.distance = std::clamp<float>(override.distance * delta_distance, constants::stream::gui_min_foveation_distance, constants::stream::gui_max_foveation_distance);
bool ok = application::read_action_bool(foveation_ok).value_or(std::pair{0, false}).second;
bool cancel = application::read_action_bool(foveation_cancel).value_or(std::pair{0, false}).second;
@@ -506,12 +501,13 @@ void scenes::stream::gui_foveation_settings(float predicted_display_period)
if (ok)
{
next_gui_status = stream_tab::settings;
override.enabled = true;
// Save settings
auto & config = application::get_config();
config.override_foveation_enable = true;
config.override_foveation_pitch = override_foveation_pitch;
config.override_foveation_distance = override_foveation_distance;
config.override_foveation_enable = override.enabled;
config.override_foveation_pitch = override.pitch;
config.override_foveation_distance = override.distance;
config.save();
}
else if (cancel)
@@ -520,16 +516,14 @@ void scenes::stream::gui_foveation_settings(float predicted_display_period)
// Restore settings
const auto & config = application::get_config();
override_foveation_enable = config.override_foveation_enable;
override_foveation_pitch = config.override_foveation_pitch;
override_foveation_distance = config.override_foveation_distance;
override = {
.enabled = config.override_foveation_enable,
.pitch = config.override_foveation_pitch,
.distance = config.override_foveation_distance,
};
}
network_session->send_control(from_headset::override_foveation_center{
.enabled = override_foveation_enable,
.pitch = override_foveation_pitch,
.distance = override_foveation_distance,
});
foveation_center.set_manual_mode(override);
}
void scenes::stream::gui_applications()
@@ -729,10 +723,13 @@ void scenes::stream::draw_gui(XrTime predicted_display_time, XrDuration predicte
glm::mat3 M = glm::mat3_cast(head_position->second);
switch (gui_status)
{
case stream_tab::foveation_settings:
case stream_tab::foveation_settings: {
auto override = foveation_center.get_manual_mode();
imgui_ctx->layers()[0].orientation = head_position->second;
imgui_ctx->layers()[0].position = head_position->first + M * glm::vec3{0, override_foveation_distance * sin(override_foveation_pitch), -override_foveation_distance};
imgui_ctx->layers()[0].position = head_position->first + M * glm::vec3{0, override.distance * sin(override.pitch), -override.distance};
break;
}
case stream_tab::hidden:
// Always use the same position for the GUI shortcut tip
@@ -1096,13 +1093,15 @@ void scenes::stream::draw_gui(XrTime predicted_display_time, XrDuration predicte
if (left_hand and right_hand)
{
auto left = left_hand->locate(world_space, predicted_display_time);
auto right = right_hand->locate(world_space, predicted_display_time);
auto left = left_hand->locate(world_space, predicted_display_time).joints;
auto right = right_hand->locate(world_space, predicted_display_time).joints;
if (left and xr::hand_tracker::check_flags(*left, XR_SPACE_LOCATION_POSITION_TRACKED_BIT | XR_SPACE_LOCATION_POSITION_VALID_BIT, 0))
if (left and
xr::hand_tracker::check_flags(*left, XR_SPACE_LOCATION_POSITION_TRACKED_BIT | XR_SPACE_LOCATION_POSITION_VALID_BIT, 0))
hide_left_controller = true;
if (right and xr::hand_tracker::check_flags(*right, XR_SPACE_LOCATION_POSITION_TRACKED_BIT | XR_SPACE_LOCATION_POSITION_VALID_BIT, 0))
if (right and
xr::hand_tracker::check_flags(*right, XR_SPACE_LOCATION_POSITION_TRACKED_BIT | XR_SPACE_LOCATION_POSITION_VALID_BIT, 0))
hide_right_controller = true;
}
+116 -77
View File
@@ -25,16 +25,13 @@
#include "xr/face_tracker.h"
#include "xr/fb_body_tracker.h"
#include "xr/to_string.h"
#include <glm/gtc/quaternion.hpp>
#include <magic_enum.hpp>
#include <magic_enum_containers.hpp>
#include <ranges>
#include <spdlog/spdlog.h>
#include <thread>
#ifdef __ANDROID__
#include "android/battery.h"
#endif
namespace
{
@@ -63,6 +60,37 @@ from_headset::tracking::pose locate_space(device_id device, XrSpace space, XrSpa
return {.device = device};
}
from_headset::tracking::pose make_eye_gaze_view_relative(
const from_headset::tracking::pose & gaze_pose,
const from_headset::tracking::pose & view_pose)
{
glm::quat gaze_quat(
gaze_pose.pose.orientation.w,
gaze_pose.pose.orientation.x,
gaze_pose.pose.orientation.y,
gaze_pose.pose.orientation.z);
const glm::quat view_quat(
view_pose.pose.orientation.w,
view_pose.pose.orientation.x,
view_pose.pose.orientation.y,
view_pose.pose.orientation.z);
gaze_quat = glm::conjugate(view_quat) * gaze_quat;
using flags = from_headset::pose_flags;
return {
.pose = {
.orientation = {
.x = gaze_quat.x,
.y = gaze_quat.y,
.z = gaze_quat.z,
.w = gaze_quat.w,
},
},
.device = gaze_pose.device,
.flags = uint8_t(gaze_pose.flags & view_pose.flags & ~(flags::linear_velocity_valid | flags::angular_velocity_valid)),
};
}
class locate_spaces_functor
{
std::vector<XrSpaceLocationData> locations;
@@ -158,16 +186,33 @@ public:
} // namespace
static std::optional<std::array<from_headset::hand_tracking::pose, XR_HAND_JOINT_COUNT_EXT>> locate_hands(xr::hand_tracker & hand, XrSpace space, XrTime time)
static from_headset::hand_tracking locate_hands(
xr::hand_tracker & tracker,
XrSpace space,
XrTime now,
XrTime time)
{
auto joints = hand.locate(space, time);
using hand_id = from_headset::hand_tracking::hand_id;
auto located = tracker.locate(space, time);
if (joints)
from_headset::hand_tracking res{
.production_timestamp = now,
.timestamp = time,
.hand = tracker.hand() == XR_HAND_LEFT_EXT ? hand_id::left : hand_id::right,
};
if (located.data_source == XR_HAND_TRACKING_DATA_SOURCE_CONTROLLER_EXT)
res.hand = tracker.hand() == XR_HAND_LEFT_EXT
? hand_id::left_controller
: hand_id::right_controller;
if (located.joints)
{
std::array<from_headset::hand_tracking::pose, XR_HAND_JOINT_COUNT_EXT> poses;
const auto & joints = *located.joints;
auto & poses = res.joints.emplace();
for (int i = 0; i < XR_HAND_JOINT_COUNT_EXT; i++)
{
const auto & joint = (*joints)[i];
const auto & joint = joints[i];
poses[i] = {
.position = joint.first.pose.position,
.orientation = pack(joint.first.pose.orientation),
@@ -177,11 +222,9 @@ static std::optional<std::array<from_headset::hand_tracking::pose, XR_HAND_JOINT
.flags = from_headset::to_pose_flags(joint.first.locationFlags, joint.second.velocityFlags),
};
}
return poses;
}
else
return std::nullopt;
return res;
}
template <typename T>
@@ -233,14 +276,12 @@ void scenes::stream::tracking()
#ifdef __ANDROID__
// Runtime may use JNI and needs the thread to be attached
application::instance().setup_jni();
XrTime next_battery_check = 0;
const XrDuration battery_check_interval = 30'000'000'000; // 30s
#endif
magic_enum::containers::array<device_id, XrSpace> spaces{};
const auto & config = application::get_config();
const bool eye_gaze_enabled = config.check_feature(feature::eye_gaze);
{
std::vector ids{
@@ -258,7 +299,7 @@ void scenes::stream::tracking()
ids.insert(ids.end(), {device_id::LEFT_PINCH_POSE, device_id::LEFT_POKE, device_id::RIGHT_PINCH_POSE, device_id::RIGHT_POKE});
}
if (config.check_feature(feature::eye_gaze))
if (eye_gaze_enabled)
ids.emplace_back(device_id::EYE_GAZE);
for (auto id: ids)
@@ -271,9 +312,29 @@ void scenes::stream::tracking()
}
XrSpace view_space = application::space(xr::spaces::view);
XrSpace world_space = application::space(xr::spaces::world);
XrTime t0 = instance.now();
// poses sent to the PC are located against this space instead of xr::spaces::world
// directly, so the configured player height offset applies uniformly to the head, hands
// and body. It shares xr::spaces::world's STAGE origin, translated by -offset: locating a
// pose in it therefore reports that pose offset up by +offset, i.e. increases perceived
// height.
auto make_height_offset_space = [&](float offset) {
return session.create_reference_space(XR_REFERENCE_SPACE_TYPE_STAGE, {{0, 0, 0, 1}, {0, -offset, 0}});
};
float applied_height_offset = config.get_height_offset();
xr::space height_offset_space = make_height_offset_space(applied_height_offset);
XrSpace world_space = application::space(xr::spaces::world);
auto locate_eye_gaze = [&](XrTime time) {
// Eye gaze uses view pose as the origin.
if (application::get_hmd_traits().view_locate)
return locate_space(device_id::EYE_GAZE, spaces[device_id::EYE_GAZE], view_space, time);
// Pico headsets fail to locate gaze relative to view.
return make_eye_gaze_view_relative(
locate_space(device_id::EYE_GAZE, spaces[device_id::EYE_GAZE], world_space, time),
locate_space(device_id::EYE_GAZE, view_space, world_space, time));
};
from_headset::tracking tracking;
std::vector<from_headset::hand_tracking> hands;
std::vector<std::variant<from_headset::meta_body, from_headset::bd_body, from_headset::htc_body>> body;
@@ -291,7 +352,7 @@ void scenes::stream::tracking()
const bool body_tracking = config.check_feature(feature::body_tracking);
xr::body_tracker body_tracker;
locate_spaces_functor locate_spaces{instance, world_space};
locate_spaces_functor locate_spaces{instance, height_offset_space};
on_interaction_profile_changed({});
@@ -305,6 +366,13 @@ void scenes::stream::tracking()
{
try
{
if (float offset = config.get_height_offset(); offset != applied_height_offset)
{
applied_height_offset = offset;
height_offset_space = make_height_offset_space(applied_height_offset);
locate_spaces = locate_spaces_functor{instance, height_offset_space};
}
if (pattern_position == pattern.size())
{
// Upper limit to 200FPS
@@ -328,10 +396,14 @@ void scenes::stream::tracking()
if (hand_tracking)
{
std::array data_sources = {
XR_HAND_TRACKING_DATA_SOURCE_UNOBSTRUCTED_EXT,
XR_HAND_TRACKING_DATA_SOURCE_CONTROLLER_EXT,
};
if (std::ranges::contains(pattern, device_id::LEFT_HAND, &to_headset::tracking_control::sample::device))
{
if (not left_hand)
left_hand = session.create_hand_tracker(XR_HAND_LEFT_EXT);
left_hand = session.create_hand_tracker(XR_HAND_LEFT_EXT, data_sources);
}
else
left_hand.reset();
@@ -339,7 +411,7 @@ void scenes::stream::tracking()
if (std::ranges::contains(pattern, device_id::RIGHT_HAND, &to_headset::tracking_control::sample::device))
{
if (not right_hand)
right_hand = session.create_hand_tracker(XR_HAND_RIGHT_EXT);
right_hand = session.create_hand_tracker(XR_HAND_RIGHT_EXT, data_sources);
}
else
right_hand.reset();
@@ -398,11 +470,19 @@ void scenes::stream::tracking()
if (auto htc = std::get_if<xr::htc_body_tracker>(&body_tracker))
htc->update_active();
const bool emulating_gamepad = using_frame_gamepad();
tracking.interaction_profiles = {
interaction_profiles[0].load(),
interaction_profiles[1].load(),
interaction_profiles[2].load(),
};
if (emulating_gamepad)
{
// The server must see only a gamepad, no VR controllers
tracking.interaction_profiles[0] = interaction_profile::none;
tracking.interaction_profiles[1] = interaction_profile::none;
tracking.interaction_profiles[2] = interaction_profile::microsoft_xbox_controller;
}
tracking.production_timestamp = t0;
tracking.timestamp = t0 + pattern[pattern_position].prediction_ns;
@@ -436,6 +516,7 @@ void scenes::stream::tracking()
j.pose = i.pose;
j.fov = i.fov;
}
locate_spaces.add_space(item.device, view_space, tracking.timestamp, tracking.device_poses);
break;
case wivrn::device_id::LEFT_GRIP:
@@ -448,36 +529,12 @@ void scenes::stream::tracking()
case wivrn::device_id::LEFT_POKE:
case wivrn::device_id::RIGHT_PINCH_POSE:
case wivrn::device_id::RIGHT_POKE:
locate_spaces.add_space(item.device, spaces[item.device], tracking.timestamp, tracking.device_poses);
if (not emulating_gamepad)
locate_spaces.add_space(item.device, spaces[item.device], tracking.timestamp, tracking.device_poses);
break;
case wivrn::device_id::EYE_GAZE:
// Eye gaze uses view pose as the origin
if (application::get_hmd_traits().view_locate)
tracking.device_poses.push_back(locate_space(item.device, spaces[item.device], spaces[wivrn::device_id::HEAD], tracking.timestamp));
else
{
// Pico headsets fail to locate gaze relative to view
auto gaze = locate_space(item.device, spaces[item.device], world_space, tracking.timestamp);
auto view_pose = locate_space(item.device, view_space, world_space, tracking.timestamp);
glm::quat gaze_quat(gaze.pose.orientation.w, gaze.pose.orientation.x, gaze.pose.orientation.y, gaze.pose.orientation.z);
glm::quat view_quat(view_pose.pose.orientation.w, view_pose.pose.orientation.x, view_pose.pose.orientation.y, view_pose.pose.orientation.z);
gaze_quat = glm::conjugate(view_quat) * gaze_quat;
using flags = from_headset::pose_flags;
tracking.device_poses.push_back(
from_headset::tracking::pose{
// Zero position and velocities
.pose = {
.orientation = {
.x = gaze_quat.x,
.y = gaze_quat.y,
.z = gaze_quat.z,
.w = gaze_quat.w,
},
},
.device = item.device,
.flags = uint8_t(gaze.flags & view_pose.flags & ~(flags::linear_velocity_valid | flags::angular_velocity_valid)),
});
}
if (eye_gaze_enabled)
tracking.device_poses.push_back(locate_eye_gaze(tracking.timestamp));
break;
case wivrn::device_id::FACE:
std::visit(utils::overloaded{
@@ -491,28 +548,24 @@ void scenes::stream::tracking()
case wivrn::device_id::LEFT_HAND:
if (left_hand)
{
hands.emplace_back(
t0,
at_time,
from_headset::hand_tracking::left,
locate_hands(*left_hand, world_space, tracking.timestamp));
auto hand = locate_hands(*left_hand, height_offset_space, t0, at_time);
if (not emulating_gamepad or hand.hand != from_headset::hand_tracking::hand_id::left_controller)
hands.emplace_back(std::move(hand));
}
break;
case wivrn::device_id::RIGHT_HAND:
if (right_hand)
{
hands.emplace_back(
t0,
at_time,
from_headset::hand_tracking::right,
locate_hands(*right_hand, world_space, tracking.timestamp));
auto hand = locate_hands(*right_hand, height_offset_space, t0, at_time);
if (not emulating_gamepad or hand.hand != from_headset::hand_tracking::hand_id::right_controller)
hands.emplace_back(std::move(hand));
}
break;
case wivrn::device_id::BODY:
std::visit(utils::overloaded{
[](std::monostate &) {},
[&](auto & b) {
auto packet = b.locate_spaces(at_time, world_space);
auto packet = b.locate_spaces(at_time, height_offset_space);
packet.timestamp = at_time;
packet.production_timestamp = tracking.production_timestamp;
body.push_back(packet);
@@ -533,21 +586,6 @@ void scenes::stream::tracking()
throw;
}
#ifdef __ANDROID__
// FIXME: switch to event based
if (next_battery_check < now)
{
auto status = get_battery_status();
network_session->send_stream(from_headset::battery{
.charge = status.charge.value_or(-1),
.present = status.charge.has_value(),
.charging = status.charging,
});
next_battery_check = now + battery_check_interval;
}
#endif
if (auto fb = std::get_if<xr::fb_body_tracker>(&body_tracker); fb and fb->should_send_skeleton())
{
try
@@ -591,7 +629,7 @@ void scenes::stream::tracking()
network_session->send_stream(std::span(packets.data(), packet_count));
XrTime old = scheduled_derived_pose;
if (old and now > old)
if (old and now > old and not emulating_gamepad)
{
send_derived_pose();
scheduled_derived_pose.compare_exchange_strong(old, 0);
@@ -676,6 +714,7 @@ void scenes::stream::on_interaction_profile_changed(const XrEventDataInteraction
DO_PROFILE(yvr, touch_controller_yvr)
DO_PROFILE(samsung, odyssey_controller)
DO_PROFILE(valve, index_controller)
DO_PROFILE(valve, frame_controller_valve)
// FIXME: remove once support for pre-1.1 profiles is dropped
if (profile == "/interaction_profiles/facebook/touch_controller_pro")
+123
View File
@@ -0,0 +1,123 @@
/*
* WiVRn VR streaming
* Copyright (C) 2023 Guillaume Meunier <guillaume.meunier@centraliens.net>
* Copyright (C) 2023 Patrick Nicolas <patricknicolas@laposte.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include "utils/strings.h"
#include <cstdint>
#include <cstring>
#include <optional>
#include <spdlog/spdlog.h>
#include <stdexcept>
#include <string>
#include <string_view>
#include <unordered_map>
#include <unordered_set>
#ifdef __ANDROID__
#include "android/property.h"
#endif
template <typename T>
std::optional<T> env(std::string_view name);
template <>
inline std::optional<std::string> env(std::string_view name)
{
#ifdef __ANDROID__
auto android_sysprop_name = std::format("debug.wivrn.{}", name);
return get_property(android_sysprop_name.c_str());
#else
std::string env_name = "WIVRN_";
env_name.reserve(env_name.size() + name.size());
for (const auto & c: name)
env_name += std::toupper(c);
const char * value = std::getenv(env_name.c_str());
if (value)
return value;
return std::nullopt;
#endif
}
template <>
inline std::optional<uint32_t> env(std::string_view name)
{
const auto value = env<std::string>(name);
if (not value)
return std::nullopt;
try
{
const unsigned long parsed = std::stoul(*value);
if (parsed > std::numeric_limits<uint32_t>::max())
return std::nullopt;
return static_cast<uint32_t>(parsed);
}
catch (std::runtime_error & e)
{
spdlog::warn("failed to parse {} (value: {}: {}", name, *value, e.what());
return std::nullopt;
}
}
template <>
inline std::optional<bool> env(std::string_view name)
{
const auto value = env<std::string>(name);
if (not value)
return std::nullopt;
if (strcmp(value->c_str(), "1") == 0 || strcasecmp(value->c_str(), "true") == 0 || strcasecmp(value->c_str(), "yes") == 0 || strcasecmp(value->c_str(), "on") == 0)
return true;
if (strcmp(value->c_str(), "0") == 0 || strcasecmp(value->c_str(), "false") == 0 || strcasecmp(value->c_str(), "no") == 0 || strcasecmp(value->c_str(), "off") == 0)
return false;
return std::nullopt;
}
template <>
inline std::optional<std::unordered_map<std::string, std::string>> env(std::string_view name)
{
const auto values = env<std::string>(name);
if (not values)
return std::nullopt;
std::unordered_map<std::string, std::string> map;
for (auto value: utils::split(*values, ","))
{
if (auto pos = value.find('='); pos != std::string::npos)
map.insert(std::make_pair(value.substr(0, pos), value.substr(pos + 1)));
}
return map;
}
template <>
inline std::optional<std::unordered_set<std::string>> env(std::string_view name)
{
const auto values = env<std::string>(name);
if (not values)
return std::nullopt;
#if defined(__cpp_lib_containers_ranges) && __cpp_lib_containers_ranges >= 202202L
return std::unordered_set<std::string>{std::from_range, utils::split(*values, ",")};
#else
std::optional<std::unordered_set<std::string>> res{std::in_place};
for (auto & val: utils::split(*values))
res->insert(std::move(val));
return res;
#endif
}
-8
View File
@@ -72,14 +72,6 @@ std::shared_ptr<shader> shader_loader::operator()(std::span<const uint32_t> spir
for (SpvReflectSpecializationConstant * variable: enumerate<SpvReflectSpecializationConstant>(spvReflectEnumerateSpecializationConstants, reflect))
specialization_constants.emplace_back(variable->constant_id, variable->name);
for (SpvReflectDescriptorSet * variable: enumerate<SpvReflectDescriptorSet>(spvReflectEnumerateDescriptorSets, reflect))
{
}
for (SpvReflectDescriptorBinding * variable: enumerate<SpvReflectDescriptorBinding>(spvReflectEnumerateDescriptorBindings, reflect))
{
}
spvReflectDestroyShaderModule(&reflect);
}
else
+56 -16
View File
@@ -26,21 +26,41 @@
#include <cassert>
#include <spdlog/spdlog.h>
xr::hand_tracker::hand_tracker(instance & inst, session & session, const XrHandTrackerCreateInfoEXT & info) :
handle(inst.get_proc<PFN_xrDestroyHandTrackerEXT>("xrDestroyHandTrackerEXT"))
xr::hand_tracker::hand_tracker(instance & inst, session & session, const XrHandTrackerCreateInfoEXT & info, std::span<XrHandTrackingDataSourceEXT> sources) :
handle(inst.get_proc<PFN_xrDestroyHandTrackerEXT>("xrDestroyHandTrackerEXT")),
hand_{info.hand}
{
auto xrCreateHandTrackerEXT = inst.get_proc<PFN_xrCreateHandTrackerEXT>("xrCreateHandTrackerEXT");
assert(xrCreateHandTrackerEXT);
xrLocateHandJointsEXT = inst.get_proc<PFN_xrLocateHandJointsEXT>("xrLocateHandJointsEXT");
if (inst.has_extension(XR_FB_HAND_TRACKING_MESH_EXTENSION_NAME))
xrGetHandMeshFB = inst.get_proc<PFN_xrGetHandMeshFB>("xrGetHandMeshFB");
CHECK_XR(xrCreateHandTrackerEXT(session, &info, &id));
if (not sources.empty() and inst.has_extension(XR_EXT_HAND_TRACKING_DATA_SOURCE_EXTENSION_NAME))
{
use_data_source = true;
XrHandTrackingDataSourceInfoEXT data_source_info{
.type = XR_TYPE_HAND_TRACKING_DATA_SOURCE_INFO_EXT,
.next = info.next,
.requestedDataSourceCount = static_cast<uint32_t>(sources.size()),
.requestedDataSources = sources.data(),
};
auto create_info = info;
create_info.next = &data_source_info;
CHECK_XR(xrCreateHandTrackerEXT(session, &create_info, &id));
}
else
{
CHECK_XR(xrCreateHandTrackerEXT(session, &info, &id));
}
}
std::optional<std::array<xr::hand_tracker::joint, XR_HAND_JOINT_COUNT_EXT>> xr::hand_tracker::locate(XrSpace space, XrTime time)
xr::hand_tracker::located_hand xr::hand_tracker::locate(XrSpace space, XrTime time)
{
if (!id || !xrLocateHandJointsEXT)
return std::nullopt;
return {};
XrHandJointsLocateInfoEXT info{
.type = XR_TYPE_HAND_JOINTS_LOCATE_INFO_EXT,
@@ -67,29 +87,49 @@ std::optional<std::array<xr::hand_tracker::joint, XR_HAND_JOINT_COUNT_EXT>> xr::
.jointVelocities = joints_vel.data(),
};
XrHandTrackingDataSourceStateEXT data_source_state{
.type = XR_TYPE_HAND_TRACKING_DATA_SOURCE_STATE_EXT,
.next = &velocities,
};
XrHandJointLocationsEXT locations{
.type = XR_TYPE_HAND_JOINT_LOCATIONS_EXT,
.next = &velocities,
.jointCount = joints_pos.size(),
.jointLocations = joints_pos.data(),
};
if (use_data_source)
locations.next = &data_source_state;
CHECK_XR(xrLocateHandJointsEXT(id, &info, &locations));
if (!locations.isActive)
return std::nullopt;
located_hand res{};
// bail if any of the joint is invalid
if (std::ranges::any_of(joints_pos, [](const auto & loc) { return loc.locationFlags == 0; }))
return std::nullopt;
std::array<xr::hand_tracker::joint, XR_HAND_JOINT_COUNT_EXT> joints;
for (int i = 0; i < XR_HAND_JOINT_COUNT_EXT; i++)
if (locations.isActive)
{
joints[i] = {joints_pos[i], joints_vel[i]};
res.joints.emplace();
auto & joints = *res.joints;
for (int i = 0; i < XR_HAND_JOINT_COUNT_EXT; i++)
{
if (joints_pos[i].locationFlags == 0)
{
// bail if any of the joint is invalid
res.joints.reset();
break;
}
joints[i] = {joints_pos[i], joints_vel[i]};
}
}
return joints;
if (use_data_source)
{
res.data_source = data_source_state.dataSource;
if (not data_source_state.isActive)
// returned joints are not valid
res.joints.reset();
}
return res;
}
const xr::hand_tracker::mesh_data * xr::hand_tracker::mesh()
@@ -207,7 +247,7 @@ const xr::hand_tracker::mesh_data * xr::hand_tracker::mesh()
return &*cached_hand_mesh_fb;
}
bool xr::hand_tracker::check_flags(const std::array<joint, XR_HAND_JOINT_COUNT_EXT> & joints, XrSpaceLocationFlags position, XrSpaceVelocityFlags velocity)
bool xr::hand_tracker::check_flags(const joint_array & joints, XrSpaceLocationFlags position, XrSpaceVelocityFlags velocity)
{
return std::ranges::all_of(joints, [position, velocity](const auto & joint) {
return (joint.first.locationFlags & position) == position and (joint.second.velocityFlags & velocity) == velocity;
+19 -3
View File
@@ -22,6 +22,8 @@
#include "utils/handle.h"
#include <array>
#include <optional>
#include <span>
#include <utility>
#include <vector>
#include <openxr/openxr.h>
@@ -34,6 +36,13 @@ class hand_tracker : public utils::handle<XrHandTrackerEXT>
{
public:
using joint = std::pair<XrHandJointLocationEXT, XrHandJointVelocityEXT>;
using joint_array = std::array<joint, XR_HAND_JOINT_COUNT_EXT>;
struct located_hand
{
std::optional<joint_array> joints;
std::optional<XrHandTrackingDataSourceEXT> data_source;
};
struct mesh_data
{
@@ -51,15 +60,22 @@ public:
private:
PFN_xrLocateHandJointsEXT xrLocateHandJointsEXT{};
PFN_xrGetHandMeshFB xrGetHandMeshFB{};
bool use_data_source = false;
std::optional<mesh_data> cached_hand_mesh_fb;
bool hand_mesh_fb_fetched = false;
XrHandEXT hand_;
public:
hand_tracker(instance & inst, session & session, const XrHandTrackerCreateInfoEXT & info);
hand_tracker(instance & inst, session & session, const XrHandTrackerCreateInfoEXT & info, std::span<XrHandTrackingDataSourceEXT> sources = {});
std::optional<std::array<joint, XR_HAND_JOINT_COUNT_EXT>> locate(XrSpace space, XrTime time);
located_hand locate(XrSpace space, XrTime time);
const mesh_data * mesh();
static bool check_flags(const std::array<joint, XR_HAND_JOINT_COUNT_EXT> & joints, XrSpaceLocationFlags position, XrSpaceVelocityFlags velocity);
static bool check_flags(const joint_array & joints, XrSpaceLocationFlags position, XrSpaceVelocityFlags velocity);
XrHandEXT hand() const
{
return hand_;
}
};
} // namespace xr
+1
View File
@@ -45,6 +45,7 @@ union event
XrEventDataPassthroughStateChangedFB passthrough_state_changed;
XrEventDataVisibilityMaskChangedKHR visibility_mask_changed;
XrEventDataUserPresenceChangedEXT user_presence_changed;
XrEventDataBoundaryVisibilityChangedMETA boundary_visibility_changed;
};
class instance : public utils::handle<XrInstance, xrDestroyInstance>
{
+49 -4
View File
@@ -60,6 +60,9 @@ xr::session::session(xr::instance & inst, xr::system & sys, vk::raii::Instance &
if (inst.has_extension(XR_EXT_PERFORMANCE_SETTINGS_EXTENSION_NAME))
xrPerfSettingsSetPerformanceLevelEXT = inst.get_proc<PFN_xrPerfSettingsSetPerformanceLevelEXT>("xrPerfSettingsSetPerformanceLevelEXT");
if (inst.has_extension(XR_META_BOUNDARY_VISIBILITY_EXTENSION_NAME) and sys.boundary_visibility_properties().supportsBoundaryVisibility)
xrRequestBoundaryVisibilityMETA = inst.get_proc<PFN_xrRequestBoundaryVisibilityMETA>("xrRequestBoundaryVisibilityMETA");
}
std::vector<XrReferenceSpaceType> xr::session::get_reference_spaces() const
@@ -96,7 +99,7 @@ xr::space xr::session::create_action_space(XrAction action, const XrPosef & pose
return s;
}
xr::hand_tracker xr::session::create_hand_tracker(XrHandEXT hand, XrHandJointSetEXT hand_joint_set)
xr::hand_tracker xr::session::create_hand_tracker(XrHandEXT hand, std::span<XrHandTrackingDataSourceEXT> sources, XrHandJointSetEXT hand_joint_set)
{
return {
*inst,
@@ -106,7 +109,9 @@ xr::hand_tracker xr::session::create_hand_tracker(XrHandEXT hand, XrHandJointSet
.next = nullptr,
.hand = hand,
.handJointSet = hand_joint_set,
}};
},
sources,
};
}
std::vector<vk::Format> xr::session::get_swapchain_formats() const
@@ -158,8 +163,12 @@ void xr::session::end_frame(XrTime display_time, const std::vector<XrComposition
.layers = layers.data(),
};
auto lock = queue->lock();
CHECK_XR(xrEndFrame(id, &end_info));
{
auto lock = queue->lock();
CHECK_XR(xrEndFrame(id, &end_info));
}
update_boundary_visibility();
}
void xr::session::begin_session(XrViewConfigurationType view_config)
@@ -378,6 +387,42 @@ void xr::session::disable_passthrough()
passthrough.emplace<std::monostate>();
}
void xr::session::set_passthrough_boundary_enabled(bool enabled)
{
passthrough_boundary_enabled = enabled;
boundary_request_failed = false;
}
void xr::session::on_boundary_visibility_changed(XrBoundaryVisibilityMETA v)
{
runtime_boundary_visibility = v;
}
// the runtime only allows suppression while passthrough is shown and restores
// the boundary when it stops, so this re-requests every time passthrough comes back
void xr::session::update_boundary_visibility()
{
if (not xrRequestBoundaryVisibilityMETA)
return;
auto v = not passthrough_boundary_enabled and not std::holds_alternative<std::monostate>(passthrough)
? XR_BOUNDARY_VISIBILITY_SUPPRESSED_META
: XR_BOUNDARY_VISIBILITY_NOT_SUPPRESSED_META;
if (v == runtime_boundary_visibility)
return;
if (auto res = xrRequestBoundaryVisibilityMETA(id, v); res == XR_SUCCESS)
{
runtime_boundary_visibility = v;
boundary_request_failed = false;
}
else if (not boundary_request_failed)
{
spdlog::warn("Boundary visibility change failed: {}", xr::to_string(res));
boundary_request_failed = true;
}
}
void xr::session::set_performance_level(XrPerfSettingsDomainEXT domain, XrPerfSettingsLevelEXT level)
{
if (xrPerfSettingsSetPerformanceLevelEXT)
+15 -1
View File
@@ -48,6 +48,13 @@ class session : public utils::handle<XrSession, xrDestroySession>
PFN_xrPerfSettingsSetPerformanceLevelEXT xrPerfSettingsSetPerformanceLevelEXT = nullptr;
PFN_xrRequestBoundaryVisibilityMETA xrRequestBoundaryVisibilityMETA = nullptr;
XrBoundaryVisibilityMETA runtime_boundary_visibility = XR_BOUNDARY_VISIBILITY_NOT_SUPPRESSED_META;
bool passthrough_boundary_enabled = true;
bool boundary_request_failed = false;
void update_boundary_visibility();
public:
session() = default;
session(instance &, system &, vk::raii::Instance &, vk::raii::PhysicalDevice &, vk::raii::Device &, thread_safe<vk::raii::Queue> & queue, int queue_family_index);
@@ -55,7 +62,7 @@ public:
std::vector<XrReferenceSpaceType> get_reference_spaces() const;
space create_reference_space(XrReferenceSpaceType ref, const XrPosef & pose = {{0, 0, 0, 1}, {0, 0, 0}});
space create_action_space(XrAction action, const XrPosef & pose = {{0, 0, 0, 1}, {0, 0, 0}});
hand_tracker create_hand_tracker(XrHandEXT hand, XrHandJointSetEXT hand_joint_set = XR_HAND_JOINT_SET_DEFAULT_EXT);
hand_tracker create_hand_tracker(XrHandEXT hand, std::span<XrHandTrackingDataSourceEXT> sources = {}, XrHandJointSetEXT hand_joint_set = XR_HAND_JOINT_SET_DEFAULT_EXT);
std::vector<vk::Format> get_swapchain_formats() const;
@@ -99,5 +106,12 @@ public:
}
void set_performance_level(XrPerfSettingsDomainEXT, XrPerfSettingsLevelEXT);
bool boundary_visibility_supported() const
{
return xrRequestBoundaryVisibilityMETA;
}
void set_passthrough_boundary_enabled(bool);
void on_boundary_visibility_changed(XrBoundaryVisibilityMETA);
};
} // namespace xr
+48 -5
View File
@@ -21,6 +21,7 @@
#include "application.h"
#include "details/enumerate.h"
#include "session.h"
#include <spdlog/spdlog.h>
xr::swapchain::swapchain(
xr::instance & inst,
@@ -30,7 +31,9 @@ xr::swapchain::swapchain(
int32_t width,
int32_t height,
int sample_count,
uint32_t array_size) :
uint32_t array_size,
bool foveation,
bool transfer_dst) :
width_(width),
height_(height),
sample_count_(sample_count),
@@ -55,8 +58,24 @@ xr::swapchain::swapchain(
break;
}
if (transfer_dst)
usage_flags |= XR_SWAPCHAIN_USAGE_TRANSFER_DST_BIT;
XrVulkanSwapchainCreateInfoMETA vulkan_create_info{
.type = XR_TYPE_VULKAN_SWAPCHAIN_CREATE_INFO_META,
.additionalCreateFlags = VK_IMAGE_CREATE_FRAGMENT_DENSITY_MAP_OFFSET_BIT_QCOM,
.additionalUsageFlags = 0,
};
XrSwapchainCreateInfoFoveationFB foveation_create_info{
.type = XR_TYPE_SWAPCHAIN_CREATE_INFO_FOVEATION_FB,
.next = &vulkan_create_info,
.flags = XR_SWAPCHAIN_CREATE_FOVEATION_FRAGMENT_DENSITY_MAP_BIT_FB,
};
XrSwapchainCreateInfo create_info{
.type = XR_TYPE_SWAPCHAIN_CREATE_INFO,
.next = foveation ? &foveation_create_info : nullptr,
.createFlags = 0,
.usageFlags = usage_flags,
.format = static_cast<VkFormat>(format),
@@ -70,11 +89,35 @@ xr::swapchain::swapchain(
CHECK_XR(xrCreateSwapchain(s, &create_info, &id));
auto images = details::enumerate<XrSwapchainImageVulkanKHR>(xrEnumerateSwapchainImages, id);
if (foveation)
{
auto [images, foveation_images] =
details::enumerate2<XrSwapchainImageVulkanKHR, XrSwapchainImageFoveationVulkanFB>(
xrEnumerateSwapchainImages, id);
images_.reserve(images.size());
for (auto & image: images)
images_.push_back(image.image);
images_.reserve(images.size());
for (auto & image: images)
images_.push_back(image.image);
spdlog::debug("XR_FB_foveation: enumerated {} color images and {} FDM images", images.size(), foveation_images.size());
for (size_t i = 0; i < foveation_images.size(); ++i)
{
const auto & fdm = foveation_images[i];
spdlog::debug(
" {}. FDM image @ {}x{}",
i,
fdm.width,
fdm.height);
}
}
else
{
auto images = details::enumerate<XrSwapchainImageVulkanKHR>(xrEnumerateSwapchainImages, id);
images_.reserve(images.size());
for (auto & image: images)
images_.push_back(image.image);
}
}
int xr::swapchain::acquire()
+3 -1
View File
@@ -53,7 +53,9 @@ public:
int32_t width,
int32_t height,
int sample_count = 1,
uint32_t array_size = 1);
uint32_t array_size = 1,
bool foveation = false,
bool transfer_dst = false);
int32_t width() const
{
+40
View File
@@ -53,6 +53,10 @@ xr::system::system(xr::instance & inst, XrFormFactor formfactor)
body_tracker = xr::body_tracker_supported(inst, *this);
face_tracker = xr::face_tracker_supported(inst, *this);
auto views = view_configuration_views(XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO);
assert(views.size() == 2);
stereo_view_ = views[0];
}
XrGraphicsRequirementsVulkan2KHR xr::system::graphics_requirements() const
@@ -117,6 +121,24 @@ XrSystemEyeGazeInteractionPropertiesEXT xr::system::eye_gaze_interaction_propert
return eye_gaze_prop;
}
XrSystemFoveationEyeTrackedPropertiesMETA xr::system::foveation_eye_tracked_properties() const
{
if (!id)
throw std::invalid_argument("this");
XrSystemFoveationEyeTrackedPropertiesMETA foveation_prop{
.type = XR_TYPE_SYSTEM_FOVEATION_EYE_TRACKED_PROPERTIES_META,
};
XrSystemProperties prop{
.type = XR_TYPE_SYSTEM_PROPERTIES,
.next = &foveation_prop,
};
CHECK_XR(xrGetSystemProperties(*inst, id, &prop));
return foveation_prop;
}
XrSystemUserPresencePropertiesEXT xr::system::user_presence_properties() const
{
if (!id)
@@ -242,6 +264,24 @@ XrSystemBodyTrackingPropertiesBD xr::system::bd_body_tracking_properties() const
return body_tracking_prop;
}
XrSystemBoundaryVisibilityPropertiesMETA xr::system::boundary_visibility_properties() const
{
if (!id)
throw std::invalid_argument("this");
XrSystemBoundaryVisibilityPropertiesMETA boundary_prop{
.type = XR_TYPE_SYSTEM_BOUNDARY_VISIBILITY_PROPERTIES_META,
};
XrSystemProperties prop{
.type = XR_TYPE_SYSTEM_PROPERTIES,
.next = &boundary_prop,
};
CHECK_XR(xrGetSystemProperties(*inst, id, &prop));
return boundary_prop;
}
xr::passthrough_type xr::system::passthrough_supported() const
{
if (utils::contains(environment_blend_modes(XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO), XR_ENVIRONMENT_BLEND_MODE_ALPHA_BLEND))
+7
View File
@@ -66,6 +66,7 @@ class system
passthrough_type passthrough;
body_tracker_type body_tracker;
face_tracker_type face_tracker;
XrViewConfigurationView stereo_view_;
public:
system() = default;
@@ -85,6 +86,7 @@ public:
XrSystemProperties properties() const;
XrSystemHandTrackingPropertiesEXT hand_tracking_properties() const;
XrSystemEyeGazeInteractionPropertiesEXT eye_gaze_interaction_properties() const;
XrSystemFoveationEyeTrackedPropertiesMETA foveation_eye_tracked_properties() const;
XrSystemUserPresencePropertiesEXT user_presence_properties() const;
XrSystemFaceTrackingPropertiesANDROID android_face_tracking_properties() const;
XrSystemFaceTrackingProperties2FB fb_face_tracking2_properties() const;
@@ -92,6 +94,7 @@ public:
XrSystemBodyTrackingPropertiesFB fb_body_tracking_properties() const;
XrSystemPropertiesBodyTrackingFullBodyMETA meta_body_tracking_properties() const;
XrSystemBodyTrackingPropertiesBD bd_body_tracking_properties() const;
XrSystemBoundaryVisibilityPropertiesMETA boundary_visibility_properties() const;
bool hand_tracking_supported() const;
bool hand_mesh_fb_supported() const;
@@ -104,6 +107,10 @@ public:
vk::raii::Device create_device(vk::raii::PhysicalDevice & pdev, vk::DeviceCreateInfo & create_info) const;
std::vector<XrViewConfigurationType> view_configurations() const;
const XrViewConfigurationView & stereo_view() const
{
return stereo_view_;
}
XrViewConfigurationProperties view_configuration_properties(XrViewConfigurationType) const;
std::vector<XrViewConfigurationView> view_configuration_views(XrViewConfigurationType) const;
std::vector<XrEnvironmentBlendMode> environment_blend_modes(XrViewConfigurationType) const;
+3 -5
View File
@@ -8,7 +8,7 @@ if (NOT (GIT_TAG OR GIT_DESC OR GIT_COMMIT))
OUTPUT_VARIABLE GIT_TAG
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
)
endif()
if (GIT_TAG)
@@ -23,8 +23,7 @@ else()
COMMAND ${GIT_EXECUTABLE} describe --tags --always
OUTPUT_VARIABLE GIT_DESC
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
)
message(STATUS "Setting version to ${GIT_DESC} from git")
else()
message(STATUS "Setting version to ${GIT_DESC} from parameters")
@@ -34,8 +33,7 @@ else()
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
OUTPUT_VARIABLE GIT_COMMIT
ERROR_QUIET
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
)
string(STRIP "${GIT_COMMIT}" GIT_COMMIT)
endif()
+1
View File
@@ -2,6 +2,7 @@ if (WIVRN_USE_SYSTEM_BOOST)
add_library(Boost::pfr ALIAS Boost::headers)
else()
set(BOOST_INCLUDE_LIBRARIES locale url pfr iostreams)
set(BOOST_LOCALE_ENABLE_ICU OFF)
FetchContent_MakeAvailable(boost)
endif()
+1 -1
View File
@@ -237,7 +237,7 @@ std::unordered_map<std::string, application> list_applications()
application{
.name = std::move(app.name),
.exec = cmd + app.url,
.icon_path = steam.get_icon(app.appid),
.icon_path = std::move(app.icon),
});
}
}
+1 -1
View File
@@ -507,10 +507,10 @@ void decrypt_context::decrypt_in_place(std::span<std::span<uint8_t>> text)
std::vector<uint8_t> pbkdf2(std::string pass, std::string salt, std::span<uint8_t> secret, size_t size)
{
pass.append((char *)secret.data(), secret.size());
std::array params{
OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SALT, salt.data(), salt.size()),
OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_PASSWORD, pass.data(), pass.size()),
OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SECRET, secret.data(), secret.size()),
OSSL_PARAM_construct_end(),
};
+273 -136
View File
@@ -27,6 +27,7 @@
#include <fstream>
#include <iostream>
#include <nlohmann/json.hpp>
#include <unordered_set>
namespace
{
@@ -64,6 +65,7 @@ public:
}
std::vector<std::string> string_table();
std::vector<std::string> string_table(uint32_t count);
auto tellg()
{
@@ -100,6 +102,15 @@ std::vector<std::string> binary_reader::string_table()
return res;
}
std::vector<std::string> binary_reader::string_table(uint32_t count)
{
std::vector<std::string> res;
res.reserve(count);
for (size_t i = 0; i < count; ++i)
res.emplace_back(read<std::string>());
return res;
}
template <typename T>
void read_dict(binary_reader & in, T & visitor, const std::vector<std::string> * string_table = nullptr)
{
@@ -174,17 +185,155 @@ std::optional<uint32_t> guess_steam_userid(const std::filesystem::path & root)
}
}
} // namespace
void read_steam_icons(std::filesystem::path path, std::unordered_map<uint32_t, wivrn::steam::icon> & icons)
std::unordered_set<uint64_t> installed_appids(std::filesystem::path root)
{
binary_reader in{std::ifstream{path}};
std::unordered_set<uint64_t> res;
try
{
wivrn::vdf::root vdf(root / "config/libraryfolders.vdf");
using values_t = std::vector<wivrn::vdf::keyvalue>;
if (vdf.key != "libraryfolders")
return {};
for (const auto & kv: std::get<values_t>(vdf.value))
{
for (const auto & [appid, _]: std::get<values_t>(kv["apps"].value))
{
uint64_t val;
if (std::from_chars(appid.data.begin(), appid.data.end(), val).ec == std::errc())
res.emplace(val);
}
}
}
catch (...)
{}
return res;
}
std::unordered_set<uint64_t> owned_appids(std::filesystem::path localconfig)
{
wivrn::vdf::root localconfig_vdf(localconfig);
using values_t = std::vector<wivrn::vdf::keyvalue>;
if (localconfig_vdf.key != "UserLocalConfigStore")
return {};
std::unordered_set<uint64_t> res;
for (const auto & [k, entries]: std::get<values_t>(localconfig_vdf["Software"]["Valve"]["Steam"]["apps"].value))
{
uint64_t val;
if (std::from_chars(k.data.begin(), k.data.end(), val).ec == std::errc())
res.emplace(val);
}
return res;
}
struct app_data
{
enum section
{
common,
other,
};
std::vector<enum section> section;
wivrn::steam::application current{};
std::string clienticon;
std::string linuxclienticon;
bool VR = false;
void clear()
{
section.clear();
current.icon.clear();
current.name.clear();
current.url.clear();
clienticon.clear();
linuxclienticon.clear();
VR = false;
section.push_back(section::other);
}
void begin_dict(const std::string & key)
{
if (key == "common")
section.push_back(section::common);
else
section.push_back(section::other);
}
void end_dict()
{
section.pop_back();
}
void on_string(const std::string & key, std::string && val)
{
switch (section.back())
{
case common:
if (strcasecmp(key.c_str(), "clienticon") == 0)
clienticon = std::move(val);
else if (strcasecmp(key.c_str(), "linuxclienticon") == 0)
linuxclienticon = std::move(val);
else if (strcasecmp(key.c_str(), "name") == 0)
current.name[""] = std::move(val);
break;
case other:
break;
}
}
void on_uint32_t(const std::string & key, uint32_t val)
{
switch (section.back())
{
case common:
if (key == "openvrsupport")
VR = val;
break;
case other:
break;
}
}
};
bool is_appid_magic(uint32_t magic)
{
return (magic & 0xff'ff'ff'00) == 0x07'56'44'00;
}
void try_parse_application(std::vector<wivrn::steam::application> & out, std::filesystem::path root, uint32_t app_id, binary_reader & in, app_data & v, const std::vector<std::string> * string_table)
{
try
{
v.clear();
read_dict(in, v, string_table);
if (v.VR)
{
auto & item = out.emplace_back(std::move(v.current));
item.appid = app_id;
item.url = std::format("steam://launch/{}/VR", app_id);
if (auto icon_path = root / "steam/games" / (v.clienticon + ".ico"); std::filesystem::exists(icon_path))
item.icon = icon_path;
else if (auto icon_path = root / "steam/games" / (v.linuxclienticon + ".zip"); std::filesystem::exists(icon_path))
item.icon = icon_path;
}
}
catch (...)
{
// Ignore errors
}
}
// TODO: Remove when v42 appinfo is used in stable Steam Client
std::vector<wivrn::steam::application> read_appinfo_pre_v42(std::filesystem::path root, std::unordered_set<uint64_t> const & appids)
{
binary_reader in{std::ifstream{root / "appcache/appinfo.vdf"}};
uint32_t magic = in.read<uint32_t>();
if ((magic & 0xff'ff'ff'00) != 0x07'56'44'00)
if (!is_appid_magic(magic))
throw std::runtime_error{"Wrong magic number"};
auto universe = in.read<uint32_t>();
in.discard(4); // universe
int version = magic & 0xff;
@@ -195,28 +344,9 @@ void read_steam_icons(std::filesystem::path path, std::unordered_map<uint32_t, w
string_table = in.string_table();
string_table_ptr = &string_table;
}
std::vector<wivrn::steam::application> res;
struct V
{
wivrn::steam::icon current{};
void begin_dict(const std::string & key)
{
}
void end_dict()
{
}
void on_string(const std::string & key, std::string && val)
{
if (strcasecmp(key.c_str(), "clienticon") == 0)
current.clienticon = std::move(val);
else if (strcasecmp(key.c_str(), "linuxclienticon") == 0)
current.linuxclienticon = std::move(val);
}
void on_uint32_t(const std::string & key, uint32_t val)
{
}
};
app_data v;
while (true)
{
@@ -237,25 +367,112 @@ void read_steam_icons(std::filesystem::path path, std::unordered_map<uint32_t, w
+ 4 // checksum
+ 1 // type
);
try
if (appids.contains(app_id))
{
V v;
read_dict(in, v, string_table_ptr);
if (not(v.current.clienticon.empty() and v.current.linuxclienticon.empty()))
icons.emplace(app_id, std::move(v.current));
}
catch (...)
{
// Ignore errors
try_parse_application(res, root, app_id, in, v, string_table_ptr);
}
in.seekg(pos + size_data);
}
return res;
}
std::vector<wivrn::steam::application> read_appinfo_v42(std::filesystem::path root, std::unordered_set<uint64_t> const & appids)
{
std::vector<wivrn::steam::application> res;
for (auto const & entry: std::filesystem::directory_iterator(root / "appcache/appinfo"))
{
try
{
if (auto extension = entry.path().extension(); extension != ".vdf")
throw std::runtime_error{"Improper file extension"};
binary_reader in{std::ifstream{entry.path()}};
// https://github.com/xPaw/SteamAppInfo/blob/master/README.md#shard-header
uint32_t magic = in.read<uint32_t>();
if (!is_appid_magic(magic))
throw std::runtime_error{"Wrong magic number"};
int version = magic & 0xff;
if (version < 42)
throw std::runtime_error{std::format("Invalid version {}", version)};
in.discard(4 // universe
+ 4 // shard_index
+ 4 // shard_count
);
auto index_count = in.read<uint32_t>();
auto index_size = in.read<uint32_t>();
auto string_table_count = in.read<uint32_t>();
auto string_table_size = in.read<uint32_t>();
in.discard(4 // data_size
+ 4 // index_crc
+ 4 // header_crc
);
size_t index_data_pos = in.tellg();
size_t string_table_pos = index_data_pos + index_size;
size_t data_pos = string_table_pos + string_table_size;
in.seekg(string_table_pos);
std::vector<std::string> string_table = in.string_table(string_table_count);
// https://github.com/xPaw/SteamAppInfo/blob/master/README.md#index-entry-repeated
in.seekg(index_data_pos);
app_data v;
for (uint32_t i = 0; i < index_count; i++)
{
auto app_id = in.read<uint32_t>();
if (app_id == 0)
break;
auto data_offset = in.read<uint32_t>();
in.discard(4); // data_size
auto remaining = in.read<uint32_t>();
auto next = (size_t)in.tellg() + remaining;
if (appids.contains(app_id))
{
in.seekg(data_pos + data_offset);
in.discard(20); // SHA-1 of the bin data
try_parse_application(res, root, app_id, in, v, &string_table);
}
in.seekg(next);
}
}
catch (std::exception & e)
{
std::cerr << "Failed to read appinfo shard " << entry.path().filename() << ": " << e.what() << std::endl;
}
}
return res;
}
std::vector<wivrn::steam::application> read_appinfo(std::filesystem::path root, std::unordered_set<uint64_t> const & appids)
{
std::error_code ec;
if (std::filesystem::exists(root / "appcache/appinfo.vdf", ec))
{
return read_appinfo_pre_v42(root, appids);
}
else if (std::filesystem::is_directory(root / "appcache/appinfo", ec))
{
return read_appinfo_v42(root, appids);
}
throw std::runtime_error("No appinfos found in appcache");
}
} // namespace
void read_steam_shortcuts(
const std::filesystem::path & path,
std::vector<wivrn::steam::application> & apps,
std::unordered_map<uint32_t, std::filesystem::path> & icons)
std::vector<wivrn::steam::application> & apps)
{
if (not std::filesystem::exists(path))
return;
@@ -270,11 +487,9 @@ void read_steam_shortcuts(
struct V
{
std::vector<wivrn::steam::application> & apps;
std::unordered_map<uint32_t, std::filesystem::path> & icons;
int depth = 0;
wivrn::steam::application current{};
std::filesystem::path icon;
bool VR = false;
void begin_dict(const std::string & key)
@@ -283,7 +498,6 @@ void read_steam_shortcuts(
if (depth == 1)
{
current = decltype(current){};
icon.clear();
VR = false;
}
}
@@ -294,8 +508,6 @@ void read_steam_shortcuts(
{
if (VR)
{
if (not icon.empty())
icons[current.appid] = std::move(icon);
// ¯\_(ツ)_/¯
current.appid = (current.appid << 32) | 0x02000000;
current.url = std::format("steam://rungameid/{}", current.appid);
@@ -310,7 +522,7 @@ void read_steam_shortcuts(
if (strcasecmp(key.c_str(), "AppName") == 0)
current.name[""] = std::move(val);
else if (strcasecmp(key.c_str(), "icon") == 0 and not val.empty())
icon = std::move(val);
current.icon = std::move(val);
}
}
void on_uint32_t(const std::string & key, uint32_t val)
@@ -323,7 +535,7 @@ void read_steam_shortcuts(
VR = val;
}
}
} v{apps, icons};
} v{apps};
read_dict(in, v);
}
@@ -371,67 +583,21 @@ std::vector<wivrn::steam> wivrn::steam::find_installations()
std::vector<wivrn::steam::application> wivrn::steam::list_applications()
{
std::vector<wivrn::steam::application> res;
// Steam games, from VR manifest
try
{
std::ifstream manifest(root / "config/steamapps.vrmanifest");
nlohmann::json json = nlohmann::json::parse(manifest);
for (auto & i: json["applications"])
{
try
{
// Steam games have an url launch
// shortcuts may be in this file, or may not...
if (i["launch_type"] != "url")
continue;
const auto installed = installed_appids(root);
std::string app_key = i["app_key"];
const char prefix[] = "steam.app.";
if (not app_key.starts_with(prefix))
continue;
application app{
.appid = stoul(app_key.substr(strlen(prefix))),
.url = i["url"],
};
for (auto [locale, items]: i["strings"].items())
{
if (auto it = items.find("name"); it != items.end())
app.name[locale] = *it;
}
if (not app.name.contains(""))
{
auto it = app.name.find("en_us");
if (it == app.name.end())
it = app.name.begin();
if (it != app.name.end())
app.name[""] = it->second;
else
continue; // skip unnamed app
}
res.push_back(std::move(app));
}
catch (std::exception & e)
{
std::cerr << "Failed to parse Steam VR manifest: " << e.what() << std::endl;
}
}
}
catch (std::exception & e)
{
}
// Shortcuts
if (default_userid)
{
try
{
read_steam_shortcuts(root / "userdata" / std::to_string(*default_userid) / "config/shortcuts.vdf", res, shortcut_icons);
auto const & config = root / "userdata" / std::to_string(*default_userid) / "config";
auto ids = owned_appids(config / "localconfig.vdf");
std::erase_if(ids, [&](auto id) { return not installed.contains(id); });
res = read_appinfo(root, ids);
read_steam_shortcuts(config / "shortcuts.vdf", res);
}
catch (std::exception & e)
{
std::cerr << "Listing Steam applications failed (user id " << *default_userid << "): " << e.what() << std::endl;
}
}
else
@@ -441,53 +607,24 @@ std::vector<wivrn::steam::application> wivrn::steam::list_applications()
for (auto const & entry: std::filesystem::directory_iterator{root / "userdata", ec})
try
{
read_steam_shortcuts(entry.path() / "config/shortcuts.vdf", res, shortcut_icons);
auto const & config = entry.path() / "config";
auto ids = owned_appids(config / "localconfig.vdf");
std::erase_if(ids, [&](auto id) { return not installed.contains(id); });
auto tmp = read_appinfo(root, ids);
res.insert(res.end(),
std::make_move_iterator(tmp.begin()),
std::make_move_iterator(tmp.end()));
read_steam_shortcuts(config / "shortcuts.vdf", res);
}
catch (std::exception & e)
{
std::cerr << "Listing Steam applications failed (" << entry.path().filename() << "): " << e.what() << std::endl;
}
}
return res;
}
std::optional<std::filesystem::path> wivrn::steam::get_icon(uint64_t appid)
{
if (appid & 0x02000000)
{
// Shortcut
auto it = shortcut_icons.find(appid >> 32);
if (it != shortcut_icons.end())
return it->second;
return {};
}
if (not icons)
{
icons.emplace();
try
{
read_steam_icons(root / "appcache/appinfo.vdf", *icons);
}
catch (...)
{}
}
auto it = icons->find(appid);
if (it == icons->end())
return {};
auto icon_path = root / "steam/games" / (it->second.clienticon + ".ico");
if (std::filesystem::exists(icon_path))
return icon_path;
icon_path = root / "steam/games" / (it->second.linuxclienticon + ".zip");
if (std::filesystem::exists(icon_path))
return icon_path;
return {};
}
std::string wivrn::steam::get_steam_command() const
{
if (flatpak)
+1 -8
View File
@@ -35,19 +35,13 @@ public:
// localised names, with empty locale for default
std::unordered_map<std::string, std::string> name;
std::string url;
};
struct icon
{
std::string clienticon;
std::string linuxclienticon;
std::filesystem::path icon;
};
private:
std::filesystem::path root;
bool flatpak;
std::optional<uint32_t> default_userid;
std::optional<std::unordered_map<uint32_t, icon>> icons;
std::unordered_map<uint32_t, std::filesystem::path> shortcut_icons;
steam(std::filesystem::path root, bool flatpak);
@@ -55,7 +49,6 @@ public:
static std::vector<steam> find_installations();
std::vector<application> list_applications();
std::optional<std::filesystem::path> get_icon(uint64_t app_id);
std::string get_steam_command() const;
};
+23 -5
View File
@@ -19,6 +19,7 @@
#include "vdf.h"
#include <boost/iostreams/device/mapped_file.hpp>
#include <format>
#include <iostream>
namespace
@@ -132,14 +133,31 @@ bool wivrn::vdf::string::operator==(const char * b) const
return *b == '\0';
}
wivrn::vdf::keyvalue const & wivrn::vdf::keyvalue::operator[](const char * key) const
{
for (auto const & kv: std::get<std::vector<keyvalue>>(value))
{
if (kv.key == key)
return kv;
}
throw std::out_of_range{std::format("no key {}", key)};
}
wivrn::vdf::root::root(const std::filesystem::path & file)
{
boost::iostreams::mapped_file in{file};
opaque = in;
try
{
boost::iostreams::mapped_file_source in{file};
opaque = in;
const char * pos = in.begin();
key = read_string(pos, in.end());
value = read_value(pos, in.end());
const char * pos = in.begin();
key = read_string(pos, in.end());
value = read_value(pos, in.end());
}
catch (std::exception & e)
{
throw std::runtime_error(std::format("failed to parse {}: {}", file.native(), e.what()));
}
}
void dump(const wivrn::vdf::keyvalue & kv, int depth)
+2
View File
@@ -40,6 +40,8 @@ struct keyvalue
{
string key;
std::variant<string, std::vector<keyvalue>> value;
keyvalue const & operator[](const char *) const;
};
struct root : public keyvalue
+1
View File
@@ -32,6 +32,7 @@ static const int64_t max_extrapolation_ns = 80'000'000;
#cmakedefine01 WIVRN_USE_VAAPI
#cmakedefine01 WIVRN_USE_VULKAN_ENCODE
#cmakedefine01 WIVRN_USE_X264
#cmakedefine01 WIVRN_USE_V4L2
#cmakedefine01 WIVRN_USE_PIPEWIRE
+60 -25
View File
@@ -40,7 +40,7 @@
namespace wivrn
{
static constexpr int protocol_revision = 1;
static constexpr int protocol_revision = 2;
enum class device_id : uint8_t
{
@@ -61,13 +61,23 @@ enum class device_id : uint8_t
RIGHT_GRIP, // /user/hand/right/input/grip/pose
RIGHT_AIM, // /user/hand/right/input/aim/pose
RIGHT_PALM, // /user/hand/right/palm_ext/pose
X_CLICK, // /user/hand/left/input/x/click
X_TOUCH, // /user/hand/left/input/x/touch
Y_CLICK, // /user/hand/left/input/y/click
Y_TOUCH, // /user/hand/left/input/y/touch
MENU_CLICK, // /user/hand/left/input/menu/click
DPAD_UP_CLICK, // /user/hand/left/input/dpad_up/click
DPAD_UP_TOUCH, // /user/hand/left/input/dpad_up/touch
DPAD_LEFT_CLICK, // /user/hand/left/input/dpad_left/click
DPAD_LEFT_TOUCH, // /user/hand/left/input/dpad_left/touch
LEFT_X_CLICK, // /user/hand/left/input/x/click or /user/hand/left/input/dpad_down/click
LEFT_X_TOUCH, // /user/hand/left/input/x/touch or /user/hand/left/input/dpad_down/touch
LEFT_Y_CLICK, // /user/hand/left/input/y/click or /user/hand/left/input/dpad_right/click
LEFT_Y_TOUCH, // /user/hand/left/input/y/touch or /user/hand/left/input/dpad_right/touch
LEFT_MENU_CLICK, // /user/hand/left/input/{menu,view}/click
LEFT_MENU_TOUCH, // /user/hand/left/input/{menu,view}/touch
LEFT_SYSTEM_CLICK, // /user/hand/left/input/system/click
LEFT_SYSTEM_TOUCH, // /user/hand/left/input/system/touch
LEFT_BUMPER_CLICK, // /user/hand/left/input/bumper/click
LEFT_BUMPER_TOUCH, // /user/hand/left/input/bumper/touch
LEFT_SQUEEZE_CLICK, // /user/hand/left/input/squeeze/click
LEFT_SQUEEZE_FORCE, // /user/hand/left/input/squeeze/force
LEFT_SQUEEZE_TOUCH, // /user/hand/left/input/squeeze/touch
LEFT_SQUEEZE_VALUE, // /user/hand/left/input/squeeze/value
LEFT_TRIGGER_CLICK, // /user/hand/left/input/trigger/click
LEFT_TRIGGER_VALUE, // /user/hand/left/input/trigger/value
@@ -101,9 +111,19 @@ enum class device_id : uint8_t
A_TOUCH, // /user/hand/right/input/a/touch
B_CLICK, // /user/hand/right/input/b/click
B_TOUCH, // /user/hand/right/input/b/touch
SYSTEM_CLICK, // /user/hand/right/input/system/click
RIGHT_X_CLICK, // /user/hand/right/input/x/click
RIGHT_X_TOUCH, // /user/hand/right/input/x/touch
RIGHT_Y_CLICK, // /user/hand/right/input/y/click
RIGHT_Y_TOUCH, // /user/hand/right/input/y/touch
RIGHT_MENU_CLICK, // /user/hand/right/input/menu/click
RIGHT_MENU_TOUCH, // /user/hand/right/input/menu/touch
RIGHT_SYSTEM_CLICK, // /user/hand/right/input/system/click
RIGHT_SYSTEM_TOUCH, // /user/hand/right/input/system/touch
RIGHT_BUMPER_CLICK, // /user/hand/right/input/bumper/click
RIGHT_BUMPER_TOUCH, // /user/hand/right/input/bumper/touch
RIGHT_SQUEEZE_CLICK, // /user/hand/right/input/squeeze/click
RIGHT_SQUEEZE_FORCE, // /user/hand/right/input/squeeze/force
RIGHT_SQUEEZE_TOUCH, // /user/hand/right/input/squeeze/touch
RIGHT_SQUEEZE_VALUE, // /user/hand/right/input/squeeze/value
RIGHT_TRIGGER_CLICK, // /user/hand/right/input/trigger/click
RIGHT_TRIGGER_VALUE, // /user/hand/right/input/trigger/value
@@ -134,10 +154,14 @@ enum class device_id : uint8_t
RIGHT_GRASP_VALUE, // /user/hand/right/input/grasp_ext/value
RIGHT_GRASP_READY, // /user/hand/right/input/grasp_ext/ready_ext
EYE_GAZE, // /user/eyes_ext/input/gaze_ext/pose
LEFT_HAND, // identify hand tracking
RIGHT_HAND, // identify hand tracking
BODY, // identify body tracking
FACE, // identify face tracking
LEFT_CONTROLLER, // identify controller
RIGHT_CONTROLLER, // identify controller
LEFT_HAND = LEFT_CONTROLLER, // identify hand tracking
RIGHT_HAND = RIGHT_CONTROLLER, // identify hand tracking
BODY, // identify body tracking
FACE, // identify face tracking
GAMEPAD, // identify gamepad
// Gamepad, microsoft/xbox_controller profile (/user/gamepad)
GAMEPAD_MENU_CLICK, // /user/gamepad/input/menu/click
@@ -190,6 +214,7 @@ enum class interaction_profile : uint8_t
yvr_touch_controller_yvr,
samsung_odyssey_controller,
valve_index_controller,
valve_frame_controller_valve,
};
enum video_codec
@@ -201,6 +226,14 @@ enum video_codec
raw,
};
struct video_codec_capability
{
video_codec codec;
bool supports_10bit;
bool operator==(const video_codec_capability &) const = default;
};
enum class stream_tab : uint8_t
{
hidden,
@@ -317,7 +350,7 @@ struct headset_info_packet
};
std::optional<audio_description> speaker;
std::optional<audio_description> microphone;
std::array<XrFovf, 2> fov;
bool battery_status; // supports XR_EXT_interaction_profile_battery_state_display, for reporting controller/gamepad battery status
bool hand_tracking;
bool eye_gaze;
bool palm_pose;
@@ -327,8 +360,8 @@ struct headset_info_packet
body_type body_tracking;
// htc body only
uint32_t num_generic_trackers;
std::vector<video_codec> supported_codecs; // from preferred to least preferred
std::optional<uint8_t> bit_depth;
std::vector<video_codec_capability> supported_codecs; // from preferred to least preferred
std::optional<uint8_t> bit_depth; // explicit preference
std::string system_name;
// Used for the application list
@@ -371,6 +404,11 @@ inline uint8_t to_pose_flags(XrSpaceLocationFlags location_flags, XrSpaceVelocit
return flags;
}
struct foveation
{
std::array<XrVector2f, 2> angles; // Per-eye x/y view angles in radians
};
struct tracking
{
enum state_flags : uint8_t
@@ -451,6 +489,10 @@ struct hand_tracking
{
left,
right,
// with data_source
left_controller,
right_controller,
};
struct pose
{
@@ -631,8 +673,8 @@ struct feedback
struct battery
{
float charge;
bool present;
device_id device;
std::optional<float> charge;
bool charging;
};
@@ -658,13 +700,6 @@ struct stream_tab_changed
stream_tab tab;
};
struct override_foveation_center
{
bool enabled;
float pitch;
float distance;
};
struct get_application_list
{
std::string language;
@@ -715,13 +750,13 @@ using packets = std::variant<
session_state_changed,
user_presence_changed,
stream_tab_changed,
override_foveation_center,
get_application_list,
start_app,
get_running_applications,
set_active_application,
hid::input,
stop_application>;
stop_application,
foveation>;
} // namespace from_headset
namespace to_headset
@@ -68,6 +68,17 @@
<content_rating type="oars-1.1" />
<releases>
<release version="26.11" date="2026-11-28">
<url type="details">https://github.com/WiVRn/WiVRn/releases/tag/v26.11</url>
<description>
<ul>
<li>Initial support for Steam Frame</li>
<li>Use vulkan video encode by default on all GPU</li>
<li>Experimental AV1 support for vulkan video encode, only if manually configured</li>
<li>Don't show boundary/guardian by default</li>
</ul>
</description>
</release>
<release version="26.9" date="2026-09-12">
<url type="details">https://github.com/WiVRn/WiVRn/releases/tag/v26.9</url>
<description>
-3
View File
@@ -56,9 +56,6 @@
<property name="SpeakerSampleRate" type="u" access="read"/>
<property name="MicChannels" type="u" access="read"/>
<property name="MicSampleRate" type="u" access="read"/>
<property name="FieldOfView" type="a(dddd)" access="read">
<annotation name="org.qtproject.QtDBus.QtTypeName" value="QList&lt;field_of_view&gt;"/>
</property>
<property name="HandTracking" type="b" access="read"/>
<property name="EyeGaze" type="b" access="read"/>
<property name="FaceTracking" type="b" access="read"/>
+11 -11
View File
@@ -4,13 +4,13 @@
## Compile
From your checkout directory, with automatic detection of encoders
From your checkout directory
```bash
cmake -B build-server . -GNinja -DWIVRN_BUILD_CLIENT=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo
cmake --build build-server
```
It is possible to disable specific encoders, by adding options
By default, all encoders are enabled. It is possible to disable them at build time with the following options:
```
-DWIVRN_USE_NVENC=OFF
-DWIVRN_USE_VAAPI=OFF
@@ -18,14 +18,10 @@ It is possible to disable specific encoders, by adding options
-DWIVRN_USE_X264=OFF
```
Force specific audio backends
wivrnctl is an optional tool enabled by default and the only part that requires libsystemd/libelogind.
It can be disabled with
```
-DWIVRN_USE_PIPEWIRE=ON
```
Systemd service and pretty hostname support
```
-DWIVRN_USE_SYSTEMD=ON
-DWIVRN_USE_WIVRNCTL=OFF
```
Lighthouse driver support for use with lighthouse-tracked devices
@@ -33,7 +29,11 @@ Lighthouse driver support for use with lighthouse-tracked devices
-DWIVRN_FEATURE_STEAMVR_LIGHTHOUSE=ON
```
Additionally, if your environment requires absolute paths inside the OpenXR runtime manifest, you can add `-DWIVRN_OPENXR_MANIFEST_TYPE=absolute` to the build configuration.
For a few dependencies it is possible to select system or embedded versions, check `WIVRN_USE_SYSTEM_xxx` in case you are missing dependencies.
For more advanced options, check [CMakeLists.txt](../CMakeLists.txt).
For the Flatpak, see [flatpak](flatpak.md).
## Profiling / tracing build
@@ -52,7 +52,7 @@ See [profiling](profiling.md) for how to run the server with tracing and capture
# Dashboard
The WiVRn dashboard requires Qt6, and the WiVRn server.
The WiVRn dashboard requires Qt6, Kirigami, and the WiVRn server.
## Compile
+6 -6
View File
@@ -1,6 +1,6 @@
# Configurable items
Configuration is done on server side.
Configuration is split between headset and server. Headset contains most configuration, while server has system specific items such as encoders and paths.
Files are read from
- `/usr/share/wivrn/config.json` (where `/usr` is selected at configure time with `CMAKE_INSTALL_PREFIX`)
- `/etc/wivrn/config.json`
@@ -13,9 +13,9 @@ If you installed WiVRn from a flatpack, the config is in `$HOME/.var/app/io.gith
All elements are optional and have default values.
## `bit-depth`
Default value: `8` (bits)
Default value: 10-bit if supported by the selected codec, encoder and decoder. 8-bit otherwise.
Bit depth of the video. 8-bit is supported by all encoders. 10-bit is supported by `vaapi` and `nvenc` encoders using `h265` or `av1`.
Bit depth of the video. 8-bit is supported by all encoders. 10-bit is supported by `vulkan`, `vaapi` and `nvenc` with `h265` or `av1` codecs.
## `encoder`
The encoder to use, either a single string or object applied to all streams, or a list of string or objects with values for left, right and alpha.
@@ -24,13 +24,13 @@ When a string it is used, it is equivalent to the `encoder` item of the object.
WiVRn encodes each eye separately, and the alpha channel as one for both eyes. Each stream is processed independently, this may use resources more effectively and reduce latency.
### `encoder`
Default value: `vulkan` if supported, `nvenc` if Nvidia GPU and compiled with nvenc, `vaapi` for all other GPU when compiled with ffmpeg, else `x264`.
Default value, in order: `vulkan` if supported, `nvenc` on Nvidia GPU, `vaapi` on all other GPU, else `x264`.
Identifier of the encoder, one of
* `x264`: software encoding
* `nvenc`: Nvidia hardware encoding
* `vaapi`: AMD/Intel hardware encoding
* `vulkan`: for any GPU that supports vulkan video encode
* `vulkan`: Vulkan Video encode, cross-vendor hardware encoding
### `codec`
Default value: best supported by both headset and encoder of `av1`, `h264`, `h265`.
@@ -39,7 +39,7 @@ One of `h264`, `h265`, `av1`, `raw`.
Not all encoders support every codec:
- `x264` encoder only supports `h264` codec
- `vulkan` encoder supports `h264` and `h265` codecs
- `vulkan` encoder supports `h264`, `h265` and `av1` codecs, but `av1` is never selected automatically: it must be requested by setting `encoder` to `vulkan`
- `raw` encoder only supports `raw` codec
- `nvenc` and `vaapi` support all codecs, except `raw`
+11
View File
@@ -0,0 +1,11 @@
# Flatpak maintenance
The manifest template is `flatpak/io.github.wivrn.wivrn.yml.in`. All remote sources are archives pinned with a sha256, downloaded from the project's official host: a release tarball, or an archive of the official repository. Do not use third-party mirrors or `type: git` sources. Get a sha256 with `curl -L <url> | sha256sum`.
| When | Do |
|---|---|
| Updating monado | Update `monado-rev`. Nothing else. |
| Updating xrizer | Update the commit in its archive URL and its sha256. The cargo sources are regenerated by `tools/gen_flatpak_manifest.py`. |
| Updating OpenComposite | Also update the `libs/openxr-sdk`, `libs/glm` and `libs/libunwind` archives to its submodule commits: `curl "https://gitlab.com/api/v4/projects/znixian%2FOpenOVR/repository/tree?path=libs&ref=<commit>"` (entries of type `commit`). |
| Updating the KDE runtime | Update the `flatpak-github-actions:kde-<version>` container tag in [Build.yml](../.github/workflows/Build.yml) to match `runtime-version`. |
| Updating any other dependency | Update its URL and sha256. |
Generated
+9 -9
View File
@@ -5,11 +5,11 @@
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1787559586,
"narHash": "sha256-onL0VLf9vPllmT0H/OlURIU5r5t5WIEl7t4tVNKT0Nw=",
"lastModified": 1790898470,
"narHash": "sha256-zTwuwezD0w3hpga6a6P8emidzAZFyWqlNeRBlpWOOl8=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "9d0d87172c374f89da73c1cfe6d81ae62feac1f1",
"rev": "024633cd702b10285db5cb19b40ad48d2399ba60",
"type": "github"
},
"original": {
@@ -20,11 +20,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1787498568,
"narHash": "sha256-9i/VTdusq/+NM/tz+J1Re+ojkMB8MBf0QshnYfzHz30=",
"lastModified": 1792094642,
"narHash": "sha256-zp8ToDMnqZcu4o4IH9pdwXFXGp7yLm/M0dEnNWnyd7I=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "56c02bc00adcf003215cc4bd996d6efaf4cff188",
"rev": "fe13242281a67641c0102cdb1087f0ebe586c7df",
"type": "github"
},
"original": {
@@ -36,11 +36,11 @@
},
"nixpkgs-lib": {
"locked": {
"lastModified": 1785031560,
"narHash": "sha256-OmshNvn2vupOFpYinLUu+1Dnpu4n7Q5N3ggGVNHpkUI=",
"lastModified": 1790477367,
"narHash": "sha256-oujbxmVKDhci2E4EM3KyAbRUgp5/IsCoiA/LfEF7OOk=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "0e79af5e3d4dcfcd676ab5ba3f95d2e3352e078c",
"rev": "f7cd230690d9fc982d06129f9189b101fddcfa3b",
"type": "github"
},
"original": {
+108 -92
View File
@@ -2,103 +2,119 @@
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
inputs.flake-parts.url = "github:hercules-ci/flake-parts";
outputs = inputs@{ nixpkgs, flake-parts, ... }:
outputs =
inputs@{ nixpkgs, flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ "x86_64-linux" ];
perSystem = { lib, pkgs, ... }: let
# Tools used for development work (clangd, clang-format)
devTools = [
pkgs.clang-tools
pkgs.gdb
pkgs.ktx-tools
];
# Extra build inputs not yet in the nixpkgs recipe.
extraBuildInputs = [
# XRT_FEATURE_DEBUG_GUI requires SDL2
pkgs.sdl2-compat
pkgs.libpng
pkgs.kdePackages.kirigami-addons
# for client build
pkgs.curl
pkgs.ktx-tools
];
extraNativeBuildInputs = [
pkgs.util-linux
];
package = pkgs.enableDebugging (pkgs.wivrn.overrideAttrs (finalAttrs: oldAttrs: {
# Filter the directories and files we don't need to keep to avoid needless rebuilds
src = lib.cleanSourceWith {
filter = name: type: let
baseName = baseNameOf (toString name);
in
(lib.cleanSourceFilter name type) &&
!(
(type == "directory" && (
baseName == ".direnv"
|| baseName == ".cxx"
|| lib.hasPrefix "build" baseName))
|| baseName == ".envrc"
);
src = ./.;
};
version = "next";
# Because src is just a folder path and not a set from a fetcher, it doesn't need to be unpacked, so having a postUnpack throws an error.
# We also don't need the check since we read the revision from the monado-rev file.
postUnpack = null;
separateDebugInfo = false;
monado = pkgs.applyPatches {
inherit (oldAttrs.monado) patches postPatch;
# Force a refetch when the monado rev changes.
src = pkgs.testers.invalidateFetcherByDrvHash pkgs.fetchFromGitLab {
inherit (oldAttrs.monado.src) owner repo;
domain = "gitlab.freedesktop.org";
# Keep in sync with CMakeLists.txt monado rev
rev = lib.strings.trim (builtins.readFile ./monado-rev);
# Nix will output the correct hash when it doesn't match
hash = "sha256-3+bdxyXHuaweT/K+Jwh428XNMuZUd1tL2bdFBRIZ/Po=";
};
};
buildInputs = oldAttrs.buildInputs ++ extraBuildInputs;
nativeBuildInputs = oldAttrs.nativeBuildInputs ++ extraNativeBuildInputs;
cmakeFlags = (oldAttrs.cmakeFlags or []) ++ [
(lib.cmakeFeature "GIT_DESC" "nightly")
(lib.cmakeFeature "GIT_COMMIT" "nightly")
perSystem =
{ lib, pkgs, ... }:
let
# Extra build inputs only inside the devShell.
devBuildInputs = [
# for client build
pkgs.curl
pkgs.ktx-tools
];
}));
in {
packages = {
default = package;
dissector = package.overrideAttrs (oldAttrs: {
pname = "wivrn-dissector";
cmakeFlags = (lib.filter (flag: !(lib.hasPrefix "-DWIVRN_BUILD" flag)) oldAttrs.cmakeFlags) ++ [
(lib.cmakeBool "WIVRN_BUILD_CLIENT" false)
(lib.cmakeBool "WIVRN_BUILD_SERVER" false)
(lib.cmakeBool "WIVRN_BUILD_DASHBOARD" false)
(lib.cmakeBool "WIVRN_BUILD_WIVRNCTL" false)
(lib.cmakeBool "WIVRN_BUILD_DISSECTOR" true)
];
buildInputs = oldAttrs.buildInputs ++ [
(pkgs.symlinkJoin {
name = "wireshark-dev-out-combined";
paths = [
pkgs.wireshark.out
pkgs.wireshark.dev
# Tools used for development work (clangd, clang-format)
devTools = [
pkgs.clang-tools
pkgs.gdb
pkgs.ktx-tools
];
# Extra build inputs not yet in the nixpkgs recipe.
extraBuildInputs = [
# XRT_FEATURE_DEBUG_GUI requires SDL2
pkgs.sdl2-compat
pkgs.libpng
pkgs.kdePackages.kirigami-addons
];
extraNativeBuildInputs = [
pkgs.ninja
pkgs.util-linux
];
package = pkgs.enableDebugging (
pkgs.wivrn.overrideAttrs (
finalAttrs: oldAttrs: {
# Filter the directories and files we don't need to keep to avoid needless rebuilds
src = lib.cleanSourceWith {
filter =
name: type:
let
baseName = baseNameOf (toString name);
in
(lib.cleanSourceFilter name type)
&& !(
(
type == "directory"
&& (baseName == ".direnv" || baseName == ".cxx" || lib.hasPrefix "build" baseName)
)
|| baseName == ".envrc"
);
src = ./.;
};
version = "next";
# Because src is just a folder path and not a set from a fetcher, it doesn't need to be unpacked, so having a postUnpack throws an error.
# We also don't need the check since we read the revision from the monado-rev file.
postUnpack = null;
separateDebugInfo = false;
monado = pkgs.applyPatches {
inherit (oldAttrs.monado) patches postPatch;
# Force a refetch when the monado rev changes.
src = pkgs.testers.invalidateFetcherByDrvHash pkgs.fetchFromGitLab {
inherit (oldAttrs.monado.src) owner repo;
domain = "gitlab.freedesktop.org";
# Keep in sync with CMakeLists.txt monado rev
rev = lib.strings.trim (builtins.readFile ./monado-rev);
# Nix will output the correct hash when it doesn't match
hash = "sha256-yGkuD2jAG/ACSGkH1Cz8o23wHLtEqtNCUe2kS5OyC68=";
};
};
buildInputs = oldAttrs.buildInputs ++ extraBuildInputs;
nativeBuildInputs = oldAttrs.nativeBuildInputs ++ extraNativeBuildInputs;
cmakeFlags = (lib.filter (flag: !lib.hasInfix "GIT_" flag) oldAttrs.cmakeFlags) ++ [
(lib.cmakeFeature "GIT_DESC" "nightly")
(lib.cmakeFeature "GIT_COMMIT" "nightly")
];
})
];
preFixup = null;
}
)
);
in
{
formatter = pkgs.nixfmt;
packages = {
default = package;
dissector = package.overrideAttrs (oldAttrs: {
pname = "wivrn-dissector";
cmakeFlags = (lib.filter (flag: !(lib.hasPrefix "-DWIVRN_BUILD" flag)) oldAttrs.cmakeFlags) ++ [
(lib.cmakeBool "WIVRN_BUILD_CLIENT" false)
(lib.cmakeBool "WIVRN_BUILD_SERVER" false)
(lib.cmakeBool "WIVRN_BUILD_DASHBOARD" false)
(lib.cmakeBool "WIVRN_BUILD_WIVRNCTL" false)
(lib.cmakeBool "WIVRN_BUILD_DISSECTOR" true)
];
buildInputs = oldAttrs.buildInputs ++ [
(pkgs.symlinkJoin {
name = "wireshark-dev-out-combined";
paths = [
pkgs.wireshark.out
pkgs.wireshark.dev
];
})
];
preFixup = null;
});
};
devShells.default = package.overrideAttrs (oldAttrs: {
buildInputs = oldAttrs.buildInputs ++ devBuildInputs;
nativeBuildInputs = oldAttrs.nativeBuildInputs ++ devTools;
});
};
devShells.default = package.overrideAttrs (oldAttrs: {
nativeBuildInputs = oldAttrs.nativeBuildInputs ++ devTools;
});
};
};
}
+1 -2
View File
@@ -210,8 +210,7 @@ CT_SYSROOT_DIR_PREFIX=""
CT_WANTS_STATIC_LINK=y
CT_WANTS_STATIC_LINK_CXX=y
# CT_STATIC_TOOLCHAIN is not set
CT_SHOW_CT_VERSION=y
CT_TOOLCHAIN_PKGVERSION=""
# CT_SHOW_CT_VERSION is not set
CT_TOOLCHAIN_BUGURL=""
#
+1 -2
View File
@@ -189,8 +189,7 @@ CT_SYSROOT_DIR_PREFIX=""
CT_WANTS_STATIC_LINK=y
CT_WANTS_STATIC_LINK_CXX=y
# CT_STATIC_TOOLCHAIN is not set
CT_SHOW_CT_VERSION=y
CT_TOOLCHAIN_PKGVERSION=""
# CT_SHOW_CT_VERSION is not set
CT_TOOLCHAIN_BUGURL=""
#
+55 -42
View File
@@ -67,13 +67,16 @@ cleanup:
- '*.la'
- '*.cmake'
# Sources are sha256-pinned archives, not git, so flatpak-builder reuses
# downloads and unchanged module builds from .flatpak-builder. CI caches that
# directory plus the monado archive, keyed on this file, ct-ng configs and monado-rev.
modules:
- name: crosstool
buildsystem: autotools
sources:
- type: git
url: https://github.com/crosstool-ng/crosstool-ng.git
commit: 620b909cd0713f68084378b63cf61b5232757b90
- type: archive
url: https://github.com/crosstool-ng/crosstool-ng/archive/620b909cd0713f68084378b63cf61b5232757b90.tar.gz
sha256: d109c9315c0ae0cbb7622d540b1f395b663243371413bbecba03e800c5caa18b
- type: shell
commands:
# Make the build lighter:
@@ -94,9 +97,11 @@ modules:
config-opts:
- --disable-md2man
sources:
- type: git
url: https://github.com/RsyncProject/rsync.git
commit: 3305a7a063ab0167cab5bf7029da53abaa9fdb6e
- type: archive
url: https://github.com/RsyncProject/rsync/releases/download/v3.4.1/rsync-3.4.1.tar.gz
mirror-urls:
- https://download.samba.org/pub/rsync/src/rsync-3.4.1.tar.gz
sha256: 2924bcb3a1ed8b551fc101f740b9f0fe0a202b115027647cf69850d65fd88c52
cleanup:
- '*'
@@ -209,10 +214,9 @@ modules:
- --disable-manpages
- --disable-static
sources:
- type: git
url: https://github.com/avahi/avahi.git
tag: v0.8
commit: f060abee2807c943821d88839c013ce15db17b58
- type: archive
url: https://github.com/avahi/avahi/releases/download/v0.8/avahi-0.8.tar.gz
sha256: 060309d7a333d38d951bc27598c677af1796934dbd98e1024e7ad8de798fedda
cleanup:
- /share/locale
- /share/runtime/locale
@@ -223,9 +227,9 @@ modules:
config-opts:
- --enable-shared
sources:
- type: git
url: https://code.videolan.org/videolan/x264.git
commit: 31e19f92f00c7003fa115047ce50978bc98c3a0d
- type: archive
url: https://code.videolan.org/videolan/x264/-/archive/31e19f92f00c7003fa115047ce50978bc98c3a0d/x264-31e19f92f00c7003fa115047ce50978bc98c3a0d.tar.gz
sha256: d053c9d86988d6bc78237ca5205865c5ddf99c98ef4cd9927eec8f6d388f6dd9
cleanup:
- /bin/x264
@@ -251,10 +255,9 @@ modules:
- /bin/ffplay
- /bin/ffprobe
sources:
- type: git
url: https://gitlab.com/freedesktop-sdk/mirrors/ffmpeg/ffmpeg.git
tag: n7.1.4
commit: 9abe92e3af7fa7becc8f7f742b1457b4c28220a6
- type: archive
url: https://ffmpeg.org/releases/ffmpeg-7.1.4.tar.xz
sha256: 71f4aac3573ed9060489cb62526a6c7dda815ae10993789611acd7be9fa9fbf4
- name: eigen3
buildsystem: cmake-ninja
@@ -262,10 +265,9 @@ modules:
- -DBUILD_TESTING=OFF
builddir: true
sources:
- type: git
url: https://gitlab.com/libeigen/eigen.git
tag: 5.0.1
commit: bc3b39870ecb690a623a3f49149a358b95c5781d
- type: archive
url: https://gitlab.com/libeigen/eigen/-/archive/5.0.1/eigen-5.0.1.tar.gz
sha256: e9c326dc8c05cd1e044c71f30f1b2e34a6161a3b6ecf445d56b53ff1669e3dec
cleanup:
- '*'
@@ -274,10 +276,9 @@ modules:
config-opts:
- -DJSON_BuildTests=OFF
sources:
- type: git
url: https://github.com/nlohmann/json.git
tag: v3.12.0
commit: 55f93686c01528224f448c19128836e7df245f72
- type: archive
url: https://github.com/nlohmann/json/releases/download/v3.12.0/json.tar.xz
sha256: 42f6e95cad6ec532fd372391373363b62a14af6d771056dbfc86160e6dfff7aa
- name: cli11
buildsystem: cmake-ninja
@@ -287,10 +288,9 @@ modules:
- -DCLI11_BUILD_TESTS=OFF
- -DCLI11_BUILD_EXAMPLES=OFF
sources:
- type: git
url: https://github.com/CLIUtils/CLI11
tag: v2.6.2
commit: 37bb6edc5317e99af72ef48405e65d9ca5218861
- type: archive
url: https://github.com/CLIUtils/CLI11/archive/refs/tags/v2.6.2.tar.gz
sha256: c6ea6b2e5608b3ea8617999bd5f47420c71b2ebdb8dc4767c1034d1da5785711
cleanup:
- '*'
@@ -314,9 +314,22 @@ modules:
- -DUSE_SYSTEM_OPENXR=OFF
- -DUSE_SYSTEM_GLM=OFF
sources:
- type: git
url: https://gitlab.com/znixian/OpenOVR.git
commit: cff07db75c4823afe93ed7027b03d5f7bc86f164
- type: archive
url: https://gitlab.com/znixian/OpenOVR/-/archive/cff07db75c4823afe93ed7027b03d5f7bc86f164/OpenOVR-cff07db75c4823afe93ed7027b03d5f7bc86f164.tar.gz
sha256: d7ac1b9b12b3681414370be301909789ccdbb948412689780b2dec8cd47070bf
# git submodules of OpenOVR at the commit above
- type: archive
url: https://github.com/KhronosGroup/OpenXR-SDK/archive/91a8a8d9d70f4b469bca0726122c3b5a6096010e.tar.gz
dest: libs/openxr-sdk
sha256: 3b615f994adfa6184c6ff3b1b6af24965048ea1ddd3c3cf15c2b042282e74c05
- type: archive
url: https://github.com/g-truc/glm/archive/bf71a834948186f4097caa076cd2663c69a10e1e.tar.gz
dest: libs/glm
sha256: 70ad78e872c145f0164d54da833b651914c184edc65958906937b9739fb8fb1b
- type: archive
url: https://github.com/libunwind/libunwind/archive/f27f6a860335fc6c8107702dbde4b215ea74b164.tar.gz
dest: libs/libunwind
sha256: 3beb15d894759234dcb568f9d2be8b6ddc04c5d112836772e99884c58a07a285
- name: xrizer
buildsystem: simple
@@ -341,13 +354,13 @@ modules:
RUSTFLAGS: -C linker=/app/x86_64-unknown-linux-gnu/bin/x86_64-unknown-linux-gnu-gcc
build-commands:
- cargo --offline fetch --manifest-path Cargo.toml --verbose
- cargo xbuild --release
- cargo xbuild --release -F static-openxr
- mkdir /app/xrizer
- cp -rL target/release/bin/ /app/xrizer/
sources:
- type: git
url: https://github.com/Supreeeme/xrizer.git
commit: be664bb93eebdd82336d00230154bacc6f8b9765
- type: archive
url: https://github.com/Supreeeme/xrizer/archive/a1216c7b53fb562a5bc4de473163e97a483042af.tar.gz
sha256: d75bb0a301bcafb57e94ca56b9ea6ccbe847f3db9181d7fb61bffccb26a40c88
- xrizer-gen-src.json
- name: wivrn-library
@@ -389,9 +402,9 @@ modules:
- WIVRN_SRC1
WIVRN_SRC2
WIVRN_SRC3
- type: git
url: https://gitlab.freedesktop.org/monado/monado
commit: MONADO_COMMIT
- type: archive
url: MONADO_URL
sha256: MONADO_SHA256
dest: deps/monado-src
- type: shell
commands:
@@ -429,9 +442,9 @@ modules:
url: BOOST_URL
dest: deps/boost-src
sha256: BOOST_SHA256
- type: git
url: https://gitlab.freedesktop.org/monado/monado
commit: MONADO_COMMIT
- type: archive
url: MONADO_URL
sha256: MONADO_SHA256
dest: deps/monado-src
- type: shell
commands:
File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 158 KiB

+130 -108
View File
@@ -128,19 +128,19 @@ msgstr "ADB ist nicht installiert"
#, kde-format
msgid "Connect a headset and make sure developer mode is enabled"
msgstr ""
"Verbinde ein Headset und stelle sicher, dass die Entwickleroptionen "
"aktiviert sind"
"Verbinde ein Headset und stelle sicher, dass der Entwicklermodus aktiviert "
"ist"
#: dashboard/qml/ApkInstallPage.qml:51 dashboard/qml/WizardPage.qml:204
#, kde-format
msgid ""
"Follow the instructions in the <a href=\"https://github.com/WiVRn/WiVRn/blob/"
"master/docs/building.md#client-headset\">documentation</a> to build your own "
"client."
"Follow the instructions in the <a "
"href=\"https://github.com/WiVRn/WiVRn/blob/master/docs/building.md#client-"
"headset\">documentation</a> to build your own client."
msgstr ""
"Folge den Anleitungen in der <a href=\"https://github.com/WiVRn/WiVRn/blob/"
"master/docs/building.md#client-headset\">Dokumentation</a>, um einen eigenen "
"Client zu bauen"
"Folge den Anweisungen in der <a "
"href=\"https://github.com/WiVRn/WiVRn/blob/master/docs/building.md#client-"
"headset\">Dokumentation</a>, um deinen eigenen Client zu bauen."
#: dashboard/qml/ConnectUsbDialog.qml:11
#, kde-format
@@ -241,7 +241,8 @@ msgstr "Starte die WiVRn App auf dem Headset und verwende diesen PIN: %1"
#, kde-format
msgid "Enable pairing to allow your headset to connect to this computer"
msgstr ""
"Aktiviere Koppeln, damit sich das Headset mit diesem Computer verbinden kann"
"Aktiviere die Kopplung, damit dein Headset sich mit diesem Computer "
"verbinden kann"
#: dashboard/qml/HeadsetsPage.qml:171 dashboard/qml/TroubleshootPage.qml:45
#, kde-format
@@ -273,9 +274,7 @@ msgstr "Beende WiVRn"
msgid ""
"The WiVRn server is active.\n"
"Closing the window will terminate it."
msgstr ""
"Der WiVRn Server ist aktiv.\n"
"Das Schließen dieses Fensters wird ihn beenden."
msgstr "Der WiVRn-Server ist aktiv. Das Schließen des Fensters beendet ihn."
#: dashboard/qml/Main.qml:142
#, kde-format
@@ -303,8 +302,8 @@ msgstr "Firewall blockiert möglicherweise Port 9757"
msgid ""
"NVIDIA GPUs require at least driver version 565.77, current version is %1"
msgstr ""
"NVIDIA-GPUs benötigen mindestens die Treiber-Version 565.77, jetzige Version "
"ist %1"
"NVIDIA-GPUs benötigen mindestens Treiberversion 565.77, aktuelle Version ist"
" %1"
#: dashboard/qml/Main.qml:185
#, kde-format
@@ -315,8 +314,8 @@ msgstr "Mehr Infos"
#, kde-format
msgid "Vulkan drivers cannot be found, you may need to run \"flatpak update\""
msgstr ""
"Vulkan Treiber können nicht gefunden werden, möglicherweise muss \"Flatpak "
"Update\" ausgeführt werden"
"Vulkan-Treiber wurden nicht gefunden, du musst eventuell „flatpak update“ "
"ausführen"
#: dashboard/qml/Main.qml:193
#, kde-format
@@ -329,8 +328,8 @@ msgid ""
"Use the Mesa (radv) driver for AMD GPUs\n"
"Hardware encoding with vaapi does not work with AMDVLK and AMDGPU-PRO"
msgstr ""
"Verwende Mesa (radv) Treiber für AMD-GPUs\n"
"Hardware-Encoding mit Vaapi funktioniert nicht mit AMDVLK und AMDGPU-PRO"
"Verwende den Mesa-Treiber (radv) für AMD-GPUs Hardware-Encoding mit vaapi "
"funktioniert nicht mit AMDVLK und AMDGPU-PRO"
#: dashboard/qml/Main.qml:209
#, kde-format
@@ -338,27 +337,27 @@ msgid ""
"No OpenVR compatibility detected, Steam games won't be able to load VR.\n"
"Install xrizer or OpenComposite."
msgstr ""
"Keine Kompatibilität mit OpenVR gefunden, Steam Spiele werden nicht mit VR "
"starten können.\n"
"Installiere Xrizer oder OpenComposite"
"Keine OpenVR-Kompatibilität erkannt, Steam-Spiele können VR nicht laden. "
"Installiere xrizer oder OpenComposite."
#: dashboard/qml/Main.qml:217
#, kde-format
msgid "Steam is installed as a snap. Snaps are not compatible with WiVRn."
msgstr "Steam ist als Snap installiert. Snaps sind nicht mit WiVRn kompatibel."
msgstr ""
"Steam ist als Snap installiert. Snaps sind nicht mit WiVRn kompatibel."
#: dashboard/qml/Main.qml:225
#, kde-format
msgid ""
"Steam is installed as a flatpak but does not have sufficient permissions."
msgstr ""
"Steam ist als Flatpak installiert und hat nicht die nötigen Berechtigungen."
"Steam ist als Flatpak installiert, hat aber nicht die erforderlichen "
"Berechtigungen."
#: dashboard/qml/Main.qml:240
#, kde-format
msgid "Restart the server for configuration changes to take effect"
msgstr ""
"Starte den Server neu, damit die Änderungen der Konfiguration wirksam werden"
msgstr "Starte den Server neu, damit Konfigurationsänderungen wirksam werden"
#: dashboard/qml/Main.qml:246
#, kde-format
@@ -430,9 +429,7 @@ msgstr "Verbinden (Kabelgebunden)"
#: dashboard/qml/Main.qml:383 dashboard/qml/WizardPage.qml:339
#, kde-format
msgid "No headset is connected or your headset is not in developer mode"
msgstr ""
"Kein Headset ist verbunden oder die Entwickleroptionen im Headset sind "
"deaktiviert"
msgstr "Kein Headset verbunden oder dein Headset ist nicht im Entwicklermodus"
#: dashboard/qml/Main.qml:404
#, kde-format
@@ -531,9 +528,7 @@ msgstr "x264 (Software Encoding)"
#: dashboard/qml/SettingsPage.qml:79
#, kde-format
msgid "\"Auto\" will use hardware acceleration if it is available"
msgstr ""
"\"Automatisch\" wird Hardware Beschleunigung verwenden, sofern diese "
"verfügbar ist"
msgstr "„Auto“ verwendet Hardware-Beschleunigung, falls verfügbar"
#: dashboard/qml/SettingsPage.qml:89
#, kde-format
@@ -558,18 +553,20 @@ msgstr "Systemkonfigurationen beim Start überprüfen"
#: dashboard/qml/SettingsPage.qml:114
#, kde-format
msgid "Expose forwarded input devices via uinput"
msgstr ""
msgstr "Leitet Eingabegeräte über uinput weiter"
#: dashboard/qml/SettingsPage.qml:117
#, kde-format
msgid ""
"Replicate mouse, keyboard and gamepad connected to the headset as virtual "
"devices on PC.\n"
"Replicated devices will appear as if they were plugged to the PC, some keys "
"may be reserved by the headset OS and not be available. Gamepad is also "
"available without virtual devices for applications that access it through "
"OpenXR."
"Replicate mouse, keyboard and gamepad connected to the headset as virtual devices on PC.\n"
"Replicated devices will appear as if they were plugged to the PC, some keys may be reserved by the headset OS and not be available. Gamepad is also available without virtual devices for applications that access it through OpenXR."
msgstr ""
"Bildet Maus, Tastatur und Gamepad, die am Headset angeschlossen sind, als "
"virtuelle Geräte auf dem PC ab. Weitergeleitete Geräte erscheinen, als wären"
" sie am PC angeschlossen; einige Tasten können vom Headset-Betriebssystem "
"belegt sein und sind dann nicht verfügbar. Das Gamepad ist auch ohne "
"virtuelle Geräte für Anwendungen verfügbar, die über OpenXR darauf "
"zugreifen."
#: dashboard/qml/SettingsPage.qml:122
#, kde-format
@@ -589,11 +586,10 @@ msgid ""
"Devices must be be powered on before connecting to WiVRn.\n"
"An external tool such as motoc is needed for calibration."
msgstr ""
"Erlaubt die Nutzung von Basisstationen-basierten Controllern und Trackern.\n"
"SteamVR muss installiert sein.\n"
"Geräte müssen eingeschaltet sein bevor eine Verbindung mit WiVRn hergestellt "
"wird.\n"
"Für die Kalibrierung wird ein externes Tool wie Motoc benötigt."
"Ermöglicht die Verwendung von Lighthouse-basierten Controllern und Trackern."
" Erfordert eine installierte SteamVR-Installation. Geräte müssen vor der "
"Verbindung mit WiVRn eingeschaltet sein. Für die Kalibrierung ist ein "
"externes Werkzeug wie motoc erforderlich."
#: dashboard/qml/SettingsPage.qml:140
#, kde-format
@@ -649,15 +645,14 @@ msgid ""
"For Steam games, right click on the game in Steam, go in Properties > "
"General and paste this in \"Launch options\":"
msgstr ""
"Für Steam Spiele, klicke rechts auf das Spiel in Steam, gehe zu "
"Einstellungen >Allgemein und füge das Folgende in \"Startoptionen\" ein:"
"Bei Steam-Spielen: Rechtsklick auf das Spiel in Steam, zu Eigenschaften > "
"Allgemein gehen und dies bei „Startoptionen“ einfügen:"
#: dashboard/qml/SteamLaunchOptions.qml:20
#, kde-format
msgid "Paste this in the Steam launch options for the app you want to start"
msgstr ""
"Füge das für das Spiel, welches du starten möchtest, in die Steam "
"Startoptionen ein"
"Füge dies in die Steam-Startoptionen der App ein, die du starten möchtest"
#: dashboard/qml/SteamLaunchOptions.qml:26
#, kde-format
@@ -678,11 +673,11 @@ msgstr "Ich kann die WiVRn-App nicht auf dem Headset finden"
#: dashboard/qml/TroubleshootPage.qml:21 dashboard/qml/WizardPage.qml:353
#, kde-format
msgid ""
"If you installed WiVRn over USB on a Meta or Pico headset, the app is in the "
"\"unknown sources\" section."
"If you installed WiVRn over USB on a Meta or Pico headset, the app is in the"
" \"unknown sources\" section."
msgstr ""
"Wenn du WiVRn über USB auf einem Meta oder Pico Headset installiert hast, "
"dann findet sich die App in \"Unbekannte Quellen\"."
"Wenn du WiVRn über USB auf einem Meta- oder Pico-Headset installiert hast, "
"findest du die App im Abschnitt „Unbekannte Quellen“."
#: dashboard/qml/TroubleshootPage.qml:24
#, kde-format
@@ -693,7 +688,8 @@ msgstr "Ich kann den Computer nicht in der WiVRn-App sehen"
#, kde-format
msgid "If you have a firewall, make sure that port 5353/UDP is open."
msgstr ""
"Wenn eine Firewall aktiv ist, stelle sicher, dass Port 5353/UDP offen ist."
"Wenn du eine Firewall verwendest, stelle sicher, dass Port 5353/UDP offen "
"ist."
#: dashboard/qml/TroubleshootPage.qml:28
#, kde-format
@@ -706,8 +702,8 @@ msgid ""
"If you have a firewall, make sure that port 9757 is open both for TCP and "
"UDP."
msgstr ""
"Wenn eine Firewall aktiv ist, stelle sicher, dass Port 9757 für TCP und UPD "
"offen ist."
"Wenn du eine Firewall verwendest, stelle sicher, dass Port 9757 sowohl für "
"TCP als auch für UDP offen ist."
#: dashboard/qml/TroubleshootPage.qml:32
#, kde-format
@@ -722,13 +718,13 @@ msgstr "Ich habe den Fehler \"Inkompatibler WiVRn Server\" auf meinem Headset"
#: dashboard/qml/TroubleshootPage.qml:37
#, kde-format
msgid ""
"<p>The version of the headset app and the server on your computer must match."
"</p><ul><li>The headset app version is in the \"About\" page</li><li>The "
"server version is <b>%1</b></li></ul>"
"<p>The version of the headset app and the server on your computer must "
"match.</p><ul><li>The headset app version is in the \"About\" "
"page</li><li>The server version is <b>%1</b></li></ul>"
msgstr ""
"<p>Die Version der Headset-App und des Servers auf dem Computer müssen "
"gleich sein.</p><ul><li>Die Version der Headset-App ist in der \"Über "
"WiVRn\" Seite</li><li> Die Version des Servers ist <b>%1</b></li></ul>"
"<p>Die Version der Headset-App und die des Servers auf deinem Computer "
"müssen übereinstimmen.</p><ul><li>Die Version der Headset-App findest du auf"
" der Seite „Über“</li><li>Die Serverversion ist <b>%1</b></li></ul>"
#: dashboard/qml/TroubleshootPage.qml:40
#, kde-format
@@ -741,9 +737,9 @@ msgid ""
"If you have reinstalled the server or the client or if you want to connect "
"another headset, you must enable pairing before connecting."
msgstr ""
"Wenn der Server oder der Client neu installiert wurde, oder wenn ein anderes "
"Headset verbunden werden soll, dann muss Koppeln vor dem Verbinden aktiviert "
"werden."
"Wenn du den Server oder den Client neu installiert hast oder ein weiteres "
"Headset verbinden möchtest, musst du vor dem Verbinden die Kopplung "
"aktivieren."
#: dashboard/qml/TroubleshootPage.qml:41
#, kde-format
@@ -766,8 +762,8 @@ msgid ""
"When the headset is connected, select \"WiVRn\" as the default audio output "
"device for applications to use it."
msgstr ""
"Wenn das Headset verbunden ist, dann wähle \"WiVRn\" als die Standard-"
"Audioausgabe aus, damit Programme diese verwenden können."
"Wenn das Headset verbunden ist, wähle „WiVRn“ als Standard-"
"Audioausgabegerät, damit Anwendungen es verwenden."
#: dashboard/qml/TroubleshootPage.qml:61
#, kde-format
@@ -777,12 +773,13 @@ msgstr "Manche Spiele können nicht starten oder haben Eingabeprobleme"
#: dashboard/qml/TroubleshootPage.qml:62
#, kde-format
msgid ""
"For game specific issues, check on <a href=\"https://db.vronlinux.org/"
"\">vronlinux DB</a> if there are known bugs or workarounds."
"For game specific issues, check on <a "
"href=\"https://db.vronlinux.org/\">vronlinux DB</a> if there are known bugs "
"or workarounds."
msgstr ""
"Für Probleme mit einzelnen Spielen, gehe zu <a href=\"https://"
"db.vronlinux.org/\">vronlinux DB</a>, um herauszufinden ob es bereits Bugs "
"oder Workarounds gibt."
"Prüfe bei Spielspezifischen Problemen in der <a "
"href=\"https://db.vronlinux.org/\">vronlinux DB</a>, ob bekannte Fehler oder"
" Workarounds existieren."
#: dashboard/qml/TroubleshootPage.qml:79
#, kde-format
@@ -817,8 +814,8 @@ msgid ""
"This wizard will help you set up WiVRn on your headset and connect it to "
"your computer."
msgstr ""
"Dieser Einrichtungsassistent hilft dir, um WiVRn auf diesem Computer und dem "
"Headset einzurichten."
"Dieser Assistent hilft dir, WiVRn auf deinem Headset einzurichten und es mit"
" deinem Computer zu verbinden."
#: dashboard/qml/WizardPage.qml:83 dashboard/qml/WizardPage.qml:258
#: dashboard/qml/WizardPage.qml:418 dashboard/qml/WizardPage.qml:455
@@ -839,13 +836,12 @@ msgstr "Befolge den folgenden Anweisungen des Herstellers:"
#: dashboard/qml/WizardPage.qml:142
#, kde-format
msgid ""
"In order to use WiVRn, you will have to install the client app on your "
"headset.\n"
"In order to use WiVRn, you will have to install the client app on your headset.\n"
"You can either install it from the Meta store or directly over USB."
msgstr ""
"Um WiVRn zu nutzen, muss die Client-App auf einem Headset installiert "
"werden.\n"
"Die App kann entweder vom Meta Store oder direkt über USB installiert werden."
"Um WiVRn zu verwenden, musst du die Client-App auf deinem Headset "
"installieren. Du kannst sie entweder aus dem Meta Store installieren oder "
"direkt über USB."
#: dashboard/qml/WizardPage.qml:148
#, kde-format
@@ -858,8 +854,8 @@ msgid ""
"For the Quest 2, 3, 3S, and Pro, you can get the app from the <a "
"href=\"https://www.meta.com/experiences/7959676140827574/\">Meta store</a>."
msgstr ""
"Für Quest 2, 3, 3S, und Pro, ist die App im <a href=\"https://www.meta.com/"
"experiences/7959676140827574/\">Meta store</a> erhältlich."
"Für Quest 2, 3, 3S und Pro gibt es die App im <a "
"href=\"https://www.meta.com/experiences/7959676140827574/\">Meta Store</a>."
#: dashboard/qml/WizardPage.qml:164
#, kde-format
@@ -867,8 +863,8 @@ msgid ""
"A newer release is available: %1 → %2, the client app on the Meta store may "
"not be compatible."
msgstr ""
"Eine neue Version ist erhältlich: %1 → %2, die Client-App im Meta Store ist "
"möglicherweise nicht kompatibel."
"Eine neuere Version ist verfügbar: %1 → %2; die Client-App im Meta Store ist"
" möglicherweise nicht kompatibel."
#: dashboard/qml/WizardPage.qml:171
#, kde-format
@@ -876,7 +872,7 @@ msgid ""
"This is a nightly build, the client app on the Meta store may not be "
"compatible."
msgstr ""
"Dies ist ein nightly build, die Client-App im Meta Store ist möglicherweise "
"Dies ist ein Nightly-Build; die Client-App im Meta Store ist möglicherweise "
"nicht kompatibel."
#: dashboard/qml/WizardPage.qml:181
@@ -894,12 +890,11 @@ msgstr "Installiere über USB"
#, kde-format
msgid ""
"<p>No headset detected. Make sure that:\n"
"<ul><li>The ADB udev rules are installed</li><li>The headset is in <a "
"href=\"#\">developer mode</a></li></ul></p>"
"<ul><li>The ADB udev rules are installed</li><li>The headset is in <a href=\"#\">developer mode</a></li></ul></p>"
msgstr ""
"<p>Kein Headset gefunden. Stelle sicher:\n"
"<ul><li>Die ADB udev Regeln sind installiert</li><li>Das Headset hat "
"aktivierte <a href=\"#\">Entwickleroptionen</a></li></ul></p>"
"<p>Kein Headset erkannt. Stelle sicher, dass: <ul><li>Die ADB-udev-Regeln "
"installiert sind</li><li>Das Headset im <a href=\"#\">Entwicklermodus</a> "
"ist</li></ul></p>"
#: dashboard/qml/WizardPage.qml:295
#, kde-format
@@ -909,11 +904,11 @@ msgstr "Wichtige Informationen"
#: dashboard/qml/WizardPage.qml:301
#, kde-format
msgid ""
"WiVRn entirely replaces SteamVR, you should not start SteamVR while WiVRn is "
"running."
"WiVRn entirely replaces SteamVR, you should not start SteamVR while WiVRn is"
" running."
msgstr ""
"WiVRn ersetzt SteamVR komplett. Daher sollte SteamVR nicht gestartet werden, "
"während WiVRn aktiv ist."
"WiVRn ersetzt SteamVR vollständig; du solltest SteamVR nicht starten, "
"während WiVRn läuft."
#: dashboard/qml/WizardPage.qml:313
#, kde-format
@@ -923,17 +918,16 @@ msgstr "Starte die WiVRn-App auf dem Headset"
#: dashboard/qml/WizardPage.qml:319
#, kde-format
msgid ""
"To connect over WiFi, start the WiVRn app on your headset, connect to \"%1\" "
"and enter PIN \"%2\"."
"To connect over WiFi, start the WiVRn app on your headset, connect to \"%1\""
" and enter PIN \"%2\"."
msgstr ""
"Um eine Verbindung über WiFi aufzubauen, starte die WiVRn-App auf dem "
"Headset, verbinde zu \"%1\", und gib den PIN \"%2\" ein."
"Um dich über WLAN zu verbinden, starte die WiVRn-App auf deinem Headset, "
"verbinde dich mit „%1“ und gib die PIN „%2“ ein."
#: dashboard/qml/WizardPage.qml:326
#, kde-format
msgid "To connect over USB, click on \"Connect by USB\"."
msgstr ""
"Um eine Verbindung über USB aufzubauen, klicke auf \"Per USB verbinden\"."
msgstr "Um dich über USB zu verbinden, klicke auf „Verbinden per USB“."
#: dashboard/qml/WizardPage.qml:329
#, kde-format
@@ -951,9 +945,9 @@ msgid ""
"If the server is not visible or the connection fails, check that ports 5353 "
"(UDP) and 9757 (TCP and UDP) are open in your firewall."
msgstr ""
"Falls der Server nicht sichtbar ist oder die Verbindung fehlschlägt, stelle "
"sicher, dass die Ports 5353 (UDP) und 9757 (TCP und UPD) in der Firewall "
"offen sind."
"Wenn der Server nicht sichtbar ist oder die Verbindung fehlschlägt, prüfe, "
"ob die Ports 5353 (UDP) und 9757 (TCP und UDP) in deiner Firewall offen "
"sind."
#: dashboard/qml/WizardPage.qml:371
#, kde-format
@@ -976,8 +970,8 @@ msgid ""
"To connect another headset, make sure pairing is enabled in the dashboard "
"before connecting."
msgstr ""
"Um ein anderes Headset zu verbinden, stelle sicher, dass Koppeln im "
"Dashboard aktiviert ist, bevor eine Verbindung aufgebaut wird."
"Um ein weiteres Headset zu verbinden, stelle sicher, dass die Kopplung im "
"Dashboard aktiviert ist, bevor du dich verbindest."
#: dashboard/qml/WizardPage.qml:423 dashboard/qml/WizardPage.qml:460
#, kde-format
@@ -999,17 +993,45 @@ msgstr "Xrizer"
msgid "Open Composite"
msgstr "Open Composite"
msgid "Clamp extrapolation for SteamVR tracked devices"
msgstr "Extrapolation für SteamVR-getrackte Geräte begrenzen"
msgid "SteamVR max pose extrapolation"
msgstr "SteamVR maximale Posen-Extrapolation"
msgid "%1ms"
msgstr "%1ms"
msgid ""
"Maximum time in milliseconds that poses may be extrapolated ahead for "
"SteamVR tracked devices. Tune this value if you experience jittery or wobbly"
" tracking."
msgstr ""
"Maximale Zeit in Millisekunden, um die Posen für SteamVR-getrackte Geräte "
"extrapoliert werden. Passen Sie diesen Wert an, wenn das Tracking zitterig "
"oder wackelig wirkt."
msgid "SteamVR joystick deadzone"
msgstr "SteamVR Joystick-Totzone"
msgid ""
"Deadzone to apply to joysticks on lighthouse-tracked controllers, such as Index.\n"
"For standalone controllers, deadzones may be adjusted via the headset's system settings."
msgstr ""
"Totzone für die Joysticks von Lighthouse-getrackten Controllern wie dem Index.\n"
"Bei Standalone-Controllern kann die Totzone über die Systemeinstellungen des Headsets angepasst werden."
#, kde-format
#~ msgid "Forward keyboard & mouse from headset"
#~ msgstr "Tastatur- und Mauseingaben vom Headset weiterleiten"
#, kde-format
#~ msgid ""
#~ "Keyboard and mouse connected to the client will act as if connected to "
#~ "the server. Client OS may reserve specific keys and combinations, which "
#~ "cannot be forwarded."
#~ "Keyboard and mouse connected to the client will act as if connected to the "
#~ "server. Client OS may reserve specific keys and combinations, which cannot "
#~ "be forwarded."
#~ msgstr ""
#~ "Tastaturen und Mäuse, die mit dem Client verbunden sind werden sich so "
#~ "verhalten, als ob sie mit dem Server verbunden wären. Das Betriebssystem "
#~ "des Clients behält sich möglicherweise bestimmte Tasten und "
#~ "Tastenkombinationen vor, welche nicht weitergeleitet werden können."
#~ "verhalten, als ob sie mit dem Server verbunden wären. Das Betriebssystem des"
#~ " Clients behält sich möglicherweise bestimmte Tasten und Tastenkombinationen"
#~ " vor, welche nicht weitergeleitet werden können."
+218 -157
View File
File diff suppressed because it is too large Load Diff
+271 -188
View File
File diff suppressed because it is too large Load Diff
+275 -190
View File
File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More