Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
472f6d8fc0 |
No files matched your search
@@ -1,9 +1 @@
|
||||
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
|
||||
|
||||
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
|
||||
use flake
|
||||
@@ -1,5 +0,0 @@
|
||||
* text=auto
|
||||
|
||||
*.png binary
|
||||
*.webp binary
|
||||
*.gif binary
|
||||
@@ -1,36 +1,30 @@
|
||||
# Make everyone be able to approve SolarXR submodule changes
|
||||
/solarxr-protocol @ButterscotchV @Erimelowo @loucass003
|
||||
|
||||
# Make Loucass the owner of all GUI stuff
|
||||
/gui/ @loucass003
|
||||
/pnpm-lock.yaml @loucass003
|
||||
/pnpm-workspace.yaml @loucass003
|
||||
|
||||
# loucass003 and Erimel responsible for i18n
|
||||
/gui/public/i18n/ @loucass003 @Erimelowo @ImSapphire
|
||||
/gui/src/i18n/ @loucass003 @Erimelowo
|
||||
/l10n.toml @loucass003 @Erimelowo
|
||||
|
||||
/gui/src/components/settings/ @Erimelowo @loucass003
|
||||
|
||||
# Electron part of the GUI
|
||||
/gui/electron/ @loucass003
|
||||
|
||||
# Some server code~
|
||||
/server/ @ButterscotchV @loucass003 @Erimelowo
|
||||
|
||||
/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
|
||||
|
||||
/bindings-provider/ @ImSapphire
|
||||
|
||||
# Linux files
|
||||
*.nix @loucass003
|
||||
/flake.lock @loucass003
|
||||
/dev.slimevr.SlimeVR.metainfo.xml @loucass003
|
||||
/.envrc @loucass003
|
||||
# Global code owner
|
||||
* @Eirenliel
|
||||
|
||||
# Make Loucas and Uriel the owners of all GUI stuff
|
||||
/gui/ @loucass003 @ImUrX
|
||||
/package-lock.json @loucass003 @ImUrX
|
||||
|
||||
# Uriel and Erimel responsible for i18n
|
||||
/gui/public/i18n/ @ImUrX @Louka3000
|
||||
/gui/src/i18n/ @ImUrX @Louka3000
|
||||
/l10n.toml @ImUrX @Louka3000
|
||||
|
||||
/gui/src/components/settings/ @Louka3000 @loucass003
|
||||
|
||||
# Rust part of the GUI
|
||||
/gui/src-tauri/ @ImUrX @TheButlah
|
||||
/Cargo.lock @ImUrX @TheButlah
|
||||
|
||||
# Some server code~
|
||||
/server/ @ButterscotchV @Eirenliel @Louka3000
|
||||
|
||||
/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/ @Louka3000
|
||||
/server/src/main/java/dev/slimevr/tracking/processor/ @Louka3000
|
||||
/server/src/main/java/dev/slimevr/filtering/ @Louka3000
|
||||
|
||||
server/src/main/java/dev/slimevr/config/ @loucass003
|
||||
@@ -1,3 +0,0 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: SlimeVR
|
||||
@@ -1,8 +0,0 @@
|
||||
version: 2
|
||||
updates:
|
||||
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
# Check for updates to GitHub Actions every week
|
||||
interval: "weekly"
|
||||
@@ -0,0 +1,110 @@
|
||||
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@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version-file: '.node-version'
|
||||
cache: 'npm'
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
npm ci
|
||||
cd gui
|
||||
npm run lint
|
||||
|
||||
build:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-20.04, windows-latest, macos-latest]
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
env:
|
||||
# Don't mark warnings as errors
|
||||
CI: false
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- if: matrix.os == 'ubuntu-20.04'
|
||||
name: Set up Linux dependencies
|
||||
uses: awalsh128/cache-apt-pkgs-action@latest
|
||||
with:
|
||||
packages: libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf
|
||||
# Increment to invalidate the cache
|
||||
version: 1.0
|
||||
# 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: Cache cargo dependencies
|
||||
uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
shared-key: "${{ matrix.os }}"
|
||||
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version-file: '.node-version'
|
||||
cache: 'npm'
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
npm ci
|
||||
npm run skipbundler
|
||||
|
||||
- if: matrix.os == 'windows-latest'
|
||||
name: Upload a Build Artifact (Windows)
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
# Artifact name
|
||||
name: SlimeVR-GUI-Windows
|
||||
# A file, directory or wildcard pattern that describes what to upload
|
||||
path: target/release/slimevr.exe
|
||||
|
||||
- if: matrix.os == 'ubuntu-20.04'
|
||||
name: Upload a Build Artifact (Linux)
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
# Artifact name
|
||||
name: SlimeVR-GUI-Linux
|
||||
# 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@v3
|
||||
with:
|
||||
# Artifact name
|
||||
name: SlimeVR-GUI-macOS
|
||||
# A file, directory or wildcard pattern that describes what to upload
|
||||
path: target/release/slimevr
|
||||
@@ -1,340 +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 && cd gui && pnpm run lint
|
||||
|
||||
java-checks:
|
||||
name: Java Checks
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
java-version: '17'
|
||||
distribution: 'adopt'
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@v6
|
||||
- name: Java 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 17
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
java-version: '17'
|
||||
distribution: 'adopt'
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@v6
|
||||
- name: Build ShadowJar
|
||||
run: ./gradlew :server:desktop:shadowJar --build-cache
|
||||
- name: Test with Gradle
|
||||
run: ./gradlew :server:desktop:test
|
||||
- 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 }}
|
||||
run: pnpm i && cd gui && pnpm run build
|
||||
- name: Tar GUI Dist
|
||||
run: tar -czf slimevr-gui-dist.tar.gz -C gui/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/out && tar -xzf slimevr-gui-dist.tar.gz -C gui/out
|
||||
- name: Run Electron Builder
|
||||
shell: bash
|
||||
env:
|
||||
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
|
||||
run: |
|
||||
mkdir -p gui/dist/artifacts/linux/ \
|
||||
gui/dist/artifacts/win \
|
||||
gui/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
|
||||
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/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 17
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
java-version: '17'
|
||||
distribution: 'adopt'
|
||||
- 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/out && tar -xzf slimevr-gui-dist.tar.gz -C gui/out
|
||||
- name: Build APK
|
||||
run: ./gradlew :server:android:build --build-cache
|
||||
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: Test with Gradle
|
||||
run: ./gradlew test
|
||||
- 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:
|
||||
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
|
||||
@@ -1,34 +0,0 @@
|
||||
# This workflow will build the update manifest for the updater and update a GitHub release
|
||||
|
||||
name: Generate update manifest
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
release:
|
||||
types: [released]
|
||||
|
||||
jobs:
|
||||
generate-manifest:
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
steps:
|
||||
- uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: '22.x'
|
||||
|
||||
- name: Generate update-manifest.json
|
||||
run: |
|
||||
npx @slimevr/update-manifest-generator@latest
|
||||
|
||||
- uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: "update-manifest.json"
|
||||
path: ./update-manifest.json
|
||||
|
||||
- name: Upload update-manifest.json to release
|
||||
uses: softprops/action-gh-release@v3
|
||||
with:
|
||||
tag_name: ${{ secrets.UPDATE_MANIFEST_RELEASE_TAG }}
|
||||
files: ./update-manifest.json
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -0,0 +1,291 @@
|
||||
# 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@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Get tags
|
||||
run: git fetch --tags origin --recurse-submodules=no
|
||||
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: "17"
|
||||
distribution: "adopt"
|
||||
|
||||
- name: Setup Gradle
|
||||
uses: gradle/gradle-build-action@v2
|
||||
|
||||
- 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@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Get tags
|
||||
run: git fetch --tags origin --recurse-submodules=no
|
||||
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: "17"
|
||||
distribution: "adopt"
|
||||
|
||||
- name: Setup Gradle
|
||||
uses: gradle/gradle-build-action@v2
|
||||
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew shadowJar
|
||||
|
||||
- name: Upload the Server JAR as a Build Artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
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/*
|
||||
|
||||
- name: Upload to draft release
|
||||
uses: softprops/action-gh-release@v1
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
draft: true
|
||||
generate_release_notes: true
|
||||
files: |
|
||||
server/desktop/build/libs/*
|
||||
|
||||
|
||||
bundle-linux:
|
||||
runs-on: ubuntu-20.04
|
||||
needs: [build, test]
|
||||
if: contains(fromJSON('["workflow_dispatch", "create"]'), github.event_name)
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: "SlimeVR-Server"
|
||||
path: server/desktop/build/libs/
|
||||
|
||||
- name: Set up Linux dependencies
|
||||
uses: awalsh128/cache-apt-pkgs-action@latest
|
||||
with:
|
||||
packages: libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf libfuse2
|
||||
# Increment to invalidate the cache
|
||||
version: 1.0
|
||||
# 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: Cache cargo dependencies
|
||||
uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
shared-key: "ubuntu-20.04"
|
||||
|
||||
- name: Use Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version-file: '.node-version'
|
||||
cache: 'npm'
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
npm ci
|
||||
npm run tauri build
|
||||
|
||||
- uses: actions/[email protected]
|
||||
with:
|
||||
name: SlimeVR-GUI-Deb
|
||||
path: target/release/bundle/deb/slimevr*.deb
|
||||
|
||||
- name: Install appimage-builder
|
||||
run: |
|
||||
wget "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage"
|
||||
chmod a+x appimagetool-x86_64.AppImage
|
||||
sudo mv appimagetool-x86_64.AppImage /usr/local/bin/appimagetool
|
||||
|
||||
- name: Modify and Build AppImage
|
||||
run: |
|
||||
cd target/release/bundle/appimage
|
||||
chmod a+x slimevr*.AppImage
|
||||
./slimevr*.AppImage --appimage-extract
|
||||
cp $( git rev-parse --show-toplevel )/server/desktop/build/libs/slimevr.jar squashfs-root/slimevr.jar
|
||||
chmod 644 squashfs-root/slimevr.jar
|
||||
appimagetool squashfs-root slimevr*.AppImage
|
||||
|
||||
- uses: actions/[email protected]
|
||||
with:
|
||||
name: SlimeVR-GUI-AppImage
|
||||
path: target/release/bundle/appimage/slimevr*.AppImage
|
||||
|
||||
- name: Prepare for release
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
run: |
|
||||
cp target/release/bundle/appimage/slimevr*.AppImage ./SlimeVR-amd64.appimage
|
||||
cp target/release/bundle/deb/slimevr*.deb ./SlimeVR-amd64.deb
|
||||
|
||||
- name: Upload to draft release
|
||||
uses: softprops/action-gh-release@v1
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
draft: true
|
||||
generate_release_notes: true
|
||||
files: |
|
||||
./SlimeVR-amd64.appimage
|
||||
./SlimeVR-amd64.deb
|
||||
|
||||
|
||||
bundle-mac:
|
||||
runs-on: macos-latest
|
||||
needs: [build, test]
|
||||
if: contains(fromJSON('["workflow_dispatch", "create"]'), github.event_name)
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: "SlimeVR-Server"
|
||||
path: server/desktop/build/libs/
|
||||
|
||||
- name: Cache cargo dependencies
|
||||
uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
shared-key: "macos-latest"
|
||||
|
||||
- name: Use Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version-file: '.node-version'
|
||||
cache: 'npm'
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
npm ci
|
||||
npm run tauri build -- "--target universal-apple-darwin"
|
||||
|
||||
- name: Modify Application
|
||||
run: |
|
||||
cd target/release/bundle/macos/slimevr.app/Contents/MacOS
|
||||
cp $( git rev-parse --show-toplevel )/server/desktop/build/libs/slimevr.jar ./
|
||||
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/[email protected]
|
||||
with:
|
||||
name: SlimeVR-GUI-MacApp
|
||||
path: target/release/bundle/macos/slimevr*.app
|
||||
|
||||
- uses: actions/[email protected]
|
||||
with:
|
||||
name: SlimeVR-GUI-MacDmg
|
||||
path: target/release/bundle/dmg/slimevr.dmg
|
||||
|
||||
- name: Prepare for release
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
run: |
|
||||
cp target/release/bundle/dmg/slimevr.dmg ./SlimeVR-mac.dmg
|
||||
|
||||
- name: Upload to draft release
|
||||
uses: softprops/action-gh-release@v1
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
draft: true
|
||||
generate_release_notes: true
|
||||
files: |
|
||||
./SlimeVR-mac.dmg
|
||||
|
||||
|
||||
bundle-windows:
|
||||
runs-on: windows-latest
|
||||
needs: [build, test]
|
||||
if: contains(fromJSON('["workflow_dispatch", "create"]'), github.event_name)
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: "SlimeVR-Server"
|
||||
path: server/desktop/build/libs/
|
||||
|
||||
- name: Cache cargo dependencies
|
||||
uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
shared-key: "windows-latest"
|
||||
|
||||
- name: Use Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version-file: '.node-version'
|
||||
cache: 'npm'
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
npm ci
|
||||
npm run skipbundler
|
||||
|
||||
- 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-win64.zip ./SlimeVR/
|
||||
|
||||
mv ./SlimeVR/slimevr.exe ./SlimeVR/slimevr-ui.exe
|
||||
7z a -tzip SlimeVR.zip ./SlimeVR/
|
||||
|
||||
- uses: actions/[email protected]
|
||||
with:
|
||||
name: SlimeVR-GUI-Windows
|
||||
path: ./SlimeVR*.zip
|
||||
|
||||
- name: Upload to draft release
|
||||
uses: softprops/action-gh-release@v1
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
draft: true
|
||||
generate_release_notes: true
|
||||
files: |
|
||||
./SlimeVR-win64.zip
|
||||
./SlimeVR.zip
|
||||
@@ -3,19 +3,22 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- pontoon
|
||||
|
||||
jobs:
|
||||
pull_request:
|
||||
if: ${{ github.repository == 'SlimeVR/SlimeVR-Server' }}
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
pull-requests: write
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: pull-request
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.PONTOON_BOT_KEY }}
|
||||
run: |
|
||||
gh_pr_up() { gh pr create "$@" --label "Area: Translation" --base main || gh pr edit "$@"; }
|
||||
gh_pr_up --title "New Pontoon translations" --body "Please don't squash me 🥺"
|
||||
- uses: repo-sync/pull-request@v2
|
||||
with:
|
||||
destination_branch: "main"
|
||||
pr_title: "New Pontoon translations"
|
||||
pr_body: "Please don't squash me 🥺"
|
||||
pr_label: "Area: Translation"
|
||||
github_token: ${{ secrets.PONTOON_BOT_KEY }}
|
||||
@@ -15,7 +15,7 @@ jobs:
|
||||
contents: write
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
ref: pontoon
|
||||
submodules: recursive
|
||||
@@ -24,7 +24,7 @@ jobs:
|
||||
- name: Rebase
|
||||
run: |
|
||||
git config --local user.name "slimevr-bot"
|
||||
git config --local user.email '[email protected]'
|
||||
git config --local user.email [email protected]
|
||||
git fetch origin main
|
||||
git rebase origin/main
|
||||
git submodule update
|
||||
@@ -36,4 +36,3 @@ jobs:
|
||||
commit-message: "update"
|
||||
force-push: "true"
|
||||
name: "slimevr-bot"
|
||||
email: "[email protected]"
|
||||
@@ -17,7 +17,6 @@
|
||||
|
||||
# VSCode stuff
|
||||
/.vscode/settings.json
|
||||
/.vscode/launch.json
|
||||
|
||||
# Ignore eclipse stuff
|
||||
.project
|
||||
@@ -28,22 +27,15 @@
|
||||
/node_modules
|
||||
.husky
|
||||
|
||||
# kotlin stuff
|
||||
/.kotlin
|
||||
|
||||
# ignore gradle build folder
|
||||
build/
|
||||
|
||||
# Rust build artifacts
|
||||
/target
|
||||
|
||||
# direnv has been claimed for Nix usage
|
||||
.direnv/
|
||||
.devenv
|
||||
|
||||
# Ignore Android local properties
|
||||
local.properties
|
||||
|
||||
# Ignore temporary config
|
||||
vrconfig.yml.tmp
|
||||
|
||||
|
||||
# Nixos
|
||||
.bin/
|
||||
@@ -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,33 +0,0 @@
|
||||
YELLOW="\033[1;33m"
|
||||
GREEN="\033[1;32m"
|
||||
RESET="\033[0m"
|
||||
|
||||
if git rev-parse -q --verify MERGE_HEAD; then
|
||||
echo -e "${YELLOW}Skipping precommit hook because of merge${RESET}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
APP_PRE_COMMIT_OPTIONS="$(dirname "$0")/_/pre-commit.options"
|
||||
|
||||
if ! [ -f "$APP_PRE_COMMIT_OPTIONS" ]; then
|
||||
echo -e "${YELLOW}\nSkipping pre-commit hook."
|
||||
echo -e "If you want to use pre-commit for lint-staged, run:\n"
|
||||
echo -e " ${GREEN}echo -e 'APP_LINT=true;' > ${APP_PRE_COMMIT_OPTIONS}${RESET}"
|
||||
echo -e "${YELLOW}\nIt will add some delay before committing!\n${RESET}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
source $APP_PRE_COMMIT_OPTIONS
|
||||
|
||||
if [ -n "${APP_LINT}" ] && [ "${APP_LINT}" == "true" ]; then
|
||||
echo -e "${GREEN}[husky] [pre-commit] [lint-staged]${RESET}"
|
||||
case "$(uname -sr)" in
|
||||
CYGWIN*|MINGW*|MINGW32*|MSYS*)
|
||||
npx.cmd lint-staged
|
||||
;;
|
||||
|
||||
*)
|
||||
npx lint-staged
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
@@ -1,9 +0,0 @@
|
||||
export default {
|
||||
'server/**/*.{java,kt,kts}': (filenames) =>
|
||||
filenames.map(
|
||||
(filename) =>
|
||||
`./gradlew${
|
||||
process.platform === 'win32' ? '.bat' : ''
|
||||
} spotlessApply "-PspotlessIdeHook=${filename}"`
|
||||
),
|
||||
};
|
||||
@@ -1 +1 @@
|
||||
22.17.0
|
||||
18.12.1
|
||||
@@ -7,10 +7,10 @@
|
||||
"gaborv.flatbuffers",
|
||||
"dbaeumer.vscode-eslint",
|
||||
"esbenp.prettier-vscode",
|
||||
"rust-lang.rust-analyzer",
|
||||
"bradlc.vscode-tailwindcss",
|
||||
"EditorConfig.EditorConfig",
|
||||
"macabeus.vscode-fluent",
|
||||
"redhat.vscode-yaml"
|
||||
],
|
||||
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
|
||||
"unwantedRecommendations": []
|
||||
|
||||
@@ -6,7 +6,9 @@ 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)
|
||||
- [Node.js v16+](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.
|
||||
@@ -30,13 +32,12 @@ 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 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`.
|
||||
- Finally, to compile for production, run `pnpm package:build`. The result
|
||||
will be at `dist/artifacts/` content will change depending of the platform.
|
||||
- Run `npm install` in your IDE's terminal to download and install dependencies.
|
||||
- To launch the GUI in dev mode, run `npm run gui`.
|
||||
- Finally, to compile for production, run `npm run tauri build`. The result
|
||||
will be at `target/release/slimevr.exe`.
|
||||
|
||||
## Code style
|
||||
|
||||
@@ -82,12 +83,12 @@ 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.
|
||||
- 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`
|
||||
- To check code formatting, run `npm run lint`.
|
||||
- To fix code formatting, run `npm run lint:fix` and `npm run format`
|
||||
|
||||
Don't forget to run `cd ..` to return to the root directory.
|
||||
|
||||
@@ -103,7 +104,6 @@ When touching SolarXR:
|
||||
- After editing files, you should run `cd solarxr-protocol`, then either run
|
||||
`./generate-flatbuffer.ps1` (Windows) or `./generate-flatbuffer.sh` (Linux/OSX)
|
||||
- Make sure to commit your changes inside the submodule.
|
||||
- To make sure the gui use the latest generated code, run `pnpm i`.
|
||||
|
||||
## Code Licensing
|
||||
SlimeVR uses dual MIT and Apache-2.0 license. Be sure that any code that you reference,
|
||||
@@ -114,9 +114,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,17 @@
|
||||
[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.65" # This version stabilized GATs and let-else
|
||||
repository = "https://github.com/SlimeVR/SlimeVR-Server"
|
||||
|
||||
[profile.release]
|
||||
lto = "thin"
|
||||
strip = "debuginfo" # Only affects Unix binaries with DWARF
|
||||
@@ -47,11 +47,6 @@ on SlimeVR, you need to be aware of them:**
|
||||
Please refer to the [LICENSE-MIT] and [LICENSE-APACHE] files if you are at any point
|
||||
uncertain what the exact requirements are.
|
||||
|
||||
## Trademark and Logo use
|
||||
**SlimeVR is a trademark or a registered trademark of SlimeVR B.V. Usage of SlimeVR software, hardware, or other intellectual property in this or other repositories does not grant you the right to use SlimeVR trademark as your own.**
|
||||
|
||||
For more information, please refer to the [TRADEMARK].
|
||||
|
||||
## Contributions
|
||||
Any contributions submitted for inclusion in this repository will be dual-licensed under
|
||||
either:
|
||||
@@ -69,7 +64,3 @@ okay with this and that you are authorized to provide the above licenses.
|
||||
|
||||
[LICENSE-MIT]: LICENSE-MIT
|
||||
[LICENSE-APACHE]: LICENSE-APACHE
|
||||
[TRADEMARK]: TRADEMARK.md
|
||||
|
||||
|
||||
*if you read this, u cute*
|
||||
@@ -1,33 +0,0 @@
|
||||
## SlimeVR is a trademark or a registered trademark of SlimeVR B.V.
|
||||
|
||||
**Usage of SlimeVR software, hardware, or other intellectual property in this or other repositories does not grant you the right to use SlimeVR trademark as your own.**
|
||||
|
||||
The purpose of a trademark is to remove uncertainty for users and customers regarding the product's manufacturer or endorsement. You're not allowed to market your product using SlimeVR name, and your usage of the name should be only factual and descriptive. For example, calling original SlimeVR products SlimeVR or describing compatibility of other products or derivatives. This applies to all products, including software, and hardware including non-official Full-Body Trackers.
|
||||
|
||||
**Here are a few _acceptable_ uses of SlimeVR name when selling unofficial Slime trackers:**
|
||||
* SlimeVR-compatible trackers
|
||||
* Unofficial SlimeVR trackers / Non-official SlimeVR trackers
|
||||
* DIY SlimeVR trackers
|
||||
* Third-party SlimeVR Trackers
|
||||
* Custom SlimeVR-compatible trackers
|
||||
* < Your Brand > Slime Trackers
|
||||
* Using "SlimeVR" as a search tag
|
||||
|
||||
**_Unacceptable_ uses include, but are not limited to:**
|
||||
* SlimeVR store
|
||||
* Buy SlimeVR
|
||||
* SlimeVR Trackers
|
||||
* Original SlimeVR
|
||||
* Official SlimeVR
|
||||
* SlimeVR BMI270 (or any other IMU model along with SlimeVR name)
|
||||
* < Your brand > SlimeVR / < your brand > SlimeVR Trackers
|
||||
|
||||
Use of the SlimeVR name that can cause confusion is not allowed in any part of the listing, including, but not limited to: product title, product description, product metadata, site title, site name, site metadata, site texts, social media posts, or other advertisement.
|
||||
|
||||
Also, please ensure you use the correct spelling and capitalization: only **"SlimeVR" is acceptable**. Not "Slimevr", "slimevr", or "Slime VR". You're allowed to use the word "slime" as you wish, it's not a trademark.
|
||||
|
||||
Please understand that we have an obligation to reduce confusion for the customers, and we believe that our usage terms are generous compared to many other companies and products. This applies to all sellers or derivative products, we do not make exceptions.
|
||||
|
||||
---
|
||||
|
||||
If you have any questions about SlimeVR trademark or copyrighted materials, you can reach out to us at *tm[at]slimevr.dev*.
|
||||
@@ -1,297 +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: Never
|
||||
OverEmptyLines: 0
|
||||
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: false
|
||||
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: Right
|
||||
PPIndentWidth: -1
|
||||
QualifierAlignment: Leave
|
||||
ReferenceAlignment: Pointer
|
||||
ReflowComments: Always
|
||||
RemoveBracesLLVM: false
|
||||
RemoveEmptyLinesInUnwrappedLines: false
|
||||
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
|
||||
...
|
||||
|
||||
@@ -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,78 +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/solarxr.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(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,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,288 +0,0 @@
|
||||
#include <cassert>
|
||||
#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 "logger.hpp"
|
||||
#include "solarxr.hpp"
|
||||
#include "vr_utils.hpp"
|
||||
|
||||
#include "openvr.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
using namespace solarxr_protocol;
|
||||
|
||||
static void shutdown_vr(vr::IVRSystem *_sys) { vr::VR_Shutdown(); }
|
||||
|
||||
static void onYawReset(SolarXRConnection &conn) {
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
|
||||
auto resetReq = rpc::CreateResetRequest(fbb, rpc::ResetType::Yaw, 0, 0.f);
|
||||
auto msgHeader = rpc::CreateRpcMessageHeader(
|
||||
fbb, nullptr, rpc::RpcMessage::ResetRequest, resetReq.Union());
|
||||
|
||||
auto rpcMsgs = fbb.CreateVector({ msgHeader });
|
||||
auto bundle = CreateMessageBundle(fbb, 0, rpcMsgs, 0);
|
||||
fbb.Finish(bundle);
|
||||
conn.sendMsg(fbb);
|
||||
}
|
||||
static void onFullReset(SolarXRConnection &conn) {
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
|
||||
auto resetReq = rpc::CreateResetRequest(fbb, rpc::ResetType::Full, 0, 0.f);
|
||||
auto msgHeader = rpc::CreateRpcMessageHeader(
|
||||
fbb, nullptr, rpc::RpcMessage::ResetRequest, resetReq.Union());
|
||||
|
||||
auto rpcMsgs = fbb.CreateVector({ msgHeader });
|
||||
auto bundle = CreateMessageBundle(fbb, 0, rpcMsgs, 0);
|
||||
fbb.Finish(bundle);
|
||||
conn.sendMsg(fbb);
|
||||
}
|
||||
static void onMountingCalibration(SolarXRConnection &conn) {
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
|
||||
auto resetReq = rpc::CreateResetRequest(fbb, rpc::ResetType::Mounting, 0, 0.f);
|
||||
auto msgHeader = rpc::CreateRpcMessageHeader(
|
||||
fbb, nullptr, rpc::RpcMessage::ResetRequest, resetReq.Union());
|
||||
|
||||
auto rpcMsgs = fbb.CreateVector({ msgHeader });
|
||||
auto bundle = CreateMessageBundle(fbb, 0, rpcMsgs, 0);
|
||||
fbb.Finish(bundle);
|
||||
conn.sendMsg(fbb);
|
||||
}
|
||||
static void onFeetMountingCalibration(SolarXRConnection &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, nullptr, rpc::RpcMessage::ResetRequest, resetReq.Union());
|
||||
|
||||
auto rpcMsgs = fbb.CreateVector({ msgHeader });
|
||||
auto bundle = CreateMessageBundle(fbb, 0, rpcMsgs, 0);
|
||||
fbb.Finish(bundle);
|
||||
conn.sendMsg(fbb);
|
||||
}
|
||||
static void onToggleTracking(SolarXRConnection &conn) {
|
||||
static bool shouldPause = false;
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
|
||||
shouldPause = !shouldPause;
|
||||
auto toggleReq = rpc::CreateSetPauseTrackingRequest(fbb, shouldPause);
|
||||
auto msgHeader = rpc::CreateRpcMessageHeader(
|
||||
fbb, nullptr, rpc::RpcMessage::SetPauseTrackingRequest,
|
||||
toggleReq.Union());
|
||||
|
||||
auto rpcMsgs = fbb.CreateVector({ msgHeader });
|
||||
auto bundle = CreateMessageBundle(fbb, 0, rpcMsgs, 0);
|
||||
fbb.Finish(bundle);
|
||||
conn.sendMsg(fbb);
|
||||
}
|
||||
|
||||
sig_atomic_t should_exit = 0;
|
||||
|
||||
static void signal_handler(int signal) {
|
||||
Logger::get().info("Received signal {}", signal);
|
||||
should_exit = 1;
|
||||
}
|
||||
|
||||
int main() {
|
||||
auto &logger = Logger::get();
|
||||
|
||||
try {
|
||||
SolarXRConnection conn;
|
||||
std::unique_ptr<vr::IVRSystem, decltype(&shutdown_vr)> sys{ nullptr,
|
||||
shutdown_vr };
|
||||
|
||||
// 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();
|
||||
|
||||
auto [appManifestPath, actionManifestPath] = VRUtils::initialiseManifest();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// 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(SolarXRConnection &)>>>
|
||||
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, signal_handler);
|
||||
signal(SIGTERM, signal_handler);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
if (!conn.connected()) {
|
||||
logger.warning("Connection to SlimeVR lost, exiting");
|
||||
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,33 +0,0 @@
|
||||
#include "paths.hpp"
|
||||
|
||||
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"; }
|
||||
@@ -1,11 +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);
|
||||
} // 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,163 +0,0 @@
|
||||
#include "solarxr.hpp"
|
||||
#include "logger.hpp"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#elif defined(_WIN32)
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#error "Unsupported platform"
|
||||
#endif
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
fs::path SolarXRConnection::getSocketPath() {
|
||||
using namespace std::string_view_literals;
|
||||
#if defined(__linux__)
|
||||
#define MAKE_SOCKET_PATH(PATH) \
|
||||
std::make_pair(PATH##sv, static_cast<const char *>(getenv(PATH)))
|
||||
|
||||
constexpr std::string_view socketName = "SlimeVRRpc";
|
||||
std::array<std::pair<std::string_view, const char *>, 4> socketPaths{
|
||||
MAKE_SOCKET_PATH("SLIMEVR_SOCKET_DIR"),
|
||||
MAKE_SOCKET_PATH("XDG_RUNTIME_DIR"),
|
||||
MAKE_SOCKET_PATH("TMPDIR"),
|
||||
{ "/tmp", "/tmp" }
|
||||
};
|
||||
|
||||
#undef MAKE_SOCKET_PATH
|
||||
|
||||
for (auto [name, path] : socketPaths) {
|
||||
if (path == nullptr) {
|
||||
Logger::get().info(
|
||||
"Skipping socket directory {} because it doesn't exist", name);
|
||||
continue;
|
||||
}
|
||||
fs::path socketPath = fs::path(path) / socketName;
|
||||
if (fs::exists(socketPath))
|
||||
return socketPath;
|
||||
|
||||
Logger::get().info(
|
||||
"Skipping socket directory {} because socket does not exist", name);
|
||||
}
|
||||
#elif defined(_WIN32)
|
||||
throw std::logic_error(
|
||||
"SolarXRConnection::getSocketPath should not be called on Windows");
|
||||
#else
|
||||
#error "Unsupported platform"
|
||||
#endif
|
||||
|
||||
throw std::runtime_error("Failed to find socket directory");
|
||||
}
|
||||
|
||||
SolarXRConnection::SolarXRConnection() {
|
||||
#if defined(__linux__)
|
||||
sockaddr_un addr{};
|
||||
addr.sun_family = AF_UNIX;
|
||||
strcpy(addr.sun_path, getSocketPath().string().data());
|
||||
|
||||
fd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (fd == -1) {
|
||||
throw std::runtime_error(
|
||||
std::format("Failed to create listen socket: {}", strerror(errno)));
|
||||
}
|
||||
|
||||
if (connect(fd, reinterpret_cast<sockaddr *>(&addr), sizeof(addr)) == -1) {
|
||||
int e = errno;
|
||||
close(fd);
|
||||
throw std::runtime_error(std::format("Failed to connect to socket {}: {}",
|
||||
addr.sun_path, strerror(e)));
|
||||
}
|
||||
|
||||
#elif defined(_WIN32)
|
||||
const char *pipeName = R"(\\.\pipe\SlimeVRRpc)";
|
||||
if (!WaitNamedPipe(pipeName, 5000)) {
|
||||
throw std::runtime_error("Timed out waiting for pipe");
|
||||
}
|
||||
|
||||
pipe = CreateFile(pipeName, GENERIC_READ | GENERIC_WRITE, 0, nullptr,
|
||||
OPEN_EXISTING, 0, nullptr);
|
||||
if (pipe == INVALID_HANDLE_VALUE) {
|
||||
throw std::runtime_error(
|
||||
std::format("Unable to open pipe (error={})", GetLastError()));
|
||||
}
|
||||
#else
|
||||
#error "Unsupported platform"
|
||||
#endif
|
||||
}
|
||||
|
||||
SolarXRConnection::~SolarXRConnection() {
|
||||
#if defined(__linux__)
|
||||
if (fd != -1)
|
||||
close(fd);
|
||||
#elif defined(_WIN32)
|
||||
if (pipe != INVALID_HANDLE_VALUE)
|
||||
CloseHandle(pipe);
|
||||
#else
|
||||
#error "Unsupported platform"
|
||||
#endif
|
||||
}
|
||||
|
||||
bool SolarXRConnection::connected() {
|
||||
#if defined(__linux__)
|
||||
if (read(fd, nullptr, 0) == -1) {
|
||||
return !(errno == EBADF || errno == EINVAL);
|
||||
}
|
||||
|
||||
return true;
|
||||
#elif defined(_WIN32)
|
||||
if (!WriteFile(pipe, nullptr, 0, nullptr, nullptr)) {
|
||||
int err = GetLastError();
|
||||
// The documentation says it should return ERROR_BROKEN_PIPE
|
||||
// when the write-end has been closed, but it seems to actually
|
||||
// return ERROR_NO_DATA...
|
||||
return !(err == ERROR_NO_DATA || err == ERROR_BROKEN_PIPE);
|
||||
}
|
||||
|
||||
return true;
|
||||
#else
|
||||
#error "Unsupported platform"
|
||||
#endif
|
||||
}
|
||||
|
||||
void SolarXRConnection::sendMsg(flatbuffers::FlatBufferBuilder &fbb) {
|
||||
// The server expects the total size of the buffer to be written at the
|
||||
// start of the packet, including the first 4 bytes for the size
|
||||
int size = fbb.GetSize() + 4;
|
||||
// This may be wrong on mixed-endianness, but oh well...
|
||||
if constexpr (std::endian::native != std::endian::little)
|
||||
size = std::byteswap(size);
|
||||
|
||||
#if defined(__linux__)
|
||||
if (write(fd, &size, sizeof(size)) == -1) {
|
||||
Logger::get().warning("Failed to write message size to socket: {}",
|
||||
strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
if (write(fd, fbb.GetBufferPointer(), fbb.GetSize()) == -1) {
|
||||
Logger::get().warning("Failed to write message to socket: {}",
|
||||
strerror(errno));
|
||||
return;
|
||||
}
|
||||
#elif defined(_WIN32)
|
||||
uint8_t tempBuf[2048];
|
||||
if (fbb.GetSize() > 2048 - 4) {
|
||||
Logger::get().warning("Message is too big for temporary buffer");
|
||||
return;
|
||||
}
|
||||
|
||||
*reinterpret_cast<int *>(&tempBuf[0]) = size;
|
||||
memcpy(&tempBuf[4], fbb.GetBufferPointer(), fbb.GetSize());
|
||||
if (!WriteFile(pipe, tempBuf, fbb.GetSize() + 4, nullptr, nullptr)) {
|
||||
Logger::get().warning("Failed to write message to pipe (error={})",
|
||||
GetLastError());
|
||||
return;
|
||||
}
|
||||
#else
|
||||
#error "Unsupported platform"
|
||||
#endif
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define WIN32_MEAN_AND_LEAN
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
#include "flatbuffers/flatbuffer_builder.h"
|
||||
|
||||
class SolarXRConnection {
|
||||
private:
|
||||
#if defined(__linux__)
|
||||
int fd{ -1 };
|
||||
#elif defined(_WIN32)
|
||||
HANDLE pipe{ INVALID_HANDLE_VALUE };
|
||||
#else
|
||||
#error "Unsupported platform"
|
||||
#endif
|
||||
|
||||
static std::filesystem::path getSocketPath();
|
||||
|
||||
public:
|
||||
SolarXRConnection() noexcept(false);
|
||||
|
||||
~SolarXRConnection();
|
||||
|
||||
bool connected();
|
||||
void sendMsg(flatbuffers::FlatBufferBuilder &fbb);
|
||||
};
|
||||
@@ -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::initialiseManifest() {
|
||||
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> initialiseManifest();
|
||||
} // namespace VRUtils
|
||||
@@ -1,3 +1,3 @@
|
||||
plugins {
|
||||
id("org.ajoberstar.grgit")
|
||||
id("org.ajoberstar.grgit") version "5.2.0"
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
dev.slimevr.SlimeVR.metainfo.xml by SlimeVR contributors
|
||||
|
||||
To the extent possible under law, the person who associated CC0 with
|
||||
dev.slimevr.SlimeVR.metainfo.xml has waived all copyright and related or neighboring rights
|
||||
to dev.slimevr.SlimeVR.metainfo.xml.
|
||||
|
||||
You should have received a copy of the CC0 legalcode along with this
|
||||
work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
-->
|
||||
<component type="desktop-application">
|
||||
<id>dev.slimevr.SlimeVR</id>
|
||||
|
||||
<name>SlimeVR</name>
|
||||
<summary>An app for facilitating full-body tracking in virtual reality</summary>
|
||||
<developer_name>SlimeVR Team</developer_name>
|
||||
|
||||
<!-- CC0 so attribution is not required -->
|
||||
<metadata_license>CC0-1.0</metadata_license>
|
||||
<project_license>MIT OR Apache-2.0</project_license>
|
||||
|
||||
<content_rating type="oars-1.1" />
|
||||
<url type="homepage">https://slimevr.dev/</url>
|
||||
<url type="bugtracker">https://github.com/SlimeVR/SlimeVR-Server/issues</url>
|
||||
<url type="faq">https://docs.slimevr.dev/slimevr101.html</url>
|
||||
<url type="vcs-browser">https://github.com/SlimeVR/SlimeVR-Server</url>
|
||||
<url type="translate">https://i18n.slimevr.dev</url>
|
||||
<url type="help">https://docs.slimevr.dev/server-setup/slimevr-setup.html</url>
|
||||
<url type="contribute">https://github.com/SlimeVR/SlimeVR-Server/blob/main/CONTRIBUTING.md</url>
|
||||
<url type="contact">https://discord.gg/SlimeVR</url>
|
||||
<recommends>
|
||||
<display_length compare="ge">300</display_length>
|
||||
</recommends>
|
||||
<supports>
|
||||
<control>pointing</control>
|
||||
<control>keyboard</control>
|
||||
<control>touch</control>
|
||||
</supports>
|
||||
|
||||
<branding>
|
||||
<color type="primary">#663499</color>
|
||||
</branding>
|
||||
|
||||
<description>
|
||||
<p>
|
||||
SlimeVR is a set of open hardware sensors and open source software that facilitates full-body
|
||||
tracking (FBT) in virtual reality. With no base station required, SlimeVR makes wireless
|
||||
VR FBT affordable and comfortable.
|
||||
</p>
|
||||
|
||||
</description>
|
||||
|
||||
<launchable type="desktop-id">dev.slimevr.SlimeVR.desktop</launchable>
|
||||
<screenshots>
|
||||
<screenshot type="default">
|
||||
<caption>The onboarding for the GUI</caption>
|
||||
<image>https://raw.githubusercontent.com/SlimeVR/SlimeVR-Server/main/assets/img/onboarding.png</image>
|
||||
</screenshot>
|
||||
</screenshots>
|
||||
<releases>
|
||||
<release version="0.8.3" date="2023-07-09"><url>https://github.com/SlimeVR/SlimeVR-Server/releases/tag/v0.8.3</url></release>
|
||||
<release version="0.8.2" date="2023-07-09"><url>https://github.com/SlimeVR/SlimeVR-Server/releases/tag/v0.8.2</url></release>
|
||||
<release version="0.8.2-rc.1" type="development" date="2023-07-07"><url>https://github.com/SlimeVR/SlimeVR-Server/releases/tag/v0.8.2-rc.1</url></release>
|
||||
<release version="0.8.1" date="2023-07-04"><url>https://github.com/SlimeVR/SlimeVR-Server/releases/tag/v0.8.1</url></release>
|
||||
<release version="0.8.0" date="2023-06-22"><url>https://github.com/SlimeVR/SlimeVR-Server/releases/tag/v0.8.0</url></release>
|
||||
<release version="0.8.0-rc.3" type="development" date="2023-06-20"><url>https://github.com/SlimeVR/SlimeVR-Server/releases/tag/v0.8.0-rc.3</url></release>
|
||||
<release version="0.8.0-rc.2" type="development" date="2023-06-15"><url>https://github.com/SlimeVR/SlimeVR-Server/releases/tag/v0.8.0-rc.2</url></release>
|
||||
<release version="0.8.0-rc.1" type="development" date="2023-06-01"><url>https://github.com/SlimeVR/SlimeVR-Server/releases/tag/v0.8.0-rc.1</url></release>
|
||||
<release version="0.7.1" date="2023-04-14"><url>https://github.com/SlimeVR/SlimeVR-Server/releases/tag/v0.7.1</url></release>
|
||||
<release version="0.7.0" date="2023-04-11"><url>https://github.com/SlimeVR/SlimeVR-Server/releases/tag/v0.7.0</url></release>
|
||||
<release version="0.6.3" date="2023-02-22"><url>https://github.com/SlimeVR/SlimeVR-Server/releases/tag/v0.6.3</url></release>
|
||||
<release version="0.6.2" date="2023-02-17"><url>https://github.com/SlimeVR/SlimeVR-Server/releases/tag/v0.6.2</url></release>
|
||||
<release version="0.6.1" date="2023-02-12"><url>https://github.com/SlimeVR/SlimeVR-Server/releases/tag/v0.6.1</url></release>
|
||||
<release version="0.6.0" date="2023-01-05"><url>https://github.com/SlimeVR/SlimeVR-Server/releases/tag/v0.6.0</url></release>
|
||||
<release version="0.5.1" date="2022-12-12"><url>https://github.com/SlimeVR/SlimeVR-Server/releases/tag/v0.5.1</url></release>
|
||||
<release version="0.5.0" date="2022-12-07"><url>https://github.com/SlimeVR/SlimeVR-Server/releases/tag/v0.5.0</url></release>
|
||||
<release version="0.4.0" date="2022-11-24"><url>https://github.com/SlimeVR/SlimeVR-Server/releases/tag/v0.4.0</url></release>
|
||||
<release version="0.3.1" date="2022-11-22"><url>https://github.com/SlimeVR/SlimeVR-Server/releases/tag/v0.3.1</url></release>
|
||||
<release version="0.3.0" date="2022-11-16"><url>https://github.com/SlimeVR/SlimeVR-Server/releases/tag/v0.3.0</url></release>
|
||||
<release version="0.2.1" date="2022-08-24"><url>https://github.com/SlimeVR/SlimeVR-Server/releases/tag/v0.2.1</url></release>
|
||||
<release version="0.2.0" date="2022-06-28"><url>https://github.com/SlimeVR/SlimeVR-Server/releases/tag/v0.2.0</url></release>
|
||||
</releases>
|
||||
</component>
|
||||
@@ -1,58 +1,126 @@
|
||||
{
|
||||
"nodes": {
|
||||
"flake-parts": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"nixpkgs-lib": "nixpkgs-lib"
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1777988971,
|
||||
"narHash": "sha256-qIoWPDs+0/8JecyYgE3gpKQxW/4bLW/gp45vow9ioCQ=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "0678d8986be1661af6bb555f3489f2fdfc31f6ff",
|
||||
"lastModified": 1685518550,
|
||||
"narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_2": {
|
||||
"inputs": {
|
||||
"systems": "systems_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1681202837,
|
||||
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "cfacdce06f30d2b68473a46042957675eebb3401",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1777954456,
|
||||
"narHash": "sha256-hGdgeU2Nk87RAuZyYjyDjFL6LK7dAZN5RE9+hrDTkDU=",
|
||||
"lastModified": 1686412476,
|
||||
"narHash": "sha256-inl9SVk6o5h75XKC79qrDCAobTD1Jxh6kVYTZKHzewA=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "549bd84d6279f9852cae6225e372cc67fb91a4c1",
|
||||
"rev": "21951114383770f96ae528d0ae68824557768e81",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"id": "nixpkgs",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"nixpkgs-lib": {
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1777168982,
|
||||
"narHash": "sha256-GOkGPcboWE9BmGCRMLX3worL4EMnsnG8MyKmXNeYuhQ=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs.lib",
|
||||
"rev": "f5901329dade4a6ea039af1433fb087bd9c1fe14",
|
||||
"lastModified": 1681358109,
|
||||
"narHash": "sha256-eKyxW4OohHQx9Urxi7TQlFBTDWII+F+x2hklDOQPB50=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "96ba1c52e54e74c3197f4d43026b3f3d92e83ff9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs.lib",
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-parts": "flake-parts",
|
||||
"nixpkgs": "nixpkgs"
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"rust-overlay": "rust-overlay"
|
||||
}
|
||||
},
|
||||
"rust-overlay": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_2",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1686364106,
|
||||
"narHash": "sha256-h4gCQg+jizmAbdg6UPlhxQVk4A7Ar/zoLa0wx3wBya0=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "ba011dd1c5028dbb880bc3b0f427e0ff689e6203",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems_2": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,99 +1,87 @@
|
||||
{
|
||||
description = "SlimeVR Server & GUI";
|
||||
description = "Server app for SlimeVR ecosystem";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
};
|
||||
inputs.nixpkgs.url = "nixpkgs/nixos-unstable";
|
||||
inputs.flake-utils.url = "github:numtide/flake-utils";
|
||||
|
||||
outputs =
|
||||
inputs@{
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-parts,
|
||||
...
|
||||
}:
|
||||
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||
systems = [ "x86_64-linux" ];
|
||||
inputs.rust-overlay.url = "github:oxalica/rust-overlay";
|
||||
|
||||
perSystem =
|
||||
{ pkgs, ... }:
|
||||
let
|
||||
runtimeLibs =
|
||||
pkgs:
|
||||
(with pkgs; [
|
||||
jdk17
|
||||
|
||||
alsa-lib
|
||||
libpulseaudio
|
||||
at-spi2-atk
|
||||
at-spi2-core
|
||||
cairo
|
||||
cups
|
||||
dbus
|
||||
expat
|
||||
gdk-pixbuf
|
||||
glib
|
||||
gtk3
|
||||
libdrm
|
||||
libgbm
|
||||
libglvnd
|
||||
libnotify
|
||||
libxkbcommon
|
||||
mesa
|
||||
nspr
|
||||
nss
|
||||
pango
|
||||
systemd
|
||||
vulkan-loader
|
||||
wayland
|
||||
libX11
|
||||
libXcomposite
|
||||
libXdamage
|
||||
libXext
|
||||
libXfixes
|
||||
libXrandr
|
||||
libxcb
|
||||
libxshmfence
|
||||
libusb1
|
||||
udev
|
||||
libxcrypt-legacy
|
||||
rpm
|
||||
fpm
|
||||
|
||||
wineWow64Packages.stable
|
||||
zlib
|
||||
squashfsTools
|
||||
fakeroot
|
||||
libarchive
|
||||
icu
|
||||
nodejs_22
|
||||
pnpm
|
||||
pkg-config
|
||||
python3
|
||||
gcc
|
||||
gnumake
|
||||
binutils
|
||||
git
|
||||
node-gyp-build
|
||||
]);
|
||||
|
||||
slimeShell = pkgs.buildFHSEnv {
|
||||
name = "slimevr-env";
|
||||
targetPkgs = runtimeLibs;
|
||||
profile = ''
|
||||
export JAVA_HOME=${pkgs.jdk17}
|
||||
export PATH="${pkgs.jdk17}/bin:$PATH"
|
||||
|
||||
# Tell electron-builder to use system tools instead of downloading them
|
||||
export USE_SYSTEM_FPM=true
|
||||
export USE_SYSTEM_MKSQUASHFS=true
|
||||
'';
|
||||
runScript = "bash";
|
||||
};
|
||||
in
|
||||
{
|
||||
devShells.default = slimeShell.env;
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
rust-overlay,
|
||||
}:
|
||||
flake-utils.lib.eachDefaultSystem
|
||||
(
|
||||
system: let
|
||||
overlays = [(import rust-overlay)];
|
||||
pkgs = import nixpkgs {
|
||||
inherit system overlays;
|
||||
};
|
||||
};
|
||||
rustTarget = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
||||
nativeBuildInputs = with pkgs; [
|
||||
curl
|
||||
gcc
|
||||
openssl
|
||||
pkgconfig
|
||||
which
|
||||
zlib
|
||||
|
||||
freetype
|
||||
expat
|
||||
];
|
||||
buildInputs = with pkgs; [
|
||||
appimagekit
|
||||
atk
|
||||
cairo
|
||||
dbus
|
||||
dbus.lib
|
||||
dprint
|
||||
gdk-pixbuf
|
||||
glib.out
|
||||
gobject-introspection
|
||||
gtk3
|
||||
harfbuzz
|
||||
libayatana-appindicator-gtk3
|
||||
libffi
|
||||
libsoup
|
||||
openssl.out
|
||||
pango
|
||||
pkg-config
|
||||
treefmt
|
||||
webkitgtk
|
||||
zlib
|
||||
gst_all_1.gstreamer
|
||||
gst_all_1.gst-plugins-base
|
||||
gst_all_1.gst-plugins-good
|
||||
gst_all_1.gst-plugins-bad
|
||||
|
||||
# Some nice things to have
|
||||
exa
|
||||
fd
|
||||
|
||||
jdk17 # JDK17
|
||||
nodejs
|
||||
gradle
|
||||
];
|
||||
in {
|
||||
devShells.default = pkgs.mkShell {
|
||||
nativeBuildInputs =
|
||||
nativeBuildInputs
|
||||
++ [
|
||||
];
|
||||
buildInputs =
|
||||
buildInputs
|
||||
++ [
|
||||
rustTarget
|
||||
];
|
||||
|
||||
shellHook = ''
|
||||
alias ls=exa
|
||||
alias find=fd
|
||||
'';
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -13,14 +13,7 @@ android.useAndroidX=true
|
||||
android.nonTransitiveRClass=true
|
||||
org.gradle.unsafe.configuration-cache=false
|
||||
|
||||
kotlinVersion=2.3.10
|
||||
spotlessVersion=8.2.1
|
||||
shadowJarVersion=9.3.1
|
||||
buildconfigVersion=6.0.7
|
||||
# We should probably stop using grgit, see:
|
||||
# https://andrewoberstar.com/posts/2024-04-02-dont-commit-to-grgit/
|
||||
grgitVersion=5.3.3
|
||||
|
||||
# Fix gradle leaving multiple java processes running that accumulate and use multiple GBs of RAM
|
||||
# This mostly seems to affect it when running from console, and then sending a SIGINT (Ctrl + C)
|
||||
org.gradle.daemon.idletimeout=10000
|
||||
kotlinVersion=1.9.0-RC
|
||||
spotlessVersion=6.12.0
|
||||
shadowJarVersion=8.1.1
|
||||
buildconfigVersion=3.1.0
|
||||
@@ -1,8 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.4-bin.zip
|
||||
distributionSha256Sum=f1771298a70f6db5a29daf62378c4e18a17fc33c9ba6b14362e0cdf40610380d
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -15,8 +15,6 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
@@ -57,7 +55,7 @@
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
@@ -85,9 +83,10 @@ done
|
||||
# This is normally unused
|
||||
# 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
|
||||
' "$PWD" ) || exit
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
@@ -134,13 +133,10 @@ location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
@@ -148,7 +144,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
# shellcheck disable=SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
@@ -156,7 +152,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
# shellcheck disable=SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
@@ -201,15 +197,11 @@ if "$cygwin" || "$msys" ; then
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * 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.
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
@rem SPDX-License-Identifier: Apache-2.0
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@@ -45,11 +43,11 @@ set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
@@ -59,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
VITE_FIRMWARE_TOOL_URL=https://fw-tool-api-v2.slimevr.io
|
||||
VITE_FIRMWARE_TOOL_S3_URL=https://fw-tool-bucket-v2.slimevr.io
|
||||
FIRMWARE_TOOL_SCHEMA_URL=https://fw-tool-api-v2.slimevr.io/api-json
|
||||
|
||||
|
||||
# VITE_FIRMWARE_TOOL_URL=http://localhost:3000
|
||||
# VITE_FIRMWARE_TOOL_S3_URL=http://localhost:9099
|
||||
# FIRMWARE_TOOL_SCHEMA_URL=http://localhost:3000/api-json
|
||||
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"env": {
|
||||
"browser": true,
|
||||
"es2021": true,
|
||||
"jest": true
|
||||
},
|
||||
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"ecmaFeatures": {
|
||||
"jsx": true
|
||||
},
|
||||
"ecmaVersion": "latest",
|
||||
"sourceType": "module"
|
||||
},
|
||||
"plugins": ["react-hooks", "@typescript-eslint"],
|
||||
"rules": {
|
||||
"react/react-in-jsx-scope": "off",
|
||||
"react/prop-types": "off",
|
||||
"spaced-comment": "error",
|
||||
"quotes": ["error", "single"],
|
||||
"no-duplicate-imports": "error",
|
||||
"no-inline-styles": "off",
|
||||
"@typescript-eslint/no-explicit-any": "off",
|
||||
"react/no-unescaped-entities": "off",
|
||||
"camelcase": "error",
|
||||
"@typescript-eslint/no-unused-vars": [
|
||||
"warn",
|
||||
{
|
||||
"argsIgnorePattern": "^_",
|
||||
"varsIgnorePattern": "^_"
|
||||
}
|
||||
]
|
||||
},
|
||||
"settings": {
|
||||
"import/resolver": {
|
||||
"typescript": {}
|
||||
},
|
||||
"react": {
|
||||
"version": "detect"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,14 +28,3 @@ yarn-error.log*
|
||||
# vite
|
||||
/dist
|
||||
/stats.html
|
||||
vite.config.ts.timestamp*
|
||||
electron.vite.config.*.mjs
|
||||
|
||||
# eslint
|
||||
.eslintcache
|
||||
|
||||
# Sentry Config File
|
||||
.env.sentry-build-plugin
|
||||
|
||||
# electron
|
||||
out/
|
||||
@@ -1,5 +0,0 @@
|
||||
export default {
|
||||
'**/*.{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,78 +0,0 @@
|
||||
appId: dev.slimevr.SlimeVR
|
||||
productName: SlimeVR
|
||||
# Global naming pattern
|
||||
artifactName: "${productName}-${version}-${os}-${arch}.${ext}"
|
||||
|
||||
directories:
|
||||
output: dist/artifacts/${os}
|
||||
|
||||
asar: true
|
||||
asarUnpack:
|
||||
- out/main/chunks/*.jar
|
||||
|
||||
electronLanguages:
|
||||
- en-US
|
||||
|
||||
files:
|
||||
- out/**/*
|
||||
- index.html
|
||||
- package.json
|
||||
- node_modules/**
|
||||
- "!node_modules/*/{README,readme,README.md,readme.md,CHANGELOG,CHANGELOG.md,changelog.md}"
|
||||
- "!node_modules/*/{test,tests,__tests__,docs,doc,example,examples}"
|
||||
- "!node_modules/*/.{git,github,vscode,editorconfig,eslintrc,prettierrc}"
|
||||
- "!node_modules/**/*.{map,ts,tsx,d.ts}"
|
||||
- "!**/.DS_Store"
|
||||
|
||||
|
||||
linux:
|
||||
category: Game
|
||||
artifactName: "${productName}-${arch}.${ext}"
|
||||
target:
|
||||
- target: AppImage
|
||||
- target: deb
|
||||
- target: rpm
|
||||
extraFiles:
|
||||
- from: "../server/desktop/build/libs/slimevr.jar"
|
||||
to: "."
|
||||
- from: "../bindings-provider/build/linux-${arch}/slimevr-bindings-provider"
|
||||
to: "."
|
||||
- from: "../bindings-provider/build/linux-${arch}/libopenvr_api.so"
|
||||
to: "."
|
||||
- from: "./electron/resources/69-slimevr-devices.rules"
|
||||
to: "."
|
||||
icon: "./electron/resources/icons"
|
||||
|
||||
deb:
|
||||
depends: [openjdk-17-jre-headless, udev]
|
||||
afterInstall: "./electron/resources/scripts/postinstall.sh"
|
||||
afterRemove: "./electron/resources/scripts/postremove.sh"
|
||||
|
||||
rpm:
|
||||
depends: [java-latest-openjdk, udev]
|
||||
afterInstall: "./electron/resources/scripts/postinstall.sh"
|
||||
afterRemove: "./electron/resources/scripts/postremove.sh"
|
||||
|
||||
win:
|
||||
artifactName: "${productName}-${os}-${arch}.${ext}"
|
||||
target: zip
|
||||
icon: "./electron/resources/icons/icon.ico"
|
||||
extraFiles:
|
||||
- from: "../server/desktop/build/libs/slimevr.jar"
|
||||
to: "."
|
||||
- from: "../server/core/resources"
|
||||
to: "."
|
||||
filter: ["**/*"]
|
||||
- from: "../bindings-provider/build/${os}-${arch}/Release/SlimeVR-Bindings-Provider.exe"
|
||||
to: "."
|
||||
- from: "../bindings-provider/build/${os}-${arch}/openvr_api.dll"
|
||||
to: "."
|
||||
|
||||
mac:
|
||||
target: dmg
|
||||
artifactName: "SlimeVR-mac.${ext}"
|
||||
x64ArchFiles: "**/register-protocol-handler.node"
|
||||
icon: "./electron/resources/icons/icon.icns"
|
||||
extraFiles:
|
||||
- from: "../server/desktop/build/libs/slimevr.jar"
|
||||
to: "Resources/slimevr.jar"
|
||||
@@ -1,41 +0,0 @@
|
||||
import { defineConfig } from 'electron-vite';
|
||||
import { resolve } from 'path';
|
||||
import rendererConfig from './vite.config'; // Import your existing React config
|
||||
|
||||
export default defineConfig({
|
||||
main: {
|
||||
build: {
|
||||
rollupOptions: {
|
||||
input: resolve(__dirname, 'electron/main/index.ts'),
|
||||
external: ['pino', 'pino-pretty', 'pino-roll', 'commander', 'open'],
|
||||
},
|
||||
},
|
||||
},
|
||||
preload: {
|
||||
build: {
|
||||
rollupOptions: {
|
||||
input: resolve(__dirname, 'electron/preload/index.ts'),
|
||||
output: {
|
||||
format: 'cjs', // Force CJS for the preload
|
||||
entryFileNames: 'index.js', // Change back to .js
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
renderer: {
|
||||
...rendererConfig,
|
||||
root: '.',
|
||||
build: {
|
||||
commonjsOptions: {
|
||||
// Force Rollup to treat the protocol directory as CommonJS
|
||||
// even though it's not in node_modules
|
||||
include: [/solarxr-protocol/, /node_modules/],
|
||||
// Required for Flatbuffers/Generated code interop
|
||||
transformMixedEsModules: true,
|
||||
},
|
||||
rollupOptions: {
|
||||
input: resolve(__dirname, 'index.html'),
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -1 +0,0 @@
|
||||
resources/java-version/JavaVersion.class
|
||||
@@ -1,22 +0,0 @@
|
||||
import { Option, program } from "commander";
|
||||
|
||||
program
|
||||
.option('-p, --path <path>', 'set launch path')
|
||||
.option('-s, --steam', 'steam mode')
|
||||
.option('-i, --install', 'run the driver installer')
|
||||
.option(
|
||||
'--skip-server-if-running',
|
||||
'gui will not launch the server if it is already running'
|
||||
)
|
||||
.allowUnknownOption()
|
||||
// Allow passing arguments to Electron.
|
||||
.allowExcessArguments();
|
||||
|
||||
if (process.platform === "linux") {
|
||||
const noUdevOption = new Option('--no-udev', 'disable udev warning');
|
||||
noUdevOption.negate = false;
|
||||
program.addOption(noUdevOption)
|
||||
}
|
||||
|
||||
program.parse(process.argv);
|
||||
export const options = program.opts();
|
||||
@@ -1,527 +0,0 @@
|
||||
import {
|
||||
app,
|
||||
BrowserWindow,
|
||||
dialog,
|
||||
Menu,
|
||||
nativeImage,
|
||||
net,
|
||||
protocol,
|
||||
screen,
|
||||
shell,
|
||||
Tray,
|
||||
} from 'electron';
|
||||
import { IPC_CHANNELS } from '../shared';
|
||||
import path, { dirname, join } from 'path';
|
||||
import open from 'open';
|
||||
import trayIcon from '../resources/icons/icon.png?asset';
|
||||
import appleTrayIcon from '../resources/icons/Square30x30Logo.png?asset';
|
||||
import { readFile, stat } from 'fs/promises';
|
||||
import { pathToFileURL } from 'node:url';
|
||||
import { getPlatform, handleIpc, isPortAvailable } from './utils';
|
||||
import {
|
||||
findServerJar,
|
||||
findSystemJRE,
|
||||
getExeFolder,
|
||||
getGuiDataFolder,
|
||||
getLogsFolder,
|
||||
getServerDataFolder,
|
||||
getWindowStateFile,
|
||||
} from './paths';
|
||||
import { initStores } from './store';
|
||||
import { closeLogger, logger } from './logger';
|
||||
import { spawn } from 'node:child_process';
|
||||
import { discordPresence } from './presence';
|
||||
import { options } from './cli';
|
||||
import { ServerStatusEvent } from 'electron/preload/interface';
|
||||
import { mkdir, writeFile } from 'node:fs/promises';
|
||||
import { MenuItem } from 'electron/main';
|
||||
|
||||
type Stores = Awaited<ReturnType<typeof initStores>>;
|
||||
let stores: Stores;
|
||||
|
||||
// Fixes colors looking washed on linux
|
||||
// Might affect hdr
|
||||
if (process.platform === 'linux') {
|
||||
app.commandLine.appendSwitch('disable-features', 'WaylandWpColorManagerV1');
|
||||
app.commandLine.appendSwitch('force-color-profile', 'srgb');
|
||||
}
|
||||
|
||||
app.setPath('userData', getGuiDataFolder());
|
||||
app.setPath('sessionData', join(getGuiDataFolder(), 'electron'));
|
||||
|
||||
protocol.registerSchemesAsPrivileged([
|
||||
{
|
||||
scheme: 'app',
|
||||
privileges: {
|
||||
standard: true,
|
||||
secure: true,
|
||||
supportFetchAPI: true,
|
||||
corsEnabled: true,
|
||||
stream: true,
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
let mainWindow: BrowserWindow | null = null;
|
||||
|
||||
handleIpc(IPC_CHANNELS.GH_FETCH, async (e, options) => {
|
||||
if (options.type === 'fw-releases') {
|
||||
return fetch(
|
||||
'https://api.github.com/repos/SlimeVR/SlimeVR-Tracker-ESP/releases'
|
||||
).then((res) => res.json());
|
||||
}
|
||||
if (options.type === 'asset') {
|
||||
if (
|
||||
!options.url.startsWith(
|
||||
'https://github.com/SlimeVR/SlimeVR-Tracker-ESP/releases/download'
|
||||
)
|
||||
)
|
||||
return null;
|
||||
return fetch(options.url).then((res) => res.json());
|
||||
}
|
||||
});
|
||||
|
||||
handleIpc(IPC_CHANNELS.OS_STATS, async () => {
|
||||
return {
|
||||
type: getPlatform(),
|
||||
};
|
||||
});
|
||||
|
||||
handleIpc(IPC_CHANNELS.I18N_OVERRIDE, async () => {
|
||||
const overridefile = join(getServerDataFolder(), 'override.ftl');
|
||||
const exists = await stat(overridefile)
|
||||
.then(() => true)
|
||||
.catch(() => false);
|
||||
|
||||
if (!exists) return false;
|
||||
return readFile(overridefile, { encoding: 'utf-8' });
|
||||
});
|
||||
|
||||
handleIpc(IPC_CHANNELS.LOG, (e, type, ...args) => {
|
||||
let payload: Record<string, unknown> = {};
|
||||
const messageParts: unknown[] = [];
|
||||
|
||||
args.forEach((arg) => {
|
||||
if (arg instanceof Error) {
|
||||
payload.err = arg;
|
||||
} else if (typeof arg === 'object' && arg !== null) {
|
||||
payload = { ...payload, ...arg };
|
||||
} else {
|
||||
messageParts.push(arg);
|
||||
}
|
||||
});
|
||||
|
||||
const msg = messageParts.join(' ');
|
||||
|
||||
switch (type) {
|
||||
case 'error':
|
||||
logger.error(payload, msg);
|
||||
break;
|
||||
case 'warn':
|
||||
logger.warn(payload, msg);
|
||||
break;
|
||||
default:
|
||||
logger.info(payload, msg);
|
||||
}
|
||||
});
|
||||
|
||||
handleIpc(IPC_CHANNELS.OPEN_URL, (e, url) => {
|
||||
const allowed_urls = [
|
||||
/^steam:\/\//,
|
||||
/^ms-settings:network$/,
|
||||
/^https:\/\/(?:.+\.)?slimevr\.dev(?:\/.+)?$/,
|
||||
/^https:\/\/github\.com\/SlimeVR(?:\/.+)?$/,
|
||||
/^https:\/\/discord\.gg\/slimevr$/,
|
||||
];
|
||||
if (allowed_urls.find((a) => url.match(a))) open(url);
|
||||
else logger.error({ url }, 'attempted to open non-whitelisted URL');
|
||||
});
|
||||
|
||||
handleIpc(IPC_CHANNELS.STORAGE, async (e, { type, method, key, value }) => {
|
||||
const store = stores[type];
|
||||
if (!store) throw new Error(`Storage type ${type} not found`);
|
||||
|
||||
switch (method) {
|
||||
case 'get':
|
||||
return store.get(key!);
|
||||
case 'set':
|
||||
return store.set(key!, value);
|
||||
case 'delete':
|
||||
return store.delete(key!);
|
||||
case 'save':
|
||||
return store.save();
|
||||
}
|
||||
});
|
||||
|
||||
handleIpc(IPC_CHANNELS.DISCORD_PRESENCE, async (e, options) => {
|
||||
if (options.enable) {
|
||||
if (!discordPresence.state.ready) await discordPresence.connect();
|
||||
discordPresence.updateActivity(options.activity, options.iconText);
|
||||
} else if (discordPresence.state.ready) {
|
||||
discordPresence.destroy();
|
||||
}
|
||||
});
|
||||
|
||||
handleIpc(IPC_CHANNELS.OPEN_FILE, (e, folder) => {
|
||||
const requestedPath = path.resolve(folder);
|
||||
|
||||
const isAllowed = [getServerDataFolder(), getGuiDataFolder(), getLogsFolder()].some(
|
||||
(parent) => {
|
||||
const absoluteParent = path.resolve(parent);
|
||||
const relative = path.relative(absoluteParent, requestedPath);
|
||||
return !relative.includes('..') && !path.isAbsolute(relative);
|
||||
}
|
||||
);
|
||||
|
||||
if (isAllowed) {
|
||||
shell.openPath(requestedPath);
|
||||
} else {
|
||||
logger.error({ path: requestedPath }, 'Blocked unauthorized path');
|
||||
}
|
||||
});
|
||||
|
||||
handleIpc(IPC_CHANNELS.GET_FOLDER, (e, folder) => {
|
||||
switch (folder) {
|
||||
case 'config':
|
||||
return getGuiDataFolder();
|
||||
case 'logs':
|
||||
return getLogsFolder();
|
||||
case 'exe':
|
||||
return getExeFolder();
|
||||
}
|
||||
});
|
||||
|
||||
handleIpc(IPC_CHANNELS.IS_STEAM, () => {
|
||||
return options.steam;
|
||||
});
|
||||
|
||||
const defaultWindowState: {
|
||||
width: number;
|
||||
height: number;
|
||||
x?: number;
|
||||
y?: number;
|
||||
} = {
|
||||
width: 1289.0,
|
||||
height: 709.0,
|
||||
x: undefined,
|
||||
y: undefined,
|
||||
};
|
||||
|
||||
const windowState = await readFile(getWindowStateFile(), {
|
||||
encoding: 'utf-8',
|
||||
})
|
||||
.then((data) => JSON.parse(data))
|
||||
.catch(() => {
|
||||
logger.error('Failed to load window state, using defaults');
|
||||
return defaultWindowState;
|
||||
});
|
||||
|
||||
const MIN_WIDTH = 393;
|
||||
const MIN_HEIGHT = 667;
|
||||
|
||||
function validateWindowState(state: typeof defaultWindowState) {
|
||||
if (state.x === undefined || state.y === undefined) {
|
||||
return state;
|
||||
}
|
||||
|
||||
const displays = screen.getAllDisplays();
|
||||
|
||||
const isVisible = displays.some((display) => {
|
||||
return (
|
||||
state.x! >= display.bounds.x &&
|
||||
state.y! >= display.bounds.y &&
|
||||
state.x! + state.width <= display.bounds.x + display.bounds.width &&
|
||||
state.y! + state.height <= display.bounds.y + display.bounds.height
|
||||
);
|
||||
});
|
||||
|
||||
const minWidth = MIN_WIDTH;
|
||||
const minHeight = MIN_HEIGHT;
|
||||
|
||||
if (!isVisible || state.width < minWidth || state.height < minHeight) {
|
||||
return defaultWindowState;
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
const saveWindowState = async () => {
|
||||
await mkdir(dirname(getWindowStateFile()), { recursive: true });
|
||||
await writeFile(getWindowStateFile(), JSON.stringify(windowState), {
|
||||
encoding: 'utf-8',
|
||||
});
|
||||
};
|
||||
|
||||
function createWindow() {
|
||||
const validatedState = validateWindowState(windowState);
|
||||
|
||||
mainWindow = new BrowserWindow({
|
||||
width: validatedState.width,
|
||||
height: validatedState.height,
|
||||
x: validatedState.x,
|
||||
y: validatedState.y,
|
||||
minHeight: MIN_HEIGHT,
|
||||
minWidth: MIN_WIDTH,
|
||||
movable: true,
|
||||
frame: false,
|
||||
roundedCorners: true,
|
||||
webPreferences: {
|
||||
preload: join(__dirname, '../preload/index.js'),
|
||||
nodeIntegration: false,
|
||||
contextIsolation: true,
|
||||
devTools: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (process.env.ELECTRON_RENDERER_URL) {
|
||||
mainWindow.loadURL(process.env.ELECTRON_RENDERER_URL);
|
||||
mainWindow.webContents.openDevTools();
|
||||
} else {
|
||||
mainWindow.loadURL('app://./index.html');
|
||||
}
|
||||
|
||||
mainWindow.on('closed', () => {
|
||||
mainWindow = null;
|
||||
});
|
||||
|
||||
handleIpc('window-actions', (e, action) => {
|
||||
if (mainWindow === null) return;
|
||||
switch (action) {
|
||||
case 'close':
|
||||
mainWindow.close();
|
||||
break;
|
||||
case 'hide':
|
||||
mainWindow.hide();
|
||||
break;
|
||||
case 'minimize':
|
||||
mainWindow.minimize();
|
||||
break;
|
||||
case 'toggle-maximize':
|
||||
if (mainWindow.isMaximized()) mainWindow.unmaximize();
|
||||
else mainWindow.maximize();
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
handleIpc('open-dialog', (e, options) => dialog.showOpenDialog(options));
|
||||
handleIpc('save-dialog', (e, options) => dialog.showSaveDialog(options));
|
||||
|
||||
const icon = nativeImage.createFromPath(
|
||||
getPlatform() === 'macos' ? appleTrayIcon : trayIcon
|
||||
);
|
||||
const tray = new Tray(icon);
|
||||
tray.setToolTip('SlimeVR');
|
||||
tray.on('click', () => {
|
||||
mainWindow?.show();
|
||||
});
|
||||
const contextMenu = Menu.buildFromTemplate([
|
||||
{
|
||||
label: 'Show',
|
||||
click: () => {
|
||||
mainWindow?.show();
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Hide',
|
||||
click: () => {
|
||||
mainWindow?.hide();
|
||||
},
|
||||
},
|
||||
{ role: 'quit' },
|
||||
]);
|
||||
tray.setContextMenu(contextMenu);
|
||||
|
||||
const updateWindowState = () => {
|
||||
if (!mainWindow) return;
|
||||
|
||||
windowState.minimized = mainWindow.isMinimized();
|
||||
if (!mainWindow.isMinimized() && !mainWindow.isMaximized()) {
|
||||
const bounds = mainWindow.getBounds();
|
||||
windowState.width = bounds.width;
|
||||
windowState.height = bounds.height;
|
||||
windowState.x = bounds.x;
|
||||
windowState.y = bounds.y;
|
||||
}
|
||||
};
|
||||
|
||||
mainWindow.on('move', updateWindowState);
|
||||
mainWindow.on('resize', updateWindowState);
|
||||
mainWindow.on('minimize', updateWindowState);
|
||||
mainWindow.on('maximize', updateWindowState);
|
||||
|
||||
mainWindow.webContents.on('context-menu', (event, params) => {
|
||||
const menu = new Menu();
|
||||
|
||||
menu.append(
|
||||
new MenuItem({
|
||||
label: 'Inspect Element',
|
||||
click: () => {
|
||||
mainWindow?.webContents.inspectElement(params.x, params.y);
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
menu.append(new MenuItem({ type: 'separator' }));
|
||||
menu.append(new MenuItem({ label: 'Copy', role: 'copy' }));
|
||||
menu.append(new MenuItem({ label: 'Paste', role: 'paste' }));
|
||||
|
||||
if (mainWindow) menu.popup({ window: mainWindow });
|
||||
});
|
||||
}
|
||||
|
||||
const checkEnvironmentVariables = () => {
|
||||
const to_check = ['_JAVA_OPTIONS', 'JAVA_TOOL_OPTIONS'];
|
||||
|
||||
const set = to_check.filter((env) => !!process.env[env]);
|
||||
if (set.length > 0) {
|
||||
dialog.showErrorBox(
|
||||
'SlimeVR',
|
||||
`You have environment variables ${set.join(', ')} set, which may cause the SlimeVR Server to fail to launch properly.`
|
||||
);
|
||||
app.quit();
|
||||
}
|
||||
};
|
||||
|
||||
const isServerRunning = async () => !(await isPortAvailable(21110));
|
||||
|
||||
const spawnServer = async () => {
|
||||
if (options.skipServerIfRunning && (await isServerRunning())) {
|
||||
logger.info(
|
||||
{ skipServerIfRunning: options.skipServerIfRunning },
|
||||
'Server is already running, skipping server start'
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const serverJar = findServerJar();
|
||||
if (!serverJar) {
|
||||
logger.info('server jar not found, skipping');
|
||||
return;
|
||||
}
|
||||
const sharedDir = dirname(serverJar);
|
||||
const javaBin = await findSystemJRE(sharedDir);
|
||||
if (!javaBin) {
|
||||
dialog.showErrorBox(
|
||||
'SlimeVR',
|
||||
`Couldn't find a compatible Java version, please download Java 17 or higher`
|
||||
);
|
||||
app.quit();
|
||||
return;
|
||||
}
|
||||
|
||||
logger.info({ javaBin, serverJar }, 'Found Java and server jar');
|
||||
const platform = getPlatform();
|
||||
|
||||
const serverArgs = ['-Xmx128M', '-jar', serverJar];
|
||||
if (options.steam) serverArgs.push('--steam');
|
||||
if (options.install) serverArgs.push('--install');
|
||||
if (options.noUdev) serverArgs.push('--no-udev');
|
||||
|
||||
serverArgs.push('run');
|
||||
|
||||
const serverProcess = spawn(javaBin, serverArgs, {
|
||||
cwd: sharedDir,
|
||||
shell: false,
|
||||
env:
|
||||
platform === 'windows'
|
||||
? {
|
||||
...process.env,
|
||||
APPDATA: app.getPath('appData'),
|
||||
LOCALAPPDATA: process.env['USERPROFILE']
|
||||
? path.join(process.env['USERPROFILE'], 'AppData', 'Local')
|
||||
: undefined,
|
||||
}
|
||||
: undefined,
|
||||
});
|
||||
|
||||
const sendToWindow = (event: ServerStatusEvent) => {
|
||||
if (mainWindow && !mainWindow.webContents.isDestroyed()) {
|
||||
mainWindow.webContents.send(IPC_CHANNELS.SERVER_STATUS, event);
|
||||
}
|
||||
};
|
||||
|
||||
serverProcess.stdout?.on('data', (message) => {
|
||||
sendToWindow({ message: message.toString(), type: 'stdout' });
|
||||
});
|
||||
|
||||
serverProcess.stderr?.on('data', (message) => {
|
||||
sendToWindow({ message: message.toString(), type: 'stderr' });
|
||||
});
|
||||
|
||||
serverProcess.on('error', (err) => {
|
||||
logger.info({ err }, 'Error launching the java server');
|
||||
if (!isQuitting) app.quit();
|
||||
});
|
||||
|
||||
serverProcess.on('exit', () => {
|
||||
logger.info('Server process exiting');
|
||||
});
|
||||
|
||||
const exited = new Promise<void>((resolve) => serverProcess.once('exit', resolve));
|
||||
|
||||
return {
|
||||
process: serverProcess,
|
||||
close: () => serverProcess.kill(),
|
||||
waitForExit: () => exited,
|
||||
};
|
||||
};
|
||||
|
||||
const createFolders = async () => {
|
||||
await mkdir(getServerDataFolder(), { recursive: true });
|
||||
await mkdir(getGuiDataFolder(), { recursive: true });
|
||||
};
|
||||
|
||||
let isQuitting = false;
|
||||
|
||||
app.whenReady().then(async () => {
|
||||
protocol.handle('app', (request) => {
|
||||
const { pathname } = new URL(request.url);
|
||||
const filePath = path.normalize(join(__dirname, '../renderer', pathname));
|
||||
return net.fetch(pathToFileURL(filePath).toString(), { headers: request.headers });
|
||||
});
|
||||
|
||||
try {
|
||||
await createFolders();
|
||||
} catch (err) {
|
||||
logger.error(err, 'Failed to initialize stores');
|
||||
dialog.showErrorBox(
|
||||
'SlimeVR',
|
||||
'Failed to initialize application storage. Please make sure the application has write permissions to its data folder.'
|
||||
);
|
||||
app.quit();
|
||||
return;
|
||||
}
|
||||
|
||||
stores = await initStores();
|
||||
checkEnvironmentVariables();
|
||||
const server = await spawnServer();
|
||||
|
||||
createWindow();
|
||||
|
||||
logger.info('SlimeVR started!');
|
||||
|
||||
process.on('exit', async (code) => {
|
||||
console.log(code);
|
||||
server?.close();
|
||||
await server?.waitForExit();
|
||||
});
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
app.quit();
|
||||
});
|
||||
|
||||
app.on('before-quit', async (event) => {
|
||||
if (isQuitting) return;
|
||||
isQuitting = true;
|
||||
event.preventDefault();
|
||||
logger.info('App quitting, saving...');
|
||||
server?.close();
|
||||
await server?.waitForExit();
|
||||
await stores.settings.save();
|
||||
await stores.cache.save();
|
||||
discordPresence.destroy();
|
||||
await saveWindowState();
|
||||
await closeLogger();
|
||||
app.exit(0);
|
||||
});
|
||||
});
|
||||
@@ -1,34 +0,0 @@
|
||||
import pino from 'pino';
|
||||
import { getLogsFolder } from './paths';
|
||||
import { join } from 'node:path';
|
||||
|
||||
const transport = pino.transport({
|
||||
targets: [
|
||||
{
|
||||
target: 'pino-roll',
|
||||
options: {
|
||||
file: join(getLogsFolder(), 'slimevr-gui.log'),
|
||||
frequency: 'daily',
|
||||
size: '10m',
|
||||
mkdir: true,
|
||||
limit: { count: 7 },
|
||||
},
|
||||
level: 'info',
|
||||
},
|
||||
{
|
||||
target: 'pino-pretty',
|
||||
options: { colorize: true },
|
||||
level: 'debug',
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
export const logger = pino(transport);
|
||||
|
||||
export const closeLogger = () =>
|
||||
new Promise<void>((resolve) => {
|
||||
logger.flush(() => {
|
||||
transport.once('close', resolve);
|
||||
transport.end();
|
||||
});
|
||||
});
|
||||
@@ -1,132 +0,0 @@
|
||||
import { app } from 'electron';
|
||||
import path, { join } from 'node:path';
|
||||
import { getPlatform } from './utils';
|
||||
import { glob } from 'glob';
|
||||
import { spawn } from 'node:child_process';
|
||||
import javaVersionJar from '../resources/java-version/JavaVersion.jar?asset&asarUnpack';
|
||||
import { existsSync } from 'node:fs';
|
||||
import { options } from './cli';
|
||||
|
||||
const javaBin = getPlatform() === 'windows' ? 'java.exe' : 'java';
|
||||
export const CONFIG_IDENTIFIER = 'dev.slimevr.SlimeVR';
|
||||
|
||||
export const getGuiDataFolder = () => {
|
||||
const platform = getPlatform();
|
||||
|
||||
switch (platform) {
|
||||
case 'linux':
|
||||
if (process.env['XDG_DATA_HOME'])
|
||||
return join(process.env['XDG_DATA_HOME'], CONFIG_IDENTIFIER);
|
||||
return join(app.getPath('home'), '.local/share', CONFIG_IDENTIFIER);
|
||||
case 'windows':
|
||||
return join(app.getPath('appData'), CONFIG_IDENTIFIER);
|
||||
case 'macos':
|
||||
return join(
|
||||
app.getPath('home'),
|
||||
'Library/Application Support',
|
||||
CONFIG_IDENTIFIER
|
||||
);
|
||||
case 'unknown':
|
||||
throw 'error';
|
||||
}
|
||||
};
|
||||
|
||||
export const getServerDataFolder = () => {
|
||||
const platform = getPlatform();
|
||||
|
||||
switch (platform) {
|
||||
case 'linux':
|
||||
case 'windows':
|
||||
case 'macos':
|
||||
return join(app.getPath('appData'), CONFIG_IDENTIFIER);
|
||||
case 'unknown':
|
||||
throw 'error';
|
||||
}
|
||||
};
|
||||
|
||||
export const getLogsFolder = () => {
|
||||
return join(getGuiDataFolder(), 'logs');
|
||||
};
|
||||
|
||||
export const getExeFolder = () => {
|
||||
return path.dirname(app.getPath('exe'));
|
||||
};
|
||||
|
||||
export const getWindowStateFile = () =>
|
||||
join(getServerDataFolder(), '.window-state.json');
|
||||
|
||||
const localJavaBin = (sharedDir: string) => {
|
||||
const platform = getPlatform();
|
||||
switch (platform) {
|
||||
case 'macos':
|
||||
return join(sharedDir, '../../../../jre/Contents/Home/bin', javaBin);
|
||||
default:
|
||||
return join(sharedDir, 'jre/bin', javaBin);
|
||||
}
|
||||
};
|
||||
|
||||
const javaHomeBin = () => {
|
||||
const javaHome = process.env['JAVA_HOME'];
|
||||
if (!javaHome) return null;
|
||||
const javaHomeJre = join(javaHome, 'bin', javaBin);
|
||||
return javaHomeJre;
|
||||
};
|
||||
|
||||
export const findSystemJRE = async (sharedDir: string) => {
|
||||
const paths = [
|
||||
localJavaBin(sharedDir),
|
||||
javaHomeBin(),
|
||||
...(await glob('/usr/lib/jvm/*/bin/' + javaBin)),
|
||||
...(await glob('/Library/Java/JavaVirtualMachines/*/Contents/Home/bin/' + javaBin)),
|
||||
];
|
||||
|
||||
for (const path of paths) {
|
||||
if (!path) continue;
|
||||
|
||||
const version = await new Promise<number | null>((resolve) => {
|
||||
const process = spawn(path, ['-jar', javaVersionJar], {});
|
||||
|
||||
let version: number | null = null;
|
||||
|
||||
process.stdout?.once('data', (data) => {
|
||||
try {
|
||||
version = parseFloat(data.toString());
|
||||
} catch {
|
||||
version = null;
|
||||
}
|
||||
});
|
||||
|
||||
process.on('error', () => {
|
||||
resolve(null);
|
||||
});
|
||||
|
||||
process.on('exit', () => {
|
||||
resolve(version);
|
||||
});
|
||||
});
|
||||
if (version && version >= 17) return path;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
export const findServerJar = () => {
|
||||
const paths = [
|
||||
options.path ? path.resolve(options.path) : undefined,
|
||||
app.isPackaged ? path.resolve(process.resourcesPath) : undefined,
|
||||
// AppImage passes the fakeroot in `APPDIR` env var.
|
||||
process.env['APPDIR']
|
||||
? path.resolve(join(process.env['APPDIR'], 'usr/share/slimevr/'))
|
||||
: undefined,
|
||||
path.dirname(app.getPath('exe')),
|
||||
// For flatpack container
|
||||
path.resolve('/app/share/slimevr/'),
|
||||
path.resolve('/usr/share/slimevr/'),
|
||||
|
||||
// For macos on steam
|
||||
path.resolve(`${app.getPath('exe')}/../../../../`),
|
||||
];
|
||||
return paths
|
||||
.filter((p) => !!p)
|
||||
.map((p) => join(p!, 'slimevr.jar'))
|
||||
.find((p) => existsSync(p));
|
||||
};
|
||||
@@ -1,52 +0,0 @@
|
||||
import { Client } from '@xhayper/discord-rpc';
|
||||
import { logger } from './logger';
|
||||
|
||||
export const richPresence = () => {
|
||||
const initialState = () => ({ ready: false, start: Date.now() });
|
||||
|
||||
const state = initialState();
|
||||
|
||||
const client = new Client({
|
||||
clientId: '1237970689009647639',
|
||||
transport: { type: 'ipc' },
|
||||
});
|
||||
client.on('ready', () => {
|
||||
state.ready = true;
|
||||
});
|
||||
|
||||
client.on('disconnected', () => {
|
||||
state.ready = false;
|
||||
});
|
||||
|
||||
return {
|
||||
state,
|
||||
connect: async () => {
|
||||
try {
|
||||
logger.info('Logging into Discord RPC');
|
||||
await client.login();
|
||||
} catch (e) {
|
||||
logger.error(e, 'Unable to connect to Discord RPC');
|
||||
}
|
||||
},
|
||||
updateActivity: (content: string, iconText: string | undefined) => {
|
||||
if (!state.ready) return;
|
||||
client.user
|
||||
?.setActivity({
|
||||
state: content,
|
||||
largeImageKey: 'icon',
|
||||
largeImageText: iconText,
|
||||
startTimestamp: state.start,
|
||||
})
|
||||
.catch((e) => {
|
||||
logger.error(e, 'Failed to update Discord RPC activity');
|
||||
});
|
||||
},
|
||||
destroy: () => {
|
||||
logger.info('Destroying Discord RPC');
|
||||
client.destroy();
|
||||
Object.assign(state, initialState());
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export const discordPresence = richPresence();
|
||||
@@ -1,79 +0,0 @@
|
||||
import { access, mkdir, readFile, writeFile } from "fs/promises";
|
||||
import { dirname, join } from "path";
|
||||
import { logger } from "./logger";
|
||||
import { getGuiDataFolder } from "./paths";
|
||||
|
||||
|
||||
export class CustomStore {
|
||||
private data: Record<string, unknown> = {};
|
||||
private saveTimeout: NodeJS.Timeout | null = null;
|
||||
private filePath: string;
|
||||
private debounceMs: number;
|
||||
|
||||
private constructor(filePath: string, debounceMs: number = 2000) {
|
||||
this.filePath = filePath;
|
||||
this.debounceMs = debounceMs;
|
||||
}
|
||||
|
||||
static async create(filePath: string, debounceMs: number = 2000): Promise<CustomStore> {
|
||||
const store = new CustomStore(filePath, debounceMs);
|
||||
await store.load();
|
||||
return store;
|
||||
}
|
||||
|
||||
private async load(): Promise<void> {
|
||||
try {
|
||||
await access(this.filePath);
|
||||
const raw = await readFile(this.filePath, 'utf-8');
|
||||
this.data = JSON.parse(raw);
|
||||
} catch {
|
||||
this.data = {};
|
||||
logger.warn(`No existing store found at ${this.filePath}, starting with empty store.`);
|
||||
}
|
||||
}
|
||||
|
||||
set(key: string, value: unknown) {
|
||||
this.data[key] = value;
|
||||
this.triggerAutoSave();
|
||||
}
|
||||
|
||||
get<T>(key: string): T | undefined {
|
||||
return this.data[key] as T;
|
||||
}
|
||||
|
||||
delete(key: string): boolean {
|
||||
if (key in this.data) {
|
||||
delete this.data[key];
|
||||
this.triggerAutoSave();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private triggerAutoSave() {
|
||||
if (this.saveTimeout) clearTimeout(this.saveTimeout);
|
||||
this.saveTimeout = setTimeout(() => {
|
||||
this.save();
|
||||
}, this.debounceMs);
|
||||
}
|
||||
|
||||
async save(): Promise<boolean> {
|
||||
try {
|
||||
if (this.saveTimeout) clearTimeout(this.saveTimeout);
|
||||
|
||||
await mkdir(dirname(this.filePath), { recursive: true });
|
||||
await writeFile(this.filePath, JSON.stringify(this.data, null, 2), 'utf-8');
|
||||
return true;
|
||||
} catch (err) {
|
||||
logger.error(err, 'Save failed', this.filePath);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function initStores() {
|
||||
return {
|
||||
settings: await CustomStore.create(join(getGuiDataFolder(), 'gui-settings.dat'), 1000),
|
||||
cache: await CustomStore.create(join(getGuiDataFolder(), 'gui-cache.dat'), 100),
|
||||
};
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
import os from 'os'
|
||||
import { OSStats } from "../preload/interface";
|
||||
import { ipcMain, IpcMainInvokeEvent } from 'electron';
|
||||
import { IpcInvokeMap } from '../shared';
|
||||
import net from 'net'
|
||||
|
||||
export const getPlatform = (): OSStats['type'] => {
|
||||
switch (os.platform()) {
|
||||
case 'darwin':
|
||||
return 'macos';
|
||||
case 'win32':
|
||||
return 'windows';
|
||||
case 'linux':
|
||||
return 'linux';
|
||||
default:
|
||||
return 'unknown';
|
||||
}
|
||||
};
|
||||
|
||||
export const isPortAvailable = (port: number) => {
|
||||
return new Promise((resolve) => {
|
||||
const s = net.createServer();
|
||||
s.once('error', (err) => {
|
||||
s.close();
|
||||
if ("code" in err && err["code"] == "EADDRINUSE") {
|
||||
resolve(false);
|
||||
} else {
|
||||
resolve(false);
|
||||
}
|
||||
});
|
||||
s.once('listening', () => {
|
||||
resolve(true);
|
||||
s.close();
|
||||
});
|
||||
s.listen(port);
|
||||
});
|
||||
};
|
||||
|
||||
export function handleIpc<K extends keyof IpcInvokeMap>(
|
||||
channel: K,
|
||||
handler: (
|
||||
event: IpcMainInvokeEvent,
|
||||
...args: Parameters<IpcInvokeMap[K]>
|
||||
) => ReturnType<IpcInvokeMap[K]>
|
||||
) {
|
||||
ipcMain.handle(channel, (event, ...args) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return handler(event, ...args as any);
|
||||
});
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
import { contextBridge, ipcRenderer, IpcRendererEvent } from 'electron';
|
||||
import { IElectronAPI, ServerStatusEvent } from './interface';
|
||||
import { IPC_CHANNELS } from '../shared';
|
||||
|
||||
contextBridge.exposeInMainWorld('electronAPI', {
|
||||
onServerStatus: (callback) => {
|
||||
const subscription = (_event: IpcRendererEvent, value: ServerStatusEvent) =>
|
||||
callback(value);
|
||||
ipcRenderer.on(IPC_CHANNELS.SERVER_STATUS, subscription);
|
||||
return () => ipcRenderer.removeListener(IPC_CHANNELS.SERVER_STATUS, subscription);
|
||||
},
|
||||
openUrl: (url) => ipcRenderer.invoke(IPC_CHANNELS.OPEN_URL, url),
|
||||
osStats: () => ipcRenderer.invoke(IPC_CHANNELS.OS_STATS),
|
||||
close: () => ipcRenderer.invoke(IPC_CHANNELS.WINDOW_ACTIONS, 'close'),
|
||||
hide: () => ipcRenderer.invoke(IPC_CHANNELS.WINDOW_ACTIONS, 'hide'),
|
||||
minimize: () => ipcRenderer.invoke(IPC_CHANNELS.WINDOW_ACTIONS, 'minimize'),
|
||||
toggleMaximize: () =>
|
||||
ipcRenderer.invoke(IPC_CHANNELS.WINDOW_ACTIONS, 'toggle-maximize'),
|
||||
getStorage: async (type) => {
|
||||
return {
|
||||
get: (key) =>
|
||||
ipcRenderer.invoke(IPC_CHANNELS.STORAGE, { type, method: 'get', key }),
|
||||
set: (key, value) =>
|
||||
ipcRenderer.invoke(IPC_CHANNELS.STORAGE, { type, method: 'set', key, value }),
|
||||
delete: (key) =>
|
||||
ipcRenderer.invoke(IPC_CHANNELS.STORAGE, { type, method: 'delete', key }),
|
||||
save: () => ipcRenderer.invoke(IPC_CHANNELS.STORAGE, { type, method: 'save' }),
|
||||
};
|
||||
},
|
||||
log: (type, ...args) => ipcRenderer.invoke(IPC_CHANNELS.LOG, type, ...args),
|
||||
i18nOverride: async () => ipcRenderer.invoke(IPC_CHANNELS.I18N_OVERRIDE),
|
||||
showDecorations: () => {},
|
||||
setTranslations: () => {},
|
||||
openDialog: (options) => ipcRenderer.invoke(IPC_CHANNELS.OPEN_DIALOG, options),
|
||||
saveDialog: (options) => ipcRenderer.invoke(IPC_CHANNELS.SAVE_DIALOG, options),
|
||||
openConfigFolder: async () =>
|
||||
ipcRenderer.invoke(
|
||||
IPC_CHANNELS.OPEN_FILE,
|
||||
await ipcRenderer.invoke(IPC_CHANNELS.GET_FOLDER, 'config')
|
||||
),
|
||||
openLogsFolder: async () =>
|
||||
ipcRenderer.invoke(
|
||||
IPC_CHANNELS.OPEN_FILE,
|
||||
await ipcRenderer.invoke(IPC_CHANNELS.GET_FOLDER, 'logs')
|
||||
),
|
||||
openFile: (path) => ipcRenderer.invoke(IPC_CHANNELS.OPEN_FILE, path),
|
||||
ghGet: (req) => ipcRenderer.invoke(IPC_CHANNELS.GH_FETCH, req),
|
||||
setPresence: (options) => ipcRenderer.invoke(IPC_CHANNELS.DISCORD_PRESENCE, options),
|
||||
getInstallDir: () => ipcRenderer.invoke(IPC_CHANNELS.GET_FOLDER, 'exe'),
|
||||
isSteam: () => ipcRenderer.invoke(IPC_CHANNELS.IS_STEAM),
|
||||
} satisfies IElectronAPI);
|
||||
@@ -1,69 +0,0 @@
|
||||
import {
|
||||
OpenDialogOptions,
|
||||
OpenDialogReturnValue,
|
||||
SaveDialogOptions,
|
||||
SaveDialogReturnValue,
|
||||
} from 'electron';
|
||||
|
||||
export type ServerStatusEvent = {
|
||||
type: 'stdout' | 'stderr' | 'error' | 'terminated' | 'other';
|
||||
message: string;
|
||||
};
|
||||
|
||||
export type OSStats = {
|
||||
type: 'linux' | 'windows' | 'macos' | 'unknown';
|
||||
};
|
||||
|
||||
export interface CrossStorage {
|
||||
set(key: string, value: unknown): Promise<void>;
|
||||
get<T>(key: string): Promise<T | undefined>;
|
||||
delete(key: string): Promise<boolean>;
|
||||
save(): Promise<boolean>;
|
||||
}
|
||||
|
||||
export type GHGet = { type: 'fw-releases' } | { type: 'asset'; url: string };
|
||||
export type GHReturn = {
|
||||
asset: [number, string][] | null;
|
||||
['fw-releases']:
|
||||
| {
|
||||
assets: { browser_download_url: string; name: string; digest: string }[];
|
||||
prerelease: boolean;
|
||||
tag_name: string;
|
||||
body: string;
|
||||
}[]
|
||||
| null;
|
||||
};
|
||||
|
||||
export type DiscordPresence =
|
||||
| { enable: false }
|
||||
| { enable: true; activity: string; iconText: string | undefined };
|
||||
|
||||
export interface IElectronAPI {
|
||||
onServerStatus: (cb: (data: ServerStatusEvent) => void) => () => void;
|
||||
openUrl: (url: string) => Promise<void>;
|
||||
osStats: () => Promise<OSStats>;
|
||||
openLogsFolder: () => Promise<void>;
|
||||
openConfigFolder: () => Promise<void>;
|
||||
close: () => void;
|
||||
hide: () => void;
|
||||
minimize: () => void;
|
||||
toggleMaximize: () => void;
|
||||
showDecorations: (decorations: boolean) => void;
|
||||
setTranslations: (translations: Record<string, string>) => void;
|
||||
i18nOverride: () => Promise<string | false>;
|
||||
getStorage: (type: 'settings' | 'cache') => Promise<CrossStorage>;
|
||||
openDialog: (options: OpenDialogOptions) => Promise<OpenDialogReturnValue>;
|
||||
saveDialog: (options: SaveDialogOptions) => Promise<SaveDialogReturnValue>;
|
||||
log: (type: 'info' | 'error' | 'warn', ...args: unknown[]) => void;
|
||||
openFile: (path: string) => void;
|
||||
ghGet: <T extends GHGet>(options: T) => Promise<GHReturn[T['type']]>;
|
||||
setPresence: (options: DiscordPresence) => void;
|
||||
getInstallDir: () => Promise<string>;
|
||||
isSteam: () => Promise<boolean>;
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
electronAPI: IElectronAPI;
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
# Copyright 2025 Eiren Rain and SlimeVR Contributors
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
## QinHeng
|
||||
# CH340
|
||||
SUBSYSTEMS=="usb", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7522", MODE="0660", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523", MODE="0660", TAG+="uaccess"
|
||||
# CH341
|
||||
SUBSYSTEMS=="usb", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="5523", MODE="0660", TAG+="uaccess"
|
||||
# CH343
|
||||
SUBSYSTEMS=="usb", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="55d3", MODE="0660", TAG+="uaccess"
|
||||
# CH9102x
|
||||
SUBSYSTEMS=="usb", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="55d4", MODE="0660", TAG+="uaccess"
|
||||
|
||||
## Silabs
|
||||
# CP210x
|
||||
SUBSYSTEMS=="usb", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", MODE="0660", TAG+="uaccess"
|
||||
|
||||
## Espressif
|
||||
# ESP32-S3 / ESP32-C3 / ESP32-C5 / ESP32-C6 / ESP32-C61 / ESP32-H2 / ESP32-P4
|
||||
SUBSYSTEMS=="usb", ATTRS{idVendor}=="303a", ATTRS{idProduct}=="1001", MODE="0660", TAG+="uaccess"
|
||||
# ESP32-S2
|
||||
SUBSYSTEMS=="usb", ATTRS{idVendor}=="303a", ATTRS{idProduct}=="0002", MODE="0660", TAG+="uaccess"
|
||||
|
||||
## FTDI
|
||||
# FT232BM/L/Q, FT245BM/L/Q
|
||||
# FT232RL/Q, FT245RL/Q
|
||||
# VNC1L with VDPS Firmware
|
||||
# VNC2 with FT232Slave
|
||||
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", MODE="0660", TAG+="uaccess"
|
||||
|
||||
## SlimeVR
|
||||
# smol slime dongle
|
||||
SUBSYSTEM=="usb", ATTR{idVendor}=="1209", ATTR{idProduct}=="7690", MODE="0660", TAG+="uaccess"
|
||||
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="7690", MODE="0660", TAG+="uaccess"
|
||||
|
Before Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 747 B |
|
Before Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 6.3 KiB |
|
Before Width: | Height: | Size: 698 B |
|
Before Width: | Height: | Size: 6.8 KiB |
|
Before Width: | Height: | Size: 1008 B |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 922 B |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 12 KiB |
@@ -1 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" stroke-miterlimit="10" clip-rule="evenodd" version="1.1" viewBox="0 0 380 380" xml:space="preserve"><rect id="bg" width="380" height="380" fill="#663499" stroke-width="1" rx="76" /><g id="logo" fill="none" stroke="#fff"><path id="left" stroke-width="13.62" d="m72.867 191.74 37-39 39 36"/><path id="right" stroke-width="13.62" d="m208.87 187.74 38-35 36 38"/><path id="outer" stroke-linecap="square" stroke-width="17" d="m56.867 253.74s130.61-31.182 248 5c13.45 4.146 20.244 2.975 20-8s1.909-126.06-46-131"/></g></svg>
|
||||
|
Before Width: | Height: | Size: 579 B |
|
Before Width: | Height: | Size: 555 B |
|
Before Width: | Height: | Size: 848 B |
|
Before Width: | Height: | Size: 848 B |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 645 B |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 848 B |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 25 KiB |