Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
12354f0a95 |
No files matched your search
@@ -1,15 +0,0 @@
|
||||
# Copy to .env.local to report to Sentry from local builds.
|
||||
# Read by the gui (vite), electron and server (gradle) builds. Real environment variables win.
|
||||
# Rebuild after changing it, the values are baked in at build time.
|
||||
|
||||
# Forces a Sentry release. Without it only clean tagged builds report.
|
||||
# Source maps are never uploaded for a forced release.
|
||||
SENTRY_RELEASE=v0.0.0-local
|
||||
|
||||
# Keeps local events out of production alerts and release health. Defaults to production.
|
||||
SENTRY_ENVIRONMENT=development
|
||||
|
||||
# Leave a DSN empty to disable that part.
|
||||
SENTRY_GUI_DSN=
|
||||
SENTRY_ELECTRON_DSN=
|
||||
SENTRY_SERVER_DSN=
|
||||
@@ -1,9 +1,10 @@
|
||||
if ! has nix_direnv_version || ! nix_direnv_version 3.1.1; then
|
||||
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.1.1/direnvrc" "sha256-p+fzQdrms/hDa7g+soShAybJNo4bN4SIAeSfqNKgD5I="
|
||||
if ! has nix_direnv_version || ! nix_direnv_version 2.2.1; then
|
||||
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.2.1/direnvrc" "sha256-zelF0vLbEl5uaqrfIzbgNzJWGmLzCmYAkInj/LNxvKs="
|
||||
fi
|
||||
|
||||
watch_file package.json
|
||||
if ! use flake .
|
||||
nix_direnv_watch_file rust-toolchain.toml
|
||||
nix_direnv_watch_file package.json
|
||||
if ! use flake . --impure
|
||||
then
|
||||
echo "devenv could not be built. The devenv environment was not loaded. Make the necessary changes to devenv.nix and hit enter to try again." >&2
|
||||
fi
|
||||
@@ -3,5 +3,3 @@
|
||||
*.png binary
|
||||
*.webp binary
|
||||
*.gif binary
|
||||
|
||||
*.ftl -linguist-detectable
|
||||
@@ -1,3 +1,6 @@
|
||||
# Global code owner
|
||||
* @Eirenliel
|
||||
|
||||
# Make everyone be able to approve SolarXR submodule changes
|
||||
/solarxr-protocol @ButterscotchV @Erimelowo @loucass003
|
||||
|
||||
@@ -13,13 +16,20 @@
|
||||
|
||||
/gui/src/components/settings/ @Erimelowo @loucass003
|
||||
|
||||
# Electron part of the GUI
|
||||
/gui/electron/ @loucass003
|
||||
# Rust part of the GUI
|
||||
/gui/src-tauri/ @loucass003
|
||||
/Cargo.lock @loucass003
|
||||
|
||||
# Some server code~
|
||||
/server/ @ButterscotchV @loucass003 @Erimelowo
|
||||
/server/ @ButterscotchV @Eirenliel @Erimelowo
|
||||
|
||||
/bindings-provider/ @ImSapphire
|
||||
/server/src/main/java/dev/slimevr/autobone/ @ButterscotchV
|
||||
/server/src/main/java/dev/slimevr/poserecorder/ @ButterscotchV
|
||||
/server/src/main/java/dev/slimevr/posestreamer/ @ButterscotchV
|
||||
|
||||
/server/src/main/java/dev/slimevr/osc/ @Erimelowo
|
||||
/server/src/main/java/dev/slimevr/tracking/processor/ @Erimelowo
|
||||
/server/src/main/java/dev/slimevr/filtering/ @Erimelowo
|
||||
|
||||
# Linux files
|
||||
*.nix @loucass003
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
"Area: Continuous Integration":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: ".github/**"
|
||||
"Area: Application Protocol":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: ["solarxr-protocol"]
|
||||
"Area: AutoBone":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: "server/core/src/main/java/dev/slimevr/autobone/**"
|
||||
"Area: Documentation":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: "**/*.md"
|
||||
"Area: GUI":
|
||||
- all:
|
||||
- changed-files:
|
||||
- all-globs-to-any-file: ["gui/**/*", "!gui/public/i18n/**/*"]
|
||||
"Area: Hardware Protocol":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: "server/core/src/main/java/dev/slimevr/tracking/trackers/udp/**"
|
||||
"Area: Server":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: ["server/**", "*gradle*", "gradle/**"]
|
||||
"Area: Skeletal Model":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: "server/core/src/main/java/dev/slimevr/tracking/processor/**"
|
||||
"Area: SteamVR Driver":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: "server/desktop/src/main/java/dev/slimevr/desktop/platform/**"
|
||||
"Area: Translation":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: "gui/public/i18n/**"
|
||||
"Area: VMC":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: ["server/core/src/main/java/dev/slimevr/osc/Unity*", "server/core/src/main/java/dev/slimevr/osc/VMC*", "server/core/src/main/java/dev/slimevr/osc/VRM*"]
|
||||
"Area: VRCOSC":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: ["server/core/src/main/java/dev/slimevr/osc/VRC*"]
|
||||
@@ -0,0 +1,129 @@
|
||||
name: Build GUI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- .github/workflows/build-gui.yml
|
||||
- gui/**
|
||||
- package*.json
|
||||
pull_request:
|
||||
paths:
|
||||
- .github/workflows/build-gui.yml
|
||||
- gui/**
|
||||
- package*.json
|
||||
workflow_dispatch:
|
||||
create:
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- uses: pnpm/action-setup@v4
|
||||
- name: Use Node.js
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version-file: '.node-version'
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
pnpm i
|
||||
cd gui
|
||||
pnpm run lint
|
||||
|
||||
build:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os:
|
||||
[
|
||||
ubuntu-22.04,
|
||||
windows-latest,
|
||||
macos-latest,
|
||||
ubuntu-22.04-arm,
|
||||
windows-11-arm,
|
||||
]
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
env:
|
||||
# Don't mark warnings as errors
|
||||
CI: false
|
||||
BUILD_ARCH: ${{ endsWith(matrix.os, 'arm') && 'aarch64' || 'amd64' }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- if: startsWith(matrix.os, 'ubuntu')
|
||||
name: Set up Linux dependencies
|
||||
uses: awalsh128/[email protected]
|
||||
with:
|
||||
packages: libgtk-3-dev webkit2gtk-4.1 libappindicator3-dev librsvg2-dev patchelf
|
||||
# Increment to invalidate the cache
|
||||
version: ${{ format('v1.0-{0}', env.BUILD_ARCH) }}
|
||||
# Enables a workaround to attempt to run pre and post install scripts
|
||||
execute_install_scripts: true
|
||||
# Disables uploading logs as a build artifact
|
||||
debug: false
|
||||
|
||||
- if: matrix.os == 'windows-11-arm'
|
||||
uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
cache: false
|
||||
|
||||
- name: Cache cargo dependencies
|
||||
uses: Swatinem/rust-cache@v2
|
||||
|
||||
- uses: pnpm/action-setup@v4
|
||||
- name: Use Node.js
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version-file: '.node-version'
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Install dependencies
|
||||
shell: bash
|
||||
run: pnpm i
|
||||
|
||||
- name: Build
|
||||
shell: bash
|
||||
env:
|
||||
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
|
||||
NODE_OPTIONS: ${{ matrix.os == 'macos-latest' && '--max-old-space-size=4096' || '' }}
|
||||
run: pnpm run skipbundler --config $( ./gui/scripts/gitversion.mjs )
|
||||
|
||||
- if: startsWith(matrix.os, 'windows')
|
||||
name: Upload a Build Artifact (Windows)
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
# Artifact name
|
||||
name: ${{ format('SlimeVR-GUI-Windows-{0}', env.BUILD_ARCH) }}
|
||||
# A file, directory or wildcard pattern that describes what to upload
|
||||
path: target/release/slimevr.exe
|
||||
|
||||
- if: startsWith(matrix.os, 'ubuntu')
|
||||
name: Upload a Build Artifact (Linux)
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
# Artifact name
|
||||
name: ${{ format('SlimeVR-GUI-Linux-{0}', env.BUILD_ARCH) }}
|
||||
# A file, directory or wildcard pattern that describes what to upload
|
||||
path: target/release/slimevr
|
||||
|
||||
- if: matrix.os == 'macos-latest'
|
||||
name: Upload a Build Artifact (macOS)
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
# Artifact name
|
||||
name: SlimeVR-GUI-macOS
|
||||
# A file, directory or wildcard pattern that describes what to upload
|
||||
path: target/release/slimevr
|
||||
@@ -1,344 +0,0 @@
|
||||
name: SlimeVR Full Build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
tags: ["v*"]
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
setup-matrix:
|
||||
name: Configure Build Matrix
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
||||
matrix-cpp: ${{ steps.set-matrix.outputs.matrix-cpp }}
|
||||
steps:
|
||||
- id: set-matrix
|
||||
shell: bash
|
||||
run: |
|
||||
BASE='[{"os":"ubuntu-22.04","platform":"linux"},{"os":"windows-latest","platform":"windows"},{"os":"macos-latest","platform":"macos"}]'
|
||||
EXTRA='[{"os":"ubuntu-22.04-arm","platform":"linux"},{"os":"windows-11-arm","platform":"windows"}]'
|
||||
|
||||
if [[ "${{ github.ref }}" == refs/tags/v* || "${{ github.ref }}" == refs/heads/main || "${{ github.event_name }}" == "workflow_dispatch" ]]; then
|
||||
RESULT=$(echo "$BASE $EXTRA" | jq -c -s 'add')
|
||||
else
|
||||
RESULT=$(echo "$BASE" | jq -c '.')
|
||||
fi
|
||||
RESULT_CPP=$(echo "$RESULT" | jq -c '[ .[] | select ( (.platform != "macos") and ( (.platform != "windows") or (.os | endswith("-arm") | not) ) ) ]')
|
||||
|
||||
echo "matrix={\"include\":$RESULT}" >> "$GITHUB_OUTPUT"
|
||||
echo "matrix-cpp={\"include\":$RESULT_CPP}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
build-bindings-provider:
|
||||
name: Build bindings provider for ${{ matrix.os }}
|
||||
needs: [setup-matrix]
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix-cpp) }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
- if: matrix.platform == 'linux'
|
||||
name: Install GCC
|
||||
uses: egor-tensin/setup-gcc@v2
|
||||
with:
|
||||
version: 16
|
||||
- name: Get CMake
|
||||
uses: lukka/get-cmake@latest
|
||||
- name: Configure
|
||||
run: cmake -S bindings-provider/ -B bindings-provider/build -DCMAKE_BUILD_TYPE=Release
|
||||
- name: Build
|
||||
run: cmake --build bindings-provider/build --config Release -j6
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: bindings-provider-${{ matrix.platform }}-${{ matrix.os }}
|
||||
path: |
|
||||
bindings-provider/build/slimevr-bindings-provider
|
||||
bindings-provider/build/libopenvr_api.so
|
||||
bindings-provider/build/Release/SlimeVR-Bindings-Provider.exe
|
||||
bindings-provider/build/openvr_api.dll
|
||||
|
||||
gui-checks:
|
||||
name: Gui Checks
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Get tags
|
||||
run: git fetch --tags origin --recurse-submodules=no --force
|
||||
- name: Setup PNPM
|
||||
uses: pnpm/action-setup@v6
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version-file: '.node-version'
|
||||
cache: 'pnpm'
|
||||
- name: GUI Lint
|
||||
run: pnpm i && pnpm run lint
|
||||
|
||||
server-checks:
|
||||
name: Server Checks
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Set up JDK 25
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
java-version: '25'
|
||||
distribution: 'temurin'
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@v6
|
||||
- name: Server Spotless Check
|
||||
run: ./gradlew spotlessCheck --build-cache
|
||||
|
||||
build-server-jar:
|
||||
name: Build Desktop Server
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Get tags
|
||||
run: git fetch --tags origin --recurse-submodules=no --force
|
||||
- name: Set up JDK 25
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
java-version: '25'
|
||||
distribution: 'temurin'
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@v6
|
||||
- name: Build ShadowJar
|
||||
run: ./gradlew :server:desktop:shadowJar --build-cache
|
||||
env:
|
||||
SENTRY_SERVER_DSN: ${{ vars.SENTRY_SERVER_DSN }}
|
||||
- name: Test with Gradle
|
||||
run: ./gradlew :server:core:jvmTest
|
||||
- name: Upload Server Jar
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: server-jar
|
||||
path: |
|
||||
server/desktop/build/libs/slimevr.jar
|
||||
server/core/resources
|
||||
|
||||
build-gui-frontend:
|
||||
name: Build GUI Assets
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Get tags
|
||||
run: git fetch --tags origin --recurse-submodules=no --force
|
||||
- name: Setup PNPM
|
||||
uses: pnpm/action-setup@v6
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version-file: '.node-version'
|
||||
cache: 'pnpm'
|
||||
- name: Build JS
|
||||
env:
|
||||
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
|
||||
SENTRY_GUI_DSN: ${{ vars.SENTRY_GUI_DSN }}
|
||||
SENTRY_ELECTRON_DSN: ${{ vars.SENTRY_ELECTRON_DSN }}
|
||||
SENTRY_SERVER_DSN: ${{ vars.SENTRY_SERVER_DSN }}
|
||||
run: pnpm i && pnpm run build
|
||||
- name: Tar GUI Dist
|
||||
run: tar -czf slimevr-gui-dist.tar.gz -C gui/electron/out .
|
||||
- name: Upload GUI Dist
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: gui-dist
|
||||
path: slimevr-gui-dist.tar.gz
|
||||
|
||||
package-desktop:
|
||||
name: Package Desktop (${{ matrix.platform }} - ${{ matrix.os }})
|
||||
needs: [setup-matrix, build-server-jar, build-gui-frontend, build-bindings-provider]
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Get tags
|
||||
run: git fetch --tags origin --recurse-submodules=no --force
|
||||
- name: Setup PNPM
|
||||
uses: pnpm/action-setup@v6
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version-file: '.node-version'
|
||||
cache: 'pnpm'
|
||||
- name: Download Server Jar
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: server-jar
|
||||
path: server
|
||||
- if: contains(fromJson(needs.setup-matrix.outputs.matrix-cpp).include.*.os, matrix.os)
|
||||
name: Download bindings provider artifact
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: bindings-provider-${{ matrix.platform }}-${{ matrix.os }}
|
||||
path: bindings-provider/build/${{ matrix.platform == 'windows' && 'win' || 'linux' }}-${{ endsWith(matrix.os, '-arm') && 'arm64' || 'x64' }}
|
||||
- name: Download GUI Dist
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: gui-dist
|
||||
- name: Extract GUI for Electron
|
||||
shell: bash
|
||||
run: mkdir -p gui/electron/out && tar -xzf slimevr-gui-dist.tar.gz -C gui/electron/out
|
||||
- name: Run Electron Builder
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p gui/electron/dist/artifacts/linux/ \
|
||||
gui/electron/dist/artifacts/win \
|
||||
gui/electron/dist/artifacts/mac
|
||||
VERSION=$(git --no-pager tag --sort -taggerdate --points-at HEAD | head -1)
|
||||
[ -z "$VERSION" ] && VERSION="0.0.0"
|
||||
VERSION="${VERSION#v}"
|
||||
echo "Building version: $VERSION"
|
||||
pnpm i
|
||||
cd gui/electron
|
||||
pnpm exec electron-builder --${{ matrix.platform }} \
|
||||
${{ matrix.platform == 'macos' && '--universal' || '' }} \
|
||||
--config.extraMetadata.version="$VERSION" \
|
||||
--publish never
|
||||
- name: Collect and Rename Artifacts
|
||||
shell: bash
|
||||
run: |
|
||||
SRC_DIR="${{ github.workspace }}/gui/electron/dist/artifacts"
|
||||
DEST_DIR="${{ github.workspace }}/release-out"
|
||||
mkdir -p "$DEST_DIR"
|
||||
|
||||
if [ "${{ matrix.platform }}" == "windows" ]; then
|
||||
[[ "${{ matrix.os }}" == *"arm"* ]] && SUFFIX="win-aarch64" || SUFFIX="win64"
|
||||
cp "$SRC_DIR"/win/*.zip "$DEST_DIR/SlimeVR-$SUFFIX.zip"
|
||||
|
||||
elif [ "${{ matrix.platform }}" == "linux" ]; then
|
||||
for f in "$SRC_DIR"/linux/*; do
|
||||
[ -d "$f" ] && continue
|
||||
BASE=$(basename "$f")
|
||||
NEW_NAME=$(echo "$BASE" | sed -e 's/x86_64/amd64/g' -e 's/arm64/aarch64/g')
|
||||
cp "$f" "$DEST_DIR/$NEW_NAME"
|
||||
done
|
||||
|
||||
elif [ "${{ matrix.platform }}" == "macos" ]; then
|
||||
cp "$SRC_DIR"/mac/*.dmg "$DEST_DIR/SlimeVR-mac.dmg"
|
||||
fi
|
||||
|
||||
echo "Collected files:"
|
||||
ls -lh "$DEST_DIR"
|
||||
- name: Upload For Release
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: release-${{ matrix.platform }}-${{ matrix.os }}
|
||||
path: release-out/*
|
||||
|
||||
bundle-android:
|
||||
name: Build Android APK
|
||||
needs: [build-gui-frontend]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Get tags
|
||||
run: git fetch --tags origin --recurse-submodules=no --force
|
||||
- name: Set up JDK 25
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
java-version: '25'
|
||||
distribution: 'temurin'
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@v6
|
||||
- name: Download GUI Dist
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: gui-dist
|
||||
- name: Extract GUI for Android
|
||||
run: mkdir -p gui/electron/out && tar -xzf slimevr-gui-dist.tar.gz -C gui/electron/out
|
||||
- name: Build APK
|
||||
run: ./gradlew :server:android:build --build-cache
|
||||
env:
|
||||
SENTRY_SERVER_DSN: ${{ vars.SENTRY_SERVER_DSN }}
|
||||
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
|
||||
ANDROID_STORE_FILE: ${{ secrets.ANDROID_STORE_FILE }}
|
||||
ANDROID_STORE_PASSWD: ${{ secrets.ANDROID_STORE_PASSWD }}
|
||||
ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }}
|
||||
ANDROID_KEY_PASSWD: ${{ secrets.ANDROID_KEY_PASSWD }}
|
||||
- name: Prepare APK
|
||||
run: cp server/android/build/outputs/apk/release/*.apk ./SlimeVR-android.apk
|
||||
- name: Upload APK
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: release-android
|
||||
path: SlimeVR-android.apk
|
||||
|
||||
- name: Build Google Play release bundle
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
run: ./gradlew :server:android:bundleRelease
|
||||
env:
|
||||
SENTRY_SERVER_DSN: ${{ vars.SENTRY_SERVER_DSN }}
|
||||
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
|
||||
ANDROID_STORE_FILE: ${{ secrets.ANDROID_GPLAY_STORE_FILE }}
|
||||
ANDROID_STORE_PASSWD: ${{ secrets.ANDROID_GPLAY_STORE_PASSWD }}
|
||||
ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_GPLAY_KEY_ALIAS }}
|
||||
ANDROID_KEY_PASSWD: ${{ secrets.ANDROID_GPLAY_KEY_PASSWD }}
|
||||
|
||||
- name: Upload the Google Play artifact
|
||||
uses: actions/upload-artifact@v7
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
# Artifact name
|
||||
name: 'SlimeVR-Android-GPDev' # optional, default is artifact
|
||||
# A file, directory or wildcard pattern that describes what to upload
|
||||
path: server/android/build/outputs/bundle/release/*
|
||||
|
||||
create-release:
|
||||
name: Finalize Release Draft
|
||||
needs: [package-desktop, bundle-android, build-server-jar, build-gui-frontend]
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Download All Release Artifacts
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
pattern: release-*
|
||||
path: release-out
|
||||
merge-multiple: true
|
||||
- name: Download Server Jar
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: server-jar
|
||||
path: server
|
||||
- name: Download GUI Dist
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: gui-dist
|
||||
- name: Create GitHub Release
|
||||
uses: softprops/action-gh-release@v3
|
||||
with:
|
||||
draft: true
|
||||
generate_release_notes: true
|
||||
files: |
|
||||
release-out/*
|
||||
server/desktop/build/libs/slimevr.jar
|
||||
slimevr-gui-dist.tar.gz
|
||||
@@ -20,13 +20,13 @@ jobs:
|
||||
run: |
|
||||
npx @slimevr/update-manifest-generator@latest
|
||||
|
||||
- uses: actions/upload-artifact@v7
|
||||
- uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: "update-manifest.json"
|
||||
path: ./update-manifest.json
|
||||
|
||||
- name: Upload update-manifest.json to release
|
||||
uses: softprops/action-gh-release@v3
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: ${{ secrets.UPDATE_MANIFEST_RELEASE_TAG }}
|
||||
files: ./update-manifest.json
|
||||
|
||||
@@ -0,0 +1,413 @@
|
||||
# This workflow will build a Java project with Gradle
|
||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
|
||||
|
||||
name: SlimeVR Server
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
create:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Get tags
|
||||
run: git fetch --tags origin --recurse-submodules=no --force
|
||||
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
java-version: '17'
|
||||
distribution: 'adopt'
|
||||
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@v5
|
||||
|
||||
- run: mkdir ./gui/dist && touch ./gui/dist/somefile
|
||||
shell: bash
|
||||
|
||||
- name: Check code formatting
|
||||
run: ./gradlew spotlessCheck
|
||||
|
||||
- name: Test with Gradle
|
||||
run: ./gradlew test
|
||||
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Get tags
|
||||
run: git fetch --tags origin --recurse-submodules=no --force
|
||||
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
java-version: '17'
|
||||
distribution: 'adopt'
|
||||
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@v5
|
||||
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew :server:desktop:shadowJar
|
||||
|
||||
- name: Upload the Server JAR as a Build Artifact
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
# Artifact name
|
||||
name: 'SlimeVR-Server' # optional, default is artifact
|
||||
# A file, directory or wildcard pattern that describes what to upload
|
||||
path: server/desktop/build/libs/slimevr.jar
|
||||
|
||||
- name: Upload to draft release
|
||||
uses: softprops/action-gh-release@v2
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
draft: true
|
||||
generate_release_notes: true
|
||||
files: |
|
||||
server/desktop/build/libs/slimevr.jar
|
||||
|
||||
bundle-android:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Get tags
|
||||
run: git fetch --tags origin --recurse-submodules=no --force
|
||||
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
java-version: '17'
|
||||
distribution: 'adopt'
|
||||
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@v5
|
||||
|
||||
- uses: pnpm/action-setup@v4
|
||||
- name: Use Node.js
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version-file: '.node-version'
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm i
|
||||
|
||||
- name: Build GUI
|
||||
env:
|
||||
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
|
||||
run: cd gui && pnpm run build
|
||||
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew :server:android:build
|
||||
env:
|
||||
ANDROID_STORE_FILE: ${{ secrets.ANDROID_STORE_FILE }}
|
||||
ANDROID_STORE_PASSWD: ${{ secrets.ANDROID_STORE_PASSWD }}
|
||||
ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }}
|
||||
ANDROID_KEY_PASSWD: ${{ secrets.ANDROID_KEY_PASSWD }}
|
||||
|
||||
- name: Upload the Android build artifact
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
# Artifact name
|
||||
name: 'SlimeVR-Android' # optional, default is artifact
|
||||
# A file, directory or wildcard pattern that describes what to upload
|
||||
path: server/android/build/outputs/apk/*
|
||||
|
||||
- name: Prepare for release
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
run: |
|
||||
cp server/android/build/outputs/apk/release/android-release.apk ./SlimeVR-android.apk
|
||||
|
||||
- name: Upload to draft release
|
||||
uses: softprops/action-gh-release@v2
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
draft: true
|
||||
generate_release_notes: true
|
||||
files: |
|
||||
./SlimeVR-android.apk
|
||||
|
||||
- name: Build Google Play release bundle
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
run: ./gradlew :server:android:bundleRelease
|
||||
env:
|
||||
ANDROID_STORE_FILE: ${{ secrets.ANDROID_GPLAY_STORE_FILE }}
|
||||
ANDROID_STORE_PASSWD: ${{ secrets.ANDROID_GPLAY_STORE_PASSWD }}
|
||||
ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_GPLAY_KEY_ALIAS }}
|
||||
ANDROID_KEY_PASSWD: ${{ secrets.ANDROID_GPLAY_KEY_PASSWD }}
|
||||
|
||||
- name: Upload the Google Play artifact
|
||||
uses: actions/upload-artifact@v6
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
# Artifact name
|
||||
name: 'SlimeVR-Android-GPDev' # optional, default is artifact
|
||||
# A file, directory or wildcard pattern that describes what to upload
|
||||
path: server/android/build/outputs/bundle/release/*
|
||||
|
||||
bundle-linux:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, ubuntu-24.04-arm]
|
||||
runs-on: ${{ matrix.os }}
|
||||
needs: [build, test]
|
||||
if: contains(fromJSON('["workflow_dispatch", "create"]'), github.event_name)
|
||||
|
||||
env:
|
||||
BUILD_ARCH: ${{ endsWith(matrix.os, 'arm') && 'aarch64' || 'amd64' }}
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- uses: actions/download-artifact@v7
|
||||
with:
|
||||
name: 'SlimeVR-Server'
|
||||
path: server/desktop/build/libs/
|
||||
|
||||
- name: Set up Linux dependencies
|
||||
uses: awalsh128/[email protected]
|
||||
with:
|
||||
packages: |
|
||||
build-essential curl wget file libssl-dev libgtk-3-dev libappindicator3-dev librsvg2-dev xdg-utils
|
||||
# Increment to invalidate the cache
|
||||
version: ${{ format('v1.0-{0}', env.BUILD_ARCH) }}
|
||||
# Enables a workaround to attempt to run pre and post install scripts
|
||||
execute_install_scripts: true
|
||||
# Disables uploading logs as a build artifact
|
||||
debug: false
|
||||
|
||||
- name: Set up specific Linux versioned dependencies
|
||||
run: |
|
||||
sudo apt-get update && sudo apt-get install -y \
|
||||
libwebkit2gtk-4.1-0=2.44.0-2 \
|
||||
libwebkit2gtk-4.1-dev=2.44.0-2 \
|
||||
libjavascriptcoregtk-4.1-0=2.44.0-2 \
|
||||
libjavascriptcoregtk-4.1-dev=2.44.0-2 \
|
||||
gir1.2-javascriptcoregtk-4.1=2.44.0-2 \
|
||||
gir1.2-webkit2-4.1=2.44.0-2;
|
||||
|
||||
- name: Cache cargo dependencies
|
||||
uses: Swatinem/rust-cache@v2
|
||||
|
||||
- uses: pnpm/action-setup@v4
|
||||
- name: Use Node.js
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version-file: '.node-version'
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm i
|
||||
|
||||
- name: Build
|
||||
env:
|
||||
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
|
||||
run: pnpm run tauri build --config $( ./gui/scripts/gitversion.mjs )
|
||||
|
||||
- name: Make GUI tarball
|
||||
run: |
|
||||
tar czf slimevr-gui-dist.tar.gz -C gui/dist/ .
|
||||
|
||||
- uses: actions/upload-artifact@v6
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
with:
|
||||
name: SlimeVR-GUI-Dist
|
||||
path: ./slimevr-gui-dist.tar.gz
|
||||
|
||||
- uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: ${{ format('SlimeVR-GUI-Deb-{0}', env.BUILD_ARCH) }}
|
||||
path: target/release/bundle/deb/slimevr*.deb
|
||||
|
||||
- uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: ${{ format('SlimeVR-GUI-AppImage-{0}', env.BUILD_ARCH) }}
|
||||
path: target/release/bundle/appimage/slimevr*.AppImage
|
||||
|
||||
- uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: ${{ format('SlimeVR-GUI-RPM-{0}', env.BUILD_ARCH) }}
|
||||
path: target/release/bundle/rpm/slimevr*.rpm
|
||||
|
||||
- name: Prepare for release
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
run: |
|
||||
cp target/release/bundle/appimage/slimevr*.AppImage "./SlimeVR-$BUILD_ARCH.appimage"
|
||||
cp target/release/bundle/deb/slimevr*.deb "./SlimeVR-$BUILD_ARCH.deb"
|
||||
cp target/release/bundle/rpm/slimevr*.rpm "./SlimeVR-$BUILD_ARCH.rpm"
|
||||
|
||||
- name: Upload to draft release
|
||||
uses: softprops/action-gh-release@v2
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
draft: true
|
||||
generate_release_notes: true
|
||||
files: |
|
||||
./slimevr-gui-dist.tar.gz
|
||||
./SlimeVR-*.appimage
|
||||
./SlimeVR-*.deb
|
||||
./SlimeVR-*.rpm
|
||||
|
||||
bundle-mac:
|
||||
runs-on: macos-latest
|
||||
needs: [build, test]
|
||||
if: contains(fromJSON('["workflow_dispatch", "create"]'), github.event_name)
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- uses: actions/download-artifact@v7
|
||||
with:
|
||||
name: 'SlimeVR-Server'
|
||||
path: server/desktop/build/libs/
|
||||
|
||||
- name: Cache cargo dependencies
|
||||
uses: Swatinem/rust-cache@v2
|
||||
|
||||
- uses: pnpm/action-setup@v4
|
||||
- name: Use Node.js
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version-file: '.node-version'
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
rustup target add x86_64-apple-darwin
|
||||
pnpm i
|
||||
|
||||
- name: Build
|
||||
env:
|
||||
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
|
||||
NODE_OPTIONS: --max-old-space-size=4096
|
||||
run: pnpm run tauri build --target universal-apple-darwin --config $( ./gui/scripts/gitversion.mjs )
|
||||
|
||||
- name: Modify Application
|
||||
run: |
|
||||
cd target/universal-apple-darwin/release/bundle/macos/slimevr.app/Contents/MacOS
|
||||
cp $( git rev-parse --show-toplevel )/server/desktop/build/libs/slimevr.jar ./
|
||||
cd ../../../
|
||||
/usr/libexec/PlistBuddy -c "Set :CFBundleDisplayName SlimeVR" slimevr.app/Contents/Info.plist
|
||||
/usr/libexec/PlistBuddy -c "Set :CFBundleName SlimeVR" slimevr.app/Contents/Info.plist
|
||||
codesign --sign - --deep --force slimevr.app
|
||||
mv slimevr.app SlimeVR.app
|
||||
cd ../dmg/
|
||||
./bundle_dmg.sh --volname SlimeVR --icon slimevr 180 170 --app-drop-link 480 170 \
|
||||
--window-size 660 400 --hide-extension ../macos/SlimeVR.app \
|
||||
--volicon ../macos/SlimeVR.app/Contents/Resources/icon.icns --skip-jenkins \
|
||||
--eula ../../../../../LICENSE-MIT slimevr.dmg ../macos/SlimeVR.app
|
||||
|
||||
- uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: SlimeVR-GUI-MacApp
|
||||
path: target/universal-apple-darwin/release/bundle/macos/SlimeVR*.app
|
||||
|
||||
- uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: SlimeVR-GUI-MacDmg
|
||||
path: target/universal-apple-darwin/release/bundle/dmg/slimevr.dmg
|
||||
|
||||
- name: Prepare for release
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
run: |
|
||||
cp target/universal-apple-darwin/release/bundle/dmg/slimevr.dmg ./SlimeVR-mac.dmg
|
||||
|
||||
- name: Upload to draft release
|
||||
uses: softprops/action-gh-release@v2
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
draft: true
|
||||
generate_release_notes: true
|
||||
files: |
|
||||
./SlimeVR-mac.dmg
|
||||
|
||||
bundle-windows:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [windows-latest, windows-11-arm]
|
||||
runs-on: ${{ matrix.os }}
|
||||
needs: [build, test]
|
||||
if: contains(fromJSON('["workflow_dispatch", "create"]'), github.event_name)
|
||||
|
||||
env:
|
||||
BUILD_ARCH: ${{ endsWith(matrix.os, 'arm') && 'win-aarch64' || 'win64' }}
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- uses: actions/download-artifact@v7
|
||||
with:
|
||||
name: 'SlimeVR-Server'
|
||||
path: server/desktop/build/libs/
|
||||
|
||||
- if: matrix.os == 'windows-11-arm'
|
||||
uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
cache: false
|
||||
|
||||
- name: Cache cargo dependencies
|
||||
uses: Swatinem/rust-cache@v2
|
||||
|
||||
- uses: pnpm/action-setup@v4
|
||||
- name: Use Node.js
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version-file: '.node-version'
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Install dependencies
|
||||
shell: bash
|
||||
run: pnpm i
|
||||
|
||||
- name: Build
|
||||
shell: bash
|
||||
env:
|
||||
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
|
||||
run: pnpm run skipbundler --config $( ./gui/scripts/gitversion.mjs )
|
||||
|
||||
- name: Bundle to zips
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir SlimeVR
|
||||
cp gui/src-tauri/icons/icon.ico ./SlimeVR/run.ico
|
||||
cp server/desktop/build/libs/slimevr.jar ./SlimeVR/slimevr.jar
|
||||
cp server/core/resources/* ./SlimeVR/
|
||||
cp target/release/slimevr.exe ./SlimeVR/
|
||||
7z a -tzip "SlimeVR-$BUILD_ARCH.zip" ./SlimeVR/
|
||||
|
||||
- uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: ${{ format('SlimeVR-GUI-Windows-{0}', env.BUILD_ARCH) }}
|
||||
path: ./SlimeVR*.zip
|
||||
|
||||
- name: Upload to draft release
|
||||
uses: softprops/action-gh-release@v2
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
draft: true
|
||||
generate_release_notes: true
|
||||
files: ./SlimeVR-*.zip
|
||||
@@ -0,0 +1,22 @@
|
||||
# This workflow will triage pull requests and apply a label based on the
|
||||
# paths that are modified in the pull request.
|
||||
#
|
||||
# To use this workflow, you will need to set up a .github/labeler.yml
|
||||
# file with configuration. For more information, see:
|
||||
# https://github.com/actions/labeler
|
||||
|
||||
name: Labeler
|
||||
on: [pull_request_target]
|
||||
|
||||
jobs:
|
||||
label:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
|
||||
steps:
|
||||
- uses: actions/labeler@v6
|
||||
with:
|
||||
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
@@ -4,12 +4,8 @@
|
||||
# Syncthing ignore file
|
||||
.stignore
|
||||
|
||||
# Ignore .idea, except shared project inspection profiles and run configurations
|
||||
.idea/*
|
||||
!.idea/inspectionProfiles/
|
||||
!.idea/inspectionProfiles/*.xml
|
||||
!.idea/runConfigurations/
|
||||
!.idea/runConfigurations/*.xml
|
||||
# Ignore .idea
|
||||
.idea
|
||||
|
||||
# Ignore .fleet
|
||||
.fleet
|
||||
@@ -38,24 +34,15 @@
|
||||
# ignore gradle build folder
|
||||
build/
|
||||
|
||||
# created by clangd for index cache
|
||||
.cache/
|
||||
# Rust build artifacts
|
||||
/target
|
||||
|
||||
# direnv has been claimed for Nix usage
|
||||
.direnv/
|
||||
.devenv
|
||||
|
||||
# Git worktrees
|
||||
.worktree/
|
||||
|
||||
# Ignore Android local properties
|
||||
local.properties
|
||||
|
||||
# Ignore temporary config
|
||||
vrconfig.yml.tmp
|
||||
|
||||
|
||||
# Nixos
|
||||
.bin/
|
||||
|
||||
.env.local
|
||||
@@ -1,6 +1,3 @@
|
||||
[submodule "solarxr-protocol"]
|
||||
path = solarxr-protocol
|
||||
url = https://github.com/SlimeVR/SolarXR-Protocol.git
|
||||
[submodule "svr-bindings-provider/openvr"]
|
||||
path = bindings-provider/openvr
|
||||
url = https://github.com/ValveSoftware/openvr.git
|
||||
@@ -1,6 +0,0 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="ConvertLongToDuration" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
</profile>
|
||||
</component>
|
||||
@@ -1,7 +0,0 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="PROJECT_PROFILE" value="Project Default" />
|
||||
<option name="USE_PROJECT_PROFILE" value="true" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
||||
@@ -1,11 +0,0 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="SlimeVR Desktop" type="JetRunConfigurationType" factoryName="Kotlin">
|
||||
<module name="SlimeVR_Server.server.desktop.main" />
|
||||
<option name="MAIN_CLASS_NAME" value="dev.slimevr.desktop.Main" />
|
||||
<option name="VM_PARAMETERS" value="--enable-native-access=ALL-UNNAMED" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/server/desktop" />
|
||||
<method v="2">
|
||||
<option name="Make" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
@@ -7,6 +7,7 @@
|
||||
"gaborv.flatbuffers",
|
||||
"dbaeumer.vscode-eslint",
|
||||
"esbenp.prettier-vscode",
|
||||
"rust-lang.rust-analyzer",
|
||||
"bradlc.vscode-tailwindcss",
|
||||
"EditorConfig.EditorConfig",
|
||||
"macabeus.vscode-fluent",
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
# Contributing to SlimeVR
|
||||
|
||||
Please follow general contribution guidelines: [CONTRIBUTING.md](https://github.com/SlimeVR/.github/blob/main/profile/CONTRIBUTING.md).
|
||||
|
||||
This document describes essential knowledge required to contribute to the SlimeVR Server.
|
||||
|
||||
### Prerequisites
|
||||
@@ -9,6 +7,8 @@ This document describes essential knowledge required to contribute to the SlimeV
|
||||
- [Git](https://git-scm.com/downloads)
|
||||
- [Java v17+](https://adoptium.net/temurin/releases/)
|
||||
- [Node.js v16.9+](https://nodejs.org) (We recommend the use of `nvm` instead of installing Node.js directly)
|
||||
- [Microsoft Edge WebView2](https://developer.microsoft.com/en-us/microsoft-edge/webview2/#download-section) or `webkit2gtk` for Linux
|
||||
- [Rust](https://rustup.rs)
|
||||
|
||||
## Cloning the code
|
||||
First, clone the codebase using git in a terminal in the folder you want.
|
||||
@@ -24,26 +24,21 @@ Now you can open the codebase in [IDEA](https://www.jetbrains.com/idea/download/
|
||||
|
||||
### Java (server)
|
||||
|
||||
Before contributing to the server, read [server/README.md](server/README.md) for an overview of its architecture and design guidelines.
|
||||
|
||||
The Java code is built with `gradle`, a CLI tool that manages java projects and their
|
||||
dependencies.
|
||||
- You can run the server by running `./gradlew :server:desktop:run` in your IDE's terminal.
|
||||
- You can run the server by running `./gradlew run` in your IDE's terminal.
|
||||
- To compile the code, run `./gradlew shadowJar`. The result will
|
||||
be at `server/desktop/build/libs/slimevr.jar` (you can ignore `server.jar`).
|
||||
be at `server/build/libs/slimevr.jar` (you can ignore `server.jar`).
|
||||
|
||||
(Note: Your IDE may be able to do all of the above for you.)
|
||||
|
||||
### Electron (gui)
|
||||
### Tauri (gui)
|
||||
|
||||
- Activate corepack (included with Node.js) via `corepack enable`
|
||||
(might require launching Git Bash as administrator on Windows)
|
||||
- Make sure you're at the root of the repository.
|
||||
- Activate corepack (included with Node.JS) via `corepack enable` (might require administrator permissions)
|
||||
- Run `pnpm i` in your IDE's terminal to download and install dependencies.
|
||||
- To launch the GUI in dev mode, run `pnpm gui`.
|
||||
- If you get an "Electron uninstall" error, run `node .\gui\electron\node_modules\electron\install.js`.
|
||||
- Finally, to compile for production, run `pnpm package:build` under `gui/electron`.
|
||||
The result will be in `gui/dist/artifacts/`. Content will change depending on the platform.
|
||||
- Finally, to compile for production, run `pnpm run tauri build`. The result
|
||||
will be at `target/release/slimevr.exe`.
|
||||
|
||||
## Code style
|
||||
|
||||
@@ -89,10 +84,10 @@ Import the formatting settings defined in `spotless.xml`, like this:
|
||||
Eclipse will only do a subset of the checks in `spotless`, so you may still want to do
|
||||
`./gradlew spotlessApply` if you ever see an error from spotless.
|
||||
|
||||
### Electron (gui)
|
||||
### Tauri (gui)
|
||||
|
||||
We use ESLint and Prettier to format GUI code.
|
||||
- Make sure you're at the root of the repository.
|
||||
- First, go into the GUI's directory with your terminal by running `cd gui`.
|
||||
- To check code formatting, run `pnpm run lint`.
|
||||
- To fix code formatting, run `pnpm run lint:fix` and `pnpm run format`
|
||||
|
||||
@@ -121,9 +116,3 @@ licensed under `GPL-v3`.
|
||||
## Discord
|
||||
We use discord *a lot* to coordinate and discuss development. Come join us at
|
||||
https://discord.gg/SlimeVR!
|
||||
|
||||
## Use of AI
|
||||
We DO NOT accept contributions that are generated with AI (for example, "vibe-coding").
|
||||
|
||||
If you do use AI, and you believe your usage of AI is reasonable, you must clearly disclose
|
||||
how you used AI in your submission.
|
||||
@@ -0,0 +1,16 @@
|
||||
[workspace]
|
||||
# Use 2021 edition resolver, better resolves crate features.
|
||||
resolver = "2"
|
||||
|
||||
# A list of all rust crates in the workspace.
|
||||
members = ["gui/src-tauri"]
|
||||
|
||||
# These settings can be inherited by workspace members
|
||||
[workspace.package]
|
||||
edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
rust-version = "1.82" # Tauri's MSRV
|
||||
repository = "https://github.com/SlimeVR/SlimeVR-Server"
|
||||
|
||||
[profile.release]
|
||||
lto = "thin"
|
||||
@@ -22,8 +22,6 @@ Latest setup instructions are [in our docs](https://docs.slimevr.dev/server/inde
|
||||
## Building & Contributing
|
||||
For information on building and contributing to the codebase, see [CONTRIBUTING.md](CONTRIBUTING.md).
|
||||
|
||||
For an overview of the server architecture and design guidelines, see [server/README.md](server/README.md).
|
||||
|
||||
## Translating
|
||||
|
||||
Translation is done via Pontoon at [i18n.slimevr.dev](https://i18n.slimevr.dev/). Please join our [Discord translation forum](https://discord.com/channels/817184208525983775/1050413434249949235) to coordinate.
|
||||
|
||||
@@ -1,299 +0,0 @@
|
||||
---
|
||||
Language: Cpp
|
||||
AccessModifierOffset: -4
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignArrayOfStructures: None
|
||||
AlignConsecutiveAssignments:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
AlignFunctionDeclarations: false
|
||||
AlignFunctionPointers: false
|
||||
PadOperators: true
|
||||
AlignConsecutiveBitFields:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
AlignFunctionDeclarations: false
|
||||
AlignFunctionPointers: false
|
||||
PadOperators: false
|
||||
AlignConsecutiveDeclarations:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
AlignFunctionDeclarations: true
|
||||
AlignFunctionPointers: false
|
||||
PadOperators: false
|
||||
AlignConsecutiveMacros:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
AlignFunctionDeclarations: false
|
||||
AlignFunctionPointers: false
|
||||
PadOperators: false
|
||||
AlignConsecutiveShortCaseStatements:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCaseArrows: false
|
||||
AlignCaseColons: false
|
||||
AlignConsecutiveTableGenBreakingDAGArgColons:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
AlignFunctionDeclarations: false
|
||||
AlignFunctionPointers: false
|
||||
PadOperators: false
|
||||
AlignConsecutiveTableGenCondOperatorColons:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
AlignFunctionDeclarations: false
|
||||
AlignFunctionPointers: false
|
||||
PadOperators: false
|
||||
AlignConsecutiveTableGenDefinitionColons:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
AlignFunctionDeclarations: false
|
||||
AlignFunctionPointers: false
|
||||
PadOperators: false
|
||||
AlignEscapedNewlines: Right
|
||||
AlignOperands: DontAlign
|
||||
AlignTrailingComments:
|
||||
Kind: Always
|
||||
OverEmptyLines: 2
|
||||
AllowAllArgumentsOnNextLine: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
AllowBreakBeforeNoexceptSpecifier: Never
|
||||
AllowShortBlocksOnASingleLine: Empty
|
||||
AllowShortCaseExpressionOnASingleLine: true
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortCompoundRequirementOnASingleLine: true
|
||||
AllowShortEnumsOnASingleLine: true
|
||||
AllowShortFunctionsOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AllowShortNamespacesOnASingleLine: false
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AttributeMacros:
|
||||
- __capability
|
||||
BinPackArguments: true
|
||||
BinPackLongBracedList: true
|
||||
BinPackParameters: BinPack
|
||||
BitFieldColonSpacing: Both
|
||||
BracedInitializerIndentWidth: -1
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: false
|
||||
AfterControlStatement: Never
|
||||
AfterEnum: false
|
||||
AfterExternBlock: false
|
||||
AfterFunction: true
|
||||
AfterNamespace: false
|
||||
AfterObjCDeclaration: false
|
||||
AfterStruct: false
|
||||
AfterUnion: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
BeforeLambdaBody: false
|
||||
BeforeWhile: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: true
|
||||
SplitEmptyRecord: true
|
||||
SplitEmptyNamespace: true
|
||||
BreakAdjacentStringLiterals: true
|
||||
BreakAfterAttributes: Leave
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakAfterReturnType: None
|
||||
BreakArrays: true
|
||||
BreakBeforeBinaryOperators: All
|
||||
BreakBeforeConceptDeclarations: Always
|
||||
BreakBeforeBraces: Attach
|
||||
BreakBeforeInlineASMColon: OnlyMultiline
|
||||
BreakBeforeTemplateCloser: false
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakBinaryOperations: Never
|
||||
BreakConstructorInitializers: BeforeComma
|
||||
BreakFunctionDefinitionParameters: false
|
||||
BreakInheritanceList: BeforeColon
|
||||
BreakStringLiterals: true
|
||||
BreakTemplateDeclarations: MultiLine
|
||||
ColumnLimit: 0
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
CompactNamespaces: false
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: false
|
||||
DerivePointerAlignment: false
|
||||
DisableFormat: false
|
||||
EmptyLineAfterAccessModifier: Never
|
||||
EmptyLineBeforeAccessModifier: LogicalBlock
|
||||
EnumTrailingComma: Leave
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
FixNamespaceComments: true
|
||||
ForEachMacros:
|
||||
- foreach
|
||||
- Q_FOREACH
|
||||
- BOOST_FOREACH
|
||||
IfMacros:
|
||||
- KJ_IF_MAYBE
|
||||
IncludeBlocks: Preserve
|
||||
IncludeCategories:
|
||||
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
|
||||
Priority: 2
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
|
||||
Priority: 3
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
- Regex: '.*'
|
||||
Priority: 1
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
IncludeIsMainRegex: '(Test)?$'
|
||||
IncludeIsMainSourceRegex: ''
|
||||
IndentAccessModifiers: false
|
||||
IndentCaseBlocks: false
|
||||
IndentCaseLabels: false
|
||||
IndentExportBlock: true
|
||||
IndentExternBlock: AfterExternBlock
|
||||
IndentGotoLabels: true
|
||||
IndentPPDirectives: None
|
||||
IndentRequiresClause: true
|
||||
IndentWidth: 4
|
||||
IndentWrappedFunctionNames: false
|
||||
InsertBraces: false
|
||||
InsertNewlineAtEOF: false
|
||||
InsertTrailingCommas: None
|
||||
IntegerLiteralSeparator:
|
||||
Binary: 0
|
||||
BinaryMinDigits: 0
|
||||
Decimal: 0
|
||||
DecimalMinDigits: 0
|
||||
Hex: 0
|
||||
HexMinDigits: 0
|
||||
JavaScriptQuotes: Leave
|
||||
JavaScriptWrapImports: true
|
||||
KeepEmptyLines:
|
||||
AtEndOfFile: false
|
||||
AtStartOfBlock: true
|
||||
AtStartOfFile: true
|
||||
KeepFormFeed: false
|
||||
LambdaBodyIndentation: Signature
|
||||
LineEnding: DeriveLF
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MainIncludeChar: Quote
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: Inner
|
||||
ObjCBinPackProtocolList: Auto
|
||||
ObjCBlockIndentWidth: 4
|
||||
ObjCBreakBeforeNestedBlockParam: true
|
||||
ObjCSpaceAfterProperty: true
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
OneLineFormatOffRegex: ''
|
||||
PackConstructorInitializers: BinPack
|
||||
PenaltyBreakAssignment: 2
|
||||
PenaltyBreakBeforeFirstCallParameter: 19
|
||||
PenaltyBreakBeforeMemberAccess: 150
|
||||
PenaltyBreakComment: 300
|
||||
PenaltyBreakFirstLessLess: 120
|
||||
PenaltyBreakOpenParenthesis: 0
|
||||
PenaltyBreakScopeResolution: 500
|
||||
PenaltyBreakString: 1000
|
||||
PenaltyBreakTemplateDeclaration: 10
|
||||
PenaltyExcessCharacter: 1000000
|
||||
PenaltyIndentedWhitespace: 0
|
||||
PenaltyReturnTypeOnItsOwnLine: 60
|
||||
PointerAlignment: Left
|
||||
PPIndentWidth: -1
|
||||
QualifierAlignment: Leave
|
||||
ReferenceAlignment: Pointer
|
||||
ReflowComments: Always
|
||||
RemoveBracesLLVM: false
|
||||
RemoveEmptyLinesInUnwrappedLines: true
|
||||
RemoveParentheses: Leave
|
||||
RemoveSemicolon: false
|
||||
RequiresClausePosition: OwnLine
|
||||
RequiresExpressionIndentation: OuterScope
|
||||
SeparateDefinitionBlocks: Leave
|
||||
ShortNamespaceLines: 1
|
||||
SkipMacroDefinitionBody: false
|
||||
SortIncludes:
|
||||
Enabled: true
|
||||
IgnoreCase: false
|
||||
SortJavaStaticImport: Before
|
||||
SortUsingDeclarations: LexicographicNumeric
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterOperatorKeyword: false
|
||||
SpaceAfterTemplateKeyword: true
|
||||
SpaceAroundPointerQualifiers: Default
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCaseColon: false
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeJsonColon: false
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceBeforeParensOptions:
|
||||
AfterControlStatements: true
|
||||
AfterForeachMacros: true
|
||||
AfterFunctionDefinitionName: false
|
||||
AfterFunctionDeclarationName: false
|
||||
AfterIfMacros: true
|
||||
AfterNot: false
|
||||
AfterOverloadedOperator: false
|
||||
AfterPlacementOperator: true
|
||||
AfterRequiresInClause: false
|
||||
AfterRequiresInExpression: false
|
||||
BeforeNonEmptyParentheses: false
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceBeforeSquareBrackets: false
|
||||
SpaceInEmptyBlock: true
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: Never
|
||||
SpacesInContainerLiterals: true
|
||||
SpacesInLineCommentPrefix:
|
||||
Minimum: 1
|
||||
Maximum: -1
|
||||
SpacesInParens: Never
|
||||
SpacesInParensOptions:
|
||||
ExceptDoubleParentheses: false
|
||||
InCStyleCasts: false
|
||||
InConditionalStatements: false
|
||||
InEmptyParentheses: false
|
||||
Other: false
|
||||
SpacesInSquareBrackets: false
|
||||
Standard: Latest
|
||||
StatementAttributeLikeMacros:
|
||||
- Q_EMIT
|
||||
StatementMacros:
|
||||
- Q_UNUSED
|
||||
- QT_REQUIRE_VERSION
|
||||
TableGenBreakInsideDAGArg: DontBreak
|
||||
TabWidth: 8
|
||||
UseTab: Never
|
||||
VerilogBreakBetweenInstancePorts: true
|
||||
WhitespaceSensitiveMacros:
|
||||
- BOOST_PP_STRINGIZE
|
||||
- CF_SWIFT_NAME
|
||||
- NS_SWIFT_NAME
|
||||
- PP_STRINGIZE
|
||||
- STRINGIZE
|
||||
WrapNamespaceBodyWithEmptyLines: Leave
|
||||
---
|
||||
Language: Proto
|
||||
DisableFormat: true
|
||||
...
|
||||
@@ -1,12 +0,0 @@
|
||||
# Garbage left behind on Windows
|
||||
|
||||
.vs/
|
||||
out/
|
||||
CMakeFiles/
|
||||
vcpkg_installed/
|
||||
src/resources/resources.hpp
|
||||
CMakeCache.txt
|
||||
build.ninja
|
||||
*.cmake
|
||||
*.dll
|
||||
*.log
|
||||
@@ -1,82 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.26)
|
||||
|
||||
project(SlimeVR-Bindings-Provider)
|
||||
|
||||
set(SOLARXR_PROTOCOL_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../solarxr-protocol")
|
||||
set(FLATBUFFERS_GENERATED_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../solarxr-protocol/protocol/cpp")
|
||||
|
||||
# These are used to determine the OpenVR library path
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(PROCESSOR_ARCH "64")
|
||||
else()
|
||||
set(PROCESSOR_ARCH "32")
|
||||
endif()
|
||||
if(WIN32)
|
||||
set(OPENVR_LIBRARY_NAME "openvr_api")
|
||||
set(OPENVR_LIBRARY_EXT "dll")
|
||||
set(PLATFORM_NAME "win")
|
||||
elseif(APPLE)
|
||||
set(OPENVR_LIBRARY_NAME "libopenvr_api")
|
||||
set(OPENVR_LIBRARY_EXT "dylib")
|
||||
set(PLATFORM_NAME "osx")
|
||||
elseif(LINUX)
|
||||
set(OPENVR_LIBRARY_NAME "libopenvr_api")
|
||||
set(OPENVR_LIBRARY_EXT "so")
|
||||
if (CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
|
||||
set(PLATFORM_NAME "linuxarm")
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
|
||||
set(PLATFORM_NAME "linux")
|
||||
else()
|
||||
message(FATAL_ERROR "Unknown/unsupported CPU architecture")
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "Unknown/unsupported platform")
|
||||
endif()
|
||||
|
||||
set(OPENVR_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/openvr")
|
||||
|
||||
message(STATUS "OpenVR library search path: ${OPENVR_ROOT}/lib/${PLATFORM_NAME}${PROCESSOR_ARCH}")
|
||||
find_library(OPENVR_LIBRARY NAMES openvr_api REQUIRED PATHS "${OPENVR_ROOT}/lib/${PLATFORM_NAME}${PROCESSOR_ARCH}/" NO_DEFAULT_PATH)
|
||||
message(STATUS "Found OpenVR library at: ${OPENVR_LIBRARY}")
|
||||
|
||||
add_executable("${PROJECT_NAME}"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/paths.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/logger.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/bridge/BridgeClient.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/bridge/BridgeTransport.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/vr_utils.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp"
|
||||
)
|
||||
set_target_properties("${PROJECT_NAME}" PROPERTIES CXX_STANDARD 23)
|
||||
target_include_directories("${PROJECT_NAME}" PRIVATE "${SOLARXR_PROTOCOL_ROOT}/lib/flatbuffers/include" "${SOLARXR_PROTOCOL_ROOT}/lib/flatbuffers/" "${FLATBUFFERS_GENERATED_ROOT}/include" "${CMAKE_CURRENT_SOURCE_DIR}/include" "${OPENVR_ROOT}/headers")
|
||||
target_link_libraries("${PROJECT_NAME}" PRIVATE "${OPENVR_LIBRARY}")
|
||||
if(WIN32)
|
||||
target_link_libraries("${PROJECT_NAME}" PRIVATE ws2_32)
|
||||
endif()
|
||||
|
||||
if(LINUX)
|
||||
set_target_properties("${PROJECT_NAME}" PROPERTIES OUTPUT_NAME slimevr-bindings-provider)
|
||||
endif()
|
||||
|
||||
set(OPENVR_RUNTIME_LIBRARY "${OPENVR_ROOT}/bin/${PLATFORM_NAME}${PROCESSOR_ARCH}/${OPENVR_LIBRARY_NAME}.${OPENVR_LIBRARY_EXT}")
|
||||
message(STATUS "Found OpenVR runtime library: ${OPENVR_RUNTIME_LIBRARY}")
|
||||
configure_file("${OPENVR_RUNTIME_LIBRARY}" "${CMAKE_CURRENT_BINARY_DIR}/." COPYONLY)
|
||||
|
||||
# Embed the resources into resources.hpp
|
||||
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
|
||||
src/resources/manifest.vrmanifest
|
||||
src/resources/action_manifest.json
|
||||
src/resources/generic.json
|
||||
src/resources/knuckles.json
|
||||
src/resources/oculus_touch.json
|
||||
src/resources/vive_controller.json
|
||||
)
|
||||
file(STRINGS src/resources/manifest.vrmanifest SVR_VRAPP_MANIFEST NEWLINE_CONSUME)
|
||||
file(STRINGS src/resources/action_manifest.json SVR_VRAPP_ACTION_MANIFEST NEWLINE_CONSUME)
|
||||
file(STRINGS src/resources/generic.json SVR_VRAPP_GENERIC_BINDS NEWLINE_CONSUME)
|
||||
file(STRINGS src/resources/knuckles.json SVR_VRAPP_KNUCKLES_BINDS NEWLINE_CONSUME)
|
||||
file(STRINGS src/resources/oculus_touch.json SVR_VRAPP_OCULUS_BINDS NEWLINE_CONSUME)
|
||||
file(STRINGS src/resources/vive_controller.json SVR_VRAPP_VIVE_BINDS NEWLINE_CONSUME)
|
||||
|
||||
configure_file(src/resources/resources.hpp.in src/resources/resources.hpp @ONLY)
|
||||
target_include_directories("${PROJECT_NAME}" PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/src")
|
||||
@@ -1,12 +0,0 @@
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
if ((Get-Command "clang-format" -ErrorAction SilentlyContinue) -eq $null) {
|
||||
$errorObj = New-Object System.IO.FileNotFoundException("clang-format is not installed, please install clang-format via your package manager (e.g. winget/chocolatey/scoop) and re-run the script")
|
||||
throw $errorObj
|
||||
}
|
||||
|
||||
$SourceFiles = Get-ChildItem -Path '.\src\' -Recurse -Include "*.cpp","*.hpp"
|
||||
foreach ($file in $SourceFiles) {
|
||||
Write-Output "Formatting $(Resolve-Path -Relative $file.FullName)"
|
||||
clang-format -i "$($file.FullName)"
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
#!/bin/bash
|
||||
if ! command -v clang-format >/dev/null 2>&1; then
|
||||
echo "clang-format is not installed, please install clang-format via your package manager (e.g. pacman/apt/dnf/winget) and re-run the script" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
find src/ \( \
|
||||
-iname '*.cpp' \
|
||||
-or -iname '*.hpp' \
|
||||
\) \
|
||||
-exec echo Formatting {} \; \
|
||||
-exec clang-format -i {} \;
|
||||
@@ -1,52 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
// SPDX-FileCopyrightText: (c) 2026 Eiren Rain and SlimeVR Contributors
|
||||
#include "BridgeClient.hpp"
|
||||
#include "BridgeTransport.hpp"
|
||||
|
||||
#include <system_error>
|
||||
|
||||
using namespace std::literals::chrono_literals;
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
void BridgeClient::CreateConnection() {
|
||||
fs::path path = GetSocketPath();
|
||||
|
||||
Socket fd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (fd == InvalidSocket) {
|
||||
int err = GetLastSocketError();
|
||||
throw std::system_error(err, std::system_category(), "socket() failed");
|
||||
}
|
||||
|
||||
if (last_path_ != path) {
|
||||
Logger::Get().Info("Trying to connect to socket {}", path.string());
|
||||
last_path_ = path;
|
||||
}
|
||||
|
||||
struct sockaddr_un addr{
|
||||
.sun_family = AF_UNIX,
|
||||
};
|
||||
|
||||
const std::u8string path_str = path.u8string();
|
||||
if (path_str.size() > std::size(addr.sun_path) - 1) {
|
||||
CloseSocket(fd);
|
||||
throw std::runtime_error("Socket path too long to fit in sun_path");
|
||||
}
|
||||
memcpy(addr.sun_path, path_str.data(), path_str.size() + 1);
|
||||
|
||||
int ret = connect(fd, reinterpret_cast<const struct sockaddr*>(&addr), sizeof(addr));
|
||||
if (ret == SocketError) {
|
||||
int err = GetLastSocketError();
|
||||
CloseSocket(fd);
|
||||
throw std::system_error(err, std::system_category(), "connect() failed");
|
||||
}
|
||||
|
||||
Logger::Get().Info("Connected to {}", path.string());
|
||||
|
||||
ret = SetNonBlocking(fd);
|
||||
if (ret == SocketError) {
|
||||
int err = GetLastSocketError();
|
||||
Logger::Get().Warning("Failed to set socket into non-blocking mode: {}", std::error_code(err, std::system_category()).message());
|
||||
}
|
||||
|
||||
fd_ = fd;
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
// SPDX-FileCopyrightText: (c) 2026 Eiren Rain and SlimeVR Contributors
|
||||
#pragma once
|
||||
|
||||
#include "BridgeTransport.hpp"
|
||||
|
||||
/**
|
||||
* @brief Client implementation of @ref BridgeTransport for communication with SlimeVR Server using unix sockets.
|
||||
*
|
||||
* @copydoc BridgeTransport
|
||||
*/
|
||||
class BridgeClient : public BridgeTransport {
|
||||
public:
|
||||
using BridgeTransport::BridgeTransport;
|
||||
|
||||
private:
|
||||
void CreateConnection() override;
|
||||
|
||||
std::filesystem::path last_path_;
|
||||
};
|
||||
@@ -1,234 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
// SPDX-FileCopyrightText: (c) 2026 Eiren Rain and SlimeVR Contributors
|
||||
#include "BridgeTransport.hpp"
|
||||
#include "Endianness.hpp"
|
||||
|
||||
#include <solarxr_protocol/generated/all_generated.h>
|
||||
#include <system_error>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <winerror.h>
|
||||
#endif
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
#define UNIX_XDG_DATA_HOME_DEFAULT ".local/share/"
|
||||
#define SLIMEVR_IDENTIFIER "dev.slimevr.SlimeVR"
|
||||
#define UNIX_DEFAULT_TMP_DIR "/tmp"
|
||||
#define SOCKET_NAME "SlimeVRRpc"
|
||||
|
||||
void BridgeTransport::Stop() {
|
||||
if (!thread_.joinable() && !reconnect_thread_.joinable())
|
||||
return;
|
||||
Logger::Get().Info("Bridge stopping");
|
||||
StopAsync();
|
||||
thread_ = std::jthread();
|
||||
reconnect_thread_ = std::jthread();
|
||||
}
|
||||
|
||||
void BridgeTransport::StopAsync() {
|
||||
thread_.request_stop();
|
||||
reconnect_thread_.request_stop();
|
||||
cv_.notify_all();
|
||||
}
|
||||
|
||||
fs::path BridgeTransport::GetSocketPath() {
|
||||
std::vector<fs::path> paths = {};
|
||||
|
||||
if (const char* dir_override = std::getenv("SLIMEVR_SOCKET_DIR")) {
|
||||
paths.push_back(fs::path(dir_override) / SOCKET_NAME);
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
if (const char* xdg_runtime = std::getenv("XDG_RUNTIME_DIR")) {
|
||||
paths.push_back(fs::path(xdg_runtime) / SOCKET_NAME);
|
||||
}
|
||||
|
||||
if (const char* xdg_data = std::getenv("XDG_DATA_HOME")) {
|
||||
paths.push_back(fs::path(xdg_data) / SLIMEVR_IDENTIFIER / SOCKET_NAME);
|
||||
}
|
||||
|
||||
if (const char* home = std::getenv("HOME")) {
|
||||
paths.push_back(fs::path(home) / UNIX_XDG_DATA_HOME_DEFAULT / SLIMEVR_IDENTIFIER / SOCKET_NAME);
|
||||
}
|
||||
#endif
|
||||
|
||||
std::error_code ec;
|
||||
for (auto path : paths) {
|
||||
if (fs::exists(path, ec)
|
||||
#ifdef _WIN32
|
||||
|| ec.value() == ERROR_CANT_ACCESS_FILE // Windows moment???
|
||||
#endif
|
||||
) {
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
// This should work as long as the user's machine does not have
|
||||
// the java.io.tmpdir system property overriden.
|
||||
WCHAR tmp_dir[MAX_PATH + 1];
|
||||
GetTempPathW(std::size(tmp_dir), tmp_dir);
|
||||
return fs::path(tmp_dir) / SOCKET_NAME;
|
||||
#else
|
||||
if (const char* tmp_dir = std::getenv("TMPDIR")) {
|
||||
return fs::path(tmp_dir) / SOCKET_NAME;
|
||||
} else {
|
||||
return fs::path(UNIX_DEFAULT_TMP_DIR) / SOCKET_NAME;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void BridgeTransport::OnRecv(std::span<uint8_t> event) {
|
||||
if (!message_callback_)
|
||||
return;
|
||||
|
||||
auto bundle = flatbuffers::GetRoot<solarxr_protocol::MessageBundle>(event.data());
|
||||
|
||||
if (auto data_feed_msgs = bundle->data_feed_msgs()) {
|
||||
for (auto msg : *data_feed_msgs) {
|
||||
// Logger::Get().Debug("Got message DataFeedMessage::{}", EnumNameDataFeedMessage(msg->message_type()));
|
||||
message_callback_(msg);
|
||||
}
|
||||
}
|
||||
if (auto rpc_msgs = bundle->rpc_msgs()) {
|
||||
for (auto msg : *rpc_msgs) {
|
||||
Logger::Get().Debug("Got message RpcMessage::{}", EnumNameRpcMessage(msg->message_type()));
|
||||
message_callback_(msg);
|
||||
}
|
||||
}
|
||||
if (auto driver_msgs = bundle->driver_msgs()) {
|
||||
for (auto msg : *driver_msgs) {
|
||||
// Logger::Get().Debug("Got message DriverMessage::{}", EnumNameDriverMessage(msg->message_type()));
|
||||
message_callback_(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BridgeTransport::Start() {
|
||||
thread_ = std::jthread([this](std::stop_token stop) { return RunThread(stop); });
|
||||
}
|
||||
|
||||
void BridgeTransport::RunThread(std::stop_token stop) {
|
||||
std::vector<uint8_t> data;
|
||||
data.reserve(0x10000);
|
||||
|
||||
// Kick off connection.
|
||||
ResetConnection();
|
||||
|
||||
while (!stop.stop_requested()) {
|
||||
std::shared_lock fd_lock(fd_mutex_);
|
||||
|
||||
if (fd_ == InvalidSocket) [[unlikely]] {
|
||||
cv_.wait(fd_lock, stop, [this] { return fd_ != InvalidSocket; });
|
||||
if (stop.stop_requested())
|
||||
break;
|
||||
}
|
||||
|
||||
try {
|
||||
ptrdiff_t ret = Poll(fd_, 1ms);
|
||||
if (ret == 0) [[likely]] {
|
||||
// No data on the socket after timeout
|
||||
continue;
|
||||
}
|
||||
|
||||
uint32_t msg_len;
|
||||
ret = ReadFully(fd_, stop, &msg_len, sizeof(msg_len));
|
||||
if (ret == 0) [[unlikely]] {
|
||||
throw std::runtime_error("EOF");
|
||||
}
|
||||
|
||||
msg_len = ConvertEndianness<std::endian::little>(msg_len);
|
||||
// If we get something bigger than this, something's probably up
|
||||
if (msg_len > 0x40000) [[unlikely]] {
|
||||
throw std::runtime_error(std::format("Got too large message ({} bytes)", msg_len));
|
||||
}
|
||||
|
||||
const uint32_t unwrapped_len = msg_len - 4;
|
||||
data.reserve(unwrapped_len);
|
||||
|
||||
ret = ReadFully(fd_, stop, data.data(), unwrapped_len);
|
||||
if (ret == 0) [[unlikely]] {
|
||||
throw std::runtime_error("EOF");
|
||||
}
|
||||
|
||||
OnRecv({ data.data(), unwrapped_len });
|
||||
} catch (Cancelled&) {
|
||||
continue;
|
||||
} catch (std::exception& e) {
|
||||
Logger::Get().Error("Error on socket: {}", e.what());
|
||||
error_callback_(e);
|
||||
fd_lock.unlock();
|
||||
ResetConnection();
|
||||
}
|
||||
}
|
||||
|
||||
CloseConnectionHandles();
|
||||
}
|
||||
|
||||
void BridgeTransport::ResetConnection() {
|
||||
CloseConnectionHandles();
|
||||
|
||||
reconnect_thread_ = std::jthread([this](std::stop_token stop) {
|
||||
while (!stop.stop_requested()) {
|
||||
try {
|
||||
std::unique_lock fd_lock(fd_mutex_);
|
||||
CreateConnection();
|
||||
assert(fd_ != InvalidSocket);
|
||||
|
||||
cv_.notify_all();
|
||||
|
||||
// connect callback may call a function that needs to block on the fd
|
||||
fd_lock.unlock();
|
||||
OnConnect();
|
||||
|
||||
return;
|
||||
} catch (std::system_error& e) {
|
||||
if (last_error_ != e.code()) {
|
||||
Logger::Get().Error("Error when trying to connect: {}", e.what());
|
||||
last_error_ = e.code();
|
||||
}
|
||||
error_callback_(e);
|
||||
} catch (std::exception& e) {
|
||||
Logger::Get().Error("Error when trying to connect: {}", e.what());
|
||||
error_callback_(e);
|
||||
}
|
||||
|
||||
std::this_thread::sleep_for(100ms);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void BridgeTransport::CloseConnectionHandles() {
|
||||
std::unique_lock fd_lock(fd_mutex_);
|
||||
if (fd_ == InvalidSocket)
|
||||
return;
|
||||
|
||||
CloseSocket(fd_);
|
||||
OnDisconnect();
|
||||
fd_ = InvalidSocket;
|
||||
}
|
||||
|
||||
void BridgeTransport::SendMessage(const flatbuffers::FlatBufferBuilder& fbb) {
|
||||
std::shared_lock fd_lock(fd_mutex_);
|
||||
if (fd_ == InvalidSocket) [[unlikely]]
|
||||
return;
|
||||
|
||||
std::lock_guard write_lock(write_mutex_);
|
||||
|
||||
if (fbb.GetSize() + 4 > std::numeric_limits<uint32_t>::max()) [[unlikely]] {
|
||||
Logger::Get().Warning("Skipping send of message (wrapped size larger than 32-bit unsigned integer limit)");
|
||||
return;
|
||||
}
|
||||
|
||||
const uint32_t size = static_cast<uint32_t>(fbb.GetSize());
|
||||
const uint32_t le_wrapped_size = ConvertEndianness<std::endian::little>(size + 4);
|
||||
|
||||
try {
|
||||
WriteFully(fd_, &le_wrapped_size, sizeof(le_wrapped_size));
|
||||
WriteFully(fd_, fbb.GetBufferPointer(), size);
|
||||
} catch (std::exception& e) {
|
||||
Logger::Get().Error("Failed to write message: {}", e.what());
|
||||
}
|
||||
}
|
||||
@@ -1,343 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
// SPDX-FileCopyrightText: (c) 2026 Eiren Rain and SlimeVR Contributors
|
||||
#pragma once
|
||||
|
||||
#include <condition_variable>
|
||||
#include <filesystem>
|
||||
#include <shared_mutex>
|
||||
#include <span>
|
||||
#include <system_error>
|
||||
#include <thread>
|
||||
#include <variant>
|
||||
|
||||
// Needs to be before anything that includes Windows.h to avoid macro clashes
|
||||
#include <solarxr_protocol/generated/all_generated.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define NOMINMAX
|
||||
#include <Winsock2.h>
|
||||
#include <afunix.h>
|
||||
// Microsoft why
|
||||
#undef ERROR
|
||||
#undef SendMessage
|
||||
#else
|
||||
#include <fcntl.h>
|
||||
#include <poll.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#endif
|
||||
|
||||
#include "../logger.hpp"
|
||||
|
||||
/**
|
||||
* @brief Passes messages between SlimeVR Server and SteamVR Driver using Unix sockets.
|
||||
*
|
||||
* Client or Server connection handling is implemented by extending this class.
|
||||
*
|
||||
* This class provides a set of methods to start, stop an IO thread, and send messages over a Unix socket.
|
||||
*
|
||||
* When a message is received and parsed from the pipe, the on_message_received function passed in the constructor is called
|
||||
* from the bridge thread with the message as a parameter.
|
||||
*
|
||||
* @param logger A shared pointer to an Logger object to log messages from the transport.
|
||||
* @param on_message_received A function to be called from event loop thread when a message is received and parsed from the pipe.
|
||||
* @param on_connect A function to be called when the socket is connected to.
|
||||
* @param on_disconnect A function to be called when the connection is ended.
|
||||
*/
|
||||
class BridgeTransport {
|
||||
public:
|
||||
using MessageHeader = std::variant<const solarxr_protocol::data_feed::DataFeedMessageHeader*, const solarxr_protocol::rpc::RpcMessageHeader*, const solarxr_protocol::driver_protocol::DriverMessageHeader*>;
|
||||
|
||||
#ifdef _WIN32
|
||||
using Socket = SOCKET;
|
||||
constexpr static Socket InvalidSocket = INVALID_SOCKET;
|
||||
constexpr static int SocketError = SOCKET_ERROR;
|
||||
#else
|
||||
using Socket = int;
|
||||
constexpr static Socket InvalidSocket = -1;
|
||||
constexpr static int SocketError = -1;
|
||||
#endif
|
||||
|
||||
static inline int GetLastSocketError() {
|
||||
#ifdef _WIN32
|
||||
return WSAGetLastError();
|
||||
#else
|
||||
return errno;
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int CloseSocket(Socket fd) {
|
||||
#ifdef _WIN32
|
||||
return closesocket(fd);
|
||||
#else
|
||||
return close(fd);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline bool IsBlockingError(int err) {
|
||||
#ifdef _WIN32
|
||||
return err == WSAEWOULDBLOCK;
|
||||
#else
|
||||
return err == EAGAIN || err == EWOULDBLOCK;
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int SetNonBlocking(Socket fd) {
|
||||
#ifdef _WIN32
|
||||
u_long mode = 1;
|
||||
return ioctlsocket(fd, FIONBIO, &mode);
|
||||
#else
|
||||
return fcntl(fd, F_SETFL, O_NONBLOCK);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Exception thrown when IO is cancelled by stop token.
|
||||
*/
|
||||
class Cancelled : public std::exception {
|
||||
public:
|
||||
Cancelled() noexcept { };
|
||||
~Cancelled() { };
|
||||
|
||||
const char* what() const noexcept override {
|
||||
return "IO operation cancelled";
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Read @a size bytes from @a fd into @a data, retrying until all data is read or an error occurs.
|
||||
*
|
||||
* @throws @ref Cancelled stop was requested on @a stop
|
||||
* @throws std::system_error error returned on socket
|
||||
* @returns @ref SocketError on fail, otherwise number of bytes read
|
||||
*/
|
||||
static ptrdiff_t ReadFully(Socket fd, std::stop_token stop, void* data, size_t size) {
|
||||
ptrdiff_t ret;
|
||||
size_t received = 0;
|
||||
while (!stop.stop_requested() && received < size) {
|
||||
ret = recv(fd, reinterpret_cast<char*>(data) + received, size - received, 0);
|
||||
if (ret == 0) // EOF
|
||||
return ret;
|
||||
|
||||
if (ret == SocketError) [[unlikely]] {
|
||||
int err = GetLastSocketError();
|
||||
if (IsBlockingError(err)) [[likely]] {
|
||||
// we couldn't read because it would block, just try again
|
||||
continue;
|
||||
} else {
|
||||
throw std::system_error(err, std::system_category(), "recv() failed");
|
||||
}
|
||||
}
|
||||
|
||||
received += ret;
|
||||
}
|
||||
|
||||
if (stop.stop_requested())
|
||||
throw Cancelled();
|
||||
return received;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Write @a size bytes from @a data to @a fd, retrying until all data is written or an error occurs.
|
||||
*
|
||||
* @throws std::system_error error returned on socket
|
||||
*
|
||||
* @returns @ref SocketError on fail, otherwise number of bytes written
|
||||
*/
|
||||
static inline ptrdiff_t WriteFully(Socket fd, const void* data, size_t size) {
|
||||
#ifdef __linux__
|
||||
constexpr int flags = MSG_NOSIGNAL;
|
||||
#else
|
||||
constexpr int flags = 0;
|
||||
#endif
|
||||
|
||||
ptrdiff_t ret;
|
||||
size_t sent = 0;
|
||||
while (sent < size) {
|
||||
ret = send(fd, reinterpret_cast<const char*>(data) + sent, size - sent, flags);
|
||||
if (ret == SocketError) [[unlikely]] {
|
||||
int err = GetLastSocketError();
|
||||
if (IsBlockingError(err)) [[likely]] {
|
||||
// we couldn't write because it would block, just try again
|
||||
continue;
|
||||
} else {
|
||||
throw std::system_error(err, std::system_category(), "send() failed");
|
||||
}
|
||||
}
|
||||
|
||||
sent += ret;
|
||||
}
|
||||
|
||||
return sent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Wait for input to be ready on @a fd, timing out after @a timeout.
|
||||
*
|
||||
* @param fd file descriptor to poll
|
||||
* @param timeout amount of time to wait before giving up
|
||||
*
|
||||
* @throws std::system_error error returned when polling
|
||||
* @throws std::runtime_error error on socket, or hang up was detected
|
||||
*
|
||||
* @returns @ref 0 if there is no data, positive value if there is data
|
||||
*/
|
||||
template <typename Rep, typename Period>
|
||||
static int Poll(Socket fd, std::chrono::duration<Rep, Period> timeout) noexcept(false) {
|
||||
struct pollfd pollfd{
|
||||
.fd = fd,
|
||||
.events = POLLIN,
|
||||
};
|
||||
|
||||
int ret;
|
||||
|
||||
#ifdef _WIN32
|
||||
ret = WSAPoll(&pollfd, 1, std::chrono::duration_cast<std::chrono::milliseconds>(timeout).count());
|
||||
#else
|
||||
{
|
||||
auto s = std::chrono::duration_cast<std::chrono::seconds>(timeout);
|
||||
auto ns = std::chrono::duration_cast<std::chrono::nanoseconds>(timeout - s);
|
||||
struct timespec ts{
|
||||
.tv_sec = s.count(),
|
||||
.tv_nsec = ns.count(),
|
||||
};
|
||||
ret = ppoll(&pollfd, 1, timeout == timeout.zero() ? nullptr : &ts, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
constexpr int InterruptedErrno = WSAEINTR;
|
||||
#else
|
||||
constexpr int InterruptedErrno = EINTR;
|
||||
#endif
|
||||
|
||||
if (ret == SocketError) {
|
||||
int err = GetLastSocketError();
|
||||
throw std::system_error(err, std::system_category(), "Poll() failed");
|
||||
}
|
||||
|
||||
if ((pollfd.revents & (POLLERR | POLLHUP)) != 0) {
|
||||
throw std::runtime_error("Socket connection lost");
|
||||
}
|
||||
|
||||
return pollfd.revents & POLLIN;
|
||||
}
|
||||
|
||||
BridgeTransport(std::function<void(MessageHeader&&)> on_message_received = {},
|
||||
std::function<void()> on_connect = {},
|
||||
std::function<void()> on_disconnect = {},
|
||||
std::function<void(std::exception&)> on_error = {})
|
||||
: connect_callback_(on_connect)
|
||||
, message_callback_(on_message_received)
|
||||
, disconnect_callback_(on_disconnect)
|
||||
, error_callback_(on_error) {
|
||||
#ifdef _WIN32
|
||||
WSADATA _ws_data;
|
||||
if (int ret = WSAStartup(MAKEWORD(2, 2), &_ws_data); ret != 0) {
|
||||
Logger::Get().Error("WSAStartup failed with code {}", ret);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
virtual ~BridgeTransport() {
|
||||
Stop();
|
||||
#ifdef _WIN32
|
||||
WSACleanup();
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Starts the channel by creating a thread.
|
||||
*
|
||||
* Connects and automatic reconnects with a timeout are implemented internally.
|
||||
*/
|
||||
void Start();
|
||||
|
||||
/**
|
||||
* @brief Stops the channel by stopping the thread and closing the connection handles.
|
||||
*
|
||||
* Blocks until the thread is stopped and the connection handles are closed.
|
||||
*/
|
||||
void Stop();
|
||||
|
||||
/**
|
||||
* @brief Stops the channel asynchronously and returns immediately.
|
||||
*/
|
||||
void StopAsync();
|
||||
|
||||
/**
|
||||
* @brief Sends a message over the channel, you must Finish() the builder before calling this.
|
||||
*
|
||||
* @param message The message to send.
|
||||
*/
|
||||
void SendMessage(const flatbuffers::FlatBufferBuilder& fbb);
|
||||
|
||||
/**
|
||||
* @brief Checks if the channel is connected.
|
||||
*
|
||||
* @return true if the channel is connected, false otherwise.
|
||||
*/
|
||||
bool IsConnected() const {
|
||||
std::shared_lock fd_lock(fd_mutex_);
|
||||
return fd_ != InvalidSocket;
|
||||
};
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief Try to create a connection.
|
||||
*
|
||||
* Called while an exclusive lock is taken on @ref fd_mutex_.
|
||||
* Make sure this doesn't block as it will hold up shutdown.
|
||||
*
|
||||
* @ref fd_ must be initialised if this returns without throwing.
|
||||
*
|
||||
* @throws std::system_error I/O error when creating connection
|
||||
* @throws std::exception failed to create connection
|
||||
*/
|
||||
virtual void CreateConnection() = 0;
|
||||
/**
|
||||
* @brief Close the current socket if it's connected.
|
||||
*
|
||||
* Locks @ref fd_mutex_, do not call this with the mutex locked.
|
||||
*/
|
||||
void ResetConnection();
|
||||
|
||||
/**
|
||||
* @brief Closes the current connection, must be called while an exclusive lock is taken on the mutex.
|
||||
*/
|
||||
void CloseConnectionHandles();
|
||||
|
||||
void OnConnect() {
|
||||
if (connect_callback_)
|
||||
connect_callback_();
|
||||
}
|
||||
void OnRecv(std::span<uint8_t> event);
|
||||
void OnDisconnect() {
|
||||
if (disconnect_callback_)
|
||||
disconnect_callback_();
|
||||
}
|
||||
|
||||
static std::filesystem::path GetSocketPath();
|
||||
|
||||
/// Guards @ref fd_ and the condition variable @ref cv_.
|
||||
mutable std::shared_mutex fd_mutex_;
|
||||
/// Guards write operations.
|
||||
mutable std::mutex write_mutex_;
|
||||
/// Signaled on connection, or when we're exiting.
|
||||
std::condition_variable_any cv_;
|
||||
Socket fd_ = InvalidSocket;
|
||||
|
||||
private:
|
||||
void RunThread(std::stop_token stop);
|
||||
|
||||
std::function<void()> connect_callback_;
|
||||
std::function<void(MessageHeader&&)> message_callback_;
|
||||
std::function<void()> disconnect_callback_;
|
||||
std::function<void(std::exception&)> error_callback_;
|
||||
|
||||
std::jthread thread_;
|
||||
std::jthread reconnect_thread_;
|
||||
std::optional<std::error_code> last_error_;
|
||||
};
|
||||
@@ -1,17 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
// SPDX-FileCopyrightText: (c) 2026 Eiren Rain and SlimeVR Contributors
|
||||
#pragma once
|
||||
|
||||
#include <bit>
|
||||
#include <type_traits>
|
||||
|
||||
template <std::endian Endianness, typename T>
|
||||
requires(std::is_integral_v<T>)
|
||||
inline T ConvertEndianness(T v) {
|
||||
// I don't really care about mixed endianness..
|
||||
if constexpr (std::endian::native == Endianness) {
|
||||
return v;
|
||||
} else {
|
||||
return std::byteswap(v);
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
#include "logger.hpp"
|
||||
#include "paths.hpp"
|
||||
|
||||
#ifdef _WIN32
|
||||
#define WIN32_MEAN_AND_LEAN
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
Logger::Logger()
|
||||
: log_stream(Paths::GetLogPath() / "slimevr-bindings-provider.log",
|
||||
std::ios::out | std::ios::app)
|
||||
#ifdef _WIN32
|
||||
, should_log_to_std_streams(GetConsoleWindow() != nullptr)
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
Logger& Logger::Get() {
|
||||
static Logger logger;
|
||||
return logger;
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <cassert>
|
||||
#include <chrono>
|
||||
#include <format>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
|
||||
class Logger {
|
||||
private:
|
||||
std::ofstream log_stream;
|
||||
#ifdef _WIN32
|
||||
bool should_log_to_std_streams;
|
||||
#endif
|
||||
|
||||
template <bool important, typename... Args>
|
||||
void Log(std::string_view suffix, std::format_string<Args...> fmt,
|
||||
Args&&... args) {
|
||||
auto now = std::chrono::system_clock::now();
|
||||
auto time_t = std::chrono::system_clock::to_time_t(now);
|
||||
|
||||
auto s = std::format(fmt, std::forward<Args>(args)...);
|
||||
#ifdef _WIN32
|
||||
if (should_log_to_std_streams) {
|
||||
#endif
|
||||
if constexpr (important)
|
||||
std::cerr << suffix << ' ' << s << '\n';
|
||||
else
|
||||
std::cout << suffix << ' ' << s << '\n';
|
||||
#ifdef _WIN32
|
||||
}
|
||||
#endif
|
||||
|
||||
log_stream << std::put_time(std::localtime(&time_t), "[%F %T]") //
|
||||
<< ' ' << suffix << ' ' << s << '\n';
|
||||
}
|
||||
|
||||
public:
|
||||
Logger();
|
||||
|
||||
template <typename... Args>
|
||||
void Debug(std::format_string<Args...> fmt, Args&&... args) {
|
||||
#ifndef NDEBUG
|
||||
Log<false>("[DEBUG]", fmt, std::forward<Args>(args)...);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void Info(std::format_string<Args...> fmt, Args&&... args) {
|
||||
Log<false>("[INFO]", fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void Warning(std::format_string<Args...> fmt, Args&&... args) {
|
||||
Log<true>("[WARN]", fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void Error(std::format_string<Args...> fmt, Args&&... args) {
|
||||
Log<true>("[ERROR]", fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
void Flush() {
|
||||
#ifdef _WIN32
|
||||
if (should_log_to_std_streams) {
|
||||
#endif
|
||||
std::cerr.flush();
|
||||
std::cout.flush();
|
||||
#ifdef _WIN32
|
||||
}
|
||||
#endif
|
||||
log_stream.flush();
|
||||
}
|
||||
|
||||
static Logger& Get();
|
||||
};
|
||||
@@ -1,298 +0,0 @@
|
||||
#include <csignal>
|
||||
#include <map>
|
||||
#include <optional>
|
||||
#include <thread>
|
||||
#include <tuple>
|
||||
|
||||
// These must be included before Windows.h because of some macro collisions.
|
||||
#include "flatbuffers/flatbuffers.h"
|
||||
#include "solarxr_protocol/generated/all_generated.h"
|
||||
|
||||
#include "bridge/BridgeClient.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "vr_utils.hpp"
|
||||
|
||||
#include "openvr.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#define WIN32_MEAN_AND_LEAN
|
||||
#define NOMINMAX
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <cstdlib>
|
||||
#endif
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
using namespace std::chrono_literals;
|
||||
using namespace solarxr_protocol;
|
||||
|
||||
static void ShutdownVR(vr::IVRSystem* _sys) { vr::VR_Shutdown(); }
|
||||
|
||||
static void OnYawReset(BridgeTransport& conn) {
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
|
||||
auto resetReq = rpc::CreateResetRequest(fbb, rpc::ResetType::YAW, 0, 0.f);
|
||||
auto msgHeader = rpc::CreateRpcMessageHeader(fbb, 0, 0, rpc::RpcMessage::ResetRequest, resetReq.Union());
|
||||
|
||||
auto rpcMsgs = fbb.CreateVector({ msgHeader });
|
||||
auto bundle = CreateMessageBundle(fbb, 0, rpcMsgs);
|
||||
fbb.Finish(bundle);
|
||||
conn.SendMessage(fbb);
|
||||
}
|
||||
static void OnFullReset(BridgeTransport& conn) {
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
|
||||
auto resetReq = rpc::CreateResetRequest(fbb, rpc::ResetType::FULL, 0, 0.f);
|
||||
auto msgHeader = rpc::CreateRpcMessageHeader(fbb, 0, 0, rpc::RpcMessage::ResetRequest, resetReq.Union());
|
||||
|
||||
auto rpcMsgs = fbb.CreateVector({ msgHeader });
|
||||
auto bundle = CreateMessageBundle(fbb, 0, rpcMsgs);
|
||||
fbb.Finish(bundle);
|
||||
conn.SendMessage(fbb);
|
||||
}
|
||||
static void OnMountingCalibration(BridgeTransport& conn) {
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
|
||||
auto resetReq = rpc::CreateResetRequest(fbb, rpc::ResetType::MOUNTING, 0, 0.f);
|
||||
auto msgHeader = rpc::CreateRpcMessageHeader(fbb, 0, 0, rpc::RpcMessage::ResetRequest, resetReq.Union());
|
||||
|
||||
auto rpcMsgs = fbb.CreateVector({ msgHeader });
|
||||
auto bundle = CreateMessageBundle(fbb, 0, rpcMsgs);
|
||||
fbb.Finish(bundle);
|
||||
conn.SendMessage(fbb);
|
||||
}
|
||||
static void OnFeetMountingCalibration(BridgeTransport& conn) {
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
|
||||
auto bodyParts = fbb.CreateVector(
|
||||
{ datatypes::BodyPart::LEFT_FOOT, datatypes::BodyPart::RIGHT_FOOT });
|
||||
auto resetReq = rpc::CreateResetRequest(fbb, rpc::ResetType::MOUNTING, bodyParts, 0.f);
|
||||
auto msgHeader = rpc::CreateRpcMessageHeader(fbb, 0, 0, rpc::RpcMessage::ResetRequest, resetReq.Union());
|
||||
|
||||
auto rpcMsgs = fbb.CreateVector({ msgHeader });
|
||||
auto bundle = CreateMessageBundle(fbb, 0, rpcMsgs);
|
||||
fbb.Finish(bundle);
|
||||
conn.SendMessage(fbb);
|
||||
}
|
||||
static void OnToggleTracking(BridgeTransport& conn) {
|
||||
static bool shouldPause = false;
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
|
||||
shouldPause = !shouldPause;
|
||||
auto toggleReq = rpc::CreateSetPauseTrackingRequest(fbb, shouldPause);
|
||||
auto msgHeader = rpc::CreateRpcMessageHeader(fbb, 0, 0, rpc::RpcMessage::SetPauseTrackingRequest, toggleReq.Union());
|
||||
|
||||
auto rpcMsgs = fbb.CreateVector({ msgHeader });
|
||||
auto bundle = CreateMessageBundle(fbb, 0, rpcMsgs);
|
||||
fbb.Finish(bundle);
|
||||
conn.SendMessage(fbb);
|
||||
}
|
||||
|
||||
sig_atomic_t should_exit = 0;
|
||||
|
||||
static void OnSignal(int signal) {
|
||||
Logger::Get().Info("Received signal {}", signal);
|
||||
should_exit = 1;
|
||||
}
|
||||
|
||||
int main() {
|
||||
auto& logger = Logger::Get();
|
||||
|
||||
// Steam and SteamVR respectively set these environment variables on applications that
|
||||
// they spawn, which the SteamVR client library (vrclient) will then use as the
|
||||
// application key when initiating the connection with vrserver. This may not
|
||||
// be ideal if we are launched by another Steam or OpenVR application, as we will inherit
|
||||
// their app key through the environment, which means SteamVR will load the wrong bindings.
|
||||
// A real-world example of this is if someone uses an application such as OpenVR-Autostarter
|
||||
// to start the SlimeVR Server. OpenVR-Autostarter installs an application manifest with the
|
||||
// app key "dreiekk.openvr-autostarter", so when it starts SlimeVR Server, which then starts us,
|
||||
// the STEAMVR_APPKEY="dreiekk.openvr-autostarter" environment variable will be set.
|
||||
//
|
||||
// We want SteamVR to use the appkey of the Steam version of our application if possible.
|
||||
// Unfortunately, we cannot install an application vrmanifest to force the app key,
|
||||
// as SteamVR requires a binary path in the manifest to consider it valid. We do not want to install
|
||||
// a manifest with a binary path because we want the SlimeVR Server to start us when the
|
||||
// driver initiates a connection, rather than getting auto-started by SteamVR.
|
||||
//
|
||||
// This is not documented anywhere publicly, see CVRClient::SendConnectMessage in vrclient instead.
|
||||
|
||||
constexpr const char* STEAM_APPID = "3245490";
|
||||
constexpr const char* STEAMVR_APPKEY = "steam.overlay.3245490";
|
||||
|
||||
#ifdef _WIN32
|
||||
SetEnvironmentVariableA("SteamAppId", STEAM_APPID);
|
||||
SetEnvironmentVariableA("STEAMVR_APPKEY", STEAMVR_APPKEY);
|
||||
#else
|
||||
setenv("SteamAppId", STEAM_APPID, 1);
|
||||
setenv("STEAMVR_APPKEY", STEAMVR_APPKEY, 1);
|
||||
#endif
|
||||
|
||||
try {
|
||||
BridgeClient conn(nullptr, nullptr, [] { should_exit = 1; }, [](std::exception&) { should_exit = 1; });
|
||||
conn.Start();
|
||||
|
||||
std::unique_ptr<vr::IVRSystem, decltype(&ShutdownVR)> sys{ nullptr, ShutdownVR };
|
||||
|
||||
// On vrlink, VR_Init returns
|
||||
// VRInitError_Driver_WirelessHmdNotConnected while the connection
|
||||
// is initialising, so keep calling VR_Init until it ends up
|
||||
// succeeding
|
||||
|
||||
vr::EVRInitError err{ vr::VRInitError_Driver_WirelessHmdNotConnected };
|
||||
while (err == vr::VRInitError_Driver_WirelessHmdNotConnected) {
|
||||
sys.reset(vr::VR_Init(&err, vr::VRApplication_Background));
|
||||
if (err == vr::VRInitError_Driver_WirelessHmdNotConnected)
|
||||
std::this_thread::sleep_for(500ms);
|
||||
}
|
||||
|
||||
if (sys == nullptr or err != vr::VRInitError_None) {
|
||||
logger.Error("Failed to init OpenVR: {} ({})",
|
||||
vr::VR_GetVRInitErrorAsSymbol(err),
|
||||
vr::VR_GetVRInitErrorAsEnglishDescription(err));
|
||||
return 1;
|
||||
}
|
||||
|
||||
logger.Info("Initialised OpenVR, HMD model '{}'", VRUtils::GetStringProp(vr::k_unTrackedDeviceIndex_Hmd, vr::Prop_ModelNumber_String).value_or("<unknown>"));
|
||||
|
||||
vr::IVRApplications* app = vr::VRApplications();
|
||||
vr::IVRInput* input = vr::VRInput();
|
||||
|
||||
fs::path actionManifestPath;
|
||||
std::tie(std::ignore, actionManifestPath) = VRUtils::InitialiseManifests();
|
||||
|
||||
// We don't want our app key to randomly change if SteamVR decides to honour
|
||||
// application manifests with no binary path. Instead let it generate an
|
||||
// app key based on the executable name (system.generated.[lowercase executable name])
|
||||
#if false
|
||||
if (auto err = app->AddApplicationManifest(appManifestPath.string().data(), true);
|
||||
err != vr::VRApplicationError_None) {
|
||||
logger.error("Failed to add application manifest: {}",
|
||||
app->GetApplicationsErrorNameFromEnum(err));
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
// SetActionManifestPath may return IPCError if vrserver is busy and takes
|
||||
// too long to reply, so keep invoking until it succeeds
|
||||
{
|
||||
vr::EVRInputError err;
|
||||
constexpr int max_tries = 5;
|
||||
int tries = 0;
|
||||
while ((err = input->SetActionManifestPath(actionManifestPath.string().data())) == vr::VRInputError_IPCError && tries++ < max_tries) {
|
||||
logger.Debug("IPC error loading action manifest, retrying ({}/{})", tries, max_tries);
|
||||
std::this_thread::sleep_for(20ms);
|
||||
}
|
||||
|
||||
if (err != vr::VRInputError_None) {
|
||||
logger.Error("Failed to set action manifest path: {}", std::to_underlying(err));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
vr::VRActionSetHandle_t action_set;
|
||||
if (auto err = input->GetActionSetHandle("/actions/main", &action_set);
|
||||
err != vr::VRInputError_None) {
|
||||
logger.Error("Failed to get main action set handle: {}", std::to_underlying(err));
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::map<std::string, std::tuple<vr::VRActionHandle_t, std::function<void(BridgeTransport&)>>>
|
||||
actions{
|
||||
{ "/actions/main/in/YawReset", std::make_tuple(vr::k_ulInvalidActionHandle, OnYawReset) },
|
||||
{ "/actions/main/in/FullReset", std::make_tuple(vr::k_ulInvalidActionHandle, OnFullReset) },
|
||||
{ "/actions/main/in/MountingCalibration", std::make_tuple(vr::k_ulInvalidActionHandle, OnMountingCalibration) },
|
||||
{ "/actions/main/in/FeetMountingCalibration", std::make_tuple(vr::k_ulInvalidActionHandle, OnFeetMountingCalibration) },
|
||||
{ "/actions/main/in/ToggleTracking", std::make_tuple(vr::k_ulInvalidActionHandle, OnToggleTracking) },
|
||||
};
|
||||
|
||||
for (auto& [name, tuple] : actions) {
|
||||
auto& [handle, _] = tuple;
|
||||
if (auto err = input->GetActionHandle(name.c_str(), &handle);
|
||||
err != vr::VRInputError_None || handle == vr::k_ulInvalidActionHandle) {
|
||||
logger.Warning("Failed to get action handle for action {}: {}", name,
|
||||
std::to_underlying(err));
|
||||
}
|
||||
}
|
||||
|
||||
constexpr auto interval = 1000ms / 30;
|
||||
|
||||
signal(SIGINT, OnSignal);
|
||||
signal(SIGTERM, OnSignal);
|
||||
while (!should_exit) {
|
||||
vr::VREvent_t event{};
|
||||
while (sys->PollNextEvent(&event, sizeof(event))) {
|
||||
switch (event.eventType) {
|
||||
case vr::VREvent_Quit:
|
||||
logger.Info("OpenVR runtime requested quit");
|
||||
should_exit = 1;
|
||||
break;
|
||||
case vr::VREvent_Input_BindingLoadFailed: {
|
||||
auto& loadData = event.data.inputBinding;
|
||||
logger.Debug("Binding load failed (ulAppContainer={} pathMessage={} pathUrl={} pathControllerType={})",
|
||||
loadData.ulAppContainer, loadData.pathMessage, loadData.pathUrl, loadData.pathControllerType);
|
||||
break;
|
||||
}
|
||||
case vr::VREvent_Input_BindingLoadSuccessful: {
|
||||
auto& loadData = event.data.inputBinding;
|
||||
logger.Debug("Binding load successful (ulAppContainer={} pathMessage={} pathUrl={} pathControllerType={})",
|
||||
loadData.ulAppContainer, loadData.pathMessage, loadData.pathUrl, loadData.pathControllerType);
|
||||
break;
|
||||
}
|
||||
case vr::VREvent_Input_ActionManifestReloaded:
|
||||
logger.Debug("Action manifest reloaded");
|
||||
break;
|
||||
case vr::VREvent_Input_ActionManifestLoadFailed: {
|
||||
auto& manifestData = event.data.actionManifest;
|
||||
logger.Debug(
|
||||
"Action manifest load failed (pathAppKey={} pathMessage={} pathMessageParam={} pathManifestPath={})",
|
||||
manifestData.pathAppKey, manifestData.pathMessage, manifestData.pathMessageParam, manifestData.pathManifestPath);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
vr::VRActiveActionSet_t set{
|
||||
.ulActionSet = action_set,
|
||||
.ulRestrictedToDevice = vr::k_ulInvalidInputValueHandle,
|
||||
.ulSecondaryActionSet = vr::k_ulInvalidActionSetHandle,
|
||||
.nPriority = 0,
|
||||
};
|
||||
if (auto err = input->UpdateActionState(&set, sizeof(set), 1);
|
||||
err != vr::VRInputError_None) {
|
||||
logger.Warning("Error when updating action states: {}",
|
||||
std::to_underlying(err));
|
||||
}
|
||||
|
||||
for (auto& [name, tuple] : actions) {
|
||||
auto& [handle, callback] = tuple;
|
||||
vr::InputDigitalActionData_t action_data{};
|
||||
if (auto err = input->GetDigitalActionData(
|
||||
handle, &action_data, sizeof(action_data),
|
||||
vr::k_ulInvalidInputValueHandle);
|
||||
err != vr::VRInputError_None) {
|
||||
logger.Warning("Failed to get action state for {} ({}): {}", name, handle, std::to_underlying(err));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (action_data.bActive && action_data.bChanged && action_data.bState) {
|
||||
logger.Debug("Action {} triggered", name);
|
||||
callback(conn);
|
||||
}
|
||||
}
|
||||
|
||||
logger.Flush();
|
||||
std::this_thread::sleep_for(interval);
|
||||
}
|
||||
|
||||
logger.Info("Main loop done");
|
||||
} catch (std::exception& ex) {
|
||||
logger.Error("Exception in main: {}", ex.what());
|
||||
logger.Flush();
|
||||
return 1;
|
||||
}
|
||||
|
||||
logger.Flush();
|
||||
return 0;
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
#include "paths.hpp"
|
||||
|
||||
#ifdef _WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define NOMINMAX
|
||||
#include <Windows.h>
|
||||
#undef GetTempPath
|
||||
#endif
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
fs::path Paths::GetDataPath() {
|
||||
fs::path basePath{};
|
||||
|
||||
#if defined(__linux__)
|
||||
if (const char* dataHomeOverride = getenv("XDG_DATA_HOME")) {
|
||||
basePath = dataHomeOverride;
|
||||
} else {
|
||||
const char* homeDir = getenv("HOME");
|
||||
if (homeDir == nullptr)
|
||||
throw std::runtime_error("HOME is unset");
|
||||
|
||||
basePath = fs::path(homeDir) / ".local" / "share";
|
||||
}
|
||||
#elif defined(_WIN32)
|
||||
{
|
||||
const char* appData = getenv("APPDATA");
|
||||
if (appData == nullptr)
|
||||
throw std::runtime_error("APPDATA is unset");
|
||||
|
||||
basePath = appData;
|
||||
}
|
||||
#else
|
||||
#error "Unsupported platform"
|
||||
#endif
|
||||
|
||||
return basePath / "dev.slimevr.SlimeVR";
|
||||
}
|
||||
|
||||
fs::path Paths::GetLogPath() { return Paths::GetDataPath() / "logs"; }
|
||||
|
||||
fs::path Paths::GetTempPath() noexcept {
|
||||
#ifdef _WIN32
|
||||
WCHAR tmp_dir[MAX_PATH + 1];
|
||||
GetTempPathW(std::size(tmp_dir), tmp_dir);
|
||||
return tmp_dir;
|
||||
#else
|
||||
if (const char* tmp_dir = getenv("TMPDIR")) {
|
||||
return tmp_dir;
|
||||
}
|
||||
|
||||
return "/tmp";
|
||||
#endif
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
namespace Paths {
|
||||
// Throws when path cannot be found
|
||||
std::filesystem::path GetDataPath() noexcept(false);
|
||||
|
||||
// Throws when path cannot be found
|
||||
std::filesystem::path GetLogPath() noexcept(false);
|
||||
|
||||
std::filesystem::path GetTempPath() noexcept;
|
||||
} // namespace Paths
|
||||
@@ -1,64 +0,0 @@
|
||||
{
|
||||
"default_bindings": [
|
||||
{
|
||||
"controller_type": "generic",
|
||||
"binding_url": "generic.json"
|
||||
},
|
||||
{
|
||||
"controller_type": "oculus_touch",
|
||||
"binding_url": "oculus_touch.json"
|
||||
},
|
||||
{
|
||||
"controller_type": "knuckles",
|
||||
"binding_url": "knuckles.json"
|
||||
},
|
||||
{
|
||||
"controller_type": "vive_controller",
|
||||
"binding_url": "vive_controller.json"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
{
|
||||
"name": "/actions/main/in/YawReset",
|
||||
"requirement": "optional",
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"name": "/actions/main/in/FullReset",
|
||||
"requirement": "optional",
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"name": "/actions/main/in/MountingCalibration",
|
||||
"requirement": "optional",
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"name": "/actions/main/in/FeetMountingCalibration",
|
||||
"requirement": "optional",
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"name": "/actions/main/in/ToggleTracking",
|
||||
"requirement": "optional",
|
||||
"type": "boolean"
|
||||
}
|
||||
],
|
||||
"action_sets": [
|
||||
{
|
||||
"name": "/actions/main",
|
||||
"usage": "leftright"
|
||||
}
|
||||
],
|
||||
"localization": [
|
||||
{
|
||||
"language_tag": "en_us",
|
||||
"/actions/main": "Utility Bindings",
|
||||
"/actions/main/in/YawReset": "Yaw Reset",
|
||||
"/actions/main/in/FullReset": "Full Reset",
|
||||
"/actions/main/in/MountingCalibration": "Mounting Calibration",
|
||||
"/actions/main/in/FeetMountingCalibration": "Feet Mounting Calibration",
|
||||
"/actions/main/in/ToggleTracking": "Toggle Tracking"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"name": "Default Bindings for Generic",
|
||||
"controller_type": "generic",
|
||||
"bindings": {
|
||||
"/actions/main": {
|
||||
"sources": [],
|
||||
"skeleton": [],
|
||||
"haptics": [],
|
||||
"poses": []
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"name": "Default Bindings for Knuckles",
|
||||
"controller_type": "knuckles",
|
||||
"bindings": {
|
||||
"/actions/main": {
|
||||
"sources": [],
|
||||
"skeleton": [],
|
||||
"haptics": [],
|
||||
"poses": []
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
{
|
||||
"source": "builtin",
|
||||
"applications": [{
|
||||
"app_key": "dev.slimevr.BindingsProvider",
|
||||
"is_dashboard_overlay": false,
|
||||
"action_manifest_path": "action_manifest.json",
|
||||
"strings": {
|
||||
"en_us": {
|
||||
"name": "SlimeVR Bindings Provider",
|
||||
"description": "SlimeVR Bindings Provider"
|
||||
}
|
||||
}
|
||||
}]
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"name": "Default Bindings for Oculus Touch",
|
||||
"controller_type": "oculus_touch",
|
||||
"bindings": {
|
||||
"/actions/main": {
|
||||
"sources": [],
|
||||
"skeleton": [],
|
||||
"haptics": [],
|
||||
"poses": []
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#cmakedefine SVR_VRAPP_MANIFEST R"(@SVR_VRAPP_MANIFEST@)"
|
||||
#cmakedefine SVR_VRAPP_ACTION_MANIFEST R"(@SVR_VRAPP_ACTION_MANIFEST@)"
|
||||
#cmakedefine SVR_VRAPP_GENERIC_BINDS R"(@SVR_VRAPP_GENERIC_BINDS@)"
|
||||
#cmakedefine SVR_VRAPP_KNUCKLES_BINDS R"(@SVR_VRAPP_KNUCKLES_BINDS@)"
|
||||
#cmakedefine SVR_VRAPP_OCULUS_BINDS R"(@SVR_VRAPP_OCULUS_BINDS@)"
|
||||
#cmakedefine SVR_VRAPP_VIVE_BINDS R"(@SVR_VRAPP_VIVE_BINDS@)"
|
||||
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"name": "Default Bindings for Vive Wands",
|
||||
"controller_type": "vive_controller",
|
||||
"bindings": {
|
||||
"/actions/main": {
|
||||
"sources": [],
|
||||
"skeleton": [],
|
||||
"haptics": [],
|
||||
"poses": []
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
#include "vr_utils.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "paths.hpp"
|
||||
#include "resources/resources.hpp"
|
||||
|
||||
#include <array>
|
||||
#include <fstream>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
std::optional<std::string>
|
||||
VRUtils::GetStringProp(vr::TrackedDeviceIndex_t deviceIndex,
|
||||
vr::ETrackedDeviceProperty prop) {
|
||||
vr::IVRSystem* sys = vr::VRSystem();
|
||||
vr::ETrackedPropertyError err{ vr::TrackedProp_Success };
|
||||
|
||||
uint32_t required_len = sys->GetStringTrackedDeviceProperty(deviceIndex, prop, nullptr, 0, &err);
|
||||
if (err != vr::TrackedProp_BufferTooSmall) {
|
||||
Logger::Get().Info(
|
||||
"Failed to get size of string property {} for device {}: {}",
|
||||
std::to_underlying(prop), deviceIndex,
|
||||
sys->GetPropErrorNameFromEnum(err));
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::string s(required_len - 1, '\0');
|
||||
sys->GetStringTrackedDeviceProperty(deviceIndex, prop, s.data(), required_len,
|
||||
&err);
|
||||
if (err != vr::TrackedProp_Success) {
|
||||
Logger::Get().Info("Failed to get string property {} for device {}: {}",
|
||||
std::to_underlying(prop), deviceIndex,
|
||||
sys->GetPropErrorNameFromEnum(err));
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
std::tuple<fs::path, fs::path> VRUtils::InitialiseManifests() {
|
||||
fs::path manifestDir = Paths::GetDataPath() / "bindings-provider";
|
||||
std::error_code ec;
|
||||
fs::create_directories(manifestDir, ec);
|
||||
if (ec) {
|
||||
throw std::runtime_error(
|
||||
std::format("Failed to create manifest folder: {}", ec.message()));
|
||||
}
|
||||
|
||||
using namespace std::string_view_literals;
|
||||
// Make sure the vrmanifest and action manifest are 1st and 2nd respectively
|
||||
// in the array
|
||||
std::array requiredFiles{
|
||||
std::make_pair("manifest.vrmanifest"sv, SVR_VRAPP_MANIFEST),
|
||||
std::make_pair("action_manifest.json"sv, SVR_VRAPP_ACTION_MANIFEST),
|
||||
std::make_pair("generic.json"sv, SVR_VRAPP_GENERIC_BINDS),
|
||||
std::make_pair("knuckles.json"sv, SVR_VRAPP_KNUCKLES_BINDS),
|
||||
std::make_pair("oculus_touch.json"sv, SVR_VRAPP_OCULUS_BINDS),
|
||||
std::make_pair("vive_controller.json"sv, SVR_VRAPP_VIVE_BINDS),
|
||||
};
|
||||
|
||||
for (auto& [name, contents] : requiredFiles) {
|
||||
fs::path path = manifestDir / name;
|
||||
if (!fs::exists(path)) {
|
||||
std::ofstream stream(path);
|
||||
stream << contents;
|
||||
}
|
||||
}
|
||||
|
||||
return { manifestDir / requiredFiles.at(0).first,
|
||||
manifestDir / requiredFiles.at(1).first };
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
|
||||
#include "openvr.h"
|
||||
|
||||
namespace VRUtils {
|
||||
std::optional<std::string> GetStringProp(vr::TrackedDeviceIndex_t deviceIndex,
|
||||
vr::ETrackedDeviceProperty prop);
|
||||
|
||||
// Returns <app vrmanifest path, action manifest json path>
|
||||
std::tuple<std::filesystem::path, std::filesystem::path> InitialiseManifests();
|
||||
} // namespace VRUtils
|
||||
@@ -0,0 +1,3 @@
|
||||
plugins {
|
||||
id("org.ajoberstar.grgit")
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
# Crowdin Configuration File
|
||||
# https://developer.crowdin.com/configuration-file/
|
||||
|
||||
files:
|
||||
- source: /gui/app/public/i18n/en/translation.ftl
|
||||
translation: /gui/app/public/i18n/%locale%/%original_file_name%
|
||||
update_option: update_as_unapproved
|
||||
languages_mapping:
|
||||
locale:
|
||||
zh-CN: zh-Hans
|
||||
zh-TW: zh-Hant
|
||||
nb: nb-NO
|
||||
sv: sv-SE
|
||||
fr: fr
|
||||
de: de
|
||||
it: it
|
||||
ja: ja
|
||||
ko: ko
|
||||
ar: ar
|
||||
cs: cs
|
||||
da: da
|
||||
el: el
|
||||
es-419: es-419
|
||||
et: et
|
||||
fi: fi
|
||||
he: he
|
||||
lt: lt
|
||||
nl: nl
|
||||
pl: pl
|
||||
ru: ru
|
||||
th: th
|
||||
tr: tr
|
||||
uk: uk
|
||||
vi: vi
|
||||
# In-context editor pseudo-language
|
||||
ach-UG: ach-UG
|
||||
@@ -0,0 +1,242 @@
|
||||
# This template contains all of the possible sections and their default values
|
||||
|
||||
# Note that all fields that take a lint level have these possible values:
|
||||
# * deny - An error will be produced and the check will fail
|
||||
# * warn - A warning will be produced, but the check will not fail
|
||||
# * allow - No warning or error will be produced, though in some cases a note
|
||||
# will be
|
||||
|
||||
# The values provided in this template are the default values that will be used
|
||||
# when any section or field is not specified in your own configuration
|
||||
|
||||
# Root options
|
||||
|
||||
# The graph table configures how the dependency graph is constructed and thus
|
||||
# which crates the checks are performed against
|
||||
[graph]
|
||||
# If 1 or more target triples (and optionally, target_features) are specified,
|
||||
# only the specified targets will be checked when running `cargo deny check`.
|
||||
# This means, if a particular package is only ever used as a target specific
|
||||
# dependency, such as, for example, the `nix` crate only being used via the
|
||||
# `target_family = "unix"` configuration, that only having windows targets in
|
||||
# this list would mean the nix crate, as well as any of its exclusive
|
||||
# dependencies not shared by any other crates, would be ignored, as the target
|
||||
# list here is effectively saying which targets you are building for.
|
||||
targets = [
|
||||
# The triple can be any string, but only the target triples built in to
|
||||
# rustc (as of 1.40) can be checked against actual config expressions
|
||||
#"x86_64-unknown-linux-musl",
|
||||
# You can also specify which target_features you promise are enabled for a
|
||||
# particular target. target_features are currently not validated against
|
||||
# the actual valid features supported by the target architecture.
|
||||
#{ triple = "wasm32-unknown-unknown", features = ["atomics"] },
|
||||
]
|
||||
# When creating the dependency graph used as the source of truth when checks are
|
||||
# executed, this field can be used to prune crates from the graph, removing them
|
||||
# from the view of cargo-deny. This is an extremely heavy hammer, as if a crate
|
||||
# is pruned from the graph, all of its dependencies will also be pruned unless
|
||||
# they are connected to another crate in the graph that hasn't been pruned,
|
||||
# so it should be used with care. The identifiers are [Package ID Specifications]
|
||||
# (https://doc.rust-lang.org/cargo/reference/pkgid-spec.html)
|
||||
#exclude = []
|
||||
# If true, metadata will be collected with `--all-features`. Note that this can't
|
||||
# be toggled off if true, if you want to conditionally enable `--all-features` it
|
||||
# is recommended to pass `--all-features` on the cmd line instead
|
||||
all-features = false
|
||||
# If true, metadata will be collected with `--no-default-features`. The same
|
||||
# caveat with `all-features` applies
|
||||
no-default-features = false
|
||||
# If set, these feature will be enabled when collecting metadata. If `--features`
|
||||
# is specified on the cmd line they will take precedence over this option.
|
||||
#features = []
|
||||
|
||||
# The output table provides options for how/if diagnostics are outputted
|
||||
[output]
|
||||
# When outputting inclusion graphs in diagnostics that include features, this
|
||||
# option can be used to specify the depth at which feature edges will be added.
|
||||
# This option is included since the graphs can be quite large and the addition
|
||||
# of features from the crate(s) to all of the graph roots can be far too verbose.
|
||||
# This option can be overridden via `--feature-depth` on the cmd line
|
||||
feature-depth = 1
|
||||
|
||||
# This section is considered when running `cargo deny check advisories`
|
||||
# More documentation for the advisories section can be found here:
|
||||
# https://embarkstudios.github.io/cargo-deny/checks/advisories/cfg.html
|
||||
[advisories]
|
||||
# The path where the advisory databases are cloned/fetched into
|
||||
#db-path = "$CARGO_HOME/advisory-dbs"
|
||||
# The url(s) of the advisory databases to use
|
||||
#db-urls = ["https://github.com/rustsec/advisory-db"]
|
||||
# A list of advisory IDs to ignore. Note that ignored advisories will still
|
||||
# output a note when they are encountered.
|
||||
ignore = [
|
||||
#"RUSTSEC-0000-0000",
|
||||
#{ id = "RUSTSEC-0000-0000", reason = "you can specify a reason the advisory is ignored" },
|
||||
#"[email protected]", # you can also ignore yanked crate versions if you wish
|
||||
#{ crate = "[email protected]", reason = "you can specify why you are ignoring the yanked crate" },
|
||||
]
|
||||
# If this is true, then cargo deny will use the git executable to fetch advisory database.
|
||||
# If this is false, then it uses a built-in git library.
|
||||
# Setting this to true can be helpful if you have special authentication requirements that cargo-deny does not support.
|
||||
# See Git Authentication for more information about setting up git authentication.
|
||||
#git-fetch-with-cli = true
|
||||
|
||||
# This section is considered when running `cargo deny check licenses`
|
||||
# More documentation for the licenses section can be found here:
|
||||
# https://embarkstudios.github.io/cargo-deny/checks/licenses/cfg.html
|
||||
[licenses]
|
||||
# List of explicitly allowed licenses
|
||||
# See https://spdx.org/licenses/ for list of possible licenses
|
||||
# [possible values: any SPDX 3.11 short identifier (+ optional exception)].
|
||||
allow = [
|
||||
"MIT",
|
||||
"Apache-2.0",
|
||||
"Apache-2.0 WITH LLVM-exception",
|
||||
"Unicode-3.0",
|
||||
"Unicode-DFS-2016",
|
||||
"MIT-0",
|
||||
"ISC",
|
||||
"BSD-3-Clause",
|
||||
"Zlib",
|
||||
"MPL-2.0",
|
||||
]
|
||||
# The confidence threshold for detecting a license from license text.
|
||||
# The higher the value, the more closely the license text must be to the
|
||||
# canonical license text of a valid SPDX license file.
|
||||
# [possible values: any between 0.0 and 1.0].
|
||||
confidence-threshold = 0.8
|
||||
# Allow 1 or more licenses on a per-crate basis, so that particular licenses
|
||||
# aren't accepted for every possible crate as with the normal allow list
|
||||
exceptions = [
|
||||
# Each entry is the crate and version constraint, and its specific allow
|
||||
# list
|
||||
#{ allow = ["Zlib"], crate = "adler32" },
|
||||
]
|
||||
|
||||
# Some crates don't have (easily) machine readable licensing information,
|
||||
# adding a clarification entry for it allows you to manually specify the
|
||||
# licensing information
|
||||
#[[licenses.clarify]]
|
||||
# The package spec the clarification applies to
|
||||
#crate = "ring"
|
||||
# The SPDX expression for the license requirements of the crate
|
||||
#expression = "MIT AND ISC AND OpenSSL"
|
||||
# One or more files in the crate's source used as the "source of truth" for
|
||||
# the license expression. If the contents match, the clarification will be used
|
||||
# when running the license check, otherwise the clarification will be ignored
|
||||
# and the crate will be checked normally, which may produce warnings or errors
|
||||
# depending on the rest of your configuration
|
||||
#license-files = [
|
||||
# Each entry is a crate relative path, and the (opaque) hash of its contents
|
||||
#{ path = "LICENSE", hash = 0xbd0eed23 }
|
||||
#]
|
||||
|
||||
[licenses.private]
|
||||
# If true, ignores workspace crates that aren't published, or are only
|
||||
# published to private registries.
|
||||
# To see how to mark a crate as unpublished (to the official registry),
|
||||
# visit https://doc.rust-lang.org/cargo/reference/manifest.html#the-publish-field.
|
||||
ignore = false
|
||||
# One or more private registries that you might publish crates to, if a crate
|
||||
# is only published to private registries, and ignore is true, the crate will
|
||||
# not have its license(s) checked
|
||||
registries = [
|
||||
#"https://sekretz.com/registry
|
||||
]
|
||||
|
||||
# This section is considered when running `cargo deny check bans`.
|
||||
# More documentation about the 'bans' section can be found here:
|
||||
# https://embarkstudios.github.io/cargo-deny/checks/bans/cfg.html
|
||||
[bans]
|
||||
# Lint level for when multiple versions of the same crate are detected
|
||||
multiple-versions = "warn"
|
||||
# Lint level for when a crate version requirement is `*`
|
||||
wildcards = "allow"
|
||||
# The graph highlighting used when creating dotgraphs for crates
|
||||
# with multiple versions
|
||||
# * lowest-version - The path to the lowest versioned duplicate is highlighted
|
||||
# * simplest-path - The path to the version with the fewest edges is highlighted
|
||||
# * all - Both lowest-version and simplest-path are used
|
||||
highlight = "all"
|
||||
# The default lint level for `default` features for crates that are members of
|
||||
# the workspace that is being checked. This can be overridden by allowing/denying
|
||||
# `default` on a crate-by-crate basis if desired.
|
||||
workspace-default-features = "allow"
|
||||
# The default lint level for `default` features for external crates that are not
|
||||
# members of the workspace. This can be overridden by allowing/denying `default`
|
||||
# on a crate-by-crate basis if desired.
|
||||
external-default-features = "allow"
|
||||
# List of crates that are allowed. Use with care!
|
||||
allow = [
|
||||
#"[email protected]",
|
||||
#{ crate = "[email protected]", reason = "you can specify a reason it is allowed" },
|
||||
]
|
||||
# List of crates to deny
|
||||
deny = [
|
||||
#"[email protected]",
|
||||
#{ crate = "[email protected]", reason = "you can specify a reason it is banned" },
|
||||
# Wrapper crates can optionally be specified to allow the crate when it
|
||||
# is a direct dependency of the otherwise banned crate
|
||||
#{ crate = "[email protected]", wrappers = ["this-crate-directly-depends-on-ansi_term"] },
|
||||
]
|
||||
|
||||
# List of features to allow/deny
|
||||
# Each entry the name of a crate and a version range. If version is
|
||||
# not specified, all versions will be matched.
|
||||
#[[bans.features]]
|
||||
#crate = "reqwest"
|
||||
# Features to not allow
|
||||
#deny = ["json"]
|
||||
# Features to allow
|
||||
#allow = [
|
||||
# "rustls",
|
||||
# "__rustls",
|
||||
# "__tls",
|
||||
# "hyper-rustls",
|
||||
# "rustls",
|
||||
# "rustls-pemfile",
|
||||
# "rustls-tls-webpki-roots",
|
||||
# "tokio-rustls",
|
||||
# "webpki-roots",
|
||||
#]
|
||||
# If true, the allowed features must exactly match the enabled feature set. If
|
||||
# this is set there is no point setting `deny`
|
||||
#exact = true
|
||||
|
||||
# Certain crates/versions that will be skipped when doing duplicate detection.
|
||||
skip = [
|
||||
#"[email protected]",
|
||||
#{ crate = "[email protected]", reason = "you can specify a reason why it can't be updated/removed" },
|
||||
]
|
||||
# Similarly to `skip` allows you to skip certain crates during duplicate
|
||||
# detection. Unlike skip, it also includes the entire tree of transitive
|
||||
# dependencies starting at the specified crate, up to a certain depth, which is
|
||||
# by default infinite.
|
||||
skip-tree = [
|
||||
#"[email protected]", # will be skipped along with _all_ of its direct and transitive dependencies
|
||||
#{ crate = "[email protected]", depth = 20 },
|
||||
]
|
||||
|
||||
# This section is considered when running `cargo deny check sources`.
|
||||
# More documentation about the 'sources' section can be found here:
|
||||
# https://embarkstudios.github.io/cargo-deny/checks/sources/cfg.html
|
||||
[sources]
|
||||
# Lint level for what to happen when a crate from a crate registry that is not
|
||||
# in the allow list is encountered
|
||||
unknown-registry = "warn"
|
||||
# Lint level for what to happen when a crate from a git repository that is not
|
||||
# in the allow list is encountered
|
||||
unknown-git = "warn"
|
||||
# List of URLs for allowed crate registries. Defaults to the crates.io index
|
||||
# if not specified. If it is specified but empty, no registries are allowed.
|
||||
allow-registry = ["https://github.com/rust-lang/crates.io-index"]
|
||||
# List of URLs for allowed Git repositories
|
||||
allow-git = []
|
||||
|
||||
[sources.allow-org]
|
||||
# 1 or more github.com organizations to allow git sources for
|
||||
github = [""]
|
||||
# 1 or more gitlab.com organizations to allow git sources for
|
||||
gitlab = [""]
|
||||
# 1 or more bitbucket.org organizations to allow git sources for
|
||||
bitbucket = [""]
|
||||
@@ -1,15 +1,36 @@
|
||||
{
|
||||
"nodes": {
|
||||
"fenix": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
],
|
||||
"rust-analyzer-src": "rust-analyzer-src"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1756795219,
|
||||
"narHash": "sha256-tKBQtz1JLKWrCJUxVkHKR+YKmVpm0KZdJdPWmR2slQ8=",
|
||||
"owner": "nix-community",
|
||||
"repo": "fenix",
|
||||
"rev": "80dbdab137f2809e3c823ed027e1665ce2502d74",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "fenix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-parts": {
|
||||
"inputs": {
|
||||
"nixpkgs-lib": "nixpkgs-lib"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1790898470,
|
||||
"narHash": "sha256-zTwuwezD0w3hpga6a6P8emidzAZFyWqlNeRBlpWOOl8=",
|
||||
"lastModified": 1762980239,
|
||||
"narHash": "sha256-8oNVE8TrD19ulHinjaqONf9QWCKK+w4url56cdStMpM=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "024633cd702b10285db5cb19b40ad48d2399ba60",
|
||||
"rev": "52a2caecc898d0b46b2b905f058ccc5081f842da",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -20,11 +41,11 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1790822859,
|
||||
"narHash": "sha256-69xHQhAeMAD2wDXO7T2pcOZIF9Sga2W+JkmY2a11Ops=",
|
||||
"lastModified": 1756787288,
|
||||
"narHash": "sha256-rw/PHa1cqiePdBxhF66V7R+WAP8WekQ0mCDG4CFqT8Y=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "c59305bab2065cfecc4944690d9eedbb56f3a9fa",
|
||||
"rev": "d0fc30899600b9b3466ddb260fd83deb486c32f1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -36,11 +57,11 @@
|
||||
},
|
||||
"nixpkgs-lib": {
|
||||
"locked": {
|
||||
"lastModified": 1790477367,
|
||||
"narHash": "sha256-oujbxmVKDhci2E4EM3KyAbRUgp5/IsCoiA/LfEF7OOk=",
|
||||
"lastModified": 1761765539,
|
||||
"narHash": "sha256-b0yj6kfvO8ApcSE+QmA6mUfu8IYG6/uU28OFn4PaC8M=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs.lib",
|
||||
"rev": "f7cd230690d9fc982d06129f9189b101fddcfa3b",
|
||||
"rev": "719359f4562934ae99f5443f20aa06c2ffff91fc",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -51,9 +72,27 @@
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"fenix": "fenix",
|
||||
"flake-parts": "flake-parts",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
},
|
||||
"rust-analyzer-src": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1756597274,
|
||||
"narHash": "sha256-wfaKRKsEVQDB7pQtAt04vRgFphkVscGRpSx3wG1l50E=",
|
||||
"owner": "rust-lang",
|
||||
"repo": "rust-analyzer",
|
||||
"rev": "21614ed2d3279a9aa1f15c88d293e65a98991b30",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "rust-lang",
|
||||
"ref": "nightly",
|
||||
"repo": "rust-analyzer",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
|
||||
@@ -1,159 +1,73 @@
|
||||
{
|
||||
description = "SlimeVR Server & GUI";
|
||||
description = "Affordable full-body tracking for VR!";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
fenix = {
|
||||
url = "github:nix-community/fenix";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
outputs =
|
||||
inputs@{
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-parts,
|
||||
...
|
||||
}:
|
||||
outputs = inputs@{ self, nixpkgs, flake-parts, fenix, ... }:
|
||||
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||
systems = [
|
||||
"aarch64-linux"
|
||||
"x86_64-linux"
|
||||
];
|
||||
systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
|
||||
|
||||
perSystem =
|
||||
{
|
||||
system,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
perSystem = { system, lib, ... }:
|
||||
let
|
||||
runtimeLibs = [
|
||||
pkgs.alsa-lib
|
||||
pkgs.libpulseaudio
|
||||
pkgs.at-spi2-atk
|
||||
pkgs.at-spi2-core
|
||||
pkgs.cairo
|
||||
pkgs.cups
|
||||
pkgs.dbus
|
||||
pkgs.expat
|
||||
pkgs.gdk-pixbuf
|
||||
pkgs.glib
|
||||
pkgs.gtk3
|
||||
pkgs.libdrm
|
||||
pkgs.libgbm
|
||||
pkgs.libglvnd
|
||||
pkgs.libnotify
|
||||
pkgs.libxkbcommon
|
||||
pkgs.mesa
|
||||
pkgs.nspr
|
||||
pkgs.nss
|
||||
pkgs.pango
|
||||
pkgs.systemd
|
||||
pkgs.vulkan-loader
|
||||
pkgs.wayland
|
||||
pkgs.libX11
|
||||
pkgs.libXcomposite
|
||||
pkgs.libXdamage
|
||||
pkgs.libXext
|
||||
pkgs.libXfixes
|
||||
pkgs.libXrandr
|
||||
pkgs.libxcb
|
||||
pkgs.libxshmfence
|
||||
pkgs.libusb1
|
||||
pkgs.udev
|
||||
pkgs.libxcrypt-legacy
|
||||
];
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
|
||||
# we use static runtime
|
||||
# https://github.com/electron-userland/electron-builder/blob/a6117b3011a105204af8cc2eca02a56976d1ef29/packages/app-builder-lib/src/toolsets/linux.ts#L122
|
||||
appImageTools = pkgs.stdenvNoCC.mkDerivation {
|
||||
name = "electron-builder-appimage-runtime";
|
||||
src =
|
||||
let
|
||||
# Keep in sync with "appimage" toolset version in gui/electron/electron-builder.yml
|
||||
appimageToolsVersion = "1.0.3";
|
||||
in
|
||||
pkgs.fetchzip {
|
||||
url = "https://github.com/electron-userland/electron-builder-binaries/releases/download/appimage@${appimageToolsVersion}/appimage-tools-runtime-20251108.tar.gz";
|
||||
hash = "sha256-Iqhvyp6BNpH+tXvVO7MLgYbsJ6va4lXO7El3wtyWBII=";
|
||||
stripRoot = false;
|
||||
};
|
||||
rust_toolchain = lib.importTOML ./rust-toolchain.toml;
|
||||
fenixPkgs = fenix.packages.${system};
|
||||
|
||||
installPhase = ''
|
||||
mkdir $out
|
||||
cp -r -t $out/ lib/ runtimes/
|
||||
ln -s -t $out \
|
||||
"${pkgs.desktop-file-utils}/bin/desktop-file-validate" \
|
||||
"${pkgs.squashfsTools}/bin/mksquashfs"
|
||||
'';
|
||||
rustToolchainSet = fenixPkgs.fromToolchainName {
|
||||
name = rust_toolchain.toolchain.channel;
|
||||
sha256 = "sha256-+9FmLhAOezBZCOziO0Qct1NOrfpjNsXxc/8I0c7BdKE=";
|
||||
};
|
||||
in {
|
||||
|
||||
buildToolsVersion = "36.0.0";
|
||||
androidComposition = pkgs.androidenv.composeAndroidPackages {
|
||||
buildToolsVersions = [
|
||||
buildToolsVersion
|
||||
];
|
||||
platformVersions = [
|
||||
"36"
|
||||
];
|
||||
};
|
||||
in
|
||||
{
|
||||
# For Android SDK
|
||||
_module.args.pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
config.allowUnfree = true;
|
||||
config.android_sdk.accept_license = true;
|
||||
};
|
||||
devShells.default = pkgs.mkShell {
|
||||
name = "slimevr";
|
||||
|
||||
devShells.default = pkgs.mkShell rec {
|
||||
packages = [
|
||||
# for running the jar
|
||||
pkgs.jdk25
|
||||
buildInputs =
|
||||
(with pkgs; [
|
||||
cacert
|
||||
]) ++ lib.optionals pkgs.stdenv.isLinux (with pkgs; [
|
||||
atk cairo dbus dbus.lib dprint gdk-pixbuf glib.out glib-networking
|
||||
gobject-introspection gtk3 harfbuzz libffi libsoup_3 openssl.dev pango
|
||||
pkg-config treefmt webkitgtk_4_1 zlib
|
||||
gst_all_1.gstreamer gst_all_1.gst-plugins-base
|
||||
gst_all_1.gst-plugins-good gst_all_1.gst-plugins-bad
|
||||
librsvg freetype expat libayatana-appindicator udev libusb1
|
||||
]) ++ lib.optionals pkgs.stdenv.isDarwin [
|
||||
pkgs.darwin.apple_sdk.frameworks.Security
|
||||
] ++ [
|
||||
pkgs.jdk17
|
||||
pkgs.kotlin
|
||||
rustToolchainSet.rustc
|
||||
rustToolchainSet.cargo
|
||||
rustToolchainSet.rustfmt
|
||||
];
|
||||
|
||||
# for build
|
||||
pkgs.electron
|
||||
pkgs.rpm
|
||||
pkgs.fpm
|
||||
pkgs.p7zip
|
||||
# For Windows GUI cross-build
|
||||
pkgs.wineWow64Packages.stable
|
||||
pkgs.zlib
|
||||
pkgs.squashfsTools
|
||||
pkgs.desktop-file-utils
|
||||
pkgs.fakeroot
|
||||
pkgs.libarchive
|
||||
pkgs.icu
|
||||
pkgs.nodejs_22
|
||||
pkgs.pnpm
|
||||
pkgs.pkg-config
|
||||
pkgs.python3
|
||||
pkgs.gcc
|
||||
pkgs.gnumake
|
||||
pkgs.binutils
|
||||
pkgs.git
|
||||
pkgs.node-gyp-build
|
||||
androidComposition.androidsdk
|
||||
];
|
||||
buildInputs = runtimeLibs;
|
||||
nativeBuildInputs = with pkgs; [ pnpm nodejs_22 gradle ];
|
||||
|
||||
RUST_BACKTRACE = 1;
|
||||
GIO_EXTRA_MODULES = "${pkgs.glib-networking}/lib/gio/modules:${pkgs.dconf.lib}/lib/gio/modules";
|
||||
|
||||
shellHook = ''
|
||||
export LD_LIBRARY_PATH="${
|
||||
lib.makeLibraryPath [
|
||||
pkgs.systemd
|
||||
pkgs.hidapi
|
||||
]
|
||||
}:$LD_LIBRARY_PATH"
|
||||
'';
|
||||
export SLIMEVR_RUST_LD_LIBRARY_PATH="$LD_LIBRARY_PATH"
|
||||
export LD_LIBRARY_PATH="${pkgs.udev}/lib:${pkgs.libayatana-appindicator}/lib:$LD_LIBRARY_PATH"
|
||||
export GST_PLUGIN_SYSTEM_PATH_1_0="${pkgs.gst_all_1.gstreamer.out}/lib/gstreamer-1.0:${pkgs.gst_all_1.gst-plugins-base}/lib/gstreamer-1.0:${pkgs.gst_all_1.gst-plugins-good}/lib/gstreamer-1.0:${pkgs.gst_all_1.gst-plugins-bad}/lib/gstreamer-1.0"
|
||||
|
||||
JAVA_HOME = "${pkgs.jdk25}/lib/openjdk";
|
||||
USE_SYSTEM_FPM = "true";
|
||||
ELECTRON_BUILDER_7ZIP_PATH = "${pkgs.p7zip}/bin/7za";
|
||||
APPIMAGE_TOOLS_PATH = "${appImageTools}";
|
||||
# for electron-vite, so `pnpm gui` works
|
||||
ELECTRON_EXEC_PATH = "${pkgs.electron}/bin/electron";
|
||||
ANDROID_HOME = "${androidComposition.androidsdk}/libexec/android-sdk";
|
||||
GRADLE_OPTS = "-Dorg.gradle.project.android.aapt2FromMavenOverride=${ANDROID_HOME}/build-tools/${buildToolsVersion}/aapt2";
|
||||
# Force linker and pkg-config to use udev from nixpkgs so libgudev/hidapi
|
||||
# resolve against the correct libudev implementation at link time.
|
||||
export PKG_CONFIG_PATH="${pkgs.udev}/lib/pkgconfig:${pkgs.glib}/lib/pkgconfig:$PKG_CONFIG_PATH"
|
||||
export LIBRARY_PATH="${pkgs.udev}/lib:$LIBRARY_PATH"
|
||||
export LD_RUN_PATH="${pkgs.udev}/lib:$LD_RUN_PATH"
|
||||
export NIX_LDFLAGS="-L${pkgs.udev}/lib -ludev $NIX_LDFLAGS"
|
||||
export LDFLAGS="-L${pkgs.udev}/lib -Wl,-rpath,${pkgs.udev}/lib -ludev $LDFLAGS"
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,30 +1,20 @@
|
||||
# Fixes bug with spotless. See https://github.com/diffplug/spotless/issues/834#issuecomment-819118761
|
||||
org.gradle.jvmargs=-Xmx4g -Xms1g \
|
||||
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
|
||||
org.gradle.jvmargs=--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
|
||||
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \
|
||||
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED \
|
||||
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
|
||||
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
|
||||
|
||||
org.gradle.parallel=true
|
||||
#org.gradle.caching=true
|
||||
org.gradle.configureondemand=true
|
||||
|
||||
kotlin.code.style=official
|
||||
# https://github.com/Kotlin/kotlinx-atomicfu#atomicfu-compiler-plugin
|
||||
kotlinx.atomicfu.enableJvmIrTransformation=true
|
||||
|
||||
android.useAndroidX=true
|
||||
android.nonTransitiveRClass=true
|
||||
#org.gradle.configuration-cache=true
|
||||
# solarxr-protocol:kotlin-codegen's generateTestSchemas isn't cache-compatible yet (submodule); degrade to a warning there instead of failing the whole build
|
||||
#org.gradle.configuration-cache.problems=warn
|
||||
org.gradle.unsafe.configuration-cache=false
|
||||
|
||||
kotlinVersion=2.3.10
|
||||
spotlessVersion=8.2.1
|
||||
shadowJarVersion=9.3.1
|
||||
buildconfigVersion=6.0.7
|
||||
wireVersion=5.3.1
|
||||
# sentry and sentry-android-core must stay on the same version
|
||||
sentryVersion=8.+
|
||||
sentryAndroidGradleVersion=6.23.0
|
||||
kotlinVersion=2.0.20
|
||||
spotlessVersion=8.0.0
|
||||
shadowJarVersion=8.3.2
|
||||
buildconfigVersion=5.5.0
|
||||
grgitVersion=5.2.2
|
||||
@@ -1,7 +1,7 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionSha256Sum=bbaeb2fef8710818cf0e261201dab964c572f92b942812df0c3620d62a529a01
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.6.0-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
|
||||
distributionSha256Sum=bd71102213493060956ec229d946beee57158dbd89d0e62b91bca0fa2c5f3531
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
@@ -86,7 +86,8 @@ done
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
|
||||
' "$PWD" ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
@@ -114,7 +115,7 @@ case "$( uname )" in #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH="\\\"\\\""
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
@@ -205,7 +206,7 @@ fi
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
@@ -213,7 +214,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
|
||||
@@ -70,11 +70,11 @@ goto fail
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
# JS/TS dependencies
|
||||
node_modules/
|
||||
.pnp
|
||||
/node_modules
|
||||
/.pnp
|
||||
.pnp.js
|
||||
|
||||
# testing
|
||||
coverage/
|
||||
/coverage
|
||||
|
||||
# Build artifacts
|
||||
build/
|
||||
target/
|
||||
/build
|
||||
/target
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
@@ -26,16 +26,12 @@ yarn-error.log*
|
||||
*.log
|
||||
|
||||
# vite
|
||||
dist/
|
||||
stats.html
|
||||
/dist
|
||||
/stats.html
|
||||
vite.config.ts.timestamp*
|
||||
electron.vite.config.*.mjs
|
||||
|
||||
# eslint
|
||||
.eslintcache
|
||||
|
||||
# Sentry Config File
|
||||
.env.sentry-build-plugin
|
||||
|
||||
# electron
|
||||
out/
|
||||
@@ -1,5 +1,5 @@
|
||||
export default {
|
||||
'app/**/*.{js,jsx,ts,tsx}':
|
||||
'pnpm --filter @slimevr/gui-app exec eslint --no-warn-ignored --cache --fix',
|
||||
'**/*.{ts,tsx}': () => 'tsc -p tsconfig.json --noEmit',
|
||||
'src/**/*.{js,jsx,ts,tsx}': 'eslint --max-warnings=0 --no-warn-ignored --cache --fix',
|
||||
'**/*.{js,jsx,ts,tsx,css,scss,md,json}': 'prettier --write',
|
||||
};
|
||||
@@ -1,223 +0,0 @@
|
||||
# Please developers (not translators) don't reuse a key inside another key
|
||||
# or concat text with a translation string in the code, use the appropriate
|
||||
# features like variables and selectors in each appropriate case!
|
||||
# And also comment the string if it's something not easy to translate, so you help
|
||||
# translators on what it means
|
||||
|
||||
|
||||
## Websocket (server) status
|
||||
|
||||
|
||||
## Update notification
|
||||
|
||||
|
||||
## Tips
|
||||
|
||||
|
||||
## Units
|
||||
|
||||
|
||||
## Dropdown
|
||||
|
||||
|
||||
## Text input
|
||||
|
||||
|
||||
## File input
|
||||
|
||||
|
||||
## Window controls
|
||||
|
||||
|
||||
## Body parts
|
||||
|
||||
|
||||
## BoardType
|
||||
|
||||
|
||||
## Proportions
|
||||
|
||||
|
||||
## Tracker reset buttons
|
||||
|
||||
|
||||
## Navigation bar
|
||||
|
||||
|
||||
## Biovision hierarchy recording
|
||||
|
||||
|
||||
## Tracking pause
|
||||
|
||||
|
||||
## Widget: Developer settings
|
||||
|
||||
|
||||
## Widget: IMU Visualizer
|
||||
|
||||
|
||||
## Tracker status
|
||||
|
||||
|
||||
## Tracker status columns
|
||||
|
||||
|
||||
## Tracker rotation
|
||||
|
||||
|
||||
## Tracker information
|
||||
|
||||
|
||||
## Tracker settings
|
||||
|
||||
|
||||
## Dongle settings
|
||||
|
||||
|
||||
## Tracker part card info
|
||||
|
||||
|
||||
## Body assignment menu
|
||||
|
||||
|
||||
## Tracker assignment menu
|
||||
|
||||
|
||||
## Mounting menu
|
||||
|
||||
|
||||
## Sidebar settings
|
||||
|
||||
|
||||
## Bone routing settings
|
||||
|
||||
|
||||
## SteamVR / Monado output settings
|
||||
|
||||
|
||||
## Tracker mechanics
|
||||
|
||||
|
||||
## Keybinds Page
|
||||
|
||||
|
||||
## FK/Tracking settings
|
||||
|
||||
|
||||
## Gesture control settings (tracker tapping)
|
||||
|
||||
|
||||
## Appearance settings
|
||||
|
||||
settings-general-interface-dev_mode-description = This mode can be useful if you need in-depth data or need to interact with connected trackers on a more advanced level.
|
||||
|
||||
## Notification settings
|
||||
|
||||
|
||||
## Behavior settings
|
||||
|
||||
|
||||
## Serial settings
|
||||
|
||||
|
||||
## OSC VRChat settings
|
||||
|
||||
|
||||
## VRChat OSC status
|
||||
|
||||
|
||||
## VMC OSC settings
|
||||
|
||||
|
||||
## Common OSC settings
|
||||
|
||||
|
||||
## Advanced settings
|
||||
|
||||
|
||||
## Home Screen
|
||||
|
||||
|
||||
## Tracking Checklist
|
||||
|
||||
|
||||
## Setup/onboarding menu
|
||||
|
||||
|
||||
## Quiz
|
||||
|
||||
|
||||
## Wi-Fi setup
|
||||
|
||||
|
||||
## Install info
|
||||
|
||||
|
||||
## Setup start
|
||||
|
||||
|
||||
## Tracker connection setup
|
||||
|
||||
|
||||
## Tracker assignment setup
|
||||
|
||||
|
||||
## Tracker assignment warnings
|
||||
|
||||
|
||||
## Tracker mounting method choose
|
||||
|
||||
|
||||
## Tracker manual mounting setup
|
||||
|
||||
|
||||
## Tracker automatic mounting setup
|
||||
|
||||
|
||||
## Tracker manual proportions setupa
|
||||
|
||||
|
||||
## Tracker automatic proportions setup
|
||||
|
||||
|
||||
## User height calibration
|
||||
|
||||
|
||||
## Stay Aligned setup
|
||||
|
||||
|
||||
## Home
|
||||
|
||||
|
||||
## Trackers Still On notification
|
||||
|
||||
|
||||
## Firmware tool globals
|
||||
|
||||
|
||||
## Firmware tool Steps
|
||||
|
||||
|
||||
## firmware tool build status
|
||||
|
||||
|
||||
## Firmware update status
|
||||
|
||||
|
||||
## Dedicated Firmware Update Page
|
||||
|
||||
|
||||
## Tray Menu
|
||||
|
||||
|
||||
## First exit modal
|
||||
|
||||
|
||||
## Unknown device modal
|
||||
|
||||
|
||||
## Error collection consent modal
|
||||
|
||||
|
||||
## Tracking checklist section
|
||||
|
||||
@@ -1,464 +0,0 @@
|
||||
# Please developers (not translators) don't reuse a key inside another key
|
||||
# or concat text with a translation string in the code, use the appropriate
|
||||
# features like variables and selectors in each appropriate case!
|
||||
# And also comment the string if it's something not easy to translate, so you help
|
||||
# translators on what it means
|
||||
|
||||
|
||||
## Websocket (server) status
|
||||
|
||||
websocket-connecting = Sunucuya bağlanılıyor...
|
||||
websocket-connection_lost = Sunucuyla bağlantı kesildi. Tekrar bağlanılmaya çalışılıyor...
|
||||
websocket-connection_lost-desc = SlimeVR sunucusu çöktü. Kayıtları kontrol edip programı yeniden başlat.
|
||||
websocket-timedout = Sunucuya bağlanılamadı
|
||||
websocket-timedout-desc = SlimeVR sunucusu çöktü veya zaman aşımına uğradı. Kayıtları kontrol et ve programı yeniden başlat.
|
||||
websocket-error-close = SlimeVR'ı kapat
|
||||
websocket-error-logs = Kayıtlar klasörünü aç
|
||||
|
||||
## Update notification
|
||||
|
||||
version_update-title = Yeni sürüm mevcut: { $version }
|
||||
version_update-description = "{ version_update-update }" seçeneğine tıklamak SlimeVR kurulum uygulamasını indirir.
|
||||
version_update-update = Güncelle
|
||||
version_update-close = Kapat
|
||||
|
||||
## Tips
|
||||
|
||||
tips-find_tracker = Hangi takipçi hangisi emin değil misin? Takipçilerden birini hareket ettirerek belirleyebilirsin.
|
||||
tips-do_not_move_heels = Kayıt sırasında ayaklarının hareket etmediğinden emin ol!
|
||||
tips-file_select = Dosyaları sürükleyip bırak veya dosyalarından <u>seç</u>.
|
||||
tips-failed_webgl = WebGL başlatılamadı.
|
||||
|
||||
## Units
|
||||
|
||||
unit-meter = Metre
|
||||
unit-foot = Ayak
|
||||
unit-inch = Inç
|
||||
|
||||
## Dropdown
|
||||
|
||||
|
||||
## Text input
|
||||
|
||||
|
||||
## File input
|
||||
|
||||
|
||||
## Window controls
|
||||
|
||||
titlebar-close = Kapat
|
||||
|
||||
## Body parts
|
||||
|
||||
body_part-NONE = Atanmamış
|
||||
body_part-HEAD = Kafa
|
||||
body_part-NECK = Boyun
|
||||
body_part-RIGHT_SHOULDER = Sağ Omuz
|
||||
body_part-RIGHT_UPPER_ARM = Sağ Üst Kol
|
||||
body_part-RIGHT_LOWER_ARM = Sağ Alt Kol
|
||||
body_part-RIGHT_HAND = Sağ El
|
||||
body_part-RIGHT_UPPER_LEG = Sağ Uyluk
|
||||
body_part-RIGHT_LOWER_LEG = Sağ Ayak Bileği
|
||||
body_part-RIGHT_FOOT = Sağ Ayak
|
||||
body_part-UPPER_CHEST = Üst Göğüs
|
||||
body_part-HIP = Kalça
|
||||
body_part-LEFT_SHOULDER = Sol Omuz
|
||||
body_part-LEFT_UPPER_ARM = Sol Üst Kol
|
||||
body_part-LEFT_LOWER_ARM = Sol Alt Kol
|
||||
body_part-LEFT_HAND = Sol El
|
||||
body_part-LEFT_UPPER_LEG = Sol Uyluk
|
||||
body_part-LEFT_LOWER_LEG = Sol Ayak Bileği
|
||||
body_part-LEFT_FOOT = Sol Ayak
|
||||
body_part-LEFT_THUMB_METACARPAL = Sol başparmak metakarpal kemiği
|
||||
body_part-LEFT_THUMB_PROXIMAL = Sol başparmak proksimal kemiği
|
||||
body_part-LEFT_THUMB_DISTAL = Sol başparmak distal falanks kemiği
|
||||
body_part-LEFT_INDEX_PROXIMAL = Sol işaret parmağının proksimal falanks kemiği
|
||||
body_part-LEFT_INDEX_INTERMEDIATE = Sol işaret parmağının orta falanks kemiği
|
||||
body_part-LEFT_INDEX_DISTAL = Sol işaret parmağının distal falanks kemiği
|
||||
body_part-LEFT_MIDDLE_PROXIMAL = Sol orta parmağın proksimal falanks kemiği
|
||||
body_part-LEFT_MIDDLE_INTERMEDIATE = Sol orta parmağın orta falanks kemiği
|
||||
body_part-LEFT_MIDDLE_DISTAL = Sol orta parmağın distal falanks kemiği
|
||||
body_part-LEFT_RING_PROXIMAL = Sol yüzük parmağının proksimal falanks kemiği
|
||||
body_part-LEFT_RING_INTERMEDIATE = Sol yüzük parmağının orta falanks kemiği
|
||||
body_part-LEFT_RING_DISTAL = Sol yüzük parmağının distal falanks kemiği
|
||||
body_part-LEFT_LITTLE_PROXIMAL = Sol küçük parmağın proksimal falanks kemiği
|
||||
body_part-LEFT_LITTLE_INTERMEDIATE = Sol küçük parmağın orta falanks kemiği
|
||||
body_part-LEFT_LITTLE_DISTAL = Sol küçük parmağın distal falanks kemiği
|
||||
body_part-RIGHT_THUMB_METACARPAL = Sağ başparmak metakarpal kemiği
|
||||
body_part-RIGHT_THUMB_PROXIMAL = Sağ başparmağın proksimal falanks kemiği
|
||||
body_part-RIGHT_THUMB_DISTAL = Sağ başparmağın distal falanks kemiği
|
||||
body_part-RIGHT_INDEX_PROXIMAL = Sağ işaret parmağının proksimal falanks kemiği
|
||||
body_part-RIGHT_INDEX_INTERMEDIATE = Sağ işaret parmağının orta falanks kemiği
|
||||
body_part-RIGHT_INDEX_DISTAL = Sağ işaret parmağının distal falanks kemiği
|
||||
body_part-RIGHT_MIDDLE_PROXIMAL = Sağ orta parmağın proksimal falanks kemiği
|
||||
body_part-RIGHT_MIDDLE_INTERMEDIATE = Sağ orta parmağın orta falanks kemiği
|
||||
body_part-RIGHT_MIDDLE_DISTAL = Sağ orta parmağın distal falanks kemiği
|
||||
body_part-RIGHT_RING_PROXIMAL = Sağ yüzük parmağının proksimal falanks kemiği
|
||||
body_part-RIGHT_RING_INTERMEDIATE = Sağ yüzük parmağının orta falanks kemiği
|
||||
body_part-RIGHT_RING_DISTAL = Sağ yüzük parmağının distal falanks kemiği
|
||||
body_part-RIGHT_LITTLE_PROXIMAL = Sağ küçük parmağın proksimal falanks kemiği
|
||||
body_part-RIGHT_LITTLE_INTERMEDIATE = Sağ küçük parmağın orta falanks kemiği
|
||||
body_part-RIGHT_LITTLE_DISTAL = Sağ küçük parmağın distal falanks kemiği
|
||||
|
||||
## BoardType
|
||||
|
||||
board_type-UNKNOWN = Bilinmeyen
|
||||
board_type-GLOVE_IMU_SLIMEVR_DEV = SlimeVR Dev IMU Eldiveni
|
||||
board_type-GESTURES = Hareketler
|
||||
board_type-GENERIC_NRF = Jenerik nRF
|
||||
|
||||
## Proportions
|
||||
|
||||
skeleton_bone-NONE = Yok
|
||||
skeleton_bone-NECK = Boyun Uzunluğu
|
||||
skeleton_bone-NECK-desc =
|
||||
Bu, başının ortasından boynunun başlangıcına kadar olan mesafedir.
|
||||
Ayarlamak için başını 'evet' der gibi yukarı-aşağı hareket ettir veya başını hafifçe öne eğip, başını sola ve sağa kaydır,
|
||||
diğer takipçiler yerinden oynamayana kadar bunu tekrarlayıp ayarla.
|
||||
skeleton_bone-torso_group = Gövde Uzunluğu
|
||||
skeleton_bone-torso_group-desc =
|
||||
Bu, boynunun başlangıcından kalçalarına kadar olan mesafedir.
|
||||
Ayarlamak için dik dur ve sanal kalçaların, gerçek kalçalarınla hizalanana kadar değeri değiştir.
|
||||
skeleton_bone-UPPER_CHEST = Üst Göğüs Uzunluğu
|
||||
skeleton_bone-UPPER_CHEST-desc =
|
||||
Bu, boynunun başlangıcından göğsünün ortasına kadar olan mesafedir.
|
||||
Gövde uzunluğunu doğru şekilde ayarlayıp (otururken, eğilirken, uzanırken vb. duruşlarda) sanal omurgan,
|
||||
gerçek omurganla eşleşene kadar bu değeri değiştir.
|
||||
skeleton_bone-LOWER_CHEST-desc =
|
||||
Bu, göğsünün ortasından omurganın ortasına kadar olan mesafedir.
|
||||
Gövde uzunluğunu doğru şekilde ayarlayıp (otururken, eğilirken, uzanırken vb. duruşlarda) sanal omurgan,
|
||||
gerçek omurganla eşleşene kadar bu değeri değiştir.
|
||||
skeleton_bone-HIP = Kalça Uzunluğu
|
||||
skeleton_bone-HIP-desc =
|
||||
Bu, göbek deliğinden kalçalarına kadar olan mesafedir.
|
||||
Gövde uzunluğunu doğru şekilde ayarlayıp (otururken, eğilirken, uzanırken vb. duruşlarda) sanal omurgan,
|
||||
gerçek omurganla eşleşene kadar bu değeri değiştir.
|
||||
skeleton_bone-HIPS_WIDTH = Kalça Genişliği
|
||||
skeleton_bone-HIPS_WIDTH-desc =
|
||||
Bu, bacaklarının başladığı noktalar arasındaki mesafedir.
|
||||
Ayarlamak için bacaklarını düz tutarak tam bir sıfırlama yap ve,
|
||||
sanal bacaklarının aralığı, gerçek bacaklarının aralığıyla hizalanana kadar bu değeri değiştir.
|
||||
skeleton_bone-leg_group = Bacak uzunluğu
|
||||
skeleton_bone-leg_group-desc =
|
||||
Bu, kalçandan ayaklarına olan mesafedir.
|
||||
Ayarlamak için Gövde uzunluğunu doğru şekilde ayarla ve,
|
||||
sanal ayakların gerçek ayaklarınla aynı seviyeye gelene kadar bu değeri değiştir.
|
||||
skeleton_bone-UPPER_LEG = Üst Bacak Uzunluğu
|
||||
skeleton_bone-UPPER_LEG-desc =
|
||||
Bu, kalçandan dizlerine olan mesafedir.
|
||||
Ayarlamak için Bacak uzunluğunu doğru şekilde ayarla ve,
|
||||
sanal dizlerin gerçek dizlerinle aynı seviyeye gelene kadar bu değeri değiştir.
|
||||
skeleton_bone-LOWER_LEG = Alt Bacak Uzunluğu
|
||||
skeleton_bone-LOWER_LEG-desc =
|
||||
Bu, dizlerinden ayak bileklerine olan mesafedir.
|
||||
Ayarlamak için Bacak uzunluğunu doğru şekilde ayarla ve,
|
||||
sanal dizlerin gerçek dizlerinle aynı seviyeye gelene kadar bu değeri değiştir.
|
||||
skeleton_bone-FOOT_LENGTH = Ayak Uzunluğu
|
||||
skeleton_bone-FOOT_LENGTH-desc =
|
||||
Bu, ayak bileklerinden ayak parmaklarına olan mesafedir.
|
||||
Ayarlamak için parmak uçlarına çık ve sanal ayakların sabit kalana kadar bu değeri değiştir.
|
||||
skeleton_bone-FOOT_SHIFT = Ayak hizası
|
||||
skeleton_bone-FOOT_SHIFT-desc =
|
||||
Bu değer, dizinden ayak bileğine olan yatay mesafedir.
|
||||
Bu, dik dururken alt bacaklarının geriye doğru konumlanmasını telafi eder.
|
||||
Ayarlamak için Ayak uzunluğunu 0 olarak ayarla, tam sıfırlama yap ve,
|
||||
sanal ayakların ayak bileklerinin ortasıyla hizalanana kadar bu değeri değiştir.
|
||||
skeleton_bone-SHOULDERS_DISTANCE = Omuz Mesafesi
|
||||
skeleton_bone-SHOULDERS_WIDTH = Omuz Genişliği
|
||||
skeleton_bone-arm_group = Kol uzunluğu
|
||||
skeleton_bone-UPPER_ARM = Üst Kol Uzunluğu
|
||||
skeleton_bone-LOWER_ARM = Alt Kol Uzunluğu
|
||||
|
||||
## Tracker reset buttons
|
||||
|
||||
reset-reset_all = Tüm oranları sıfırla
|
||||
reset-reset_all_warning-cancel = İptal et
|
||||
reset-full = Sıfırlama
|
||||
reset-mounting-feet = Ayak Kalibrasyonu
|
||||
reset-mounting-fingers = Parmak Kalibrasyonu
|
||||
|
||||
## Navigation bar
|
||||
|
||||
navbar-home = Ana Menü
|
||||
navbar-body_proportions = Vücut Oranları
|
||||
navbar-onboarding = Kurulum Sihirbazı
|
||||
navbar-settings = Ayarlar
|
||||
|
||||
## Biovision hierarchy recording
|
||||
|
||||
bvh-start_recording = BVH Kaydet
|
||||
bvh-recording = Kaydediliyor
|
||||
|
||||
## Tracking pause
|
||||
|
||||
tracking-unpaused = Takibi duraklat
|
||||
|
||||
## Widget: Developer settings
|
||||
|
||||
widget-developer_mode = Geliştirici Modu
|
||||
widget-developer_mode-high_contrast = Yüksek kontrast
|
||||
widget-developer_mode-precise_rotation = Hassas dönüş
|
||||
|
||||
## Widget: IMU Visualizer
|
||||
|
||||
widget-imu_visualizer = Rotasyon
|
||||
widget-imu_visualizer-preview = Önizle
|
||||
widget-imu_visualizer-hide = Gizle
|
||||
widget-imu_visualizer-rotation_preview = Önizle
|
||||
|
||||
## Tracker status
|
||||
|
||||
tracker-status-none = Durum Yok
|
||||
tracker-status-busy = Meşgul
|
||||
tracker-status-error = Hata
|
||||
tracker-status-disconnected = Bağlantı kesildi
|
||||
tracker-status-ok = İYİ
|
||||
tracker-status-timed_out = Zaman aşımı
|
||||
|
||||
## Tracker status columns
|
||||
|
||||
tracker-table-column-name = İsim
|
||||
tracker-table-column-type = Tür
|
||||
tracker-table-column-battery = Pil
|
||||
tracker-table-column-temperature = Sıcaklık °C
|
||||
tracker-table-column-rotation = Rotasyon X/Y/Z
|
||||
tracker-table-column-position = Pozisyon X/Y/Z
|
||||
|
||||
## Tracker rotation
|
||||
|
||||
tracker-rotation-front = Ön
|
||||
tracker-rotation-left = Sol
|
||||
tracker-rotation-right = Sağ
|
||||
tracker-rotation-back = Arka
|
||||
|
||||
## Tracker information
|
||||
|
||||
tracker-infos-manufacturer = Üretici
|
||||
tracker-infos-display_name = Görünen Ad
|
||||
tracker-infos-custom_name = Özel Ad
|
||||
tracker-infos-url = Takipçi URL'si
|
||||
tracker-infos-hardware_identifier = Donanım Kimliği
|
||||
tracker-infos-imu = IMU Sensör
|
||||
tracker-infos-board_type = Ana kart
|
||||
|
||||
## Tracker settings
|
||||
|
||||
tracker-settings-back = Takipçi listesine geri dön
|
||||
tracker-settings-title = Takipçi ayarları
|
||||
tracker-settings-assignment_section-description = Tracker'in vücudun hangi kısmına atandığı.
|
||||
# The .<name> means it's an attribute and it's related to the top key.
|
||||
# In this case that is the settings for the assignment section.
|
||||
tracker-settings-name_section = Takipçi adı
|
||||
tracker-settings-name_section-placeholder = NightyBeast'in sol bacağı
|
||||
tracker-settings-name_section-label = Takipçi adı
|
||||
|
||||
## Dongle settings
|
||||
|
||||
dongle-infos-hardware_revision = Donanım Revizyonu
|
||||
dongle-status-disconnected = Bağlantı kesildi
|
||||
dongle-settings-back = Takipçi listesine geri dön
|
||||
|
||||
## Tracker part card info
|
||||
|
||||
tracker-part_card-unassigned = Atanmamış
|
||||
|
||||
## Body assignment menu
|
||||
|
||||
body_assignment_menu = Bu takipçinin nerede olmasını istiyorsunuz?
|
||||
body_assignment_menu-manage_trackers = Tüm takipçileri yönet
|
||||
|
||||
## Tracker assignment menu
|
||||
|
||||
tracker_selection_menu-neck_warning-done = Riskleri anlıyorum
|
||||
tracker_selection_menu-neck_warning-cancel = İptal
|
||||
|
||||
## Mounting menu
|
||||
|
||||
mounting_selection_menu = Bu takipçinin nerede olmasını istiyorsunuz?
|
||||
mounting_selection_menu-close = Kapat
|
||||
|
||||
## Sidebar settings
|
||||
|
||||
settings-sidebar-title = Ayarlar
|
||||
settings-sidebar-general = Genel
|
||||
settings-sidebar-interface = Arayüz
|
||||
settings-sidebar-serial = Seri konsol
|
||||
|
||||
## Bone routing settings
|
||||
|
||||
settings-routing-hands-warning-cancel = İptal
|
||||
|
||||
## SteamVR / Monado output settings
|
||||
|
||||
settings-driver-enable = Etkinleştir
|
||||
|
||||
## Tracker mechanics
|
||||
|
||||
settings-general-tracker_mechanics-filtering-amount = Miktar
|
||||
settings-stay_aligned-general-label = Genel
|
||||
settings-stay_aligned-relaxed_poses-close = Kapat
|
||||
|
||||
## Keybinds Page
|
||||
|
||||
settings-keybinds_full-reset = Sıfırlama
|
||||
settings-keybinds-recorder-modal-cancel-button = İptal
|
||||
|
||||
## FK/Tracking settings
|
||||
|
||||
settings-general-fk_settings-leg_fk = Bacak takibi
|
||||
settings-general-fk_settings-arm_fk-back = Arka
|
||||
|
||||
## Gesture control settings (tracker tapping)
|
||||
|
||||
|
||||
## Appearance settings
|
||||
|
||||
settings-general-interface-dev_mode = Geliştirici Modu
|
||||
settings-general-interface-dev_mode-description = This mode can be useful if you need in-depth data or need to interact with connected trackers on a more advanced level.
|
||||
settings-general-interface-dev_mode-label = Geliştirici Modu
|
||||
|
||||
## Notification settings
|
||||
|
||||
|
||||
## Behavior settings
|
||||
|
||||
settings-general-interface-dev_mode = Geliştirici Modu
|
||||
settings-general-interface-dev_mode-label = Geliştirici Modu
|
||||
|
||||
## Serial settings
|
||||
|
||||
settings-serial-reboot = Yeniden Başlat
|
||||
settings-serial-factory_reset-warning-ok = Ben ne yaptığımı biliyorum
|
||||
settings-serial-factory_reset-warning-cancel = İptal et
|
||||
settings-serial-send_command-warning-ok = Ben ne yaptığımı biliyorum
|
||||
settings-serial-send_command-warning-cancel = İptal
|
||||
|
||||
## OSC VRChat settings
|
||||
|
||||
settings-osc-vrchat-enable = Etkinleştir
|
||||
settings-osc-vrchat-enable-label = Etkinleştir
|
||||
settings-osc-vrchat-network-address = Ağ adresi
|
||||
|
||||
## VRChat OSC status
|
||||
|
||||
settings-osc-vrchat-status-tracking = Rotasyon
|
||||
settings-osc-vrchat-status-badge-error = Hata
|
||||
settings-osc-vrchat-status-badge-unknown = Bilinmeyen
|
||||
|
||||
## VMC OSC settings
|
||||
|
||||
settings-osc-vmc-enable = Etkinleştir
|
||||
settings-osc-vmc-enable-label = Etkinleştir
|
||||
settings-osc-vmc-network-address = Ağ adresi
|
||||
settings-osc-vmc-status-badge-error = Hata
|
||||
|
||||
## Common OSC settings
|
||||
|
||||
|
||||
## Advanced settings
|
||||
|
||||
settings-utils-advanced-reset_warning-cancel = İptal
|
||||
|
||||
## Home Screen
|
||||
|
||||
|
||||
## Tracking Checklist
|
||||
|
||||
|
||||
## Setup/onboarding menu
|
||||
|
||||
|
||||
## Quiz
|
||||
|
||||
onboarding-quiz_back = Arka
|
||||
|
||||
## Wi-Fi setup
|
||||
|
||||
onboarding-wifi_creds-submit = Gönder!
|
||||
|
||||
## Install info
|
||||
|
||||
install-info_udev-rules_modal_button = Kapat
|
||||
|
||||
## Setup start
|
||||
|
||||
|
||||
## Tracker connection setup
|
||||
|
||||
onboarding-connect_tracker-close = Kapat
|
||||
|
||||
## Tracker assignment setup
|
||||
|
||||
onboarding-assign_trackers-tap_modal-cancel = İptal
|
||||
onboarding-assign_trackers-side-right = Sağ
|
||||
onboarding-assign_trackers-side-left = Sol
|
||||
|
||||
## Tracker assignment warnings
|
||||
|
||||
|
||||
## Tracker mounting method choose
|
||||
|
||||
|
||||
## Tracker manual mounting setup
|
||||
|
||||
|
||||
## Tracker automatic mounting setup
|
||||
|
||||
|
||||
## Tracker manual proportions setupa
|
||||
|
||||
|
||||
## Tracker automatic proportions setup
|
||||
|
||||
|
||||
## User height calibration
|
||||
|
||||
|
||||
## Stay Aligned setup
|
||||
|
||||
|
||||
## Home
|
||||
|
||||
home-settings-close = Kapat
|
||||
|
||||
## Trackers Still On notification
|
||||
|
||||
trackers_still_on-modal-confirm = SlimeVR'ı kapat
|
||||
|
||||
## Firmware tool globals
|
||||
|
||||
firmware_tool-loading = Sunucuya bağlanılıyor...
|
||||
|
||||
## Firmware tool Steps
|
||||
|
||||
firmware_tool-select_source-version = Yazılım Sürümü
|
||||
|
||||
## firmware tool build status
|
||||
|
||||
|
||||
## Firmware update status
|
||||
|
||||
|
||||
## Dedicated Firmware Update Page
|
||||
|
||||
|
||||
## Tray Menu
|
||||
|
||||
tray_menu-hide = Gizle
|
||||
|
||||
## First exit modal
|
||||
|
||||
tray_or_exit_modal-cancel = İptal
|
||||
|
||||
## Unknown device modal
|
||||
|
||||
vrc_config-spine_mode-UNKNOWN = Bilinmeyen
|
||||
vrc_config-tracker_model-UNKNOWN = Bilinmeyen
|
||||
vrc_config-avatar_measurement_type-UNKNOWN = Bilinmeyen
|
||||
|
||||
## Error collection consent modal
|
||||
|
||||
|
||||
## Tracking checklist section
|
||||
|
||||
tracking_checklist-settings-close = Kapat
|
||||
|
Before Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 149 KiB |
|
Before Width: | Height: | Size: 92 KiB |
|
Before Width: | Height: | Size: 151 KiB |
|
Before Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 91 KiB |
@@ -1 +0,0 @@
|
||||
{"asset":{"version":"2.0","generator":"THREE.GLTFExporter r175"},"scenes":[{"name":"AuxScene","nodes":[3]}],"scene":0,"nodes":[{"name":"Butterfly_Tracker_Enclosure_simplified_1","mesh":0},{"name":"Butterfly_Tracker_Enclosure_simplified_2","mesh":1},{"matrix":[-0.007811995223164558,0,6.829463129877759e-10,0,0,0.007811995223164558,0,0,-6.829463129877759e-10,0,-0.007811995223164558,0,0,0,0,1],"name":"Butterfly_Tracker_Enclosure_simplified","extras":{"name":"Butterfly_Tracker_Enclosure_simplified"},"children":[0,1]},{"name":"Scene","children":[2]}],"bufferViews":[{"buffer":0,"byteOffset":0,"byteLength":6264,"target":34962,"byteStride":12},{"buffer":0,"byteOffset":6264,"byteLength":6264,"target":34962,"byteStride":12},{"buffer":0,"byteOffset":12528,"byteLength":4632,"target":34963},{"buffer":0,"byteOffset":17160,"byteLength":2376,"target":34962,"byteStride":12},{"buffer":0,"byteOffset":19536,"byteLength":2376,"target":34962,"byteStride":12},{"buffer":0,"byteOffset":21912,"byteLength":2256,"target":34963}],"buffers":[{"byteLength":24168,"uri":"data:application/octet-stream;base64,2i9/wfcSEMDztwpBL5WCwRGC1L/Abg1BF5+DwY+aiL+7Zw9B3R2CwSx3wb9rjxpB6yKEwag39TrE/w5BHmOLwSCBhjcnbPlAy42MwZ9kub4m4etAdrqLwXlqN78wMuJALW2DwR7Bt7x3TaA/LW2DwR7Bt7x3TaA/pP+CwbMlob83rqg/Zo6FwUVOLT+018E/Zo6FwUVOLT+018E/Zo6FwUVOLT+018E/gLWEwdA5g781OcM/gLWEwdA5g781OcM/BUWAwYMVCsAEBvI/BUWAwYMVCsAEBvI/WrCCwXqgy79bUMw/WrCCwXqgy79bUMw/WrCCwXqgy79bUMw//XGKwbZDAr9Gt80//XGKwbZDAr9Gt80//XGKwbZDAr9Gt80/oi+MwVhoIb8jh/Y/oi+MwVhoIb8jh/Y/oi+MwVhoIb8jh/Y/VJKMwRPR2T4FxfM/VJKMwRPR2T4FxfM/q5OKwXXn7T7JCs0/q5OKwXXn7T7JCs0/nk6AwTH/BcAdfBlB3+B4wXvEJcAXpBlBQ813wRWSCMCtTCVBivVtwVx4H8C18iRBapRtwc17BMBf+ypBS61twQatNsBRMBpBSYdsweEExb/Vvi5BnaR2wap7u79x2CtBbaV+wepJx783yiRBItqAwcqUwrKLiiRBOuZwwd26Ar0Cly9Bkjt/wYfjD0BgnwpBltGBwdhG6z9x2gxBx4iDwefznD8VIw9BlLuLwatQNz/pJOJASAWDwRvLnj+Aiqk/SAWDwRvLnj+Aiqk/BD6AwWA8CkCAWfE/BD6AwWA8CkCAWfE/86uCwT9tyT9v+Mk/86uCwT9tyT9v+Mk/86uCwT9tyT9v+Mk/R0+LwbyaRT/+E/Y/R0+LwbyaRT/+E/Y/0ouMwSLMtj45PexAANCAwWfy/T9RQRlBGCF7wT/MH0AiiBdBofhuwQ1dNkDF8hlBLtluwTjoIUBQJCRBBGp6wWojDEBbdSJBOuR1wetXyj+16ytBj5N+wbUTwz8++yRB+b+BwUeFwD9PzRxBgYZsweMZvj+Q4y5BtORrwYCOBEDnCytBkjt/QYfjD8BgnwpBltGBQdhG679x2gxBx4iDQefznL8VIw9B6yKEQag39brE/w5BHmOLQSCBhrcnbPlAlLuLQatQN7/pJOJAZo6FQUVOLb+018E/Zo6FQUVOLb+018E/Zo6FQUVOLb+018E/LW2DQR7Btzx3TaA/LW2DQR7Btzx3TaA/SAWDQRvLnr+Aiqk/SAWDQRvLnr+Aiqk/BD6AQWA8CsCAWfE/BD6AQWA8CsCAWfE/86uCQT9tyb9v+Mk/86uCQT9tyb9v+Mk/86uCQT9tyb9v+Mk/R0+LQbyaRb/+E/Y/R0+LQbyaRb/+E/Y/q5OKQXXn7b7JCs0/q5OKQXXn7b7JCs0/VJKMQRPR2b4FxfM/VJKMQRPR2b4FxfM/0ouMQSLMtr45PexAy42MQZ9kuT4m4etAANCAQWfy/b9RQRlBGCF7QT/MH8AiiBdBXRhvQVl4N8Ar7RZBZURrQXPTMMDm8B1BLtluQTfoIcBQJCRBBGp6QWojDMBbdSJBS412QUegvb9a1CtBj5N+QbUTw78++yRB+b+BQUeFwL9PzRxBw4ZsQRTYvb8i5S5BRWdtQWeVA8D0IytBItqAQceUwjKLiiRBOuZwQd26Aj0Cly9B2i9/QfcSEEDztwpBL5WCQRGC1D/Abg1BF5+DQY+aiD+7Zw9B3R2CQSx3wT9rjxpBdrqLQXlqNz8wMuJApP+CQbMloT83rqg/gLWEQdA5gz81OcM/gLWEQdA5gz81OcM/BUWAQYMVCkAEBvI/BUWAQYMVCkAEBvI/WrCCQXqgyz9bUMw/WrCCQXqgyz9bUMw/WrCCQXqgyz9bUMw//XGKQbZDAj9Gt80//XGKQbZDAj9Gt80//XGKQbZDAj9Gt80/oi+MQVhoIT8jh/Y/oi+MQVhoIT8jh/Y/oi+MQVhoIT8jh/Y/nk6AQTH/BUAdfBlB3+B4QXvEJUAXpBlBQ813QRWSCECtTCVBv89tQS8JJkAaBSNBVZ9tQSyGBUB3zipBUgdtQfrpN0BiIxhBQIdsQQi6xD+1wC5BnaR2Qap7uz9x2CtBbaV+QepJxz83yiRBkjt/wYbjD8BgnwrBltGBwdhG679x2gzBANCAwWfy/b9RQRnBx4iDwefznL8VIw/B6yKEwag39brE/w7BHmOLwSCBhrcnbPnAlLuLwatQN7/pJOLAGCF7wT/MH8AiiBfBXRhvwVl4N8Ar7RbBBD6AwWA8CsCAWfG/BD6AwWA8CsCAWfG/Zo6FwUVOLb+018G/Zo6FwUVOLb+018G/Zo6FwUVOLb+018G/LW2DwR7Btzx3TaC/LW2DwR7Btzx3TaC/SAWDwRrLnr+Aiqm/SAWDwRrLnr+Aiqm/86uCwUBtyb9v+Mm/86uCwUBtyb9v+Mm/86uCwUBtyb9v+Mm/R0+LwbyaRb/+E/a/R0+LwbyaRb/+E/a/q5OKwXXn7b7JCs2/q5OKwXXn7b7JCs2/VJKMwRPR2b4FxfO/VJKMwRPR2b4FxfO/0ouMwSLMtr45PezAy42MwZ9kuT4m4evAZURrwXPTMMDm8B3BLtluwTfoIcBQJCTBBGp6wWojDMBbdSLBS412wUegvb9a1CvBj5N+wbUTw78++yTB+b+BwUeFwL9PzRzBw4ZswRTYvb8i5S7BRWdtwWeVA8D0IyvBItqAwceUwjKLiiTBOuZwwd26Aj0Cly/B2i9/wfcSEEDztwrBL5WCwRGC1D/Abg3Bnk6AwTH/BUAdfBnBF5+DwY+aiD+7Zw/B3R2CwSx3wT9rjxrBdrqLwXlqNz8wMuLApP+CwbIloT83rqi/gLWEwdA5gz81OcO/gLWEwdA5gz81OcO/BUWAwYIVCkAEBvK/BUWAwYIVCkAEBvK/WrCCwXqgyz9bUMy/WrCCwXqgyz9bUMy/WrCCwXqgyz9bUMy//XGKwbZDAj9Gt82//XGKwbZDAj9Gt82//XGKwbZDAj9Gt82/oi+MwVhoIT8jh/a/oi+MwVhoIT8jh/a/oi+MwVhoIT8jh/a/3+B4wXvEJUAXpBnBQ813wRWSCECtTCXBv89twS8JJkAaBSPBj6dtwTQJBUAh3yrBUgdtwfrpN0BiIxjBQIdswQi6xD+1wC7BnaR2wap7uz9x2CvBbaV+wepJxz83yiTB2i9/QfcSEMDztwrBL5WCQRGC1L/Abg3Bnk6AQTH/BcAdfBnBF5+DQY+aiL+7Zw/B3R2CQSx3wb9rjxrB6yKEQag39TrE/w7BHmOLQSCBhjcnbPnAy42MQZ9kub4m4evAdrqLQXlqN78wMuLALW2DQR7Bt7x3TaC/LW2DQR7Bt7x3TaC/Zo6FQUVOLT+018G/Zo6FQUVOLT+018G/Zo6FQUVOLT+018G/pP+CQbIlob83rqi/gLWEQdA5g781OcO/gLWEQdA5g781OcO/BUWAQYIVCsAEBvK/BUWAQYIVCsAEBvK/WrCCQXqgy79bUMy/WrCCQXqgy79bUMy/WrCCQXqgy79bUMy//XGKQbZDAr9Gt82//XGKQbZDAr9Gt82//XGKQbZDAr9Gt82/oi+MQVhoIb8jh/a/oi+MQVhoIb8jh/a/oi+MQVhoIb8jh/a/VJKMQRPR2T4FxfO/VJKMQRPR2T4FxfO/q5OKQXXn7T7JCs2/q5OKQXXn7T7JCs2/3+B4QXvEJcAXpBnBQ813QRWSCMCtTCXBivVtQVx4H8C18iTBapRtQc17BMBf+yrBS61tQQatNsBRMBrBSYdsQeEExb/Vvi7BnaR2Qap7u79x2CvBbaV+QepJx783yiTBItqAQcqUwrKLiiTBOuZwQd26Ar0Cly/Bkjt/QYbjD0BgnwrBltGBQdhG6z9x2gzBANCALine truncated
|
||||
@@ -1,63 +0,0 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { Navigate, Outlet, useLocation } from 'react-router-dom';
|
||||
import { useWebsocketAPI } from '@/hooks/websocket-api';
|
||||
import { useErrorReporting } from '@/hooks/error-reporting';
|
||||
import { ConnectionLost } from './onboarding/pages/ConnectionLost';
|
||||
import { ErrorReportingConsentPage } from './ErrorReportingConsent';
|
||||
|
||||
export const CONNECTING_PATH = '/connecting';
|
||||
export const ERROR_REPORTING_CONSENT_PATH = '/error-reporting-consent';
|
||||
|
||||
const STATUS_PATHS = [CONNECTING_PATH, ERROR_REPORTING_CONSENT_PATH];
|
||||
|
||||
interface ReturnTo {
|
||||
path: string;
|
||||
state: unknown;
|
||||
}
|
||||
|
||||
function StatusPage({ path }: { path: string }) {
|
||||
return path === ERROR_REPORTING_CONSENT_PATH ? (
|
||||
<ErrorReportingConsentPage />
|
||||
) : (
|
||||
<ConnectionLost />
|
||||
);
|
||||
}
|
||||
|
||||
export function AppStatusGate() {
|
||||
const { isConnected } = useWebsocketAPI();
|
||||
const { needsAnswer } = useErrorReporting();
|
||||
const location = useLocation();
|
||||
const [appShown, setAppShown] = useState(false);
|
||||
|
||||
const statusPath = needsAnswer
|
||||
? ERROR_REPORTING_CONSENT_PATH
|
||||
: !isConnected
|
||||
? CONNECTING_PATH
|
||||
: null;
|
||||
const onStatusPath = STATUS_PATHS.includes(location.pathname);
|
||||
|
||||
useEffect(() => {
|
||||
if (!statusPath && !onStatusPath) setAppShown(true);
|
||||
}, [statusPath, onStatusPath]);
|
||||
|
||||
const returnTo: ReturnTo = onStatusPath
|
||||
? (location.state?.returnTo ?? { path: '/', state: null })
|
||||
: { path: location.pathname + location.search, state: location.state };
|
||||
|
||||
if (!appShown && statusPath && location.pathname !== statusPath) {
|
||||
return <Navigate to={statusPath} replace state={{ returnTo }} />;
|
||||
}
|
||||
if ((appShown || !statusPath) && onStatusPath) {
|
||||
return <Navigate to={returnTo.path} replace state={returnTo.state} />;
|
||||
}
|
||||
|
||||
const covering = appShown ? statusPath : null;
|
||||
return (
|
||||
<>
|
||||
{covering && <StatusPage path={covering} />}
|
||||
<div className={covering ? 'hidden' : 'contents'}>
|
||||
<Outlet />
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
import { Localized } from '@fluent/react';
|
||||
import { Button } from './commons/Button';
|
||||
import { LoaderIcon, SlimeState } from './commons/icon/LoaderIcon';
|
||||
|
||||
export function CrashScreen({ eventId }: { eventId: string }) {
|
||||
return (
|
||||
<div className="flex items-center justify-center h-full w-full flex-col gap-4 p-4 bg-background-80 text-background-10">
|
||||
<LoaderIcon slimeState={SlimeState.SAD} size={200} />
|
||||
<div className="max-w-xl flex flex-col gap-3">
|
||||
<Localized id="crash_screen-title">
|
||||
<h1 className="text-main-title" />
|
||||
</Localized>
|
||||
<Localized id="crash_screen-description">
|
||||
<p className="text-standard" />
|
||||
</Localized>
|
||||
{eventId && (
|
||||
<Localized id="crash_screen-event_id" vars={{ id: eventId }}>
|
||||
<p className="text-standard font-mono" />
|
||||
</Localized>
|
||||
)}
|
||||
<div className="flex flex-row gap-2">
|
||||
{eventId && (
|
||||
<Button
|
||||
variant="secondary"
|
||||
id="crash_screen-copy"
|
||||
onClick={() => navigator.clipboard.writeText(eventId)}
|
||||
/>
|
||||
)}
|
||||
<Button
|
||||
variant="primary"
|
||||
id="crash_screen-reload"
|
||||
onClick={() => window.location.reload()}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
import { Localized } from '@fluent/react';
|
||||
import { ErrorReportingConsent } from 'solarxr-protocol';
|
||||
import { Typography } from './commons/Typography';
|
||||
import { Button } from './commons/Button';
|
||||
import { EmptyLayout } from './EmptyLayout';
|
||||
import { useErrorReporting } from '@/hooks/error-reporting';
|
||||
|
||||
export function ErrorReportingConsentPage() {
|
||||
const { answer } = useErrorReporting();
|
||||
|
||||
return (
|
||||
<EmptyLayout>
|
||||
<div className="flex items-center justify-center h-full flex-col gap-3 p-4">
|
||||
<div className="max-w-2xl flex flex-col gap-4">
|
||||
<div className="flex flex-col w-full gap-4">
|
||||
<Typography
|
||||
variant="main-title"
|
||||
id="error_collection_modal-title"
|
||||
/>
|
||||
<Localized
|
||||
id="error_collection_modal-description_v2"
|
||||
elems={{
|
||||
b: <b />,
|
||||
h1: <span className="text-md font-bold" />,
|
||||
}}
|
||||
>
|
||||
<Typography variant="standard" whitespace="whitespace-pre-line" />
|
||||
</Localized>
|
||||
</div>
|
||||
<div className="flex flex-row gap-2 justify-between">
|
||||
<Button
|
||||
variant="tertiary"
|
||||
onClick={() => answer(ErrorReportingConsent.DENIED)}
|
||||
id="error_collection_modal-cancel"
|
||||
/>
|
||||
<Button
|
||||
variant="primary"
|
||||
onClick={() => answer(ErrorReportingConsent.ALLOWED)}
|
||||
id="error_collection_modal-confirm"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</EmptyLayout>
|
||||
);
|
||||
}
|
||||
@@ -1,246 +0,0 @@
|
||||
import { Typography } from './commons/Typography';
|
||||
import classNames from 'classnames';
|
||||
import { MountingMethod, ResetType } from 'solarxr-protocol';
|
||||
import {
|
||||
BODY_PARTS_GROUPS,
|
||||
MountingResetGroup,
|
||||
ResetBtnStatus,
|
||||
useReset,
|
||||
UseResetOptions,
|
||||
} from '@/hooks/reset';
|
||||
import { Tooltip } from './commons/Tooltip';
|
||||
import { useAtomValue } from 'jotai';
|
||||
import { assignedTrackersAtom } from '@/store/app-store';
|
||||
import { useBreakpoint } from '@/hooks/breakpoint';
|
||||
import { useMemo } from 'react';
|
||||
import { ResetButtonIcon } from './home/ResetButton';
|
||||
import { MountingMethodModal } from './mounting/MountingMethodModal';
|
||||
import { useMountingMethod } from '@/hooks/mounting-method';
|
||||
import { useResetsSettings } from '@/hooks/resets-settings';
|
||||
|
||||
const MAINBUTTON_CLASSES = ({ disabled }: { disabled: boolean }) =>
|
||||
classNames(
|
||||
'relative overflow-clip',
|
||||
'flex h-full items-center justify-center gap-2 px-4 bg-background-60 rounded-lg fill-background-10 aspect-square md:aspect-auto',
|
||||
{
|
||||
'cursor-pointer hover:bg-background-50 bg-background-60': !disabled,
|
||||
'cursor-not-allowed bg-background-70 brightness-75': disabled,
|
||||
}
|
||||
);
|
||||
|
||||
function ButtonProgress({
|
||||
progress,
|
||||
status,
|
||||
}: {
|
||||
progress: number;
|
||||
status: ResetBtnStatus;
|
||||
}) {
|
||||
return (
|
||||
<div
|
||||
className={classNames(
|
||||
'absolute top-0 left-0 w-0 h-full bg-accent-background-20 opacity-50'
|
||||
)}
|
||||
style={{
|
||||
width: `${progress * 100}%`,
|
||||
transition:
|
||||
status === 'counting'
|
||||
? 'width 0.3s cubic-bezier(0.68, -0.8, 0.32, 1.8)'
|
||||
: 'width 1s linear',
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function BasicResetButton({
|
||||
customName,
|
||||
...options
|
||||
}: UseResetOptions & { customName?: string }) {
|
||||
const { isMd } = useBreakpoint('md');
|
||||
const {
|
||||
triggerReset,
|
||||
status,
|
||||
name: resetName,
|
||||
timer,
|
||||
progress: resetProress,
|
||||
disabled,
|
||||
duration,
|
||||
error,
|
||||
} = useReset(options);
|
||||
const { onClick, ...picker } = useMountingMethod(options, triggerReset);
|
||||
const { resetsSettings } = useResetsSettings();
|
||||
|
||||
const progress = status === 'counting' ? resetProress / duration : 0;
|
||||
|
||||
const name = customName || resetName;
|
||||
|
||||
const skiReset =
|
||||
options.type === ResetType.MOUNTING &&
|
||||
options.group === 'default' &&
|
||||
resetsSettings?.mountingMethod === MountingMethod.POSE;
|
||||
|
||||
return (
|
||||
<>
|
||||
<Tooltip
|
||||
disabled={!error && isMd}
|
||||
content={
|
||||
error ? (
|
||||
<Typography
|
||||
id={error}
|
||||
textAlign="text-center"
|
||||
color="text-status-critical"
|
||||
/>
|
||||
) : (
|
||||
<Typography textAlign="text-center" id={name} />
|
||||
)
|
||||
}
|
||||
spacing={5}
|
||||
preferedDirection={error ? 'bottom' : 'top'}
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
disabled={disabled}
|
||||
className={classNames(
|
||||
MAINBUTTON_CLASSES({ disabled }),
|
||||
'rounded-lg',
|
||||
'absolute'
|
||||
)}
|
||||
style={{
|
||||
animationIterationCount: 1,
|
||||
}}
|
||||
onClick={() => !disabled && onClick()}
|
||||
>
|
||||
<div
|
||||
className={classNames({
|
||||
'animate-spin-ccw': !skiReset && status === 'finished',
|
||||
'animate-skiing': skiReset && status === 'finished',
|
||||
'opacity-0': status === 'counting',
|
||||
})}
|
||||
style={{
|
||||
animationIterationCount: 1,
|
||||
}}
|
||||
>
|
||||
<ResetButtonIcon {...options} />
|
||||
</div>
|
||||
|
||||
<div
|
||||
className={classNames('hidden md:block relative', {
|
||||
'opacity-0': status === 'counting',
|
||||
})}
|
||||
>
|
||||
<Typography
|
||||
variant="section-title"
|
||||
textAlign="text-center"
|
||||
id={name}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<ButtonProgress progress={progress} status={status} />
|
||||
<div
|
||||
className={classNames(
|
||||
{
|
||||
'opacity-0': status !== 'counting',
|
||||
'animate-timer-tick': status === 'counting',
|
||||
},
|
||||
'absolute top-0 h-full flex items-center justify-center'
|
||||
)}
|
||||
>
|
||||
<Typography variant="main-title" textAlign="text-center">
|
||||
{timer}
|
||||
</Typography>
|
||||
</div>
|
||||
</button>
|
||||
</Tooltip>
|
||||
<MountingMethodModal
|
||||
isOpen={picker.pickerOpen}
|
||||
onClose={picker.closePicker}
|
||||
onSelect={picker.onPick}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export function Toolbar() {
|
||||
const assignedTrackers = useAtomValue(assignedTrackersAtom);
|
||||
const { resetsSettings } = useResetsSettings();
|
||||
const splitMounting = resetsSettings?.mountingMethod === MountingMethod.POSE;
|
||||
|
||||
const { visibleGroups, groupVisibility } = useMemo(() => {
|
||||
const groupVisibility = Object.keys(BODY_PARTS_GROUPS)
|
||||
.filter((k) => ['fingers', 'toes'].includes(k))
|
||||
.reduce(
|
||||
(curr, key) => {
|
||||
const group = key as MountingResetGroup;
|
||||
curr[group] = assignedTrackers.some(
|
||||
({ tracker }) =>
|
||||
tracker.info?.bodyPart &&
|
||||
BODY_PARTS_GROUPS[group].includes(tracker.info?.bodyPart)
|
||||
);
|
||||
|
||||
return curr;
|
||||
},
|
||||
{} as Record<MountingResetGroup, boolean>
|
||||
);
|
||||
|
||||
return {
|
||||
groupVisibility,
|
||||
visibleGroups: Object.values(groupVisibility).filter((v) => v).length,
|
||||
};
|
||||
}, [assignedTrackers]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="flex mobile:py-2 flex-col items-center bg-background-70 rounded-t-lg h-[var(--toolbar-h)] mr-2 xs:mt-2 mobile:mr-0">
|
||||
<div className="px-3 py-3 w-full flex gap-4 justify-center md:justify-start">
|
||||
<div className="flex-col flex gap-1 md:w-[60%]">
|
||||
<Typography variant="section-title" id="toolbar-drift_reset" />
|
||||
<div className="gap-2 md:h-[72px] h-[62px] w-full grid-cols-2 grid">
|
||||
<BasicResetButton type={ResetType.FULL} />
|
||||
<BasicResetButton type={ResetType.YAW} />
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex-col flex gap-1 md:flex-grow">
|
||||
<Typography
|
||||
variant="section-title"
|
||||
id="toolbar-mounting_calibration"
|
||||
/>
|
||||
<div
|
||||
className="gap-2 md:h-[72px] h-[62px] w-full md:grid flex"
|
||||
style={{
|
||||
gridTemplateColumns: `repeat(${splitMounting ? 2 + visibleGroups : 1}, 1fr)`,
|
||||
}}
|
||||
>
|
||||
<BasicResetButton
|
||||
type={ResetType.MOUNTING}
|
||||
group={'default'}
|
||||
customName="toolbar-mounting_calibration-default"
|
||||
/>
|
||||
{splitMounting && (
|
||||
<>
|
||||
<BasicResetButton
|
||||
type={ResetType.MOUNTING}
|
||||
group={'feet'}
|
||||
customName="toolbar-mounting_calibration-feet"
|
||||
/>
|
||||
{groupVisibility['toes'] && (
|
||||
<BasicResetButton
|
||||
type={ResetType.MOUNTING}
|
||||
group={'toes'}
|
||||
customName="toolbar-mounting_calibration-toes"
|
||||
/>
|
||||
)}
|
||||
{groupVisibility['fingers'] && (
|
||||
<BasicResetButton
|
||||
type={ResetType.MOUNTING}
|
||||
group={'fingers'}
|
||||
customName="toolbar-mounting_calibration-fingers"
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,334 +0,0 @@
|
||||
import {
|
||||
ComponentProps,
|
||||
ReactNode,
|
||||
useContext,
|
||||
useEffect,
|
||||
useState,
|
||||
} from 'react';
|
||||
import { NavLink, useMatch } from 'react-router-dom';
|
||||
import {
|
||||
RpcMessage,
|
||||
ServerInfosRequestT,
|
||||
ServerInfosResponseT,
|
||||
TrackerStatus,
|
||||
} from 'solarxr-protocol';
|
||||
import { useWebsocketAPI } from '@/hooks/websocket-api';
|
||||
import { CloseIcon } from './commons/icon/CloseIcon';
|
||||
import { MaximiseIcon } from './commons/icon/MaximiseIcon';
|
||||
import { MinimiseIcon } from './commons/icon/MinimiseIcon';
|
||||
import { SlimeVRIcon } from './commons/icon/SimevrIcon';
|
||||
import { ProgressBar } from './commons/ProgressBar';
|
||||
import { Tooltip } from './commons/Tooltip';
|
||||
import { Typography } from './commons/Typography';
|
||||
import { DownloadIcon } from './commons/icon/DownloadIcon';
|
||||
import { DOCS_SITE, GH_REPO, VersionContext } from '@/App';
|
||||
import classNames from 'classnames';
|
||||
import { QuestionIcon } from './commons/icon/QuestionIcon';
|
||||
import { IconButton } from './commons/IconButton';
|
||||
import { useBreakpoint } from '@/hooks/breakpoint';
|
||||
import { GearIcon } from './commons/icon/GearIcon';
|
||||
import { TrackersStillOnModal } from './TrackersStillOnModal';
|
||||
import { useConfig } from '@/hooks/config';
|
||||
import { TrayOrExitModal } from './TrayOrExitModal';
|
||||
import { useAtomValue } from 'jotai';
|
||||
import { connectedIMUTrackersAtom } from '@/store/app-store';
|
||||
import { useElectron } from '@/hooks/electron';
|
||||
import { openUrl } from '@/hooks/crossplatform';
|
||||
|
||||
// Title bar buttons share one round hit target.
|
||||
const TITLE_BAR_BUTTON_CLASS =
|
||||
'flex items-center justify-center hover:bg-background-60 rounded-full w-7 h-7 cursor-pointer';
|
||||
|
||||
function TitleBarButton({
|
||||
className,
|
||||
...props
|
||||
}: ComponentProps<typeof IconButton>) {
|
||||
return (
|
||||
<IconButton
|
||||
{...props}
|
||||
className={classNames(TITLE_BAR_BUTTON_CLASS, className)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export function VersionTag() {
|
||||
const url = `https://github.com/${GH_REPO}/releases`;
|
||||
|
||||
return (
|
||||
<Tooltip
|
||||
preferedDirection="bottom"
|
||||
content={<span className="text-xs">{__COMMIT_HASH__}</span>}
|
||||
>
|
||||
<a
|
||||
href={url}
|
||||
className={classNames(
|
||||
'flex justify-around flex-col text-standard-bold',
|
||||
'text-status-success bg-status-success bg-opacity-20 rounded-lg',
|
||||
'px-3 select-text cursor-pointer shrink-0 whitespace-nowrap'
|
||||
)}
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
openUrl(url);
|
||||
}}
|
||||
>
|
||||
{(__VERSION_TAG__ || __COMMIT_HASH__) + (__GIT_CLEAN__ ? '' : '-dirty')}
|
||||
</a>
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
|
||||
export function TopBar({
|
||||
progress,
|
||||
actions,
|
||||
}: {
|
||||
children?: ReactNode;
|
||||
progress?: number;
|
||||
actions?: ReactNode;
|
||||
}) {
|
||||
const electron = useElectron();
|
||||
const { isMobile } = useBreakpoint('mobile');
|
||||
const { useRPCPacket, sendRPCPacket } = useWebsocketAPI();
|
||||
const connectedIMUTrackers = useAtomValue(connectedIMUTrackersAtom);
|
||||
const { config, setConfig, saveConfig } = useConfig();
|
||||
const version = useContext(VersionContext);
|
||||
const [localIp, setLocalIp] = useState<string | null>(null);
|
||||
const [showConnectedTrackersWarning, setConnectedTrackerWarning] =
|
||||
useState(false);
|
||||
const [showTrayOrExitModal, setShowTrayOrExitModal] = useState(false);
|
||||
const doesMatchSettings = useMatch({
|
||||
path: '/settings/*',
|
||||
});
|
||||
|
||||
const closeApp = async () => {
|
||||
if (!electron.isElectron) throw 'no electron';
|
||||
|
||||
await saveConfig();
|
||||
electron.api.close();
|
||||
};
|
||||
|
||||
const tryCloseApp = async (dontTray = false) => {
|
||||
if (!electron.isElectron) throw 'no electron';
|
||||
|
||||
if (config?.useTray === null) {
|
||||
setShowTrayOrExitModal(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (config?.useTray && !dontTray) {
|
||||
electron.api.hide();
|
||||
} else if (
|
||||
config?.connectedTrackersWarning &&
|
||||
connectedIMUTrackers.filter(
|
||||
(t) =>
|
||||
t.tracker.status !== TrackerStatus.TIMED_OUT &&
|
||||
t.tracker.status !== TrackerStatus.SLEEPING
|
||||
).length > 0
|
||||
) {
|
||||
setConnectedTrackerWarning(true);
|
||||
} else {
|
||||
await closeApp();
|
||||
}
|
||||
};
|
||||
|
||||
// useEffect(() => {
|
||||
// if (!electron.isElectron) return;
|
||||
|
||||
// const unlistenTrayClose = listen('try-close', async () => {
|
||||
// const window = getCurrentWindow();
|
||||
// await window.show();
|
||||
// await window.requestUserAttention(UserAttentionType.Critical);
|
||||
// await window.setFocus();
|
||||
// if (isTrayAvailable) await invoke('update_tray_text');
|
||||
// await tryCloseApp(true);
|
||||
// });
|
||||
|
||||
// const unlistenCloseRequested = getCurrentWindow().listen(
|
||||
// TauriEvent.WINDOW_CLOSE_REQUESTED,
|
||||
// async (data) => {
|
||||
// const ev = new CloseRequestedEvent(data);
|
||||
// ev.preventDefault();
|
||||
// await tryCloseApp();
|
||||
// }
|
||||
// );
|
||||
|
||||
// return () => {
|
||||
// unlistenTrayClose.then((fn) => fn());
|
||||
// unlistenCloseRequested.then((fn) => fn());
|
||||
// };
|
||||
// }, [
|
||||
// config?.useTray,
|
||||
// config?.connectedTrackersWarning,
|
||||
// JSON.stringify(connectedIMUTrackers.map((t) => t.tracker.status)),
|
||||
// ]);
|
||||
|
||||
useEffect(() => {
|
||||
sendRPCPacket(RpcMessage.ServerInfosRequest, new ServerInfosRequestT());
|
||||
}, []);
|
||||
|
||||
useRPCPacket(
|
||||
RpcMessage.ServerInfosResponse,
|
||||
({ localIp }: ServerInfosResponseT) => {
|
||||
if (localIp) setLocalIp(localIp.toString());
|
||||
}
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="flex gap-0 flex-col">
|
||||
<div className="h-[3px]" />
|
||||
<div className="flex gap-2 h-[38px] z-49">
|
||||
<div className="flex px-2 py-2 justify-around z-49">
|
||||
<div className="flex gap-2">
|
||||
{!isMobile && (
|
||||
<NavLink
|
||||
to="/"
|
||||
className="flex justify-around flex-col select-all"
|
||||
// Leaving the setup from here skips it
|
||||
onClick={() => {
|
||||
if (config && !config.doneOnboarding)
|
||||
setConfig({ doneOnboarding: true });
|
||||
}}
|
||||
>
|
||||
<SlimeVRIcon />
|
||||
</NavLink>
|
||||
)}
|
||||
{!isMobile && (
|
||||
<div
|
||||
className={classNames('flex justify-around flex-col')}
|
||||
data-electron-drag-region
|
||||
>
|
||||
<Typography>SlimeVR</Typography>
|
||||
</div>
|
||||
)}
|
||||
{(!doesMatchSettings || !isMobile) && <VersionTag />}
|
||||
{doesMatchSettings && (
|
||||
<div
|
||||
className={classNames(
|
||||
'flex justify-around flex-col text-standard-bold text-status-special',
|
||||
'bg-status-special bg-opacity-20 rounded-lg px-3 select-text'
|
||||
)}
|
||||
>
|
||||
{localIp || 'unknown local ip'}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{version && electron.isElectron && (
|
||||
<TitleBarButton
|
||||
labelId="titlebar-update"
|
||||
onClick={() => {
|
||||
const url =
|
||||
electron.data().os.type === 'windows'
|
||||
? 'https://slimevr.dev/download'
|
||||
: `https://github.com/${GH_REPO}/releases/latest`;
|
||||
openUrl(url);
|
||||
}}
|
||||
>
|
||||
<DownloadIcon />
|
||||
</TitleBarButton>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className="flex flex-grow items-center h-full justify-center z-50"
|
||||
data-electron-drag-region
|
||||
>
|
||||
{!isMobile && (
|
||||
<>
|
||||
<div
|
||||
className="flex max-w-xl h-full items-center w-full"
|
||||
data-electron-drag-region
|
||||
>
|
||||
{progress !== undefined && (
|
||||
<ProgressBar progress={progress} height={3} parts={3} />
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex justify-end items-center px-2 gap-2 z-50">
|
||||
{actions}
|
||||
<TitleBarButton
|
||||
labelId="titlebar-settings"
|
||||
to="/settings/trackers"
|
||||
className="fill-background-50 hover:fill-background-10"
|
||||
state={{ scrollTo: 'output' }}
|
||||
>
|
||||
<GearIcon />
|
||||
</TitleBarButton>
|
||||
|
||||
{!isMobile && (
|
||||
<TitleBarButton
|
||||
labelId="titlebar-docs"
|
||||
className="stroke-window-icon"
|
||||
onClick={() => openUrl(DOCS_SITE)}
|
||||
>
|
||||
<QuestionIcon />
|
||||
</TitleBarButton>
|
||||
)}
|
||||
{electron.isElectron && (
|
||||
<>
|
||||
<TitleBarButton
|
||||
labelId="titlebar-minimize"
|
||||
onClick={() => electron.api.minimize()}
|
||||
>
|
||||
<MinimiseIcon />
|
||||
</TitleBarButton>
|
||||
<TitleBarButton
|
||||
labelId="titlebar-maximize"
|
||||
onClick={() => electron.api.toggleMaximize()}
|
||||
>
|
||||
<MaximiseIcon />
|
||||
</TitleBarButton>
|
||||
<TitleBarButton
|
||||
labelId="titlebar-close"
|
||||
onClick={() => tryCloseApp()}
|
||||
>
|
||||
<CloseIcon />
|
||||
</TitleBarButton>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
{isMobile && progress !== undefined && (
|
||||
<div className="flex gap-2 px-2 h-6 mb-2 justify-center flex-col border-b border-accent-background-30">
|
||||
<ProgressBar progress={progress} height={3} parts={3} />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{electron.isElectron && (
|
||||
<TrayOrExitModal
|
||||
isOpen={showTrayOrExitModal}
|
||||
accept={async (useTray) => {
|
||||
await setConfig({ useTray });
|
||||
setShowTrayOrExitModal(false);
|
||||
|
||||
// Doing this in here just in case config doesn't get updated in time
|
||||
if (useTray) {
|
||||
electron.api.minimize();
|
||||
// await invoke('update_tray_text');
|
||||
} else if (
|
||||
config?.connectedTrackersWarning &&
|
||||
connectedIMUTrackers.filter(
|
||||
(t) =>
|
||||
t.tracker.status !== TrackerStatus.TIMED_OUT &&
|
||||
t.tracker.status !== TrackerStatus.SLEEPING
|
||||
).length > 0
|
||||
) {
|
||||
setConnectedTrackerWarning(true);
|
||||
} else {
|
||||
await closeApp();
|
||||
}
|
||||
}}
|
||||
cancel={() => setShowTrayOrExitModal(false)}
|
||||
/>
|
||||
)}
|
||||
<TrackersStillOnModal
|
||||
isOpen={showConnectedTrackersWarning}
|
||||
accept={() => closeApp()}
|
||||
cancel={() => {
|
||||
setConnectedTrackerWarning(false);
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,476 +0,0 @@
|
||||
import classNames from 'classnames';
|
||||
import {
|
||||
FocusEvent,
|
||||
HTMLAttributes,
|
||||
PointerEvent,
|
||||
ReactNode,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
} from 'react';
|
||||
import { BodyPart } from 'solarxr-protocol';
|
||||
import { useBreakpoint } from '@/hooks/breakpoint';
|
||||
|
||||
const DOT_HIT_PADDING = 12;
|
||||
|
||||
export interface BodySideNames {
|
||||
left: Set<string>;
|
||||
right: Set<string>;
|
||||
}
|
||||
|
||||
const bodyPartFromName = (name: string): BodyPart | null => {
|
||||
const part = (BodyPart as unknown as Record<string, number | undefined>)[
|
||||
name
|
||||
];
|
||||
return typeof part === 'number' ? part : null;
|
||||
};
|
||||
|
||||
const boxOf = (el: HTMLElement, offset: { left: number; top: number }) => {
|
||||
const rect = el.getBoundingClientRect();
|
||||
return {
|
||||
left: rect.left - offset.left,
|
||||
top: rect.top - offset.top,
|
||||
right: rect.right - offset.left,
|
||||
bottom: rect.bottom - offset.top,
|
||||
};
|
||||
};
|
||||
|
||||
const geometry = (
|
||||
slot: { left: number; top: number; width: number; height: number },
|
||||
control: HTMLElement,
|
||||
group: HTMLElement,
|
||||
offset: { left: number; top: number }
|
||||
) => {
|
||||
const slotX = slot.left + slot.width / 2;
|
||||
const slotY = slot.top + slot.height / 2;
|
||||
const { left, top, right, bottom } = boxOf(group, offset);
|
||||
const row = boxOf(control, offset);
|
||||
const rowY = (row.top + row.bottom) / 2;
|
||||
|
||||
const cap = group.dataset.connectorEdge === 'cap';
|
||||
|
||||
return {
|
||||
x: cap ? (left + right) / 2 : slotX > right ? right : left,
|
||||
y: cap
|
||||
? slotY > bottom
|
||||
? bottom
|
||||
: top
|
||||
: Math.min(Math.max(rowY, top), bottom),
|
||||
dx: cap ? 0 : slotX > right ? 1 : -1,
|
||||
dy: cap ? (slotY > bottom ? 1 : -1) : 0,
|
||||
gap: cap
|
||||
? Math.max(top - slotY, slotY - bottom, 0)
|
||||
: Math.max(left - slotX, slotX - right, 0),
|
||||
};
|
||||
};
|
||||
|
||||
const readCssVarColor = (varName: string, fallback: string) => {
|
||||
if (typeof window === 'undefined') return fallback;
|
||||
const raw = getComputedStyle(document.documentElement)
|
||||
.getPropertyValue(varName)
|
||||
.trim();
|
||||
return raw ? `rgb(${raw})` : fallback;
|
||||
};
|
||||
|
||||
export interface BodyInteractionsProps {
|
||||
leftControls?: ReactNode;
|
||||
rightControls?: ReactNode;
|
||||
topControls?: ReactNode;
|
||||
bottomControls?: ReactNode;
|
||||
dotsSize?: number;
|
||||
assignedRoles: BodyPart[];
|
||||
onSelectRole: (role: BodyPart) => void;
|
||||
highlightedRoles: BodyPart[];
|
||||
dotClass?: (part: BodyPart) => string | undefined;
|
||||
dotContent?: (part: BodyPart) => ReactNode;
|
||||
dotProps?: (part: BodyPart) => HTMLAttributes<HTMLDivElement>;
|
||||
activeParts?: BodyPart[];
|
||||
figure: ReactNode;
|
||||
sideNames: BodySideNames;
|
||||
}
|
||||
|
||||
export function BodyInteractions({
|
||||
leftControls,
|
||||
rightControls,
|
||||
topControls,
|
||||
bottomControls,
|
||||
highlightedRoles,
|
||||
assignedRoles,
|
||||
dotsSize = 15,
|
||||
onSelectRole,
|
||||
dotClass,
|
||||
dotContent,
|
||||
dotProps,
|
||||
activeParts = [],
|
||||
figure,
|
||||
sideNames,
|
||||
}: BodyInteractionsProps) {
|
||||
const { isMobile } = useBreakpoint('mobile');
|
||||
const { left: leftPartNames, right: rightPartNames } = sideNames;
|
||||
|
||||
const [hoveredControl, setHoveredControl] = useState<string | null>(null);
|
||||
|
||||
const personRef = useRef<HTMLDivElement | null>(null);
|
||||
const leftContainerRef = useRef<HTMLDivElement | null>(null);
|
||||
const rightContainerRef = useRef<HTMLDivElement | null>(null);
|
||||
const topContainerRef = useRef<HTMLDivElement | null>(null);
|
||||
const bottomContainerRef = useRef<HTMLDivElement | null>(null);
|
||||
const updateSlotsRef = useRef<() => void>(() => {});
|
||||
const mutationObserverRef = useRef<MutationObserver>(
|
||||
new MutationObserver(() => updateSlotsRef.current())
|
||||
);
|
||||
const resizeObserverRef = useRef<ResizeObserver>(
|
||||
new ResizeObserver(() => updateSlotsRef.current())
|
||||
);
|
||||
const canvasRefRef = useRef<HTMLCanvasElement | null>(null);
|
||||
const [slotsButtonsPos, setSlotsButtonPos] = useState<
|
||||
{
|
||||
id: string;
|
||||
part: BodyPart | null;
|
||||
left: number;
|
||||
top: number;
|
||||
height: number;
|
||||
width: number;
|
||||
hidden: boolean;
|
||||
buttonOffset: {
|
||||
left: number;
|
||||
top: number;
|
||||
};
|
||||
}[]
|
||||
>([]);
|
||||
|
||||
const getSlotsPos = () => {
|
||||
return (
|
||||
(personRef.current && [
|
||||
...(personRef.current.querySelectorAll('.body-part-circle') as any),
|
||||
]) ||
|
||||
[]
|
||||
);
|
||||
};
|
||||
|
||||
const getControlsPos = () => {
|
||||
const pos = (container: HTMLDivElement) =>
|
||||
[...(container.querySelectorAll('.control') as any)].filter(
|
||||
({ id }) => !!id
|
||||
);
|
||||
|
||||
const left =
|
||||
(leftContainerRef.current && pos(leftContainerRef.current)) || [];
|
||||
const right =
|
||||
(rightContainerRef.current && pos(rightContainerRef.current)) || [];
|
||||
const top = (topContainerRef.current && pos(topContainerRef.current)) || [];
|
||||
const bottom =
|
||||
(bottomContainerRef.current && pos(bottomContainerRef.current)) || [];
|
||||
return [...left, ...right, ...top, ...bottom];
|
||||
};
|
||||
|
||||
const getOffset = (el: HTMLDivElement, offset = { left: 0, top: 0 }) => {
|
||||
const rect = el.getBoundingClientRect();
|
||||
return {
|
||||
left: rect.left - (offset.left || 0),
|
||||
top: rect.top - (offset.top || 0),
|
||||
width: rect.width || el.offsetWidth,
|
||||
height: rect.height || el.offsetHeight,
|
||||
};
|
||||
};
|
||||
|
||||
const updateSlots = () => {
|
||||
if (
|
||||
!(
|
||||
personRef.current &&
|
||||
canvasRefRef.current &&
|
||||
rightContainerRef.current &&
|
||||
leftContainerRef.current
|
||||
)
|
||||
)
|
||||
return;
|
||||
const ctx = canvasRefRef.current.getContext('2d');
|
||||
if (!ctx) return;
|
||||
const slotsPos = getSlotsPos();
|
||||
const controlsPos = getControlsPos();
|
||||
|
||||
canvasRefRef.current.width = canvasRefRef.current.clientWidth;
|
||||
canvasRefRef.current.height = canvasRefRef.current.clientHeight;
|
||||
|
||||
ctx.strokeStyle = '#608AAB';
|
||||
ctx.lineWidth = 2;
|
||||
|
||||
const canvasBox = canvasRefRef.current.getBoundingClientRect();
|
||||
const personBox = personRef.current.getBoundingClientRect();
|
||||
|
||||
const controlsPosIds = controlsPos.map(({ id: cid }) => cid);
|
||||
const slots = slotsPos.map((slot: HTMLDivElement) => {
|
||||
const slotPosition = getOffset(slot, canvasBox);
|
||||
return {
|
||||
...slotPosition,
|
||||
id: slot.id,
|
||||
part: bodyPartFromName(slot.id),
|
||||
hidden: !controlsPosIds.includes(slot.id),
|
||||
buttonOffset: {
|
||||
left: canvasBox.left - personBox.left,
|
||||
top: canvasBox.top - personBox.top,
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
const whiteColor = readCssVarColor('--background-20', '#FFFFFF');
|
||||
const ASSIGN_RIGHT = readCssVarColor('--assign-right', '#FFFFFF');
|
||||
const ASSIGN_LEFT = readCssVarColor('--assign-left', '#FFFFFF');
|
||||
const LINE_BREAK_WIDTH = isMobile ? 20 : 40;
|
||||
|
||||
slots.forEach((slot) => {
|
||||
const controls = controlsPos.filter(
|
||||
({ id, dataset }) => id === slot.id && dataset.connector !== 'off'
|
||||
);
|
||||
const isAssigned = slot.part != null && assignedRoles.includes(slot.part);
|
||||
const isActive = slot.part != null && activeParts.includes(slot.part);
|
||||
|
||||
ctx.lineWidth = slot.id === hoveredControl || isActive ? 4 : 2;
|
||||
ctx.strokeStyle =
|
||||
isAssigned || isActive
|
||||
? leftPartNames.has(slot.id)
|
||||
? ASSIGN_LEFT
|
||||
: rightPartNames.has(slot.id)
|
||||
? ASSIGN_RIGHT
|
||||
: whiteColor
|
||||
: '#204A6B';
|
||||
|
||||
const slotX = slot.left + slot.width / 2;
|
||||
const slotY = slot.top + slot.height / 2;
|
||||
|
||||
controls.forEach((control) => {
|
||||
const group = control.closest('[data-connector-group]');
|
||||
const controlPosition = getOffset(group ?? control, canvasBox);
|
||||
|
||||
if (group) {
|
||||
const { x, y, dx, dy, gap } = geometry(
|
||||
slot,
|
||||
control,
|
||||
group,
|
||||
canvasBox
|
||||
);
|
||||
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(x, y);
|
||||
if (gap > LINE_BREAK_WIDTH * 2)
|
||||
ctx.lineTo(x + dx * LINE_BREAK_WIDTH, y + dy * LINE_BREAK_WIDTH);
|
||||
ctx.lineTo(slotX, slotY);
|
||||
ctx.stroke();
|
||||
return;
|
||||
}
|
||||
|
||||
const offsetX =
|
||||
controlPosition.left < slot.left ? controlPosition.width : 0;
|
||||
|
||||
const constolLeft = controlPosition.left + offsetX;
|
||||
const leftOffsetX =
|
||||
LINE_BREAK_WIDTH * (controlPosition.left < slot.left ? -1 : 1);
|
||||
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(
|
||||
constolLeft,
|
||||
controlPosition.top + controlPosition.height / 2
|
||||
);
|
||||
ctx.lineTo(
|
||||
constolLeft - leftOffsetX,
|
||||
controlPosition.top + controlPosition.height / 2
|
||||
);
|
||||
ctx.lineTo(slotX, slotY);
|
||||
ctx.stroke();
|
||||
});
|
||||
});
|
||||
setSlotsButtonPos(slots);
|
||||
};
|
||||
|
||||
const highlightFrom = (target: EventTarget | null) => {
|
||||
const control = (target as HTMLElement | null)?.closest<HTMLElement>(
|
||||
'.control'
|
||||
);
|
||||
setHoveredControl(control?.id || null);
|
||||
};
|
||||
|
||||
const onControlPointerOver = (event: PointerEvent<HTMLDivElement>) =>
|
||||
highlightFrom(event.target);
|
||||
|
||||
const controlFocusProps = {
|
||||
onPointerOver: onControlPointerOver,
|
||||
onPointerLeave: () => setHoveredControl(null),
|
||||
onFocusCapture: (event: FocusEvent<HTMLDivElement>) =>
|
||||
highlightFrom(event.target),
|
||||
onBlurCapture: () => setHoveredControl(null),
|
||||
};
|
||||
|
||||
updateSlotsRef.current = updateSlots;
|
||||
const assignedKey = useMemo(
|
||||
() => [...assignedRoles].sort((a, b) => a - b).join(','),
|
||||
[assignedRoles]
|
||||
);
|
||||
const activeKey = useMemo(
|
||||
() => [...activeParts].sort((a, b) => a - b).join(','),
|
||||
[activeParts]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
updateSlots();
|
||||
}, [figure, assignedKey, activeKey, hoveredControl]);
|
||||
|
||||
useEffect(() => {
|
||||
if (
|
||||
!rightContainerRef.current ||
|
||||
!leftContainerRef.current ||
|
||||
!personRef.current
|
||||
)
|
||||
return;
|
||||
|
||||
resizeObserverRef.current.observe(personRef.current);
|
||||
|
||||
mutationObserverRef.current.observe(rightContainerRef.current, {
|
||||
attributes: true,
|
||||
childList: true,
|
||||
subtree: true,
|
||||
});
|
||||
mutationObserverRef.current.observe(leftContainerRef.current, {
|
||||
attributes: true,
|
||||
childList: true,
|
||||
subtree: true,
|
||||
});
|
||||
if (topContainerRef.current)
|
||||
mutationObserverRef.current.observe(topContainerRef.current, {
|
||||
attributes: true,
|
||||
childList: true,
|
||||
subtree: true,
|
||||
});
|
||||
if (bottomContainerRef.current)
|
||||
mutationObserverRef.current.observe(bottomContainerRef.current, {
|
||||
attributes: true,
|
||||
childList: true,
|
||||
subtree: true,
|
||||
});
|
||||
|
||||
return () => {
|
||||
if (
|
||||
!rightContainerRef.current ||
|
||||
!leftContainerRef.current ||
|
||||
!personRef.current
|
||||
)
|
||||
return;
|
||||
mutationObserverRef.current.takeRecords();
|
||||
resizeObserverRef.current.unobserve(personRef.current);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="relative w-full h-full">
|
||||
<canvas
|
||||
ref={canvasRefRef}
|
||||
className="absolute w-full h-full top-0 z-10"
|
||||
width="100%"
|
||||
height="100%"
|
||||
/>
|
||||
<div className="flex flex-col w-full h-full">
|
||||
<div ref={topContainerRef} className="z-10" {...controlFocusProps}>
|
||||
{topControls}
|
||||
</div>
|
||||
<div className="flex flex-grow min-h-0 gap-5">
|
||||
<div ref={leftContainerRef} className="z-10" {...controlFocusProps}>
|
||||
{leftControls}
|
||||
</div>
|
||||
<div
|
||||
ref={personRef}
|
||||
className="relative flex h-full min-w-0 flex-grow justify-center"
|
||||
>
|
||||
{figure}
|
||||
{slotsButtonsPos.map(
|
||||
({
|
||||
top,
|
||||
left,
|
||||
height,
|
||||
width,
|
||||
id,
|
||||
part,
|
||||
hidden,
|
||||
buttonOffset,
|
||||
}) => {
|
||||
const hitSize = dotsSize + DOT_HIT_PADDING * 2;
|
||||
const required =
|
||||
part != null && highlightedRoles.includes(part);
|
||||
|
||||
return (
|
||||
<div
|
||||
key={id}
|
||||
{...(part != null ? dotProps?.(part) : undefined)}
|
||||
aria-hidden="true"
|
||||
className={classNames(
|
||||
'absolute z-10',
|
||||
hidden && 'pointer-events-none'
|
||||
)}
|
||||
onClick={() =>
|
||||
!hidden && part != null && onSelectRole(part)
|
||||
}
|
||||
style={{
|
||||
width: hitSize,
|
||||
height: hitSize,
|
||||
top: top + height / 2 - hitSize / 2 + buttonOffset.top,
|
||||
left: left + width / 2 - hitSize / 2 + buttonOffset.left,
|
||||
}}
|
||||
>
|
||||
<div
|
||||
className="absolute"
|
||||
style={{ top: DOT_HIT_PADDING, left: DOT_HIT_PADDING }}
|
||||
>
|
||||
{!hidden && required && (
|
||||
<div
|
||||
className={classNames(
|
||||
'absolute rounded-full bg-status-warning',
|
||||
'transition-opacity opacity-100 animate-ping'
|
||||
)}
|
||||
style={{
|
||||
width: dotsSize,
|
||||
height: dotsSize,
|
||||
animationDuration: '1.5s',
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<div
|
||||
className={classNames(
|
||||
'absolute rounded-full outline-background-90 transition duration-150 ease-linear box-border',
|
||||
'hover:bg-accent-background-40',
|
||||
'flex items-center justify-center',
|
||||
part != null && assignedRoles.includes(part)
|
||||
? 'bg-status-success'
|
||||
: required
|
||||
? 'bg-status-warning'
|
||||
: 'bg-background-10',
|
||||
leftPartNames.has(id) &&
|
||||
'border-4 border-assign-left',
|
||||
rightPartNames.has(id) &&
|
||||
'border-4 border-assign-right',
|
||||
part != null && dotClass?.(part),
|
||||
hidden ? 'opacity-0' : 'opacity-100'
|
||||
)}
|
||||
style={{
|
||||
width: dotsSize,
|
||||
height: dotsSize,
|
||||
boxShadow: '0px 0px 4px black',
|
||||
}}
|
||||
>
|
||||
{part != null && dotContent?.(part)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
)}
|
||||
</div>
|
||||
<div ref={rightContainerRef} className="z-10" {...controlFocusProps}>
|
||||
{rightControls}
|
||||
</div>
|
||||
</div>
|
||||
<div ref={bottomContainerRef} className="z-10" {...controlFocusProps}>
|
||||
{bottomControls}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
import { useState } from 'react';
|
||||
import { BaseModal } from './BaseModal';
|
||||
import { Button, ButtonProps } from './Button';
|
||||
|
||||
export type ButtonConfirmModal = Omit<ButtonProps, 'onClick' | 'to'> & {
|
||||
onConfirm: () => void;
|
||||
onCancel: (reason: 'cancel' | 'backdrop') => void;
|
||||
|
||||
confirmLabel: string;
|
||||
cancelLabel: string;
|
||||
};
|
||||
|
||||
export function ButtonConfirmModal(props: ButtonConfirmModal) {
|
||||
const {
|
||||
onConfirm,
|
||||
onCancel,
|
||||
cancelLabel,
|
||||
confirmLabel,
|
||||
children,
|
||||
...buttonProps
|
||||
} = props;
|
||||
|
||||
const [isOpen, setOpen] = useState(false);
|
||||
|
||||
return (
|
||||
<>
|
||||
<BaseModal
|
||||
isOpen={isOpen}
|
||||
onRequestClose={() => {
|
||||
setOpen(false);
|
||||
onCancel('backdrop');
|
||||
}}
|
||||
appendClasses="w-full max-w-2xl"
|
||||
>
|
||||
<div className="flex flex-col justify-between gap-4">
|
||||
{children}
|
||||
<div className="flex w-full justify-between gap-2 xs:flex-row flex-col">
|
||||
<Button
|
||||
id={cancelLabel}
|
||||
variant="tertiary"
|
||||
onClick={() => {
|
||||
setOpen(false);
|
||||
onCancel('cancel');
|
||||
}}
|
||||
/>
|
||||
<Button
|
||||
id={confirmLabel}
|
||||
variant="primary"
|
||||
onClick={() => {
|
||||
setOpen(false);
|
||||
onConfirm();
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</BaseModal>
|
||||
<Button {...buttonProps} onClick={() => setOpen(true)} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
import classNames from 'classnames';
|
||||
import { ComponentProps } from 'react';
|
||||
import { NavLink, type NavLinkProps } from 'react-router-dom';
|
||||
import { Tooltip, type Direction } from './Tooltip';
|
||||
import { Typography } from './Typography';
|
||||
|
||||
type NativeButtonProps = Omit<
|
||||
ComponentProps<'button'>,
|
||||
'aria-pressed' | 'aria-expanded' | 'aria-current' | 'aria-label'
|
||||
>;
|
||||
|
||||
type CommonProps = {
|
||||
/** Toggle or selection state, e.g. a segmented option. Button mode only. */
|
||||
pressed?: boolean;
|
||||
/** Disclosure state, e.g. an accordion header. Button mode only. */
|
||||
expanded?: boolean;
|
||||
/** Marks the active entry in a stepper or nav. */
|
||||
current?: 'step' | 'page' | true;
|
||||
/** Accessible name, for when the children don't already give one. */
|
||||
label?: string;
|
||||
/** Fluent id. Opts this surface into a tooltip (hover *and* focus). */
|
||||
tooltipId?: string;
|
||||
tooltipDirection?: Direction;
|
||||
};
|
||||
|
||||
type ButtonProps = CommonProps &
|
||||
NativeButtonProps & { [dataAttr: `data-${string}`]: unknown } & {
|
||||
to?: undefined;
|
||||
};
|
||||
|
||||
type LinkProps = CommonProps &
|
||||
Omit<NavLinkProps, 'className' | 'children'> & {
|
||||
[dataAttr: `data-${string}`]: unknown;
|
||||
} & {
|
||||
/** Router path. Renders a `NavLink` instead of a `<button>`. */
|
||||
to: NavLinkProps['to'];
|
||||
className?: string;
|
||||
children?: ComponentProps<'button'>['children'];
|
||||
};
|
||||
|
||||
/**
|
||||
* A clickable surface that keeps whatever styling you give it and only adds
|
||||
* the semantics: tab focus, Enter/Space, and a default `type="button"` so a
|
||||
* `<button>` does not submit a surrounding form unless asked to.
|
||||
*
|
||||
* Pass `to` and it renders a router `NavLink` instead, so the same call site
|
||||
* covers both an action and a navigation.
|
||||
*
|
||||
* Reach for this anywhere you would have put `onClick` on a `<div>`. Use
|
||||
* `Button` for the styled variants and `IconButton` for icon-only controls.
|
||||
*
|
||||
* No tooltip by default, since the children are already the label. Pass
|
||||
* `tooltipId` where the extra explanation earns its place.
|
||||
*
|
||||
* It cannot wrap another button or link. If the surface already contains one,
|
||||
* leave the container inert and make the inner control the real button.
|
||||
*/
|
||||
export function Clickable({
|
||||
className,
|
||||
pressed,
|
||||
expanded,
|
||||
current,
|
||||
label,
|
||||
tooltipId,
|
||||
tooltipDirection = 'bottom',
|
||||
...props
|
||||
}: ButtonProps | LinkProps) {
|
||||
const surface =
|
||||
props.to !== undefined ? (
|
||||
<NavLink
|
||||
{...(props as LinkProps)}
|
||||
aria-current={current}
|
||||
aria-label={label}
|
||||
className={classNames('text-left', className)}
|
||||
/>
|
||||
) : (
|
||||
<button
|
||||
type="button"
|
||||
{...(props as ButtonProps)}
|
||||
aria-pressed={pressed}
|
||||
aria-expanded={expanded}
|
||||
aria-current={current}
|
||||
aria-label={label}
|
||||
className={classNames('text-left', className)}
|
||||
/>
|
||||
);
|
||||
|
||||
if (!tooltipId) return surface;
|
||||
|
||||
return (
|
||||
<Tooltip
|
||||
preferedDirection={tooltipDirection}
|
||||
content={<Typography id={tooltipId} />}
|
||||
spacing={5}
|
||||
>
|
||||
{surface}
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
.dropdown-popover {
|
||||
display: none;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transform: scale(0.98);
|
||||
transition:
|
||||
opacity 120ms ease,
|
||||
transform 120ms ease,
|
||||
display 120ms allow-discrete,
|
||||
overlay 120ms allow-discrete;
|
||||
|
||||
&:popover-open {
|
||||
display: flex;
|
||||
opacity: 1;
|
||||
pointer-events: auto;
|
||||
transform: scale(1);
|
||||
}
|
||||
|
||||
@starting-style {
|
||||
&:popover-open {
|
||||
opacity: 0;
|
||||
transform: scale(0.98);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,621 +0,0 @@
|
||||
import classNames from 'classnames';
|
||||
import { Clickable } from './Clickable';
|
||||
import {
|
||||
CSSProperties,
|
||||
forwardRef,
|
||||
ReactNode,
|
||||
useEffect,
|
||||
useId,
|
||||
useLayoutEffect,
|
||||
useRef,
|
||||
useState,
|
||||
} from 'react';
|
||||
import {
|
||||
Control,
|
||||
FieldError,
|
||||
FieldPath,
|
||||
FieldValues,
|
||||
useController,
|
||||
UseControllerProps,
|
||||
} from 'react-hook-form';
|
||||
import { ArrowDownIcon, ArrowUpIcon } from './icon/ArrowIcons';
|
||||
import { CheckIcon } from './icon/CheckIcon';
|
||||
import { ProgressBar } from './ProgressBar';
|
||||
import { a11yClick } from '@/utils/a11y';
|
||||
import './Dropdown.scss';
|
||||
import { Typography } from './Typography';
|
||||
import {
|
||||
FLOATING_LABEL_PADDING,
|
||||
FieldCaption,
|
||||
FloatingLabel,
|
||||
} from './FloatingLabel';
|
||||
|
||||
export type DropdownItem = {
|
||||
value: string;
|
||||
label: ReactNode;
|
||||
};
|
||||
|
||||
export type DropdownDirection = 'up' | 'down';
|
||||
|
||||
function isItemSelected(
|
||||
selection: DropdownSingleSelection | DropdownMultipleSelection,
|
||||
itemValue: string
|
||||
): boolean {
|
||||
return selection.multiple
|
||||
? selection.value.includes(itemValue)
|
||||
: selection.value === itemValue;
|
||||
}
|
||||
|
||||
type DropdownProps = {
|
||||
direction?: DropdownDirection;
|
||||
variant?: 'primary' | 'secondary' | 'tertiary' | 'quaternary';
|
||||
alignment?: 'left' | 'right';
|
||||
display?: 'fit' | 'block';
|
||||
placeholder: ReactNode;
|
||||
// Field label. Rendered as a caption above the box, unless `inside` is 'label'.
|
||||
label?: string;
|
||||
// What fills the box while nothing is selected:
|
||||
// 'placeholder' (default) - the placeholder text (blank if it is empty/null)
|
||||
// 'label' - the label, as a floating label inside the box
|
||||
// 'none' - nothing
|
||||
inside?: 'placeholder' | 'label' | 'none';
|
||||
// Keep the caption once a value is selected (default). Set false to drop it.
|
||||
persistLabel?: boolean;
|
||||
name: string;
|
||||
items: DropdownItem[];
|
||||
maxHeight?: string | number;
|
||||
error?: FieldError;
|
||||
loading?: boolean;
|
||||
renderValue?: () => ReactNode;
|
||||
};
|
||||
|
||||
type DropdownSingleSelection = {
|
||||
multiple?: false;
|
||||
value: string;
|
||||
onChange: (value: string) => void;
|
||||
};
|
||||
|
||||
type DropdownMultipleSelection = {
|
||||
multiple: true;
|
||||
value: string[];
|
||||
onChange: (value: string[]) => void;
|
||||
};
|
||||
|
||||
function DropdownItem({
|
||||
item,
|
||||
variant,
|
||||
onSelected,
|
||||
isOpen,
|
||||
checked,
|
||||
multiple,
|
||||
innerFocusValue,
|
||||
name,
|
||||
}: {
|
||||
item: DropdownItem;
|
||||
variant: Required<DropdownProps>['variant'];
|
||||
onSelected: () => void;
|
||||
isOpen: boolean;
|
||||
checked: boolean;
|
||||
multiple?: boolean;
|
||||
innerFocusValue: string | null;
|
||||
name: string;
|
||||
}) {
|
||||
const variantStyles = {
|
||||
primary:
|
||||
'text-background-10 checked-hover:text-background-10 checked-hover:bg-background-50 focus:text-background-10 focus:bg-background-50',
|
||||
secondary:
|
||||
'text-background-10 checked-hover:text-background-10 checked-hover:bg-background-40 focus:text-background-10 focus:bg-background-40',
|
||||
tertiary:
|
||||
'bg-accent-background-30 checked-hover:bg-accent-background-20 focus:bg-accent-background-20 text-background-10',
|
||||
quaternary:
|
||||
'text-background-10 checked-hover:text-background-10 checked-hover:bg-background-60 focus:text-background-10 focus:bg-background-60',
|
||||
};
|
||||
|
||||
const ref = useRef<HTMLDivElement>(null);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
if (!innerFocusValue) {
|
||||
return;
|
||||
}
|
||||
if (innerFocusValue === item.value) {
|
||||
ref.current?.scrollIntoView({ block: 'nearest' });
|
||||
}
|
||||
}, [innerFocusValue]);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
if (!isOpen) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (innerFocusValue === item.value || (!innerFocusValue && checked)) {
|
||||
ref.current?.scrollIntoView({ block: 'nearest' });
|
||||
}
|
||||
}, [isOpen]);
|
||||
|
||||
return (
|
||||
<div
|
||||
className={classNames(
|
||||
'py-2 px-2 min-w-max cursor-pointer transition-colors select-none',
|
||||
variantStyles[variant],
|
||||
innerFocusValue === item.value &&
|
||||
'ring-inset ring-2 ring-accent-background-10'
|
||||
)}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
onSelected();
|
||||
}}
|
||||
onKeyDown={(e) => a11yClick(e) && onSelected()}
|
||||
tabIndex={-1}
|
||||
aria-hidden={!isOpen}
|
||||
ref={ref}
|
||||
id={`__dropdownList-${name}-item-${item.value}`}
|
||||
>
|
||||
<div className="flex items-center gap-2.5">
|
||||
{multiple && (
|
||||
<div
|
||||
className={classNames(
|
||||
'w-4 h-4 rounded flex items-center justify-center transition-colors shrink-0',
|
||||
checked
|
||||
? 'bg-accent-background-30 text-background-10'
|
||||
: 'bg-background-50 border border-background-40'
|
||||
)}
|
||||
>
|
||||
{checked && <CheckIcon size={9} className="fill-current" />}
|
||||
</div>
|
||||
)}
|
||||
<div className="flex-1 min-w-0">{item.label}</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export type DropdownAction = 'all' | 'none';
|
||||
|
||||
type DropdownListProps = {
|
||||
isOpen: boolean;
|
||||
onSelect: (item: DropdownItem) => void;
|
||||
isSelected: (value: string) => boolean;
|
||||
multiple?: boolean;
|
||||
onSelectAll?: () => void;
|
||||
onDeselectAll?: () => void;
|
||||
innerFocusValue: string | null;
|
||||
focusedAction: DropdownAction | null;
|
||||
anchorName: string;
|
||||
} & Pick<
|
||||
Required<DropdownProps>,
|
||||
| 'display'
|
||||
| 'alignment'
|
||||
| 'direction'
|
||||
| 'items'
|
||||
| 'variant'
|
||||
| 'maxHeight'
|
||||
| 'name'
|
||||
>;
|
||||
|
||||
const DropdownList = forwardRef<HTMLDivElement, DropdownListProps>(function (
|
||||
{
|
||||
isOpen,
|
||||
onSelect,
|
||||
isSelected,
|
||||
multiple,
|
||||
onSelectAll,
|
||||
onDeselectAll,
|
||||
innerFocusValue,
|
||||
focusedAction,
|
||||
display,
|
||||
alignment,
|
||||
direction,
|
||||
items,
|
||||
variant,
|
||||
maxHeight,
|
||||
name,
|
||||
anchorName,
|
||||
},
|
||||
ref
|
||||
) {
|
||||
const variantStyles = {
|
||||
primary: 'bg-background-60',
|
||||
secondary: 'bg-background-50',
|
||||
tertiary: 'bg-accent-background-30',
|
||||
quaternary: 'bg-background-70',
|
||||
};
|
||||
|
||||
const columnArea =
|
||||
display === 'block'
|
||||
? 'center'
|
||||
: alignment === 'left'
|
||||
? 'span-right'
|
||||
: 'span-left';
|
||||
const rowArea = direction === 'up' ? 'top' : 'bottom';
|
||||
|
||||
const ulRef = useRef<HTMLUListElement>(null);
|
||||
|
||||
const setDivRef = (node: HTMLDivElement | null) => {
|
||||
node?.setAttribute('popover', 'manual');
|
||||
if (typeof ref === 'function') {
|
||||
ref(node);
|
||||
} else if (ref) {
|
||||
ref.current = node;
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div
|
||||
className={classNames(
|
||||
'dropdown-popover fixed inset-auto m-0 border-0 p-0 rounded overflow-hidden flex-col',
|
||||
direction === 'up' ? 'mb-3' : 'mt-3',
|
||||
variantStyles[variant],
|
||||
display === 'block' ? 'w-full' : 'w-fit'
|
||||
)}
|
||||
style={
|
||||
{
|
||||
positionAnchor: anchorName,
|
||||
positionArea: `${rowArea} ${columnArea}`,
|
||||
positionTryFallbacks: 'flip-block',
|
||||
} as CSSProperties
|
||||
}
|
||||
onTransitionEnd={(e) => {
|
||||
if (e.propertyName === 'opacity' && !isOpen) {
|
||||
ulRef.current?.scrollTo({ top: 0 });
|
||||
}
|
||||
}}
|
||||
ref={setDivRef}
|
||||
id={`__dropdownList-${name}`}
|
||||
>
|
||||
{multiple && (onSelectAll || onDeselectAll) && (
|
||||
<div className="flex items-center justify-between px-3 py-2 border-b border-background-10/10 text-xs font-bold bg-background-80/60 select-none">
|
||||
<Clickable
|
||||
id={`__dropdownList-${name}-action-all`}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
onSelectAll?.();
|
||||
}}
|
||||
className={classNames(
|
||||
'text-background-10 hover:text-background-20 transition-colors rounded',
|
||||
focusedAction === 'all' && 'ring-2 ring-accent-background-10'
|
||||
)}
|
||||
>
|
||||
<Typography id="dropdown_select-all" />
|
||||
</Clickable>
|
||||
<Clickable
|
||||
id={`__dropdownList-${name}-action-none`}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
onDeselectAll?.();
|
||||
}}
|
||||
className={classNames(
|
||||
'text-background-30 hover:text-background-10 transition-colors rounded',
|
||||
focusedAction === 'none' && 'ring-2 ring-accent-background-10'
|
||||
)}
|
||||
>
|
||||
<Typography id="dropdown_unselect-all" />
|
||||
</Clickable>
|
||||
</div>
|
||||
)}
|
||||
<ul
|
||||
ref={ulRef}
|
||||
className="flex flex-col min-h-0 text-sm overflow-y-scroll dropdown-scroll overscroll-contain"
|
||||
style={{ maxHeight }}
|
||||
>
|
||||
{items.map((item) => (
|
||||
<DropdownItem
|
||||
item={item}
|
||||
variant={variant}
|
||||
onSelected={() => onSelect(item)}
|
||||
isOpen={isOpen}
|
||||
key={item.value}
|
||||
checked={isSelected(item.value)}
|
||||
multiple={multiple}
|
||||
innerFocusValue={innerFocusValue}
|
||||
name={name}
|
||||
/>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
|
||||
export function DropdownInside(
|
||||
props: DropdownProps & (DropdownSingleSelection | DropdownMultipleSelection)
|
||||
) {
|
||||
const {
|
||||
direction = 'up',
|
||||
variant = 'primary',
|
||||
alignment = 'right',
|
||||
display = 'fit',
|
||||
placeholder,
|
||||
label,
|
||||
inside = 'placeholder',
|
||||
persistLabel = true,
|
||||
name,
|
||||
items,
|
||||
maxHeight = '50vh',
|
||||
error,
|
||||
loading,
|
||||
renderValue,
|
||||
} = props;
|
||||
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
|
||||
const variantStyles = {
|
||||
primary: 'bg-background-60 hover:bg-background-50',
|
||||
secondary: 'bg-background-50 hover:bg-background-40',
|
||||
tertiary: 'bg-accent-background-30 hover:bg-accent-background-20',
|
||||
quaternary: 'bg-background-70 hover:bg-background-60',
|
||||
};
|
||||
|
||||
const displayStyles = {
|
||||
fit: 'w-fit',
|
||||
block: 'w-full',
|
||||
};
|
||||
|
||||
const hasValue = props.multiple ? props.value.length > 0 : !!props.value;
|
||||
const labelInside = inside === 'label' && !!label;
|
||||
const showCaption = !!label && !labelInside && (persistLabel || !hasValue);
|
||||
const emptyValue = inside === 'placeholder' ? placeholder : '';
|
||||
|
||||
const getShownValue = (): ReactNode => {
|
||||
if (renderValue) return renderValue();
|
||||
if (props.multiple) {
|
||||
return props.value.length > 0
|
||||
? `${props.value.length} selected`
|
||||
: emptyValue;
|
||||
}
|
||||
return props.value
|
||||
? (items.find((item) => item.value === props.value)?.label ?? placeholder)
|
||||
: emptyValue;
|
||||
};
|
||||
|
||||
const selectItem = (item: DropdownItem) => {
|
||||
if (props.multiple) {
|
||||
const exists = props.value.includes(item.value);
|
||||
props.onChange(
|
||||
exists
|
||||
? props.value.filter((v) => v !== item.value)
|
||||
: [...props.value, item.value]
|
||||
);
|
||||
} else {
|
||||
props.onChange(item.value);
|
||||
setIsOpen(false);
|
||||
}
|
||||
};
|
||||
|
||||
const selectAll = () =>
|
||||
props.multiple && props.onChange(items.map((i) => i.value));
|
||||
const deselectAll = () => props.multiple && props.onChange([]);
|
||||
|
||||
/**
|
||||
* The header select-all / unselect-all buttons sit before the items in the
|
||||
* roving order, so arrows reach them like any option.
|
||||
*/
|
||||
const actionKeys: DropdownAction[] = props.multiple ? ['all', 'none'] : [];
|
||||
const navCount = actionKeys.length + items.length;
|
||||
const resolveNav = (
|
||||
index: number | null
|
||||
): { action: DropdownAction | null; item: DropdownItem | null } => {
|
||||
if (index === null || index < 0) return { action: null, item: null };
|
||||
if (index < actionKeys.length)
|
||||
return { action: actionKeys[index] ?? null, item: null };
|
||||
return { action: null, item: items[index - actionKeys.length] ?? null };
|
||||
};
|
||||
|
||||
const ref = useRef<HTMLDivElement>(null);
|
||||
const listRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
const anchorName = `--dropdown-anchor-${useId().replace(/:/g, '')}`;
|
||||
|
||||
const [innerFocusIndex, setInnerFocusIndex] = useState<number | null>(null);
|
||||
// Index may point past the range (items changed, empty list) - resolve safely.
|
||||
const { action: focusedAction, item: focusedItem } =
|
||||
resolveNav(innerFocusIndex);
|
||||
const getCurrentActiveIndex = () => {
|
||||
const i = props.multiple
|
||||
? items.findIndex((item) => props.value.includes(item.value))
|
||||
: items.findIndex((item) => item.value === props.value);
|
||||
return i >= 0 ? i + actionKeys.length : actionKeys.length;
|
||||
};
|
||||
const innerFocusPrev = () => {
|
||||
const current = innerFocusIndex ?? getCurrentActiveIndex();
|
||||
setInnerFocusIndex(Math.max(0, current - 1));
|
||||
};
|
||||
const innerFocusNext = () => {
|
||||
const current = innerFocusIndex ?? getCurrentActiveIndex();
|
||||
setInnerFocusIndex(Math.min(navCount - 1, current + 1));
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (!isOpen) {
|
||||
setInnerFocusIndex(null);
|
||||
}
|
||||
}, [isOpen]);
|
||||
|
||||
useEffect(() => {
|
||||
if (loading) {
|
||||
setIsOpen(false);
|
||||
}
|
||||
}, [loading]);
|
||||
|
||||
useEffect(() => {
|
||||
const el = listRef.current;
|
||||
if (!el) {
|
||||
return;
|
||||
}
|
||||
if (isOpen && !el.matches(':popover-open')) {
|
||||
el.showPopover();
|
||||
} else if (!isOpen && el.matches(':popover-open')) {
|
||||
el.hidePopover();
|
||||
}
|
||||
}, [isOpen]);
|
||||
|
||||
return (
|
||||
<div className={classNames('flex flex-col gap-1', displayStyles[display])}>
|
||||
{showCaption && <FieldCaption>{label}</FieldCaption>}
|
||||
<div
|
||||
className={classNames(
|
||||
'min-h-[48px] min-w-0 text-background-10 text-left dropdown',
|
||||
displayStyles[display]
|
||||
)}
|
||||
onKeyDown={(e) => {
|
||||
if (loading) {
|
||||
return;
|
||||
}
|
||||
if (!isOpen) {
|
||||
if (a11yClick(e)) {
|
||||
setInnerFocusIndex(getCurrentActiveIndex());
|
||||
setIsOpen(!isOpen);
|
||||
e.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
// Up/Down opens the list (APG combobox pattern).
|
||||
if (
|
||||
items.length > 0 &&
|
||||
(e.key === 'ArrowDown' || e.key === 'ArrowUp')
|
||||
) {
|
||||
setInnerFocusIndex(
|
||||
e.key === 'ArrowDown' ? actionKeys.length : navCount - 1
|
||||
);
|
||||
setIsOpen(true);
|
||||
e.preventDefault();
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
if (a11yClick(e)) {
|
||||
e.preventDefault();
|
||||
if (focusedAction === 'all') return selectAll();
|
||||
if (focusedAction === 'none') return deselectAll();
|
||||
if (!focusedItem) {
|
||||
setIsOpen(false);
|
||||
return;
|
||||
}
|
||||
|
||||
selectItem(focusedItem);
|
||||
if (!props.multiple) setIsOpen(false);
|
||||
}
|
||||
switch (e.key) {
|
||||
case 'ArrowUp':
|
||||
case 'ArrowLeft':
|
||||
innerFocusPrev();
|
||||
e.preventDefault();
|
||||
return;
|
||||
case 'ArrowDown':
|
||||
case 'ArrowRight':
|
||||
innerFocusNext();
|
||||
e.preventDefault();
|
||||
return;
|
||||
case 'Escape':
|
||||
setIsOpen(false);
|
||||
return;
|
||||
case 'Home':
|
||||
setInnerFocusIndex(0);
|
||||
return;
|
||||
case 'End':
|
||||
setInnerFocusIndex(navCount - 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}}
|
||||
onBlur={(e) => {
|
||||
if (e.currentTarget.contains(e.relatedTarget)) {
|
||||
return;
|
||||
}
|
||||
|
||||
setIsOpen(false);
|
||||
}}
|
||||
>
|
||||
<div
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
if (!loading) setIsOpen((o) => !o);
|
||||
}}
|
||||
className={classNames(
|
||||
'flex flex-row items-center gap-2 pl-3 pr-11 rounded-md relative min-h-[48px] min-w-0 overflow-hidden',
|
||||
labelInside ? FLOATING_LABEL_PADDING : 'py-3',
|
||||
loading ? 'cursor-not-allowed opacity-60' : 'cursor-pointer',
|
||||
variantStyles[variant]
|
||||
)}
|
||||
tabIndex={loading ? -1 : 0}
|
||||
aria-disabled={loading}
|
||||
ref={ref}
|
||||
style={{ anchorName } as CSSProperties}
|
||||
aria-controls={`__dropdownList-${name}`}
|
||||
aria-expanded={isOpen}
|
||||
aria-activedescendant={
|
||||
focusedAction
|
||||
? `__dropdownList-${name}-action-${focusedAction}`
|
||||
: focusedItem
|
||||
? `__dropdownList-${name}-item-${focusedItem.value}`
|
||||
: ''
|
||||
}
|
||||
role="combobox"
|
||||
>
|
||||
{labelInside && <FloatingLabel label={label} floating={hasValue} />}
|
||||
<span
|
||||
className={classNames(
|
||||
'min-w-0 flex-grow truncate',
|
||||
!hasValue && 'text-background-20 italic'
|
||||
)}
|
||||
>
|
||||
{getShownValue()}
|
||||
</span>
|
||||
<div className="fill-background-10 pointer-events-none absolute inset-y-0 right-5 flex items-center">
|
||||
{direction === 'up' ? (
|
||||
<ArrowUpIcon size={16} />
|
||||
) : (
|
||||
<ArrowDownIcon size={16} />
|
||||
)}
|
||||
</div>
|
||||
{loading && (
|
||||
<div className="absolute left-0 right-0 bottom-0">
|
||||
<ProgressBar indeterminate height={3} bottom />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{error?.message && (
|
||||
<div className="text-status-critical">{error.message}</div>
|
||||
)}
|
||||
<DropdownList
|
||||
alignment={alignment}
|
||||
direction={direction}
|
||||
display={display}
|
||||
isOpen={isOpen}
|
||||
items={items}
|
||||
multiple={props.multiple}
|
||||
onSelectAll={selectAll}
|
||||
onDeselectAll={deselectAll}
|
||||
onSelect={(item: DropdownItem) => {
|
||||
ref.current?.focus();
|
||||
selectItem(item);
|
||||
}}
|
||||
variant={variant}
|
||||
maxHeight={maxHeight}
|
||||
isSelected={(value) => isItemSelected(props, value)}
|
||||
ref={listRef}
|
||||
anchorName={anchorName}
|
||||
innerFocusValue={focusedItem?.value ?? null}
|
||||
focusedAction={focusedAction}
|
||||
name={name}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function Dropdown<T extends FieldValues = FieldValues>({
|
||||
control,
|
||||
name,
|
||||
rules,
|
||||
...props
|
||||
}: DropdownProps & {
|
||||
control: Control<T>;
|
||||
name: FieldPath<T>;
|
||||
rules?: UseControllerProps<T, FieldPath<T>>['rules'];
|
||||
}) {
|
||||
const {
|
||||
field: { value, onChange },
|
||||
} = useController({ name, control, rules });
|
||||
|
||||
return (
|
||||
<DropdownInside value={value} name={name} {...props} onChange={onChange} />
|
||||
);
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
import classNames from 'classnames';
|
||||
import { ReactNode } from 'react';
|
||||
import { LoaderIcon, SlimeState } from './icon/LoaderIcon';
|
||||
import { Typography } from './Typography';
|
||||
|
||||
/** Slime, a title and a line of guidance for a panel with nothing in it */
|
||||
export function EmptyState({
|
||||
slimeState,
|
||||
iconSize,
|
||||
glow = false,
|
||||
lowPriority = false,
|
||||
titleId,
|
||||
titleColor,
|
||||
descriptionId,
|
||||
descriptionColor,
|
||||
action,
|
||||
className,
|
||||
}: {
|
||||
slimeState: SlimeState;
|
||||
iconSize?: number;
|
||||
/** Accent halo behind the slime */
|
||||
glow?: boolean;
|
||||
lowPriority?: boolean;
|
||||
titleId: string;
|
||||
titleColor?: string;
|
||||
descriptionId: string;
|
||||
descriptionColor?: string;
|
||||
action?: ReactNode;
|
||||
className?: string;
|
||||
}) {
|
||||
const icon = (
|
||||
<LoaderIcon
|
||||
slimeState={slimeState}
|
||||
size={iconSize}
|
||||
lowPriority={lowPriority}
|
||||
/>
|
||||
);
|
||||
|
||||
return (
|
||||
<div
|
||||
className={classNames(
|
||||
'flex flex-col items-center justify-center gap-4 text-center p-6',
|
||||
className
|
||||
)}
|
||||
>
|
||||
{glow ? (
|
||||
<div className="relative flex items-center justify-center antialiased">
|
||||
<div
|
||||
className="absolute w-64 h-64 rounded-full pointer-events-none"
|
||||
style={{
|
||||
background:
|
||||
'radial-gradient(circle, rgb(var(--accent-background-30), 0.25) 0%, rgb(var(--accent-background-30), 0) 70%)',
|
||||
}}
|
||||
/>
|
||||
{icon}
|
||||
</div>
|
||||
) : (
|
||||
icon
|
||||
)}
|
||||
<div className="flex flex-col gap-1 max-w-xs">
|
||||
<Typography
|
||||
bold
|
||||
variant="section-title"
|
||||
color={titleColor}
|
||||
id={titleId}
|
||||
/>
|
||||
<Typography
|
||||
variant="standard"
|
||||
color={descriptionColor}
|
||||
id={descriptionId}
|
||||
/>
|
||||
</div>
|
||||
{action}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
import { BodyPart } from 'solarxr-protocol';
|
||||
import {
|
||||
ExtremityFigureSpec,
|
||||
ExtremityParts,
|
||||
ExtremitySide,
|
||||
} from '@/utils/extremities';
|
||||
|
||||
const CIRCLE_RADIUS = 0.0001;
|
||||
|
||||
export function ExtremityFigure({
|
||||
spec,
|
||||
parts,
|
||||
side,
|
||||
height = spec.height,
|
||||
className,
|
||||
}: {
|
||||
spec: ExtremityFigureSpec;
|
||||
parts: ExtremityParts;
|
||||
side: ExtremitySide;
|
||||
height?: number;
|
||||
className?: string;
|
||||
}) {
|
||||
const mirror = side === 'left';
|
||||
const x = (cx: number) => (mirror ? spec.width - cx : cx);
|
||||
|
||||
return (
|
||||
<svg
|
||||
width="100%"
|
||||
className={className}
|
||||
viewBox={`0 0 ${spec.width} ${height}`}
|
||||
>
|
||||
<image
|
||||
width={spec.width}
|
||||
height={spec.height}
|
||||
transform={
|
||||
mirror ? `translate(${spec.width},0) scale(-1,1)` : undefined
|
||||
}
|
||||
href={spec.image}
|
||||
/>
|
||||
{Object.entries(parts.digits).flatMap(([digit, joints]) =>
|
||||
joints.map((part, joint) => {
|
||||
const [cx, cy] = spec.anchors[digit][joint];
|
||||
return (
|
||||
<circle
|
||||
key={part}
|
||||
className="body-part-circle"
|
||||
cx={x(cx)}
|
||||
cy={cy}
|
||||
r={CIRCLE_RADIUS}
|
||||
id={BodyPart[part]}
|
||||
/>
|
||||
);
|
||||
})
|
||||
)}
|
||||
<circle
|
||||
className="body-part-circle"
|
||||
cx={x(spec.rootAnchor[0])}
|
||||
cy={spec.rootAnchor[1]}
|
||||
r={CIRCLE_RADIUS}
|
||||
id={BodyPart[parts.root]}
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
import classNames from 'classnames';
|
||||
import { ReactNode } from 'react';
|
||||
import { Typography } from './Typography';
|
||||
|
||||
export function FloatingLabel({
|
||||
label,
|
||||
floating,
|
||||
className,
|
||||
}: {
|
||||
label: ReactNode;
|
||||
floating: boolean;
|
||||
className?: string;
|
||||
}) {
|
||||
return (
|
||||
<Typography
|
||||
variant="standard"
|
||||
bold={floating}
|
||||
italic={!floating}
|
||||
color={classNames(
|
||||
'text-background-10 pointer-events-none absolute left-3 z-20 leading-none transition-all duration-150 ease-out',
|
||||
floating ? `top-[0.5rem] origin-left` : 'top-1/2 -translate-y-1/2',
|
||||
className
|
||||
)}
|
||||
>
|
||||
{label}
|
||||
</Typography>
|
||||
);
|
||||
}
|
||||
|
||||
export function FieldCaption({ children }: { children: ReactNode }) {
|
||||
return (
|
||||
<Typography
|
||||
variant="standard"
|
||||
bold
|
||||
color={classNames('text-background-10 leading-none origin-left')}
|
||||
>
|
||||
{children}
|
||||
</Typography>
|
||||
);
|
||||
}
|
||||
|
||||
// Vertical padding a control needs so a floating label clears its value.
|
||||
export const FLOATING_LABEL_PADDING = 'pt-[1.15rem] pb-[0.15rem]';
|
||||