Compare commits

...
Author SHA1 Message Date
Uriel 9238c7211b Fix many GUI bugs found (#1129) 2024-08-07 19:03:18 -03:00
Butterscotch! 518fe8d2ef Fix skeleton issues (#1132) 2024-08-07 17:41:01 -03:00
Butterscotch! 8b97c0eb27 Change Android webserver port to 34536 (#1131) 2024-08-07 20:14:34 +02:00
Uriel 9bf7f1fa5c Fix git version script trimming wrong command (#1128) 2024-08-01 18:55:27 -03:00
Butterscotch! 4abd171efc Use default security attributes for named pipes (#1116) 2024-08-01 23:35:08 +02:00
Erimel af4f9a96bf Computed head reset (#1057) 2024-08-01 00:05:34 -03:00
ErimelandUriel 58ca3fe8c1 OSCQuery support (#958)
Co-authored-by: Uriel <[email protected]>
2024-07-31 18:01:38 +02:00
gale 0859abf08d Update flake nixpkgs revision (#1121) 2024-07-24 22:13:33 -03:00
Uriel b32e1cad50 Add a way to save serial logs as a file (#1029) 2024-07-24 22:00:55 -03:00
Butterscotch! c2566afa5e Update jSerialComm library (#1117) 2024-07-23 20:32:53 -03:00
VocalFan 7a9a23c3d4 Improvement on firewall batch scripts (#1030) 2024-07-23 20:27:16 -03:00
Uriel 76b29c4af6 Update to latest tauri again (#1097) 2024-07-19 20:38:51 -03:00
ShineBrightMeow 0be9b34320 Updated IMU Constants (#1100) 2024-07-12 17:38:04 +02:00
Ondrej Hruska 0b01a4d67a Issue#1079 - Add a background to the 3d preview skeleton (#1107) 2024-07-11 21:37:24 -03:00
Ondrej Hruska c316313d2a Issue#1082 - The Exit Modals does not go on top of other (#1105) 2024-07-11 21:30:20 +03:00
Uriel d8695d3e88 Add missing head tracker status (#962) 2024-07-11 17:50:18 +02:00
Ondrej Hruska 6e942780de Issue#1092 - White theme has correct manual mounting colors (#1103) 2024-07-11 05:02:05 +02:00
Erimel 0d9f9289fb Don't use neck length if head tracker doesn't have position (#1019) 2024-07-03 16:46:27 +02:00
Erimel a6d0517a5b Fix VMC foot offset (#1020) 2024-07-03 16:37:07 +02:00
AxisAngles 708135ff4c Fix Quaternion biAlign (#1094) 2024-07-03 16:23:40 +02:00
JovannMC 1f434e1c88 Sync server constants with firmware (#1093) 2024-07-02 16:09:20 +02:00
lucas lelievreandOndrej Hruska 7ab8435595 assignments enhancements (#1083)
Co-authored-by: Ondrej Hruska <[email protected]>
2024-06-26 16:39:46 +02:00
lucas lelievre 94aec1f4ba Remove useLayout (#1080) 2024-06-25 12:10:34 +02:00
Ondrej Hruska 6a268fbbad Issue#1066 - Show the current selected direction on the tracker mounting radial menu (#1077) 2024-06-18 11:15:01 -07:00
Ondrej Hruska 5ade5eb626 Issue#1074 - Icon of the body part in correct color (#1075) 2024-06-18 00:06:11 +02:00
Uriel 63384f40b5 Update to latest Tauri v2 (#1023) 2024-06-17 18:18:51 +02:00
d9da5544bb GUI - Tracker assignment options (#1009)
Co-authored-by: Erimel <[email protected]>
Co-authored-by: loucass003 <[email protected]>
2024-06-17 08:45:06 -07:00
rcelyte cfd9223390 Fix WebSocketVRBridge HMD (#1072) 2024-06-17 08:18:59 -07:00
Uriel a135ca3459 Add Futura back to codeowners 2024-06-17 13:22:29 +02:00
Uriel 9bcccc6c36 Delete old resources from java (#984) 2024-06-17 13:02:48 +02:00
UrielandErimel 00ef667c58 Add Discord Rich Presence support (#1027)
Co-authored-by: Erimel <[email protected]>
2024-06-14 18:32:00 +02:00
Uriel fbb0b8a460 Override tauri config version with git tag (#994) 2024-06-14 17:55:09 +02:00
Zhenfu Shi 6626cabeaa macOS app naming improvements (#991) 2024-06-14 17:50:25 +02:00
nekomona d23c92dec2 De-duplicate repeated HID packets (#1036) 2024-06-14 17:36:38 +02:00
Uriel 1356e7fbe6 Create tarball of GUI bundle on release (#1004) 2024-06-14 17:31:28 +02:00
Uriel ec2909406b fix waitUntil failing with arrays and objects (#1028) 2024-06-14 17:21:16 +02:00
Uriel 37de960c1b Update how Linux bundling is done (#983) 2024-06-14 17:03:09 +02:00
Uriel 638d4e3fb1 Update metainfo to latest (#1024) 2024-06-14 15:40:39 +02:00
Uriel a6f377992d Don't check for waist or hip on hasChest (#1031) 2024-06-14 14:51:27 +02:00
Uriel 27386d5b29 Use `Exit event instead of ExitRequested` (#1062) 2024-06-13 18:50:49 +02:00
Uriel d67acf6c28 keep up with quality guidelines in Flathub (#1063) 2024-06-13 18:22:32 +02:00
Erimel 4471aaaa49 Add VMC toggle to mirror tracking (#1065) 2024-06-13 18:12:19 +02:00
Erimel a3faad4a72 Update serial console description (#1064) 2024-06-13 17:13:55 +02:00
Uriel 4e4edc24da Add padding to tracker list on onboarding (#1058) 2024-06-13 16:20:36 +02:00
Collin e64edb76dd Fix mocap mode breaking on startup (#1046) 2024-06-07 01:25:57 +03:00
Erimel 721a74aacc Fix VMC floating (#1039) 2024-06-06 01:25:01 +03:00
Erimel 775f5e9f30 Fix update button not redirecting to the installer directly on Windows (#1037) 2024-06-06 01:22:35 +03:00
VocalFan 6ca2eb6905 Begone Slimevr-ui.exe (#1018) 2024-06-06 01:21:47 +03:00
sctanf 9808ea8709 Use assigned vid/pid for HID tracker (#1044) 2024-05-31 12:31:10 -03:00
120 changed files with 9900 additions and 7831 deletions

No files matched your search

+4 -4
View File
@@ -2,12 +2,12 @@
* @Eirenliel
# Make everyone be able to approve SolarXR submodule changes
/solarxr-protocol @ButterscotchV @Erimelowo @ImUrX
/solarxr-protocol @ButterscotchV @Erimelowo @ImUrX @loucass003
# Make Loucas and Uriel the owners of all GUI stuff
/gui/ @ImUrX
/pnpm-lock.yaml @ImUrX
/pnpm-workspace.yaml @ImUrX
/gui/ @ImUrX @loucass003
/pnpm-lock.yaml @ImUrX @loucass003
/pnpm-workspace.yaml @ImUrX @loucass003
# Uriel and Erimel responsible for i18n
/gui/public/i18n/ @ImUrX @Erimelowo
+2 -6
View File
@@ -79,15 +79,11 @@ jobs:
node-version-file: '.node-version'
cache: 'pnpm'
# Tauri has a broken cache issue in windows, let's clean it for now
- name: Clean cache in Windows (Fixes tauri-apps/tauri#9045)
if: matrix.os == 'windows-latest'
run: cargo clean
- name: Build
shell: bash
run: |
pnpm i
pnpm run skipbundler
pnpm run skipbundler --config $( ./gui/scripts/gitversion.mjs )
- if: matrix.os == 'windows-latest'
name: Upload a Build Artifact (Windows)
+33 -33
View File
@@ -183,38 +183,38 @@ jobs:
- name: Build
run: |
pnpm i
pnpm run tauri build
pnpm run tauri build --config $( ./gui/scripts/gitversion.mjs )
- name: Make GUI tarball
run: |
tar czf slimevr-gui-dist.tar.gz -C gui/dist/ .
- uses: actions/upload-artifact@v4
with:
name: SlimeVR-GUI-Dist
path: ./slimevr-gui-dist.tar.gz
- uses: actions/upload-artifact@v4
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/upload-artifact@v4
with:
name: SlimeVR-GUI-AppImage
path: target/release/bundle/appimage/slimevr*.AppImage
- uses: actions/upload-artifact@v4
with:
name: SlimeVR-GUI-RPM
path: target/release/bundle/rpm/slimevr*.rpm
- name: Prepare for release
if: startsWith(github.ref, 'refs/tags/')
run: |
cp target/release/bundle/appimage/slimevr*.AppImage ./SlimeVR-amd64.appimage
cp target/release/bundle/deb/slimevr*.deb ./SlimeVR-amd64.deb
cp target/release/bundle/rpm/slimevr*.rpm ./SlimeVR-amd64.rpm
- name: Upload to draft release
uses: softprops/action-gh-release@v2
@@ -223,8 +223,10 @@ jobs:
draft: true
generate_release_notes: true
files: |
./slimevr-gui-dist.tar.gz
./SlimeVR-amd64.appimage
./SlimeVR-amd64.deb
./SlimeVR-amd64.rpm
bundle-mac:
@@ -257,22 +259,27 @@ jobs:
run: |
rustup target add x86_64-apple-darwin
pnpm i
pnpm run tauri build --target universal-apple-darwin
pnpm run tauri build --target universal-apple-darwin --config $( ./gui/scripts/gitversion.mjs )
- name: Modify Application
run: |
cd target/universal-apple-darwin/release/bundle/macos/slimevr.app/Contents/MacOS
cp $( git rev-parse --show-toplevel )/server/desktop/build/libs/slimevr.jar ./
cd ../../../../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
cd ../../../
/usr/libexec/PlistBuddy -c "Set :CFBundleDisplayName SlimeVR" slimevr.app/Contents/Info.plist
/usr/libexec/PlistBuddy -c "Set :CFBundleName SlimeVR" slimevr.app/Contents/Info.plist
codesign --sign - --deep --force slimevr.app
mv slimevr.app SlimeVR.app
cd ../dmg/
./bundle_dmg.sh --volname SlimeVR --icon slimevr 180 170 --app-drop-link 480 170 \
--window-size 660 400 --hide-extension ../macos/SlimeVR.app \
--volicon ../macos/SlimeVR.app/Contents/Resources/icon.icns --skip-jenkins \
--eula ../../../../LICENSE-MIT slimevr.dmg ../macos/SlimeVR.app
- uses: actions/upload-artifact@v4
with:
name: SlimeVR-GUI-MacApp
path: target/universal-apple-darwin/release/bundle/macos/slimevr*.app
path: target/universal-apple-darwin/release/bundle/macos/SlimeVR*.app
- uses: actions/upload-artifact@v4
with:
@@ -320,13 +327,11 @@ jobs:
node-version-file: '.node-version'
cache: 'pnpm'
- name: Clean cache in Windows (Fixes tauri-apps/tauri#9045)
run: cargo clean
- name: Build
shell: bash
run: |
pnpm i
pnpm run skipbundler
pnpm run skipbundler --config $( ./gui/scripts/gitversion.mjs )
- name: Bundle to zips
shell: bash
@@ -338,9 +343,6 @@ jobs:
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/upload-artifact@v4
with:
name: SlimeVR-GUI-Windows
@@ -352,6 +354,4 @@ jobs:
with:
draft: true
generate_release_notes: true
files: |
./SlimeVR-win64.zip
./SlimeVR.zip
files: ./SlimeVR-win64.zip
+1
View File
@@ -17,6 +17,7 @@
# VSCode stuff
/.vscode/settings.json
/.vscode/launch.json
# Ignore eclipse stuff
.project
Generated
+760 -755
View File
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -9,7 +9,7 @@ members = ["gui/src-tauri"]
[workspace.package]
edition = "2021"
license = "MIT OR Apache-2.0"
rust-version = "1.75" # This version stabilized GATs and let-else
rust-version = "1.75" # Tauri's MSRV
repository = "https://github.com/SlimeVR/SlimeVR-Server"
[profile.release]
+10 -3
View File
@@ -13,7 +13,7 @@ work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
<id>dev.slimevr.SlimeVR</id>
<name>SlimeVR</name>
<summary>An app for facilitating full-body tracking in virtual reality</summary>
<summary>Accessible full-body tracking in VR</summary>
<developer_name>SlimeVR Team</developer_name>
<!-- CC0 so attribution is not required -->
@@ -40,7 +40,8 @@ work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
</supports>
<branding>
<color type="primary">#663499</color>
<color type="primary" scheme_preference="light">#BB8AE5</color>
<color type="primary" scheme_preference="dark">#663499</color>
</branding>
<description>
@@ -53,7 +54,7 @@ work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
<launchable type="desktop-id">dev.slimevr.SlimeVR.desktop</launchable>
<screenshots>
<screenshot type="default">
<screenshot type="default" xml:lang="en">
<caption>The onboarding for the GUI</caption>
<image>https://raw.githubusercontent.com/SlimeVR/SlimeVR-Server/main/assets/img/onboarding.png</image>
</screenshot>
@@ -64,6 +65,12 @@ work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
</provides>
<releases>
<release version="0.12.1" date="2024-04-29"><url>https://github.com/SlimeVR/SlimeVR-Server/releases/tag/v0.12.1</url></release>
<release version="0.12.0" date="2024-04-26"><url>https://github.com/SlimeVR/SlimeVR-Server/releases/tag/v0.12.0</url></release>
<release version="0.12.0~rc.4" type="development" date="2024-04-21"><url>https://github.com/SlimeVR/SlimeVR-Server/releases/tag/v0.12.0-rc.4</url></release>
<release version="0.12.0~rc.3" type="development" date="2024-04-14"><url>https://github.com/SlimeVR/SlimeVR-Server/releases/tag/v0.12.0-rc.3</url></release>
<release version="0.12.0~rc.2" type="development" date="2024-04-09"><url>https://github.com/SlimeVR/SlimeVR-Server/releases/tag/v0.12.0-rc.2</url></release>
<release version="0.12.0~rc.1" type="development" date="2024-04-04"><url>https://github.com/SlimeVR/SlimeVR-Server/releases/tag/v0.12.0-rc.1</url></release>
<release version="0.11.0" date="2023-12-23"><url>https://github.com/SlimeVR/SlimeVR-Server/releases/tag/v0.11.0</url></release>
<release version="0.11.0~rc.2" type="development" date="2023-12-08"><url>https://github.com/SlimeVR/SlimeVR-Server/releases/tag/v0.11.0-rc.2</url></release>
<release version="0.11.0~rc.1" type="development" date="2023-11-23"><url>https://github.com/SlimeVR/SlimeVR-Server/releases/tag/v0.11.0-rc.1</url></release>
Generated
+10 -37
View File
@@ -23,7 +23,9 @@
},
"fenix": {
"inputs": {
"nixpkgs": "nixpkgs_2",
"nixpkgs": [
"nixpkgs"
],
"rust-analyzer-src": "rust-analyzer-src"
},
"locked": {
@@ -225,7 +227,9 @@
"nixgl": {
"inputs": {
"flake-utils": "flake-utils_3",
"nixpkgs": "nixpkgs_3"
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1685908677,
@@ -309,42 +313,11 @@
},
"nixpkgs_2": {
"locked": {
"lastModified": 1699099776,
"narHash": "sha256-X09iKJ27mGsGambGfkKzqvw5esP1L/Rf8H3u3fCqIiU=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "85f1ba3e51676fa8cc604a3d863d729026a6b8eb",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_3": {
"locked": {
"lastModified": 1660551188,
"narHash": "sha256-a1LARMMYQ8DPx1BgoI/UN4bXe12hhZkCNqdxNi6uS0g=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "441dc5d512153039f19ef198e662e4f3dbb9fd65",
"type": "github"
},
"original": {
"owner": "nixos",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_4": {
"locked": {
"lastModified": 1699099776,
"narHash": "sha256-X09iKJ27mGsGambGfkKzqvw5esP1L/Rf8H3u3fCqIiU=",
"lastModified": 1721562059,
"narHash": "sha256-Tybxt65eyOARf285hMHIJ2uul8SULjFZbT9ZaEeUnP8=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "85f1ba3e51676fa8cc604a3d863d729026a6b8eb",
"rev": "68c9ed8bbed9dfce253cc91560bf9043297ef2fe",
"type": "github"
},
"original": {
@@ -390,7 +363,7 @@
"mk-shell-bin": "mk-shell-bin",
"nix2container": "nix2container",
"nixgl": "nixgl",
"nixpkgs": "nixpkgs_4"
"nixpkgs": "nixpkgs_2"
}
},
"rust-analyzer-src": {
+19 -7
View File
@@ -4,11 +4,19 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
devenv.url = "github:cachix/devenv";
nix2container.url = "github:nlewo/nix2container";
nix2container.inputs.nixpkgs.follows = "nixpkgs";
nix2container = {
url = "github:nlewo/nix2container";
inputs.nixpkgs.follows = "nixpkgs";
};
mk-shell-bin.url = "github:rrbutani/nix-mk-shell-bin";
nixgl.url = "github:guibou/nixGL";
fenix.url = "github:nix-community/fenix";
nixgl = {
url = "github:guibou/nixGL";
inputs.nixpkgs.follows = "nixpkgs";
};
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
nixConfig = {
@@ -81,7 +89,7 @@
harfbuzz
libffi
libsoup_3
openssl.out
openssl
pango
pkg-config
treefmt
@@ -96,7 +104,6 @@
expat
libayatana-appindicator
libusb1
libudev-zero
])
++ lib.optionals pkgs.stdenv.isDarwin [
pkgs.darwin.apple_sdk.frameworks.Security
@@ -118,7 +125,7 @@
enable = true;
toolchain = fenixpkgs.fromToolchainName {
name = rust_toolchain.toolchain.channel;
sha256 = "sha256-3St/9/UKo/6lz2Kfq2VmlzHyufduALpiIKaaKX4Pq0g=";
sha256 = "sha256-Ngiz76YP4HTY75GGdH2P+APE/DEIx2R/Dn+BwwOyzZU=";
};
components = rust_toolchain.toolchain.components;
};
@@ -128,6 +135,11 @@
};
enterShell = with pkgs; ''
# Export a LD_LIBRARY_PATH without libudev-zero as libgudev not likey
export SLIMEVR_RUST_LD_LIBRARY_PATH="$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH="${libudev-zero}/lib:$LD_LIBRARY_PATH"
# GStreamer plugins won't be found without this
export GST_PLUGIN_SYSTEM_PATH_1_0="${pkgs.gst_all_1.gstreamer.out}/lib/gstreamer-1.0:${pkgs.gst_all_1.gst-plugins-base}/lib/gstreamer-1.0:${pkgs.gst_all_1.gst-plugins-good}/lib/gstreamer-1.0:${pkgs.gst_all_1.gst-plugins-bad}/lib/gstreamer-1.0"
'';
};
};
+33 -32
View File
@@ -5,43 +5,43 @@
"dependencies": {
"@fluent/bundle": "^0.18.0",
"@fluent/react": "^0.15.2",
"@fontsource/poppins": "^5.0.12",
"@fontsource/poppins": "^5.0.14",
"@formatjs/intl-localematcher": "^0.2.32",
"@react-three/drei": "^9.105.1",
"@react-three/fiber": "^8.16.1",
"@tauri-apps/api": "=2.0.0-beta.7",
"@tauri-apps/plugin-dialog": "=2.0.0-beta.2",
"@tauri-apps/plugin-fs": "=2.0.0-beta.2",
"@tauri-apps/plugin-os": "=2.0.0-beta.2",
"@tauri-apps/plugin-shell": "=2.0.0-beta.2",
"@tauri-apps/plugin-store": "=2.0.0-beta.2",
"@vitejs/plugin-react": "^4.2.1",
"@react-three/drei": "^9.107.0",
"@react-three/fiber": "^8.16.8",
"@tauri-apps/api": "2.0.0-beta.14",
"@tauri-apps/plugin-dialog": "2.0.0-beta.6",
"@tauri-apps/plugin-fs": "2.0.0-beta.6",
"@tauri-apps/plugin-os": "2.0.0-beta.6",
"@tauri-apps/plugin-shell": "2.0.0-beta.7",
"@tauri-apps/plugin-store": "2.0.0-beta.6",
"@vitejs/plugin-react": "^4.3.1",
"browser-fs-access": "^0.35.0",
"browserslist": "^4.23.0",
"browserslist": "^4.23.1",
"classnames": "^2.5.1",
"eslint-config-react-app": "^7.0.1",
"flatbuffers": "^22.10.26",
"flatbuffers": "22.10.26",
"identity-obj-proxy": "^3.0.0",
"intl-pluralrules": "^2.0.1",
"ip-num": "^1.5.1",
"postcss-flexbugs-fixes": "^5.0.2",
"postcss-normalize": "^10.0.1",
"postcss-preset-env": "^9.5.2",
"postcss-preset-env": "^9.5.14",
"prompts": "^2.4.2",
"react": "^18.2.0",
"react": "^18.3.1",
"react-dev-utils": "^12.0.1",
"react-dom": "^18.2.0",
"react-dom": "^18.3.1",
"react-error-boundary": "^4.0.13",
"react-helmet": "^6.1.0",
"react-hook-form": "^7.51.0",
"react-hook-form": "^7.52.0",
"react-modal": "^3.16.1",
"react-responsive": "^10.0.0",
"react-router-dom": "^6.22.3",
"semver": "^7.6.0",
"react-router-dom": "^6.23.1",
"semver": "^7.6.2",
"solarxr-protocol": "file:../solarxr-protocol",
"three": "^0.163.0",
"ts-pattern": "^5.0.8",
"typescript": "^5.4.3"
"ts-pattern": "^5.2.0",
"typescript": "^5.4.5"
},
"scripts": {
"start": "vite --force",
@@ -49,9 +49,9 @@
"dev": "tauri dev",
"skipbundler": "tauri build --no-bundle",
"tauri": "tauri",
"lint": "tsc --noEmit && eslint --max-warnings=0 \"src/**/*.{js,jsx,ts,tsx,json}\" && prettier --check \"src/**/*.{js,jsx,ts,tsx,css,md,json}\"",
"lint": "tsc --noEmit && eslint --max-warnings=0 \"src/**/*.{js,jsx,ts,tsx,json}\" && prettier --check \"src/**/*.{js,jsx,ts,tsx,css,scss,md,json}\"",
"lint:fix": "tsc --noEmit && eslint --fix --max-warnings=0 \"src/**/*.{js,jsx,ts,tsx,json}\" && pnpm run format",
"format": "prettier --write \"src/**/*.{js,jsx,ts,tsx,css,md,json}\"",
"format": "prettier --write \"src/**/*.{js,jsx,ts,tsx,css,scss,md,json}\"",
"preview-vite": "vite preview",
"javaversion-build": "cd src-tauri/src/ && javac JavaVersion.java && jar cvfe JavaVersion.jar JavaVersion JavaVersion.class"
},
@@ -75,16 +75,16 @@
"devDependencies": {
"@dword-design/eslint-plugin-import-alias": "^4.0.9",
"@tailwindcss/forms": "^0.5.7",
"@tauri-apps/cli": "=2.0.0-beta.12",
"@tauri-apps/cli": "2.0.0-beta.21",
"@types/file-saver": "^2.0.7",
"@types/react": "^18.2.73",
"@types/react-dom": "^18.2.23",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@types/react-helmet": "^6.1.11",
"@types/react-modal": "3.16.3",
"@types/semver": "^7.5.8",
"@types/three": "^0.163.0",
"@typescript-eslint/eslint-plugin": "^7.4.0",
"@typescript-eslint/parser": "^7.4.0",
"@typescript-eslint/eslint-plugin": "^7.13.0",
"@typescript-eslint/parser": "^7.13.0",
"autoprefixer": "^10.4.19",
"cross-env": "^7.0.3",
"eslint": "^8.57.0",
@@ -92,14 +92,15 @@
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react": "^7.34.2",
"eslint-plugin-react-hooks": "^4.6.2",
"postcss": "^8.4.38",
"prettier": "^3.2.5",
"prettier": "^3.3.2",
"pretty-quick": "^4.0.0",
"rollup-plugin-visualizer": "^5.12.0",
"sass": "^1.77.5",
"tailwind-gradient-mask-image": "^1.2.0",
"tailwindcss": "^3.4.3",
"vite": "^5.2.7"
"tailwindcss": "^3.4.4",
"vite": "^5.3.1"
}
}
+46 -8
View File
@@ -355,6 +355,9 @@ settings-general-fk_settings-leg_fk-reset_mounting_feet = Feet Mounting Reset
settings-general-fk_settings-arm_fk = Arm tracking
settings-general-fk_settings-arm_fk-description = Force arms to be tracked from the headset (HMD) even if positional hand data is available.
settings-general-fk_settings-arm_fk-force_arms = Force arms from HMD
settings-general-fk_settings-reset_settings = Reset settings
settings-general-fk_settings-reset_settings-reset_hmd_pitch-description = Reset the HMD's pitch (vertical rotation) upon doing a full reset. Useful if wearing an HMD on the forehead for VTubing or mocap. Do not enable for VR.
settings-general-fk_settings-reset_settings-reset_hmd_pitch = Reset HMD pitch
settings-general-fk_settings-arm_fk-reset_mode-description = Change which arm pose is expected for mounting reset.
settings-general-fk_settings-arm_fk-back = Back
settings-general-fk_settings-arm_fk-back-description = The default mode, with the upper arms going back and lower arms going forward.
@@ -448,13 +451,21 @@ settings-general-interface-connected_trackers_warning-label = Connected trackers
settings-general-interface-use_tray = Minimize to system tray
settings-general-interface-use_tray-description = Lets you close the window without closing the SlimeVR Server so you can continue using it without having the GUI bothering you.
settings-general-interface-use_tray-label = Minimize to system tray
settings-general-interface-discord_presence = Share activity on Discord
settings-general-interface-discord_presence-description = Tells your Discord client that you are using SlimeVR along with the number of IMU trackers you are using.
settings-general-interface-discord_presence-label = Share activity on Discord
settings-general-interface-discord_presence-message = { $amount ->
[0] Sliming around
[one] Using 1 tracker
*[other] Using { $amount } trackers
}
## Serial settings
settings-serial = Serial Console
# This cares about multilines
settings-serial-description =
This is a live information feed for serial communication.
May be useful if you need to know the firmware is acting up.
May be useful to debug firmware or hardware issues.
settings-serial-connection_lost = Connection to serial lost, Reconnecting...
settings-serial-reboot = Reboot
settings-serial-factory_reset = Factory Reset
@@ -469,6 +480,8 @@ settings-serial-get_infos = Get Infos
settings-serial-serial_select = Select a serial port
settings-serial-auto_dropdown_item = Auto
settings-serial-get_wifi_scan = Get WiFi Scan
settings-serial-file_type = Plain text
settings-serial-save_logs = Save To File
## OSC router settings
settings-osc-router = OSC router
@@ -497,14 +510,17 @@ settings-osc-router-network-address-placeholder = IPV4 address
## OSC VRChat settings
settings-osc-vrchat = VRChat OSC Trackers
# This cares about multilines
settings-osc-vrchat-description =
Change VRChat-specific settings to receive headset (HMD) data and send
tracker data for FBT without SteamVR (ex. Quest standalone).
settings-osc-vrchat-description-v1 =
Change settings specific to the OSC Trackers standard used for sending
tracking data to applications without SteamVR (ex. Quest standalone).
Make sure to enable OSC in VRChat via the Action Menu under OSC > Enabled.
To allow receiving HMD and controller data from VRChat, go in your main menu's
settings under Tracking & IK > Allow Sending Head and Wrist VR Tracking OSC Data.
settings-osc-vrchat-enable = Enable
settings-osc-vrchat-enable-description = Toggle the sending and receiving of data.
settings-osc-vrchat-enable-label = Enable
settings-osc-vrchat-network = Network ports
settings-osc-vrchat-network-description = Set the ports for listening and sending data to VRChat.
settings-osc-vrchat-network-description-v1 = Set the ports for listening and sending data. Can be left untouched for VRChat.
settings-osc-vrchat-network-port_in =
.label = Port In
.placeholder = Port in (default: 9001)
@@ -512,7 +528,7 @@ settings-osc-vrchat-network-port_out =
.label = Port Out
.placeholder = Port out (default: 9000)
settings-osc-vrchat-network-address = Network address
settings-osc-vrchat-network-address-description = Choose which address to send out data to VRChat (check your Wi-Fi settings on your device).
settings-osc-vrchat-network-address-description-v1 = Choose which address to send out data to. Can be left untouched for VRChat.
settings-osc-vrchat-network-address-placeholder = VRChat ip address
settings-osc-vrchat-network-trackers = Trackers
settings-osc-vrchat-network-trackers-description = Toggle the sending of specific trackers via OSC.
@@ -553,6 +569,9 @@ settings-osc-vmc-vrm-file_select = Drag & drop a model to use, or <u>browse</u>
settings-osc-vmc-anchor_hip = Anchor at hips
settings-osc-vmc-anchor_hip-description = Anchor the tracking at the hips, useful for seated VTubing. If disabling, load a VRM model.
settings-osc-vmc-anchor_hip-label = Anchor at hips
settings-osc-vmc-mirror_tracking = Mirror tracking
settings-osc-vmc-mirror_tracking-description = Mirror the tracking horizontally.
settings-osc-vmc-mirror_tracking-label = Mirror tracking
## Setup/onboarding menu
onboarding-skip = Skip setup
@@ -677,6 +696,24 @@ onboarding-assign_trackers-assigned = { $assigned } of { $trackers ->
onboarding-assign_trackers-advanced = Show advanced assign locations
onboarding-assign_trackers-next = I assigned all the trackers
onboarding-assign_trackers-mirror_view = Mirror view
onboarding-assign_trackers-option-amount = { $trackersCount ->
[one] x{ $trackersCount }
*[other] x{ $trackersCount }
}
onboarding-assign_trackers-option-label = { $mode ->
[lower-body] Lower-Body Set
[core] Core Set
[enhanced-core] Enhanced Core Set
[full-body] Full-Body Set
*[all] All Trackers
}
onboarding-assign_trackers-option-description = { $mode ->
[lower-body] Minimum for VR full-body tracking
[core] + Enhanced spine tracking
[enhanced-core] + Foot rotation
[full-body] + Elbow tracking
*[all] All available tracker assignments
}
## Tracker assignment warnings
# Note for devs, number is used for representing boolean states per bit.
@@ -743,11 +780,11 @@ onboarding-choose_mounting = What mounting calibration method to use?
onboarding-choose_mounting-description = Mounting orientation corrects for the placement of trackers on your body.
onboarding-choose_mounting-auto_mounting = Automatic mounting
# Italized text
onboarding-choose_mounting-auto_mounting-label = Experimental
onboarding-choose_mounting-auto_mounting-label-v2 = Recommended
onboarding-choose_mounting-auto_mounting-description = This will automatically detect the mounting orientations for all of your trackers from 2 poses
onboarding-choose_mounting-manual_mounting = Manual mounting
# Italized text
onboarding-choose_mounting-manual_mounting-label = Recommended
onboarding-choose_mounting-manual_mounting-label-v2 = Might not be precise enough
onboarding-choose_mounting-manual_mounting-description = This will let you choose the mounting orientation manually for each tracker
# Multiline text
onboarding-choose_mounting-manual_modal-title = Are you sure you want to do
@@ -896,6 +933,7 @@ status_system-StatusSteamVRDisconnected = { $type ->
[steamvr_feeder] Currently not connected to the SlimeVR Feeder App.
}
status_system-StatusTrackerError = The { $trackerName } tracker has an error.
status_system-StatusUnassignedHMD = The VR headset should be assigned as a head tracker.
## Tray Menu
tray_menu-show = Show
+19
View File
@@ -0,0 +1,19 @@
#!/usr/bin/env node
import { promisify } from 'node:util';
import { exec as execCallback } from 'node:child_process';
const exec = promisify(execCallback);
const [commitHash, versionTag, gitClean] = await Promise.all([
exec('git rev-parse --verify --short HEAD').then((res) => res.stdout.trim()),
exec('git --no-pager tag --sort -taggerdate --points-at HEAD').then((res) =>
res.stdout.split('\n')[0].trim().substring(1)
),
// If not empty then it's not clean
exec('git status --porcelain').then((res) => (res.stdout ? false : true)),
]);
console.log(
JSON.stringify({
version: `${versionTag || `0.0.0-${commitHash}`}${gitClean ? '' : '-dirty'}`,
})
);
+14 -12
View File
@@ -3,11 +3,11 @@ name = "slimevr"
version = "0.0.0"
description = "SlimeVR GUI Application"
license = "MIT OR Apache-2.0"
repository = "https://github.com/SlimeVR/SlimeVR-Server"
license.workspace = true
repository.workspace = true
edition = "2021"
rust-version = "1.65"
edition.workspace = true
rust-version.workspace = true
default-run = "slimevr"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@@ -21,20 +21,20 @@ default = ["custom-protocol"]
custom-protocol = ["tauri/custom-protocol"]
[build-dependencies]
tauri-build = { version = "=2.0.0-beta.11", features = [] }
tauri-build = { version = "=2.0.0-beta.18", features = [] }
cfg_aliases = "0.2"
shadow-rs = "0.27"
[dependencies]
serde_json = "1"
serde = { version = "1", features = ["derive"] }
tauri = { version = "=2.0.0-beta.14", features = ["devtools", "tray-icon", "image-png"] }
tauri-runtime = "=2.0.0-beta.11"
tauri-plugin-dialog = "=2.0.0-beta.4"
tauri-plugin-fs = "=2.0.0-beta.4"
tauri-plugin-os = "=2.0.0-beta.3"
tauri-plugin-shell = "=2.0.0-beta.3"
tauri-plugin-store = "=2.0.0-beta.4"
tauri = { version = "=2.0.0-beta.23", features = ["devtools", "tray-icon", "image-png"] }
tauri-runtime = "=2.0.0-beta.19"
tauri-plugin-dialog = "=2.0.0-beta.10"
tauri-plugin-fs = "=2.0.0-beta.10"
tauri-plugin-os = "=2.0.0-beta.7"
tauri-plugin-shell = "=2.0.0-beta.8"
tauri-plugin-store = "=2.0.0-beta.9"
flexi_logger = "0.28"
log-panics = { version = "2", features = ["with-backtrace"] }
log = "0.4"
@@ -51,6 +51,8 @@ cfg-if = "1"
color-eyre = "0.6"
rfd = { version = "0.14", features = ["gtk3"], default-features = false }
dirs-next = "2.0.0"
discord-sdk = "0.3.6"
tokio = { version = "1.37.0", features = ["time"] }
[target.'cfg(windows)'.dependencies]
win32job = "1"
+5
View File
@@ -1,6 +1,11 @@
use cfg_aliases::cfg_aliases;
fn main() -> shadow_rs::SdResult<()> {
// Bypass for Nix script having libudev-zero and Tauri not liking it
if let Some(path) = option_env!("SLIMEVR_RUST_LD_LIBRARY_PATH") {
println!("cargo:rustc-env=LD_LIBRARY_PATH={path}");
}
tauri_build::build();
cfg_aliases! {
mobile: { any(target_os = "ios", target_os = "android") },
+3 -3
View File
@@ -1,13 +1,13 @@
[Desktop Entry]
Version=1.5
Categories=Game;Development;GTK;
Exec=slimevr
Icon=dev.slimevr.SlimeVR
Exec={{exec}}
Icon={{icon}}
Name=SlimeVR
GenericName=Full-body tracking
Comment=An app for facilitating full-body tracking in virtual reality
Keywords=FBT
Keywords=FBT;VR;Steam;VRChat;IMU
Terminal=false
Type=Application
+13 -5
View File
@@ -18,6 +18,7 @@ use crate::util::{
get_launch_path, show_error, valid_java_paths, Cli, JAVA_BIN, MINIMUM_JAVA_VERSION,
};
mod presence;
mod state;
mod tray;
mod util;
@@ -177,7 +178,11 @@ fn main() -> Result<()> {
erroring,
warning,
tray::update_translations,
tray::update_tray_text
tray::update_tray_text,
presence::discord_client_exists,
presence::update_presence,
presence::clear_presence,
presence::create_discord_client,
])
.setup(move |app| {
let window_state =
@@ -196,6 +201,8 @@ fn main() -> Result<()> {
.visible(true)
.decorations(false)
.fullscreen(false)
// This allows drag & drop via HTML5 for Windows
.disable_drag_drop_handler()
.build()?;
if window_state.is_old() {
window_state.update_window(&window.as_ref().window(), false)?;
@@ -204,7 +211,8 @@ fn main() -> Result<()> {
#[cfg(desktop)]
{
let handle = app.handle();
tray::create_tray(&handle)?;
tray::create_tray(handle)?;
presence::create_presence(handle)?;
}
app.manage(Mutex::new(window_state));
@@ -262,15 +270,15 @@ fn main() -> Result<()> {
}
}
// See https://github.com/tauri-apps/tauri/issues/4012#issuecomment-1449499149
#[cfg(windows)]
WindowEvent::Resized(_) => std::thread::sleep(std::time::Duration::from_nanos(1)),
// #[cfg(windows)]
// WindowEvent::Resized(_) => std::thread::sleep(std::time::Duration::from_nanos(1)),
_ => (),
})
.build(tauri_context);
match build_result {
Ok(app) => {
app.run(move |app_handle, event| match event {
RunEvent::ExitRequested { .. } => {
RunEvent::Exit => {
let window_state = app_handle.state::<Mutex<WindowState>>();
let lock = window_state.lock().unwrap();
let config_dir = app_handle.path().app_config_dir().unwrap();
+212
View File
@@ -0,0 +1,212 @@
use std::time::{Duration, SystemTime};
use color_eyre::{eyre::bail, Result};
use discord_sdk as ds;
use ds::wheel::{UserSpoke, UserState};
use tauri::{async_runtime::Mutex, AppHandle, Manager, Runtime, State};
const APP_ID: ds::AppId = 1237970689009647639;
pub struct DiscordClient {
pub discord: ds::Discord,
pub wheel: ds::wheel::Wheel,
}
pub struct DiscordTimestamp(SystemTime);
pub struct ExposedClient(Mutex<Option<DiscordClient>>);
async fn make_client(subs: ds::Subscriptions) -> Result<Option<DiscordClient>> {
let (wheel, handler) = ds::wheel::Wheel::new(Box::new(|err| {
log::error!(target: "discord_presence", "encountered a discord presence error: {err}");
}));
let mut user = wheel.user();
let discord =
ds::Discord::new(ds::DiscordApp::PlainId(APP_ID), subs, Box::new(handler))?;
log::debug!(target: "discord_presence", "waiting for handshake...");
let Ok(e) = tokio::time::timeout(Duration::from_secs(5), user.0.changed()).await
else {
return Ok(None);
};
e?;
let user = match &*user.0.borrow() {
ds::wheel::UserState::Connected(user) => user.clone(),
ds::wheel::UserState::Disconnected(err) => {
bail!("failed to connect to Discord: {err}");
}
};
log::info!(target: "discord_presence", "connected to Discord, local user name is {}", user.username);
Ok(Some(DiscordClient { discord, wheel }))
}
async fn client_exists(client: &State<'_, ExposedClient>) -> bool {
let lock = client.0.lock().await;
lock.is_some()
}
#[tauri::command]
pub async fn discord_client_exists(
client: State<'_, ExposedClient>,
) -> Result<bool, ()> {
Ok(client_exists(&client).await)
}
#[tauri::command]
pub async fn update_presence(
client: State<'_, ExposedClient>,
timestamp: State<'_, DiscordTimestamp>,
details: String,
state: Option<String>,
small_icon: Option<(String, String)>,
button: Option<ds::activity::Button>,
) -> Result<(), ()> {
if !client_exists(&client).await {
return Err(());
}
let rp = ds::activity::ActivityBuilder::default()
.details(details)
.start_timestamp(timestamp.0);
let rp = if let Some(state) = state {
rp.state(state)
} else {
rp
};
let rp = if let Some((id, desc)) = small_icon {
rp.assets(
ds::activity::Assets::default()
.large("icon".to_owned(), Some("SlimeVR".to_owned()))
.small(id, Some(desc)),
)
} else {
rp.assets(
ds::activity::Assets::default()
.large("icon".to_owned(), Some("SlimeVR".to_owned())),
)
};
let rp = if let Some(button) = button {
rp.button(button)
} else {
rp
};
let lock = client.0.lock().await;
lock.as_ref()
.unwrap()
.discord
.update_activity(rp)
.await
.map_err(|_e| ())?;
Ok(())
}
#[tauri::command]
pub async fn clear_presence(client: State<'_, ExposedClient>) -> Result<(), String> {
if !client_exists(&client).await {
return Err("Missing discord client".to_owned());
}
let lock = client.0.lock().await;
lock.as_ref()
.unwrap()
.discord
.clear_activity()
.await
.map_err(|e| e.to_string())?;
Ok(())
}
#[tauri::command]
pub async fn create_discord_client<R: Runtime>(
app: AppHandle<R>,
client: State<'_, ExposedClient>,
) -> Result<(), String> {
if client_exists(&client).await {
return Err("Trying to create a client when there is one already".to_owned());
}
let Some(discord_client) = make_client(ds::Subscriptions::ACTIVITY)
.await
.map_err(|e| e.to_string())?
else {
log::debug!(target: "discord_presence", "discord took too long to answer (probably not open)");
return Ok(());
};
let user_wheel = discord_client.wheel.user();
{
let mut lock = client.0.lock().await;
*lock = Some(discord_client);
}
tauri::async_runtime::spawn(async move {
drop_client_on_loss(app, user_wheel).await;
});
Ok(())
}
async fn drop_client_on_loss<R: Runtime>(
app: tauri::AppHandle<R>,
mut user_wheel: UserSpoke,
) {
while let Ok(_) = user_wheel.0.changed().await {
if let UserState::Disconnected(e) = &*user_wheel.0.borrow() {
match e {
ds::Error::NoConnection
| ds::Error::TimedOut
| ds::Error::Close(_)
| ds::Error::CorruptConnection => break,
_ => {
log::error!(target: "discord_presence", "unhandled discord error: {e}")
}
}
}
}
log::info!(target: "discord_presence", "lost connection to discord, dropping client...");
let mutex = app.state::<ExposedClient>();
let opt = {
let mut lock = mutex.0.lock().await;
lock.take()
};
let Some(client) = opt else {
return;
};
client.discord.disconnect().await;
}
pub fn create_presence<R: Runtime>(app: &tauri::AppHandle<R>) -> tauri::Result<()> {
app.manage(ExposedClient(Mutex::new(None)));
app.manage(DiscordTimestamp(SystemTime::now()));
{
let app = app.clone();
tauri::async_runtime::spawn(async move {
let client = make_client(ds::Subscriptions::ACTIVITY).await;
if let Err(e) = client {
log::error!(target: "discord_presence", "couldn't initialize discord client: {e}");
return;
}
let Some(client) = client.unwrap() else {
log::debug!(target: "discord_presence", "discord took too long to answer (probably not open)");
return;
};
let user_wheel = client.wheel.user();
{
let mutex = app.state::<ExposedClient>();
let mut lock = mutex.0.lock().await;
*lock = Some(client)
}
tauri::async_runtime::spawn(async move {
drop_client_on_loss(app, user_wheel).await;
});
});
}
Ok(())
}
+12 -3
View File
@@ -3,7 +3,7 @@ use std::{collections::HashMap, sync::Mutex};
use tauri::{
image::Image,
menu::{Menu, MenuBuilder, MenuItemBuilder, MenuItemKind},
tray::{ClickType, TrayIconBuilder},
tray::{MouseButton, MouseButtonState, TrayIconBuilder, TrayIconEvent},
AppHandle, Manager, Runtime, State,
};
@@ -100,15 +100,24 @@ pub fn create_tray<R: Runtime>(app: &tauri::AppHandle<R>) -> tauri::Result<()> {
}
_ => {}
})
.on_tray_icon_event(|tray, event| {
if event.click_type == ClickType::Left {
.on_tray_icon_event(|tray, event| match event {
TrayIconEvent::Click {
button,
button_state,
..
} if button == MouseButton::Left
&& button_state == MouseButtonState::Up =>
{
let app = tray.app_handle();
if let Some(window) = app.get_webview_window("main") {
let _ = window.show();
let _ = window.set_focus();
}
}
_ => {}
})
// We don't want this as we open the window on left click
.menu_on_left_click(false)
.build(app)?;
app.manage(TrayMenu(menu1));
+1 -1
View File
@@ -62,7 +62,7 @@ pub fn get_launch_path(cli: Cli) -> Option<PathBuf> {
let paths = [
cli.launch_from_path,
// AppImage passes the fakeroot in `APPDIR` env var.
env::var_os("APPDIR").map(PathBuf::from),
env::var_os("APPDIR").map(|a| PathBuf::from(a).join("usr/share/slimevr/")),
env::current_dir().ok(),
// getcwd in Mac can't be trusted, so let's get the executable's path
env::current_exe()
+15 -2
View File
@@ -14,10 +14,23 @@
],
"files": {
"/usr/share/slimevr/slimevr.jar": "../../server/desktop/build/libs/slimevr.jar"
}
},
"desktopTemplate": "./dev.slimevr.SlimeVR.desktop"
},
"appimage": {
"bundleMediaFramework": true
"bundleMediaFramework": true,
"files": {
"/usr/share/slimevr/slimevr.jar": "../../server/desktop/build/libs/slimevr.jar"
}
},
"rpm": {
"depends": [
"java-17-openjdk"
],
"files": {
"/usr/share/slimevr/slimevr.jar": "../../server/desktop/build/libs/slimevr.jar"
},
"desktopTemplate": "./dev.slimevr.SlimeVR.desktop"
}
},
"category": "DeveloperTool",
+15 -18
View File
@@ -6,11 +6,11 @@ import {
Routes,
} from 'react-router-dom';
import { Home } from './components/home/Home';
import { MainLayoutRoute } from './components/MainLayout';
import { MainLayout } from './components/MainLayout';
import { AppContextProvider } from './components/providers/AppContext';
import { GeneralSettings } from './components/settings/pages/GeneralSettings';
import { Serial } from './components/settings/pages/Serial';
import { SettingsLayoutRoute } from './components/settings/SettingsLayout';
import { SettingsLayout } from './components/settings/SettingsLayout';
import {
useProvideWebsocketApi,
WebSocketApiContext,
@@ -54,6 +54,7 @@ import { error, log } from './utils/logging';
import { AppLayout } from './AppLayout';
import { Preload } from './components/Preload';
import { UnknownDeviceModal } from './components/UnknownDeviceModal';
import { useDiscordPresence } from './hooks/discord-presence';
export const GH_REPO = 'SlimeVR/SlimeVR-Server';
export const VersionContext = createContext('');
@@ -62,6 +63,7 @@ export const SLIMEVR_DISCORD = 'https://discord.gg/slimevr';
function Layout() {
const { isMobile } = useBreakpoint('mobile');
useDiscordPresence();
return (
<>
@@ -73,33 +75,33 @@ function Layout() {
<Route
path="/"
element={
<MainLayoutRoute isMobile={isMobile}>
<MainLayout isMobile={isMobile}>
<Home />
</MainLayoutRoute>
</MainLayout>
}
/>
<Route
path="/vr-mode"
element={
<MainLayoutRoute isMobile={isMobile}>
<MainLayout isMobile={isMobile}>
<VRModePage />
</MainLayoutRoute>
</MainLayout>
}
/>
<Route
path="/tracker/:trackernum/:deviceid"
element={
<MainLayoutRoute background={false} isMobile={isMobile}>
<MainLayout background={false} isMobile={isMobile}>
<TrackerSettingsPage />
</MainLayoutRoute>
</MainLayout>
}
/>
<Route
path="/settings"
element={
<SettingsLayoutRoute>
<SettingsLayout>
<Outlet />
</SettingsLayoutRoute>
</SettingsLayout>
}
>
<Route path="trackers" element={<GeneralSettings />} />
@@ -198,15 +200,10 @@ export default function App() {
if (isTauri) {
useEffect(() => {
os.type()
.then((type) => document.body.classList.add(type.toLowerCase()))
.catch(error);
const type = os.type();
document.body.classList.add(type.toLowerCase());
return () => {
os.type()
.then((type) => document.body.classList.remove(type.toLowerCase()))
.catch(error);
};
return () => document.body.classList.remove(type.toLowerCase());
}, []);
}
+22
View File
@@ -0,0 +1,22 @@
.main-layout {
display: grid;
grid-template:
't t' var(--topbar-h)
's c' calc(100% - var(--topbar-h))
/ var(--navbar-w) calc(100% - var(--navbar-w));
&:has(.widgets) {
grid-template:
't t t' var(--topbar-h)
's c w' calc(100% - var(--topbar-h))
/ var(--navbar-w) calc(100% - var(--navbar-w) - var(--widget-w)) var(--widget-w);
}
@screen mobile {
grid-template:
't' var(--topbar-h)
'c' calc(100% - var(--topbar-h) - var(--navbar-h))
's' calc(var(--navbar-h))
/ 100%;
}
}
+28 -35
View File
@@ -6,13 +6,13 @@ import {
RpcMessage,
SettingsRequestT,
} from 'solarxr-protocol';
import { useElemSize, useLayout } from '@/hooks/layout';
import { Navbar } from './Navbar';
import { TopBar } from './TopBar';
import { useWebsocketAPI } from '@/hooks/websocket-api';
import { WidgetsComponent } from './WidgetsComponent';
import './MainLayout.scss';
export function MainLayoutRoute({
export function MainLayout({
children,
background = true,
widgets = true,
@@ -23,9 +23,6 @@ export function MainLayoutRoute({
isMobile?: boolean;
widgets?: boolean;
}) {
const { height, ref: navRef } = useElemSize<HTMLDivElement>();
const { layoutHeight, ref } = useLayout<HTMLDivElement>();
const { layoutWidth, ref: refw } = useLayout<HTMLDivElement>();
const { sendRPCPacket } = useWebsocketAPI();
const [ProportionsLastPageOpen, setProportionsLastPageOpen] = useState(true);
@@ -61,37 +58,33 @@ export function MainLayoutRoute({
});
return (
<>
<TopBar></TopBar>
<div
ref={ref}
className="flex-grow"
style={{ height: layoutHeight - height }}
>
<div className="flex h-full xs:pb-3">
{!isMobile && <Navbar></Navbar>}
<div
className="flex gap-2 xs:pr-3 w-full"
ref={refw}
style={{ minWidth: layoutWidth }}
>
<div
className={classNames(
'flex flex-col rounded-xl w-full overflow-clip mobile:overflow-y-auto',
background && 'bg-background-70'
)}
>
{children}
</div>
{!isMobile && widgets && (
<div className="flex flex-col px-2 min-w-[274px] w-[274px] gap-2 pt-2 rounded-xl overflow-y-auto bg-background-70">
<WidgetsComponent></WidgetsComponent>
</div>
)}
</div>
<div className="">
<div className="main-layout w-full h-screen">
<div style={{ gridArea: 't' }}>
<TopBar></TopBar>
</div>
<div ref={navRef}>{isMobile && <Navbar></Navbar>}</div>
<div style={{ gridArea: 's' }} className="overflow-y-auto">
<Navbar></Navbar>
</div>
<div
style={{ gridArea: 'c' }}
className={classNames(
'overflow-y-auto mr-2 my-2 mobile:m-0',
'flex flex-col rounded-xl',
background && 'bg-background-70'
)}
>
{children}
</div>
{!isMobile && widgets && (
<div
style={{ gridArea: 'w' }}
className="overflow-y-auto mr-2 my-2 rounded-xl bg-background-70 flex flex-col gap-2 p-2 widgets"
>
<WidgetsComponent></WidgetsComponent>
</div>
)}
</div>
</>
</div>
);
}
+1 -1
View File
@@ -110,7 +110,7 @@ export function Navbar() {
<MainLinks></MainLinks>
</div>
) : (
<div className="flex flex-col px-2 pt-2">
<div className="flex flex-col h-full p-2 gap-2">
<div className="flex flex-col flex-grow gap-2">
<MainLinks></MainLinks>
</div>
+1 -1
View File
@@ -160,7 +160,7 @@ export function TopBar({
<div
className="cursor-pointer"
onClick={() => {
const url = document.body.classList.contains('windows_nt')
const url = document.body.classList.contains('windows')
? 'https://slimevr.dev/download'
: `https://github.com/${GH_REPO}/releases/latest`;
open(url).catch(() => window.open(url, '_blank'));
+1 -1
View File
@@ -24,7 +24,7 @@ export function TrackersStillOnModal({
const { l10n } = useLocalization();
return (
<BaseModal isOpen={isOpen} onRequestClose={cancel}>
<BaseModal isOpen={isOpen} onRequestClose={cancel} important>
<div className="flex flex-col gap-3">
<>
<div className="flex flex-col items-center gap-3 fill-accent-background-20">
+1 -1
View File
@@ -36,7 +36,7 @@ export function TrayOrExitModal({
});
return (
<BaseModal isOpen={isOpen} onRequestClose={cancel}>
<BaseModal isOpen={isOpen} onRequestClose={cancel} important>
<form
className="flex flex-col gap-3 w-[27rem]"
onSubmit={handleSubmit((form) => accept(form.exitType === '1'))}
+1 -1
View File
@@ -51,7 +51,7 @@ export function VersionUpdateModal() {
<Button
variant="primary"
onClick={async () => {
const url = document.body.classList.contains('windows_nt')
const url = document.body.classList.contains('windows')
? 'https://slimevr.dev/download'
: `https://github.com/${GH_REPO}/releases/latest`;
await open(url).catch(() => window.open(url, '_blank'));
+4 -1
View File
@@ -4,10 +4,12 @@ import ReactModal from 'react-modal';
export function BaseModal({
children,
important = false,
...props
}: {
isOpen: boolean;
children: ReactNode;
important?: boolean;
} & ReactModal.Props) {
return (
<ReactModal
@@ -18,7 +20,8 @@ export function BaseModal({
props.overlayClassName ||
classNames(
'fixed top-0 right-0 left-0 bottom-0 flex flex-col justify-center',
'items-center w-full h-full bg-background-90 bg-opacity-60 z-20'
'items-center w-full h-full bg-background-90 bg-opacity-60',
important ? 'z-50' : 'z-40'
)
}
className={
@@ -173,8 +173,7 @@ export function BodyInteractions({
({ top, left, height, width, id, hidden, buttonOffset }) => (
<div
key={id}
hidden={hidden}
className="absolute z-10"
className={classNames('absolute z-10', hidden && 'hidden')}
onClick={() => onSelectRole((BodyPart as any)[id])}
style={{
top: top + height / 2 - dotsSize / 2 + buttonOffset.top,
+1 -1
View File
@@ -84,7 +84,7 @@ export function Button({
};
return classNames(
variantsMap[variant],
'focus:ring-4 text-center relative',
'focus:ring-4 text-center relative flex items-center justify-center',
{
'rounded-full p-2 text-center min-h-[35px] min-w-[35px]': rounded,
'rounded-md px-5 py-2.5': !rounded,
+26 -12
View File
@@ -1,9 +1,8 @@
import classNames from 'classnames';
import { useEffect, useRef, useState } from 'react';
import { ReactNode, useEffect, useLayoutEffect, useRef, useState } from 'react';
import { Control, Controller, UseControllerProps } from 'react-hook-form';
import { a11yClick } from '@/utils/a11y';
import { createPortal } from 'react-dom';
import { useElemSize } from '@/hooks/layout';
import { ArrowDownIcon } from './icon/ArrowIcons';
interface DropdownProps {
@@ -30,7 +29,8 @@ type DropdownItemsProps = Pick<
};
export interface DropdownItem {
label: string;
label?: string;
component?: ReactNode;
value: string;
fontName?: string;
}
@@ -49,7 +49,17 @@ export function DropdownItems({
onSelectItem,
onBackdropClick,
}: DropdownItemsProps) {
const { height, width, ref } = useElemSize<HTMLDivElement>();
const ref = useRef<HTMLDivElement | null>(null);
const [itemBounds, setItemBounds] = useState<DOMRect>();
const updateBounds = () => {
if (!ref.current) return;
setItemBounds(ref.current?.getBoundingClientRect());
};
useLayoutEffect(() => {
updateBounds();
}, []);
const GAP = 8;
@@ -67,18 +77,20 @@ export function DropdownItems({
variant == 'primary' && 'bg-background-60',
variant == 'secondary' && 'bg-background-70',
variant == 'tertiary' && 'bg-accent-background-30',
height == 0 && 'opacity-0' // Avoid flicker while the component find its position
itemBounds?.height == 0 && 'opacity-0' // Avoid flicker while the component find its position
)}
style={{
maxHeight: maxHeight,
left:
alignment === 'left'
? dropdownBounds.left
: dropdownBounds.left + dropdownBounds.width - width,
: dropdownBounds.left +
dropdownBounds.width -
(itemBounds?.width ?? 0),
top:
direction == 'down'
? dropdownBounds.bottom + GAP
: dropdownBounds.top - height - GAP,
: dropdownBounds.top - (itemBounds?.height ?? 0) - GAP,
minWidth: display === 'block' ? dropdownBounds.width : 'inherit',
}}
>
@@ -87,7 +99,7 @@ export function DropdownItems({
<li
style={item.fontName ? { fontFamily: item.fontName } : {}}
className={classNames(
'py-2 px-4 min-w-max cursor-pointer',
'py-2 px-4 min-w-max cursor-pointer first-of-type:*:pointer-events-none',
variant == 'primary' &&
'checked-hover:bg-background-50 text-background-20 ' +
'checked-hover:text-background-10',
@@ -108,7 +120,7 @@ export function DropdownItems({
tabIndex={0}
data-checked={item.value === value}
>
{item.label}
{item.component || item.label}
</li>
))}
</ul>
@@ -184,12 +196,14 @@ export function Dropdown({
onKeyDown={(ev) => a11yClick(ev) && setOpen((open) => !open)}
tabIndex={0}
>
<div className="flex-grow text-standard">
{items.find((i) => i.value == value)?.label || placeholder}
<div className="flex-grow text-standard first:pointer-events-none">
{items.find((i) => i.value == value)?.component ||
items.find((i) => i.value == value)?.label ||
placeholder}
</div>
<div
className={classNames(
'ml-2 fill-background-10',
'ml-2 fill-background-10 flex items-center',
direction == 'up' && 'rotate-180',
direction == 'down' && 'rotate-0'
)}
+1 -1
View File
@@ -57,7 +57,7 @@ export const FileInputInside = forwardRef<
className={classNames(
'flex justify-center w-full h-32 px-4 transition border-2',
'border-background-20 border-dashed rounded-md appearance-none cursor-pointer',
'hover:border-background-40 focus:outline-none'
'hover:border-accent-background-20 focus:outline-none'
)}
onClick={() => typeof ref !== 'function' && ref?.current?.click()}
onDragOver={(ev) => ev.preventDefault()}
+7 -4
View File
@@ -1,6 +1,7 @@
import classNames from 'classnames';
import { Control, Controller } from 'react-hook-form';
import { Typography } from './Typography';
import { ReactNode } from 'react';
export function Radio({
control,
@@ -8,15 +9,17 @@ export function Radio({
label,
value,
description,
children,
// input props
disabled,
...props
}: {
control: Control<any>;
name: string;
label: string;
label?: string;
value: string;
description?: string | null;
children?: ReactNode;
} & React.HTMLProps<HTMLInputElement>) {
return (
<Controller
@@ -27,7 +30,7 @@ export function Radio({
className={classNames('w-full p-3 rounded-md flex gap-3 border-2', {
'border-accent-background-30': value == checked,
'border-transparent': value != checked,
'bg-background-60 cursor-pointer': !disabled,
'bg-background-60 cursor-pointer hover:bg-background-50': !disabled,
'bg-background-80 cursor-not-allowed': disabled,
})}
>
@@ -45,8 +48,8 @@ export function Radio({
checked={value == checked}
{...props}
/>
<div className="flex flex-col gap-2">
<Typography bold>{label}</Typography>
<div className="flex flex-col gap-2 pointer-events-none">
{children ? children : <Typography bold>{label}</Typography>}
{description && (
<Typography variant="standard" color="secondary">
{description}
@@ -1,3 +1,4 @@
import { useConfig } from '@/hooks/config';
import classNames from 'classnames';
import { createElement, ReactNode, useMemo } from 'react';
@@ -8,6 +9,7 @@ export function Typography({
whitespace = 'whitespace-normal',
children,
italic = false,
truncate = false,
textAlign,
}: {
variant?:
@@ -18,6 +20,7 @@ export function Typography({
| 'mobile-title';
bold?: boolean;
italic?: boolean;
truncate?: boolean;
block?: boolean;
color?: 'primary' | 'secondary' | string;
whitespace?:
@@ -45,6 +48,7 @@ export function Typography({
};
return tags[variant];
}, [variant]);
const { config } = useConfig();
return createElement(
tag,
@@ -65,6 +69,9 @@ export function Typography({
whitespace,
textAlign,
italic && 'italic',
truncate && 'leading-3 text-ellipsis',
truncate && (config?.textSize ?? 12) > 12 && 'line-clamp-1',
truncate && (config?.textSize ?? 12) <= 12 && 'line-clamp-2',
]),
},
children || []
+1 -1
View File
@@ -51,7 +51,7 @@ export function Home() {
<div className="h-full overflow-y-auto">
<div
className={classNames(
'px-2 pt-4 gap-3 w-full grid md:grid-cols-2 mobile:grid-cols-1',
'px-2 pt-2 gap-3 w-full grid md:grid-cols-2 mobile:grid-cols-1',
filteredStatuses.filter(([, status]) => status.prioritized)
.length === 0 && 'hidden'
)}
+209 -122
View File
@@ -1,19 +1,29 @@
import { useMemo } from 'react';
import { useCallback, useMemo } from 'react';
import { BodyPart } from 'solarxr-protocol';
import { FlatDeviceTracker } from '@/hooks/app';
import { AssignMode } from '@/hooks/config';
import { useTrackers } from '@/hooks/tracker';
import { BodyInteractions } from '@/components/commons/BodyInteractions';
import { TrackerPartCard } from '@/components/tracker/TrackerPartCard';
import { BodyPartError } from './pages/trackers-assign/TrackerAssignment';
import { SIDES } from '@/components/commons/PersonFrontIcon';
export const ARMS_PARTS = new Set([
BodyPart.LEFT_UPPER_ARM,
BodyPart.RIGHT_UPPER_ARM,
BodyPart.LEFT_LOWER_ARM,
BodyPart.RIGHT_LOWER_ARM,
]);
export const LEGS_PARTS = new Set([
BodyPart.LEFT_UPPER_LEG,
BodyPart.RIGHT_UPPER_LEG,
BodyPart.LEFT_LOWER_LEG,
BodyPart.RIGHT_LOWER_LEG,
]);
export const LOWER_BODY = new Set([
BodyPart.LEFT_FOOT,
BodyPart.RIGHT_FOOT,
BodyPart.LEFT_LOWER_LEG,
BodyPart.RIGHT_LOWER_LEG,
BodyPart.LEFT_UPPER_LEG,
BodyPart.RIGHT_UPPER_LEG,
...LEGS_PARTS,
]);
export const SPINE_PARTS = [
BodyPart.UPPER_CHEST,
@@ -44,22 +54,63 @@ export const ASSIGNMENT_RULES: Partial<
// Also don't warn if no legs.
};
export const ASSIGNMENT_MODES: Record<AssignMode, BodyPart[]> = {
// x5
[AssignMode.LowerBody]: [BodyPart.CHEST, ...LEGS_PARTS],
// x6 (5 + 1)
[AssignMode.Core]: [BodyPart.CHEST, BodyPart.HIP, ...LEGS_PARTS],
// x8 (5 + 3)
[AssignMode.EnhancedCore]: [
BodyPart.CHEST,
BodyPart.HIP,
...LEGS_PARTS,
BodyPart.LEFT_FOOT,
BodyPart.RIGHT_FOOT,
],
// x10 (7 + 3)
[AssignMode.FullBody]: [
BodyPart.CHEST,
BodyPart.HIP,
BodyPart.LEFT_UPPER_ARM,
BodyPart.RIGHT_UPPER_ARM,
...LEGS_PARTS,
BodyPart.LEFT_FOOT,
BodyPart.RIGHT_FOOT,
],
// special case with all body parts
[AssignMode.All]: [
BodyPart.HEAD,
BodyPart.NECK,
BodyPart.LEFT_SHOULDER,
BodyPart.RIGHT_SHOULDER,
BodyPart.LEFT_HAND,
BodyPart.RIGHT_HAND,
BodyPart.LEFT_FOOT,
BodyPart.RIGHT_FOOT,
...SPINE_PARTS,
...ARMS_PARTS,
...LEGS_PARTS,
],
};
export function BodyAssignment({
advanced,
assignMode,
mirror,
onRoleSelected,
rolesWithErrors = {},
highlightedRoles = [],
onlyAssigned = false,
width,
dotSize,
}: {
advanced: boolean;
assignMode: AssignMode;
mirror: boolean;
onlyAssigned?: boolean;
rolesWithErrors?: Partial<Record<BodyPart, BodyPartError>>;
highlightedRoles?: BodyPart[];
onRoleSelected: (role: BodyPart) => void;
width?: number;
dotSize?: number;
}) {
const { useAssignedTrackers } = useTrackers();
@@ -94,18 +145,26 @@ export function BodyAssignment({
const left = +!mirror;
const right = +mirror;
const hasBodyPart = useCallback(
(part: BodyPart) =>
assignMode === AssignMode.All ||
ASSIGNMENT_MODES[assignMode].indexOf(part) > -1,
[assignMode]
);
return (
<>
<BodyInteractions
width={width}
mirror={mirror}
dotsSize={dotSize}
assignedRoles={assignedRoles}
highlightedRoles={highlightedRoles}
onSelectRole={onRoleSelected}
leftControls={
<div className="flex flex-col justify-between h-full text-right">
<div className="flex flex-col gap-2">
{advanced && (
{hasBodyPart(BodyPart.HEAD) && (
<TrackerPartCard
onlyAssigned={onlyAssigned}
roleError={rolesWithErrors[BodyPart.HEAD]?.label}
@@ -115,7 +174,8 @@ export function BodyAssignment({
direction="right"
/>
)}
{advanced && (
{hasBodyPart(BodyPart.NECK) && (
<TrackerPartCard
onlyAssigned={onlyAssigned}
roleError={rolesWithErrors[BodyPart.NECK]?.label}
@@ -126,9 +186,8 @@ export function BodyAssignment({
/>
)}
</div>
<div className="flex flex-col gap-2">
{advanced && (
{hasBodyPart(SIDES[left].shoulder) && (
<TrackerPartCard
onlyAssigned={onlyAssigned}
roleError={rolesWithErrors[SIDES[left].shoulder]?.label}
@@ -138,26 +197,31 @@ export function BodyAssignment({
direction="right"
/>
)}
<TrackerPartCard
onlyAssigned={onlyAssigned}
roleError={rolesWithErrors[SIDES[left].upperArm]?.label}
td={trackerPartGrouped[SIDES[left].upperArm]}
role={SIDES[left].upperArm}
onClick={() => onRoleSelected(SIDES[left].upperArm)}
direction="right"
/>
{hasBodyPart(SIDES[left].upperArm) && (
<TrackerPartCard
onlyAssigned={onlyAssigned}
roleError={rolesWithErrors[SIDES[left].upperArm]?.label}
td={trackerPartGrouped[SIDES[left].upperArm]}
role={SIDES[left].upperArm}
onClick={() => onRoleSelected(SIDES[left].upperArm)}
direction="right"
/>
)}
</div>
<div className="flex flex-col gap-2">
<TrackerPartCard
onlyAssigned={onlyAssigned}
roleError={rolesWithErrors[SIDES[left].lowerArm]?.label}
td={trackerPartGrouped[SIDES[left].lowerArm]}
role={SIDES[left].lowerArm}
onClick={() => onRoleSelected(SIDES[left].lowerArm)}
direction="right"
/>
{hasBodyPart(SIDES[left].lowerArm) && (
<TrackerPartCard
onlyAssigned={onlyAssigned}
roleError={rolesWithErrors[SIDES[left].lowerArm]?.label}
td={trackerPartGrouped[SIDES[left].lowerArm]}
role={SIDES[left].lowerArm}
onClick={() => onRoleSelected(SIDES[left].lowerArm)}
direction="right"
/>
)}
{advanced && (
{hasBodyPart(SIDES[left].hand) && (
<TrackerPartCard
onlyAssigned={onlyAssigned}
roleError={rolesWithErrors[SIDES[left].hand]?.label}
@@ -169,37 +233,44 @@ export function BodyAssignment({
)}
</div>
<div className="flex flex-col gap-2">
<TrackerPartCard
onlyAssigned={onlyAssigned}
roleError={rolesWithErrors[SIDES[left].upperLeg]?.label}
td={trackerPartGrouped[SIDES[left].upperLeg]}
role={SIDES[left].upperLeg}
onClick={() => onRoleSelected(SIDES[left].upperLeg)}
direction="right"
/>
{hasBodyPart(SIDES[left].upperLeg) && (
<TrackerPartCard
onlyAssigned={onlyAssigned}
roleError={rolesWithErrors[SIDES[left].upperLeg]?.label}
td={trackerPartGrouped[SIDES[left].upperLeg]}
role={SIDES[left].upperLeg}
onClick={() => onRoleSelected(SIDES[left].upperLeg)}
direction="right"
/>
)}
<TrackerPartCard
onlyAssigned={onlyAssigned}
roleError={rolesWithErrors[SIDES[left].lowerLeg]?.label}
td={trackerPartGrouped[SIDES[left].lowerLeg]}
role={SIDES[left].lowerLeg}
onClick={() => onRoleSelected(SIDES[left].lowerLeg)}
direction="right"
/>
<TrackerPartCard
onlyAssigned={onlyAssigned}
roleError={rolesWithErrors[SIDES[left].foot]?.label}
td={trackerPartGrouped[SIDES[left].foot]}
role={SIDES[left].foot}
onClick={() => onRoleSelected(SIDES[left].foot)}
direction="right"
/>
{hasBodyPart(SIDES[left].lowerLeg) && (
<TrackerPartCard
onlyAssigned={onlyAssigned}
roleError={rolesWithErrors[SIDES[left].lowerLeg]?.label}
td={trackerPartGrouped[SIDES[left].lowerLeg]}
role={SIDES[left].lowerLeg}
onClick={() => onRoleSelected(SIDES[left].lowerLeg)}
direction="right"
/>
)}
{hasBodyPart(SIDES[left].foot) && (
<TrackerPartCard
onlyAssigned={onlyAssigned}
roleError={rolesWithErrors[SIDES[left].foot]?.label}
td={trackerPartGrouped[SIDES[left].foot]}
role={SIDES[left].foot}
onClick={() => onRoleSelected(SIDES[left].foot)}
direction="right"
/>
)}
</div>
</div>
}
rightControls={
<div className="flex flex-col justify-between h-full">
{advanced && (
{hasBodyPart(BodyPart.UPPER_CHEST) && (
<TrackerPartCard
onlyAssigned={onlyAssigned}
roleError={rolesWithErrors[BodyPart.UPPER_CHEST]?.label}
@@ -210,17 +281,19 @@ export function BodyAssignment({
/>
)}
<TrackerPartCard
onlyAssigned={onlyAssigned}
roleError={rolesWithErrors[BodyPart.CHEST]?.label}
td={trackerPartGrouped[BodyPart.CHEST]}
role={BodyPart.CHEST}
onClick={() => onRoleSelected(BodyPart.CHEST)}
direction="left"
/>
{hasBodyPart(BodyPart.CHEST) && (
<TrackerPartCard
onlyAssigned={onlyAssigned}
roleError={rolesWithErrors[BodyPart.CHEST]?.label}
td={trackerPartGrouped[BodyPart.CHEST]}
role={BodyPart.CHEST}
onClick={() => onRoleSelected(BodyPart.CHEST)}
direction="left"
/>
)}
<div className="flex flex-col gap-2">
{advanced && (
{hasBodyPart(SIDES[right].shoulder) && (
<TrackerPartCard
onlyAssigned={onlyAssigned}
roleError={rolesWithErrors[SIDES[right].shoulder]?.label}
@@ -231,45 +304,53 @@ export function BodyAssignment({
/>
)}
<TrackerPartCard
onlyAssigned={onlyAssigned}
roleError={rolesWithErrors[SIDES[right].upperArm]?.label}
td={trackerPartGrouped[SIDES[right].upperArm]}
role={SIDES[right].upperArm}
onClick={() => onRoleSelected(SIDES[right].upperArm)}
direction="left"
/>
{hasBodyPart(SIDES[right].upperArm) && (
<TrackerPartCard
onlyAssigned={onlyAssigned}
roleError={rolesWithErrors[SIDES[right].upperArm]?.label}
td={trackerPartGrouped[SIDES[right].upperArm]}
role={SIDES[right].upperArm}
onClick={() => onRoleSelected(SIDES[right].upperArm)}
direction="left"
/>
)}
</div>
<div className="flex flex-col gap-2">
<TrackerPartCard
onlyAssigned={onlyAssigned}
roleError={rolesWithErrors[BodyPart.WAIST]?.label}
td={trackerPartGrouped[BodyPart.WAIST]}
onClick={() => onRoleSelected(BodyPart.WAIST)}
role={BodyPart.WAIST}
direction="left"
/>
<TrackerPartCard
onlyAssigned={onlyAssigned}
roleError={rolesWithErrors[BodyPart.HIP]?.label}
td={trackerPartGrouped[BodyPart.HIP]}
onClick={() => onRoleSelected(BodyPart.HIP)}
role={BodyPart.HIP}
direction="left"
/>
{hasBodyPart(BodyPart.WAIST) && (
<TrackerPartCard
onlyAssigned={onlyAssigned}
roleError={rolesWithErrors[BodyPart.WAIST]?.label}
td={trackerPartGrouped[BodyPart.WAIST]}
onClick={() => onRoleSelected(BodyPart.WAIST)}
role={BodyPart.WAIST}
direction="left"
/>
)}
{hasBodyPart(BodyPart.HIP) && (
<TrackerPartCard
onlyAssigned={onlyAssigned}
roleError={rolesWithErrors[BodyPart.HIP]?.label}
td={trackerPartGrouped[BodyPart.HIP]}
onClick={() => onRoleSelected(BodyPart.HIP)}
role={BodyPart.HIP}
direction="left"
/>
)}
</div>
<div className="flex flex-col gap-2">
<TrackerPartCard
onlyAssigned={onlyAssigned}
roleError={rolesWithErrors[SIDES[right].lowerArm]?.label}
td={trackerPartGrouped[SIDES[right].lowerArm]}
role={SIDES[right].lowerArm}
onClick={() => onRoleSelected(SIDES[right].lowerArm)}
direction="left"
/>
{advanced && (
{hasBodyPart(SIDES[right].lowerArm) && (
<TrackerPartCard
onlyAssigned={onlyAssigned}
roleError={rolesWithErrors[SIDES[right].lowerArm]?.label}
td={trackerPartGrouped[SIDES[right].lowerArm]}
role={SIDES[right].lowerArm}
onClick={() => onRoleSelected(SIDES[right].lowerArm)}
direction="left"
/>
)}
{hasBodyPart(SIDES[right].hand) && (
<TrackerPartCard
onlyAssigned={onlyAssigned}
roleError={rolesWithErrors[SIDES[right].hand]?.label}
@@ -280,33 +361,39 @@ export function BodyAssignment({
/>
)}
</div>
<div className="flex flex-col gap-2">
<TrackerPartCard
onlyAssigned={onlyAssigned}
roleError={rolesWithErrors[SIDES[right].upperLeg]?.label}
td={trackerPartGrouped[SIDES[right].upperLeg]}
role={SIDES[right].upperLeg}
onClick={() => onRoleSelected(SIDES[right].upperLeg)}
direction="left"
/>
{hasBodyPart(SIDES[right].upperLeg) && (
<TrackerPartCard
onlyAssigned={onlyAssigned}
roleError={rolesWithErrors[SIDES[right].upperLeg]?.label}
td={trackerPartGrouped[SIDES[right].upperLeg]}
role={SIDES[right].upperLeg}
onClick={() => onRoleSelected(SIDES[right].upperLeg)}
direction="left"
/>
)}
<TrackerPartCard
onlyAssigned={onlyAssigned}
roleError={rolesWithErrors[SIDES[right].lowerLeg]?.label}
td={trackerPartGrouped[SIDES[right].lowerLeg]}
role={SIDES[right].lowerLeg}
onClick={() => onRoleSelected(SIDES[right].lowerLeg)}
direction="left"
/>
<TrackerPartCard
onlyAssigned={onlyAssigned}
roleError={rolesWithErrors[SIDES[right].foot]?.label}
td={trackerPartGrouped[SIDES[right].foot]}
role={SIDES[right].foot}
onClick={() => onRoleSelected(SIDES[right].foot)}
direction="left"
/>
{hasBodyPart(SIDES[right].lowerLeg) && (
<TrackerPartCard
onlyAssigned={onlyAssigned}
roleError={rolesWithErrors[SIDES[right].lowerLeg]?.label}
td={trackerPartGrouped[SIDES[right].lowerLeg]}
role={SIDES[right].lowerLeg}
onClick={() => onRoleSelected(SIDES[right].lowerLeg)}
direction="left"
/>
)}
{hasBodyPart(SIDES[right].foot) && (
<TrackerPartCard
onlyAssigned={onlyAssigned}
roleError={rolesWithErrors[SIDES[right].foot]?.label}
td={trackerPartGrouped[SIDES[right].foot]}
role={SIDES[right].foot}
onClick={() => onRoleSelected(SIDES[right].foot)}
direction="left"
/>
)}
</div>
</div>
}
@@ -0,0 +1,11 @@
.onboarding-layout {
display: grid;
grid-template:
't' var(--topbar-h)
'c' calc(100% - var(--topbar-h))
/ 100%;
@screen mobile {
--topbar-h: 74px;
}
}
@@ -1,26 +1,23 @@
import { ReactNode, useState } from 'react';
import { useLayout } from '@/hooks/layout';
import { useOnboarding } from '@/hooks/onboarding';
import { MainLayoutRoute } from '@/components/MainLayout';
import { MainLayout } from '@/components/MainLayout';
import { TopBar } from '@/components/TopBar';
import { useBreakpoint } from '@/hooks/breakpoint';
import { SkipSetupButton } from './SkipSetupButton';
import { SkipSetupWarningModal } from './SkipSetupWarningModal';
import './OnboardingLayout.scss';
export function OnboardingLayout({ children }: { children: ReactNode }) {
const { layoutHeight, ref } = useLayout<HTMLDivElement>();
const { isMobile } = useBreakpoint('mobile');
const { state, skipSetup } = useOnboarding();
const [skipWarning, setSkipWarning] = useState(false);
return !state.alonePage ? (
<>
<TopBar progress={state.progress}></TopBar>
<div
ref={ref}
className="flex-grow relative"
style={{ height: layoutHeight }}
>
<div className="onboarding-layout h-full">
<div style={{ gridArea: 't' }}>
<TopBar progress={state.progress}></TopBar>
</div>
<div style={{ gridArea: 'c' }} className="mt-2 relative">
<div className="absolute top-12 mobile:top-0 right-2 z-50">
<SkipSetupButton
visible={true}
@@ -28,17 +25,17 @@ export function OnboardingLayout({ children }: { children: ReactNode }) {
onClick={() => setSkipWarning(true)}
></SkipSetupButton>
</div>
{children}
<div className="h-full w-full overflow-y-auto">{children}</div>
<SkipSetupWarningModal
accept={skipSetup}
onClose={() => setSkipWarning(false)}
isOpen={skipWarning}
></SkipSetupWarningModal>
</div>
</>
</div>
) : (
<MainLayoutRoute widgets={false} isMobile={isMobile}>
<div className="flex-grow xs:pt-10 mobile:pt-2">{children}</div>
</MainLayoutRoute>
<MainLayout widgets={false} isMobile={isMobile}>
{children}
</MainLayout>
);
}
@@ -2,12 +2,16 @@ import { Localized, useLocalization } from '@fluent/react';
import { useOnboarding } from '@/hooks/onboarding';
import { Button } from '@/components/commons/Button';
import { Typography } from '@/components/commons/Typography';
import { useMemo, useState } from 'react';
import { useEffect, useMemo, useRef, useState } from 'react';
import { ProgressBar } from '@/components/commons/ProgressBar';
import { LoaderIcon, SlimeState } from '@/components/commons/icon/LoaderIcon';
import { useCountdown } from '@/hooks/countdown';
import classNames from 'classnames';
import { TaybolIcon } from '@/components/commons/icon/TaybolIcon';
import { useTrackers } from '@/hooks/tracker';
import { useRestCalibrationTrackers } from '@/hooks/imu-logic';
import { averageVector, Vector3FromVec3fT } from '@/maths/vector3';
import { Vector3 } from 'three';
export enum CalibrationStatus {
SUCCESS,
@@ -17,6 +21,7 @@ export enum CalibrationStatus {
}
export const IMU_CALIBRATION_TIME = 4;
const ACCEL_TOLERANCE = 0.2; // m/s^2
export function CalibrationTutorialPage() {
const { l10n } = useLocalization();
@@ -24,10 +29,50 @@ export function CalibrationTutorialPage() {
const [calibrationStatus, setCalibrationStatus] = useState(
CalibrationStatus.WAITING
);
const { timer, isCounting, startCountdown } = useCountdown({
const { timer, isCounting, startCountdown, abortCountdown } = useCountdown({
duration: IMU_CALIBRATION_TIME,
onCountdownEnd: () => setCalibrationStatus(CalibrationStatus.SUCCESS),
});
const { useConnectedIMUTrackers } = useTrackers();
const connectedIMUTrackers = useConnectedIMUTrackers();
const restCalibrationTrackers =
useRestCalibrationTrackers(connectedIMUTrackers);
const [rested, setRested] = useState(false);
const lastValueMap = useRef(new Map<number, Vector3[]>());
useEffect(() => {
const accelLength = restCalibrationTrackers.every((x) => {
if (
x.tracker.trackerId?.trackerNum === undefined ||
x.tracker.trackerId.deviceId?.id === undefined ||
!x.tracker.linearAcceleration
)
return false;
const trackerId =
x.tracker.trackerId.trackerNum + (x.tracker.trackerId.trackerNum << 8);
const lastValues = lastValueMap.current.get(trackerId) ?? [];
lastValueMap.current.set(trackerId, lastValues);
const vec3 = Vector3FromVec3fT(x.tracker.linearAcceleration);
if (lastValues.length > 5) {
lastValues.shift();
const avg = averageVector(lastValues).lengthSq();
lastValues.push(vec3);
return vec3.lengthSq() <= avg + ACCEL_TOLERANCE ** 2;
}
lastValues.push(vec3);
return false;
});
setRested(accelLength || restCalibrationTrackers.length === 0);
}, [restCalibrationTrackers]);
useEffect(() => {
if (calibrationStatus === CalibrationStatus.CALIBRATING && !rested) {
setCalibrationStatus(CalibrationStatus.ERROR);
abortCountdown();
}
}, [calibrationStatus, rested]);
const progressBarClass = useMemo(() => {
switch (calibrationStatus) {
@@ -101,7 +146,8 @@ export function CalibrationTutorialPage() {
progress={
isCounting
? (IMU_CALIBRATION_TIME - timer) / IMU_CALIBRATION_TIME
: calibrationStatus === CalibrationStatus.SUCCESS
: calibrationStatus === CalibrationStatus.SUCCESS ||
calibrationStatus === CalibrationStatus.ERROR
? 1
: 0
}
@@ -127,9 +173,11 @@ export function CalibrationTutorialPage() {
setCalibrationStatus(CalibrationStatus.CALIBRATING);
startCountdown();
}}
disabled={isCounting}
hidden={CalibrationStatus.SUCCESS === calibrationStatus}
className="xs:ml-auto"
disabled={isCounting || !rested}
className={classNames(
'xs:ml-auto',
CalibrationStatus.SUCCESS === calibrationStatus && 'hidden'
)}
>
{l10n.getString('onboarding-calibration_tutorial-calibrate')}
</Button>
@@ -148,7 +196,7 @@ export function CalibrationTutorialPage() {
</div>
<div className="mobile:hidden flex self-center w-[32rem] mobile:absolute">
<div className="stroke-none xs:fill-background-10 mobile:fill-background-50 mobile:blur-sm">
<TaybolIcon width="500"></TaybolIcon>
<TaybolIcon width="450"></TaybolIcon>
</div>
</div>
</div>
@@ -0,0 +1,26 @@
:root {
--connect-tracker-layout-sidebar: 350px;
--connect-tracker-layout-top: 20px;
@screen lg {
--connect-tracker-layout-sidebar: 400px;
}
}
.connect-tracker-layout {
display: grid;
grid-template:
's t' var(--connect-tracker-layout-top)
's c' calc(100% - var(--connect-tracker-layout-top))
/ calc(var(--connect-tracker-layout-sidebar)) calc(100% - var(
--connect-tracker-layout-sidebar
));
@screen mobile {
grid-template:
's' auto
't' auto
'c' auto
/ 100%;
}
}
@@ -11,7 +11,6 @@ import {
WifiProvisioningStatus,
WifiProvisioningStatusResponseT,
} from 'solarxr-protocol';
import { useLayout } from '@/hooks/layout';
import { useOnboarding } from '@/hooks/onboarding';
import { useTrackers } from '@/hooks/tracker';
import { useWebsocketAPI } from '@/hooks/websocket-api';
@@ -22,10 +21,8 @@ import { ProgressBar } from '@/components/commons/ProgressBar';
import { TipBox } from '@/components/commons/TipBox';
import { Typography } from '@/components/commons/Typography';
import { TrackerCard } from '@/components/tracker/TrackerCard';
import { useBnoExists } from '@/hooks/imu-logic';
import { useBreakpoint } from '@/hooks/breakpoint';
const BOTTOM_HEIGHT = 80;
import { useIsRestCalibrationTrackers } from '@/hooks/imu-logic';
import './ConnectTracker.scss';
const statusLabelMap = {
[WifiProvisioningStatus.NONE]:
@@ -58,9 +55,7 @@ const statusProgressMap = {
};
export function ConnectTrackersPage() {
const { isMobile } = useBreakpoint('mobile');
const { l10n } = useLocalization();
const { layoutHeight, ref } = useLayout<HTMLDivElement>();
const { useConnectedIMUTrackers } = useTrackers();
const { applyProgress, state } = useOnboarding();
const navigate = useNavigate();
@@ -72,7 +67,7 @@ export function ConnectTrackersPage() {
const connectedIMUTrackers = useConnectedIMUTrackers();
const bnoExists = useBnoExists(connectedIMUTrackers);
const bnoExists = useIsRestCalibrationTrackers(connectedIMUTrackers);
useEffect(() => {
if (!state.wifi) {
@@ -146,146 +141,123 @@ export function ConnectTrackersPage() {
);
return (
<div className="flex flex-col h-full items-center px-4 pb-4">
<div className="flex gap-10 mobile:flex-col w-full xs:max-w-7xl">
<div className="flex flex-col w-full xs:max-w-sm">
<Typography variant="main-title">
{l10n.getString('onboarding-connect_tracker-title')}
</Typography>
<Typography color="secondary">
{l10n.getString('onboarding-connect_tracker-description-p0-v1')}
</Typography>
<Typography color="secondary">
{l10n.getString('onboarding-connect_tracker-description-p1-v1')}
</Typography>
<div className="flex flex-col gap-2 py-5">
{/* <ArrowLink
to="/onboarding/connect"
direction="right"
variant="boxed"
>
I have other types of trackers
</ArrowLink> */}
<ArrowLink
to="/settings/serial"
state={{ SerialPort: 'Auto' }}
direction="right"
variant={state.alonePage ? 'boxed-2' : 'boxed'}
>
{l10n.getString('onboarding-connect_tracker-issue-serial')}
</ArrowLink>
</div>
<Localized
id={currentTip}
elems={{ em: <em className="italic"></em>, b: <b></b> }}
<div className="connect-tracker-layout h-full">
<div style={{ gridArea: 's' }} className="p-4">
<Typography variant="main-title">
{l10n.getString('onboarding-connect_tracker-title')}
</Typography>
<Typography color="secondary">
{l10n.getString('onboarding-connect_tracker-description-p0-v1')}
</Typography>
<Typography color="secondary">
{l10n.getString('onboarding-connect_tracker-description-p1-v1')}
</Typography>
<div className="flex flex-col gap-2 py-5">
<ArrowLink
to="/settings/serial"
state={{ SerialPort: 'Auto' }}
direction="right"
variant={state.alonePage ? 'boxed-2' : 'boxed'}
>
<TipBox>Conditional tip</TipBox>
</Localized>
{l10n.getString('onboarding-connect_tracker-issue-serial')}
</ArrowLink>
</div>
<Localized
id={currentTip}
elems={{ em: <em className="italic"></em>, b: <b></b> }}
>
<TipBox>Conditional tip</TipBox>
</Localized>
<div
className={classNames(
'rounded-xl h-24 flex gap-2 p-3 lg:w-full mt-4 relative',
state.alonePage ? 'bg-background-60' : 'bg-background-70',
isError && 'border-2 border-status-critical'
)}
>
<div
className={classNames(
'rounded-xl h-24 flex gap-2 p-3 lg:w-full mt-4 relative',
state.alonePage ? 'bg-background-60' : 'bg-background-70',
isError && 'border-2 border-status-critical'
'flex flex-col justify-center fill-background-10 absolute',
'right-5 bottom-8'
)}
>
<div
className={classNames(
'flex flex-col justify-center fill-background-10 absolute',
'right-5 bottom-8'
)}
>
<LoaderIcon slimeState={slimeStatus}></LoaderIcon>
</div>
<div className="flex flex-col grow self-center">
<Typography bold>
{l10n.getString('onboarding-connect_tracker-usb')}
</Typography>
<div className="flex fill-background-10 gap-1">
{/* <SpinIcon
youSpinMeRightRoundBabyRightRound={!isError}
></SpinIcon> */}
<Typography color="secondary">
{l10n.getString(statusLabelMap[provisioningStatus])}
</Typography>
</div>
<ProgressBar
progress={statusProgressMap[provisioningStatus]}
height={14}
animated={true}
colorClass={progressBarClass}
></ProgressBar>
</div>
<LoaderIcon slimeState={slimeStatus}></LoaderIcon>
</div>
<div className="flex flex-row mt-4 gap-3">
<Button
variant="secondary"
state={{ alonePage: state.alonePage }}
to="/onboarding/wifi-creds"
>
{state.alonePage
? l10n.getString('onboarding-connect_tracker-back')
: l10n.getString('onboarding-previous_step')}
</Button>
<Button
variant="primary"
to={
state.alonePage
? '/'
: bnoExists
? '/onboarding/calibration-tutorial'
: '/onboarding/assign-tutorial'
}
className="ml-auto"
>
{l10n.getString('onboarding-connect_tracker-next')}
</Button>
<div className="flex flex-col grow self-center">
<Typography bold>
{l10n.getString('onboarding-connect_tracker-usb')}
</Typography>
<div className="flex fill-background-10 gap-1">
<Typography color="secondary">
{l10n.getString(statusLabelMap[provisioningStatus])}
</Typography>
</div>
<ProgressBar
progress={statusProgressMap[provisioningStatus]}
height={14}
animated={true}
colorClass={progressBarClass}
></ProgressBar>
</div>
</div>
<div className="flex flex-col xs:flex-grow">
<Typography color="secondary" bold>
{l10n.getString('onboarding-connect_tracker-connected_trackers', {
amount: connectedIMUTrackers.length,
})}
</Typography>
<div
className="overflow-y-scroll mt-2"
ref={ref}
style={
isMobile && state.alonePage
? { height: layoutHeight - BOTTOM_HEIGHT }
: { height: layoutHeight }
}
<div className="flex flex-row mt-4 gap-3">
<Button
variant="secondary"
state={{ alonePage: state.alonePage }}
to="/onboarding/wifi-creds"
>
<div className="grid lg:grid-cols-2 md:grid-cols-1 gap-2 pr-1">
{Array.from({
...connectedIMUTrackers,
length: Math.max(connectedIMUTrackers.length, 1),
}).map((tracker, index) => (
<div key={index}>
{!tracker && (
<div
className={classNames(
'rounded-xl h-16 animate-pulse',
state.alonePage
? 'bg-background-80'
: 'bg-background-70'
)}
></div>
{state.alonePage
? l10n.getString('onboarding-connect_tracker-back')
: l10n.getString('onboarding-previous_step')}
</Button>
<Button
variant="primary"
to={
state.alonePage
? '/'
: bnoExists
? '/onboarding/calibration-tutorial'
: '/onboarding/assign-tutorial'
}
className="ml-auto"
>
{l10n.getString('onboarding-connect_tracker-next')}
</Button>
</div>
</div>
<div style={{ gridArea: 't' }} className="flex items-center px-5">
<Typography color="secondary" bold>
{l10n.getString('onboarding-connect_tracker-connected_trackers', {
amount: connectedIMUTrackers.length,
})}
</Typography>
</div>
<div style={{ gridArea: 'c' }} className="xs:overflow-y-auto">
<div className="grid lg:grid-cols-2 md:grid-cols-1 gap-2 pr-1 mx-5 py-4">
{Array.from({
...connectedIMUTrackers,
length: Math.max(connectedIMUTrackers.length, 1),
}).map((tracker, index) => (
<div key={index}>
{!tracker && (
<div
className={classNames(
'rounded-xl h-16 animate-pulse',
state.alonePage ? 'bg-background-80' : 'bg-background-70'
)}
{tracker && (
<TrackerCard
tracker={tracker.tracker}
device={tracker.device}
smol
></TrackerCard>
)}
</div>
))}
></div>
)}
{tracker && (
<TrackerCard
tracker={tracker.tracker}
device={tracker.device}
smol
></TrackerCard>
)}
</div>
</div>
))}
</div>
</div>
</div>
@@ -134,9 +134,11 @@ export function ResetTutorialPage() {
</Button>
<Button
hidden={curIndex + 1 >= order.length}
variant="secondary"
className="ml-auto"
className={classNames(
'ml-auto',
curIndex + 1 >= order.length && 'hidden'
)}
onClick={() => {
setCurIndex(curIndex + 1);
}}
@@ -6,7 +6,7 @@ import { Input } from '@/components/commons/Input';
import { Typography } from '@/components/commons/Typography';
import classNames from 'classnames';
import { useTrackers } from '@/hooks/tracker';
import { useBnoExists } from '@/hooks/imu-logic';
import { useIsRestCalibrationTrackers } from '@/hooks/imu-logic';
export function WifiCredsPage() {
const { l10n } = useLocalization();
@@ -17,7 +17,7 @@ export function WifiCredsPage() {
applyProgress(0.2);
const bnoExists = useBnoExists(connectedIMUTrackers);
const isRestCalibration = useIsRestCalibrationTrackers(connectedIMUTrackers);
return (
<form
@@ -97,7 +97,7 @@ export function WifiCredsPage() {
variant="secondary"
className={state.alonePage ? 'opacity-0' : ''}
to={
bnoExists
isRestCalibration
? '/onboarding/calibration-tutorial'
: '/onboarding/assign-tutorial'
}
@@ -3,7 +3,7 @@ import { useOnboarding } from '@/hooks/onboarding';
import { Button } from '@/components/commons/Button';
import { Typography } from '@/components/commons/Typography';
import { useTrackers } from '@/hooks/tracker';
import { useBnoExists } from '@/hooks/imu-logic';
import { useIsRestCalibrationTrackers } from '@/hooks/imu-logic';
import { StickerSlime } from './StickerSlime';
import { TrackerArrow } from './TrackerArrow';
import { ExtensionArrow } from './ExtensionArrow';
@@ -13,7 +13,7 @@ export function AssignmentTutorialPage() {
const { applyProgress } = useOnboarding();
const { useConnectedIMUTrackers } = useTrackers();
const connectedIMUTrackers = useConnectedIMUTrackers();
const bnoExists = useBnoExists(connectedIMUTrackers);
const isRestCalibration = useIsRestCalibrationTrackers(connectedIMUTrackers);
applyProgress(0.46);
@@ -67,7 +67,7 @@ export function AssignmentTutorialPage() {
<Button
variant="secondary"
to={
bnoExists
isRestCalibration
? '/onboarding/calibration-tutorial'
: '/onboarding/wifi-creds'
}
@@ -66,11 +66,11 @@ export function ManualProportionsPage() {
return (
<>
<div className="flex flex-col gap-5 h-full items-center w-full xs:justify-center overflow-y-auto relative">
<div className="flex flex-col gap-5 h-full items-center w-full xs:justify-center relative">
<div className="flex flex-col w-full h-full xs:max-w-5xl xs:justify-center">
<div className="flex gap-8 justify-center h-full xs:items-center">
<div className="flex flex-col w-full xs:max-w-2xl gap-3 items-center mobile:justify-around">
<div className="flex flex-col">
<div className="flex flex-col mx-4">
<Typography variant="main-title">
{l10n.getString('onboarding-manual_proportions-title')}
</Typography>
@@ -105,7 +105,7 @@ export function CheckHeight({
</Typography>
</Localized>
<div className="flex flex-row items-center mt-2 gap-2">
<div className="flex flex-row items-center mt-2 gap-2 mobile:flex-col">
<Button
variant="primary"
onClick={startCountdown}
@@ -7,6 +7,7 @@ import { useLocalization } from '@fluent/react';
import { P, match } from 'ts-pattern';
import { AutoboneErrorModal } from './AutoboneErrorModal';
import { PlayCircleIcon } from '@/components/commons/icon/PlayIcon';
import { useDebouncedEffect } from '@/hooks/timeout';
export function Recording({
nextStep,
@@ -52,6 +53,14 @@ export function Recording({
setPaused(videoRef.current.paused);
}
useDebouncedEffect(
() => {
if (paused) videoRef.current?.pause();
},
[paused],
250
);
useEffect(() => {
if (!active && !paused) {
toggleVideo();
@@ -154,7 +163,7 @@ export function Recording({
</div>
<video
preload=""
preload="auto"
ref={videoRef}
src="/videos/autobone.webm"
className="min-w-[12rem] w-[12rem]"
@@ -5,6 +5,7 @@ import { Typography } from '@/components/commons/Typography';
import { useLocalization } from '@fluent/react';
import { useEffect, useRef, useState } from 'react';
import { PlayCircleIcon } from '@/components/commons/icon/PlayIcon';
import { useDebouncedEffect } from '@/hooks/timeout';
export function StartRecording({
nextStep,
@@ -33,6 +34,14 @@ export function StartRecording({
setPaused(videoRef.current.paused);
}
useDebouncedEffect(
() => {
if (paused) videoRef.current?.pause();
},
[paused],
250
);
useEffect(() => {
if (!active && !paused) toggleVideo();
}, [active]);
@@ -87,7 +96,7 @@ export function StartRecording({
</div>
<video
preload=""
preload="auto"
ref={videoRef}
src="/videos/autobone.webm"
className="min-w-[12rem] w-[12rem]"
@@ -1,4 +1,4 @@
import { useEffect, useMemo, useState } from 'react';
import { useMemo, useState } from 'react';
import { AssignTrackerRequestT, BodyPart, RpcMessage } from 'solarxr-protocol';
import { FlatDeviceTracker } from '@/hooks/app';
import { useOnboarding } from '@/hooks/onboarding';
@@ -13,14 +13,14 @@ import { MountingSelectionMenu } from './MountingSelectionMenu';
import { useLocalization } from '@fluent/react';
import { useBreakpoint } from '@/hooks/breakpoint';
import { Quaternion } from 'three';
import { defaultConfig, useConfig } from '@/hooks/config';
import { AssignMode, defaultConfig, useConfig } from '@/hooks/config';
export function ManualMountingPage() {
const { isMobile } = useBreakpoint('mobile');
const { l10n } = useLocalization();
const { applyProgress, state } = useOnboarding();
const { sendRPCPacket } = useWebsocketAPI();
const { setConfig, config } = useConfig();
const { config } = useConfig();
const [selectedRole, setSelectRole] = useState<BodyPart>(BodyPart.NONE);
@@ -29,10 +29,6 @@ export function ManualMountingPage() {
const { useAssignedTrackers } = useTrackers();
const assignedTrackers = useAssignedTrackers();
useEffect(() => {
setConfig({ doneManualMounting: true });
}, []);
const trackerPartGrouped = useMemo(
() =>
assignedTrackers.reduce<{ [key: number]: FlatDeviceTracker[] }>(
@@ -104,7 +100,7 @@ export function ManualMountingPage() {
width={isMobile ? 160 : undefined}
mirror={config?.mirrorView ?? defaultConfig.mirrorView}
onlyAssigned={true}
advanced={true}
assignMode={AssignMode.All}
onRoleSelected={setSelectRole}
></BodyAssignment>
</div>
@@ -5,18 +5,12 @@ import { SkipSetupWarningModal } from '@/components/onboarding/SkipSetupWarningM
import classNames from 'classnames';
import { Typography } from '@/components/commons/Typography';
import { Button } from '@/components/commons/Button';
import { TryManualFirstModal } from './TryManualFirstModal';
import { useConfig } from '@/hooks/config';
import { useNavigate } from 'react-router-dom';
export function MountingChoose() {
const { l10n } = useLocalization();
const { applyProgress, skipSetup, state } = useOnboarding();
const navigate = useNavigate();
const { config, setConfig } = useConfig();
const [animated, setAnimated] = useState(false);
const [skipWarning, setSkipWarning] = useState(false);
const [manualModal, setManualModal] = useState(false);
applyProgress(0.65);
@@ -58,7 +52,7 @@ export function MountingChoose() {
</Typography>
<Typography variant="vr-accessible" italic>
{l10n.getString(
'onboarding-choose_mounting-auto_mounting-label'
'onboarding-choose_mounting-auto_mounting-label-v2'
)}
</Typography>
</div>
@@ -71,17 +65,8 @@ export function MountingChoose() {
</div>
</div>
<Button
variant={!state.alonePage ? 'secondary' : 'tertiary'}
to={
config?.doneManualMounting
? '/onboarding/mounting/auto'
: undefined
}
onClick={
!config?.doneManualMounting
? () => setManualModal(true)
: undefined
}
variant="primary"
to={'/onboarding/mounting/auto'}
className="self-start mt-auto"
state={{ alonePage: state.alonePage }}
>
@@ -115,7 +100,7 @@ export function MountingChoose() {
</Typography>
<Typography variant="vr-accessible" italic>
{l10n.getString(
'onboarding-choose_mounting-manual_mounting-label'
'onboarding-choose_mounting-manual_mounting-label-v2'
)}
</Typography>
</div>
@@ -129,7 +114,7 @@ export function MountingChoose() {
</div>
<Button
variant="primary"
variant={!state.alonePage ? 'secondary' : 'tertiary'}
to="/onboarding/mounting/manual"
className="self-start mt-auto"
state={{ alonePage: state.alonePage }}
@@ -152,14 +137,6 @@ export function MountingChoose() {
)}
</div>
</div>
<TryManualFirstModal
isOpen={manualModal}
accept={() => {
setConfig({ doneManualMounting: true });
navigate('/onboarding/mounting/auto');
}}
cancel={() => setManualModal(false)}
></TryManualFirstModal>
<SkipSetupWarningModal
accept={skipSetup}
onClose={() => setSkipWarning(false)}
@@ -1,12 +1,10 @@
import classNames from 'classnames';
import { MouseEventHandler } from 'react';
import ReactModal from 'react-modal';
import { useElemSize, useLayout } from '@/hooks/layout';
import { Button } from '@/components/commons/Button';
import { Typography } from '@/components/commons/Typography';
import { useLocalization } from '@fluent/react';
import { FootIcon } from '@/components/commons/icon/FootIcon';
import { rotationToQuatMap } from '@/maths/quaternion';
import { rotationToQuatMap, similarQuaternions } from '@/maths/quaternion';
import { Quaternion } from 'three';
import { SlimeUpIcon } from '@/components/commons/icon/SlimeUpIcon';
import { BodyPart } from 'solarxr-protocol';
@@ -113,14 +111,18 @@ export function MountingBodyPartIcon({
}
function PieSliceOfFeet({
onClick,
direction,
onDirectionSelected,
currRotation,
id,
d,
noText = false,
trackerTransform,
trackerWidth = 10,
}: {
onClick?: MouseEventHandler<SVGGElement>;
direction: Quaternion;
onDirectionSelected: (direction: Quaternion) => void;
currRotation?: Quaternion;
id: string;
d: string;
noText?: boolean;
@@ -131,7 +133,7 @@ function PieSliceOfFeet({
return (
<g
onClick={onClick}
onClick={() => onDirectionSelected(direction)}
className={classNames('group fill-background-10 stroke-background-10')}
>
<path
@@ -150,7 +152,12 @@ function PieSliceOfFeet({
</text>
<g
transform={trackerTransform}
className="fill-none stroke-none group-hover:fill-accent-background-20"
className={classNames(
'stroke-none group-hover:fill-accent-background-20',
currRotation && similarQuaternions(currRotation, direction)
? 'fill-background-90'
: 'fill-none'
)}
>
<SlimeUpIcon width={trackerWidth}></SlimeUpIcon>
</g>
@@ -163,17 +170,15 @@ export function MountingSelectionMenu({
onClose,
onDirectionSelected,
bodyPart,
currRotation,
}: {
isOpen: boolean;
onClose: () => void;
onDirectionSelected: (direction: Quaternion) => void;
bodyPart?: BodyPart;
currRotation?: Quaternion;
}) {
const { l10n } = useLocalization();
const { ref: refTrackers, layoutHeight: trackersHeight } =
useLayout<HTMLDivElement>();
const { ref: refOptions, height: optionsHeight } =
useElemSize<HTMLDivElement>();
return (
<ReactModal
@@ -182,104 +187,101 @@ export function MountingSelectionMenu({
shouldCloseOnEsc
onRequestClose={onClose}
overlayClassName={classNames(
'fixed top-0 right-0 left-0 bottom-0 flex flex-col items-center w-full h-full bg-black bg-opacity-90 z-20'
'fixed top-0 right-0 left-0 bottom-0 flex flex-col items-center w-full h-full bg-background-90 bg-opacity-90 z-20'
)}
className={classNames(
'focus:ring-transparent focus:ring-offset-transparent focus:outline-transparent outline-none mt-20 z-10 px-2'
'focus:ring-transparent focus:ring-offset-transparent focus:outline-transparent outline-none mt-20 z-10'
)}
>
<div className="flex w-full h-full flex-col ">
<Typography variant="main-title" bold>
<div className="flex flex-col p-4">
<Typography variant="main-title" bold textAlign="text-center">
{l10n.getString('mounting_selection_menu')}
</Typography>
<div
className="flex w-full flex-col flex-grow items-center gap-3 xs:justify-center"
ref={refTrackers}
style={{ height: trackersHeight - optionsHeight }}
>
<div className="flex justify-center items-center gap-6 w-full">
<svg
width="400"
viewBox="0 0 250 250"
className="fill-background-40"
>
<g transform="translate(80, 0)" className="fill-background-10">
<MountingBodyPartIcon width={100} bodyPart={bodyPart} />
</g>
<g strokeWidth="4" className="stroke-background-90">
<PieSliceOfFeet
d="M0 0-89 44A99 99 0 0 1-89-44Z"
onClick={() => onDirectionSelected(rotationToQuatMap.LEFT)}
id="tracker-rotation-left"
trackerTransform="translate(75, 0) scale(-1, 1)"
></PieSliceOfFeet>
<PieSliceOfFeet
d="M0 0-89-44A99 99 0 0 1-44-89Z"
onClick={() =>
onDirectionSelected(rotationToQuatMap.FRONT_LEFT)
}
id="tracker-rotation_left_front"
noText={true}
trackerTransform="translate(-2, 175) rotate(-135)"
trackerWidth={7}
></PieSliceOfFeet>
<PieSliceOfFeet
onClick={() => onDirectionSelected(rotationToQuatMap.FRONT)}
d="M0 0-44-89A99 99 0 0 1 44-89Z"
id="tracker-rotation-front"
trackerTransform="translate(0, 75) rotate(-90)"
></PieSliceOfFeet>
<PieSliceOfFeet
d="M0 0 44-89A99 99 0 0 1 89-44Z"
onClick={() =>
onDirectionSelected(rotationToQuatMap.FRONT_RIGHT)
}
id="tracker-rotation-front_right"
noText={true}
trackerTransform="translate(73, 0) rotate(-45)"
trackerWidth={7}
></PieSliceOfFeet>
<PieSliceOfFeet
d="M0 0 89-44A99 99 0 0 1 89 44Z"
onClick={() => onDirectionSelected(rotationToQuatMap.RIGHT)}
id="tracker-rotation-right"
trackerTransform="translate(175,0)"
></PieSliceOfFeet>
<PieSliceOfFeet
d="M0 0 89 44A99 99 0 0 1 44 89Z"
onClick={() =>
onDirectionSelected(rotationToQuatMap.BACK_RIGHT)
}
id="tracker-rotation-back_right"
noText={true}
trackerTransform="translate(252, 75) rotate(45)"
trackerWidth={7}
></PieSliceOfFeet>
<PieSliceOfFeet
d="M0 0 44 89A99 99 0 0 1-44 89Z"
onClick={() => onDirectionSelected(rotationToQuatMap.BACK)}
id="tracker-rotation-back"
trackerTransform="translate(250, 175) rotate(90)"
></PieSliceOfFeet>
<PieSliceOfFeet
d="M0 0-44 89A99 99 0 0 1-89 44Z"
onClick={() =>
onDirectionSelected(rotationToQuatMap.BACK_LEFT)
}
id="tracker-rotation-back_left"
noText={true}
trackerTransform="translate(177, 250) rotate(135)"
trackerWidth={7}
></PieSliceOfFeet>
</g>
</svg>
</div>
<div className="flex w-full flex-col flex-grow items-center gap-3 justify-center">
<svg width="400" viewBox="0 0 250 250" className="fill-background-40">
<g transform="translate(80, 0)" className="fill-background-10">
<MountingBodyPartIcon width={100} bodyPart={bodyPart} />
</g>
<g strokeWidth="4" className="stroke-background-90">
<PieSliceOfFeet
d="M0 0-89 44A99 99 0 0 1-89-44Z"
direction={rotationToQuatMap.LEFT}
onDirectionSelected={onDirectionSelected}
currRotation={currRotation}
id="tracker-rotation-left"
trackerTransform="translate(75, 0) scale(-1, 1)"
></PieSliceOfFeet>
<PieSliceOfFeet
d="M0 0-89-44A99 99 0 0 1-44-89Z"
direction={rotationToQuatMap.FRONT_LEFT}
onDirectionSelected={onDirectionSelected}
currRotation={currRotation}
id="tracker-rotation_left_front"
noText={true}
trackerTransform="translate(-2, 175) rotate(-135)"
trackerWidth={7}
></PieSliceOfFeet>
<PieSliceOfFeet
d="M0 0-44-89A99 99 0 0 1 44-89Z"
direction={rotationToQuatMap.FRONT}
onDirectionSelected={onDirectionSelected}
currRotation={currRotation}
id="tracker-rotation-front"
trackerTransform="translate(0, 75) rotate(-90)"
></PieSliceOfFeet>
<PieSliceOfFeet
d="M0 0 44-89A99 99 0 0 1 89-44Z"
direction={rotationToQuatMap.FRONT_RIGHT}
onDirectionSelected={onDirectionSelected}
currRotation={currRotation}
id="tracker-rotation-front_right"
noText={true}
trackerTransform="translate(73, 0) rotate(-45)"
trackerWidth={7}
></PieSliceOfFeet>
<PieSliceOfFeet
d="M0 0 89-44A99 99 0 0 1 89 44Z"
direction={rotationToQuatMap.RIGHT}
onDirectionSelected={onDirectionSelected}
currRotation={currRotation}
id="tracker-rotation-right"
trackerTransform="translate(175,0)"
></PieSliceOfFeet>
<PieSliceOfFeet
d="M0 0 89 44A99 99 0 0 1 44 89Z"
direction={rotationToQuatMap.BACK_RIGHT}
onDirectionSelected={onDirectionSelected}
currRotation={currRotation}
id="tracker-rotation-back_right"
noText={true}
trackerTransform="translate(252, 75) rotate(45)"
trackerWidth={7}
></PieSliceOfFeet>
<PieSliceOfFeet
d="M0 0 44 89A99 99 0 0 1-44 89Z"
direction={rotationToQuatMap.BACK}
onDirectionSelected={onDirectionSelected}
currRotation={currRotation}
id="tracker-rotation-back"
trackerTransform="translate(250, 175) rotate(90)"
></PieSliceOfFeet>
<PieSliceOfFeet
d="M0 0-44 89A99 99 0 0 1-89 44Z"
direction={rotationToQuatMap.BACK_LEFT}
onDirectionSelected={onDirectionSelected}
currRotation={currRotation}
id="tracker-rotation-back_left"
noText={true}
trackerTransform="translate(177, 250) rotate(135)"
trackerWidth={7}
></PieSliceOfFeet>
</g>
</svg>
</div>
</div>
<div
className="flex w-full justify-between absolute bottom-0 left-0 p-10 z-0"
onClick={onClose}
ref={refOptions}
>
<div className="flex flex-col justify-end pointer-events-auto">
<Button variant="primary" onClick={onClose}>
@@ -1,64 +0,0 @@
import { BaseModal } from '@/components/commons/BaseModal';
import { Button } from '@/components/commons/Button';
import { Typography } from '@/components/commons/Typography';
import { Localized, useLocalization } from '@fluent/react';
export function TryManualFirstModal({
isOpen = true,
cancel,
accept,
}: {
/**
* Is the parent/sibling component opened?
*/
isOpen: boolean;
/**
* Function to trigger when they want to do automatic anyways
*/
accept: () => void;
/**
* Function to trigger when they agree to do manual
*/
cancel?: () => void;
}) {
const { l10n } = useLocalization();
return (
<BaseModal isOpen={isOpen} onRequestClose={cancel}>
<div className="flex flex-col gap-3">
<>
<div className="flex flex-col items-center gap-3 fill-accent-background-20">
<div className="flex flex-col items-center gap-2">
<Typography
variant="main-title"
whitespace="whitespace-pre"
textAlign="text-center"
>
{l10n.getString(
'onboarding-choose_mounting-manual_modal-title'
)}
</Typography>
<div className="w-[30vw] min-w-fit">
<Localized
id="onboarding-choose_mounting-manual_modal-description"
elems={{ b: <b></b> }}
>
<Typography variant="standard">
You should do manual mounting first!
</Typography>
</Localized>
</div>
</div>
</div>
<Button variant="primary" onClick={accept}>
{l10n.getString('onboarding-choose_mounting-manual_modal-confirm')}
</Button>
<Button variant="tertiary" onClick={cancel}>
{l10n.getString('onboarding-choose_mounting-manual_modal-cancel')}
</Button>
</>
</div>
</BaseModal>
);
}
@@ -0,0 +1,125 @@
import { Radio } from '@/components/commons/Radio';
import { Typography } from '@/components/commons/Typography';
import { AssignMode, defaultConfig, useConfig } from '@/hooks/config';
import { ASSIGNMENT_MODES } from '@/components/onboarding/BodyAssignment';
import { useLocalization } from '@fluent/react';
import { useTrackers } from '@/hooks/tracker';
import { useForm } from 'react-hook-form';
import { useEffect } from 'react';
import { Dropdown } from '@/components/commons/Dropdown';
// Ordered collection of assign modes with the number of IMU trackers
const ASSIGN_MODE_OPTIONS = [
AssignMode.LowerBody,
AssignMode.Core,
AssignMode.EnhancedCore,
AssignMode.FullBody,
AssignMode.All,
].reduce(
(options, mode) => ({ ...options, [mode]: ASSIGNMENT_MODES[mode].length }),
{} as Record<AssignMode, number>
);
export function TrackerAssignOptions({
variant = 'radio',
}: {
variant: 'radio' | 'dropdown';
}) {
const { l10n } = useLocalization();
const { useConnectedIMUTrackers } = useTrackers();
const connectedIMUTrackers = useConnectedIMUTrackers().length;
const { config, setConfig } = useConfig();
const { control, watch, setValue } = useForm<{
assignMode: AssignMode;
}>({
defaultValues: {
assignMode: config?.assignMode ?? defaultConfig.assignMode,
},
});
const { assignMode } = watch();
useEffect(() => {
setConfig({ assignMode });
}, [assignMode]);
useEffect(() => {
if (connectedIMUTrackers <= ASSIGN_MODE_OPTIONS[assignMode]) return;
const selectedAssignMode =
(Object.entries(ASSIGN_MODE_OPTIONS).find(
([_, count]) => count >= connectedIMUTrackers
)?.[0] as AssignMode) ?? AssignMode.All;
if (assignMode !== selectedAssignMode) {
setValue('assignMode', selectedAssignMode);
}
}, [connectedIMUTrackers, assignMode]);
const ItemContent = ({
mode,
trackersCount,
}: {
mode: string;
trackersCount: number;
}) => (
<>
<Typography variant="main-title" textAlign="text-right">
{l10n.getString('onboarding-assign_trackers-option-amount', {
trackersCount,
})}
</Typography>
<div className="flex flex-col">
<Typography>
{l10n.getString('onboarding-assign_trackers-option-label', {
mode,
})}
</Typography>
<Typography variant="standard" color="secondary">
{l10n.getString('onboarding-assign_trackers-option-description', {
mode,
})}
</Typography>
</div>
</>
);
if (variant == 'dropdown')
return (
<Dropdown
control={control}
name="assignMode"
display="block"
direction="down"
placeholder={''}
items={Object.entries(ASSIGN_MODE_OPTIONS).map(
([mode, trackersCount]) => ({
component: (
<div className="flex flex-row gap-2 py-1 text-left">
<ItemContent
mode={mode}
trackersCount={trackersCount}
></ItemContent>
</div>
),
value: mode,
})
)}
></Dropdown>
);
return Object.entries(ASSIGN_MODE_OPTIONS).map(([mode, trackersCount]) => (
<Radio
key={mode}
name="assignMode"
control={control}
value={mode}
disabled={connectedIMUTrackers > trackersCount && mode !== AssignMode.All}
className="hidden"
>
<div className="flex flex-row md:gap-4 gap-2">
<ItemContent mode={mode} trackersCount={trackersCount}></ItemContent>
</div>
</Radio>
));
}
@@ -30,9 +30,10 @@ import {
} from '@/components/onboarding/BodyAssignment';
import { NeckWarningModal } from '@/components/onboarding/NeckWarningModal';
import { TrackerSelectionMenu } from './TrackerSelectionMenu';
import { useConfig } from '@/hooks/config';
import { defaultConfig, useConfig } from '@/hooks/config';
import { playTapSetupSound } from '@/sounds/sounds';
import { useBreakpoint } from '@/hooks/breakpoint';
import { TrackerAssignOptions } from './TrackerAssignOptions';
export type BodyPartError = {
label: string | undefined;
@@ -54,19 +55,17 @@ export function TrackersAssignPage() {
const { applyProgress, state } = useOnboarding();
const { sendRPCPacket, useRPCPacket } = useWebsocketAPI();
const defaultValues = {
advanced: config?.advancedAssign ?? false,
mirrorView: config?.mirrorView ?? true,
mirrorView: config?.mirrorView ?? defaultConfig.mirrorView,
};
const { control, watch } = useForm<{
advanced: boolean;
mirrorView: boolean;
}>({ defaultValues });
const { advanced, mirrorView } = watch();
const { mirrorView } = watch();
const [selectedRole, setSelectRole] = useState<BodyPart>(BodyPart.NONE);
const assignedTrackers = useAssignedTrackers();
useEffect(() => {
setConfig({ advancedAssign: advanced, mirrorView });
}, [advanced, mirrorView]);
setConfig({ mirrorView });
}, [mirrorView]);
const [tapDetectionSettings, setTapDetectionSettings] = useState<Omit<
TapDetectionSettingsT,
@@ -78,7 +77,9 @@ export function TrackersAssignPage() {
}, []);
useRPCPacket(RpcMessage.SettingsResponse, (settings: SettingsResponseT) => {
setTapDetectionSettings(settings.tapDetectionSettings);
if (settings.tapDetectionSettings) {
setTapDetectionSettings(settings.tapDetectionSettings);
}
});
useEffect(() => {
@@ -266,7 +267,7 @@ export function TrackersAssignPage() {
<NeckWarningModal
isOpen={shouldShowChokerWarn}
overlayClassName={classNames(
'fixed top-0 right-0 left-0 bottom-0 flex flex-col items-center w-full h-full justify-center bg-black bg-opacity-90 z-20'
'fixed top-0 right-0 left-0 bottom-0 flex flex-col items-center w-full h-full justify-center bg-background-90 bg-opacity-90 z-20'
)}
onClose={() => closeChokerWarning(true)}
accept={() => closeChokerWarning(false)}
@@ -290,13 +291,17 @@ export function TrackersAssignPage() {
</Typography>
</div>
<TipBox>{l10n.getString('tips-find_tracker')}</TipBox>
<div>
<CheckBox
control={control}
label={l10n.getString('onboarding-assign_trackers-advanced')}
name="advanced"
variant="toggle"
></CheckBox>
{!!firstError && (
<div className="bg-status-warning text-background-60 px-3 py-2 text-justify rounded-md">
<div className="flex flex-col gap-1 whitespace-normal">
<span>{firstError.label}</span>
</div>
</div>
)}
<div className="flex flex-col md:gap-4 sm:gap-2 xs:gap-1 mobile:gap-4">
<TrackerAssignOptions
variant={isMobile ? 'dropdown' : 'radio'}
/>
<CheckBox
control={control}
label={l10n.getString(
@@ -306,13 +311,6 @@ export function TrackersAssignPage() {
variant="toggle"
></CheckBox>
</div>
{!!firstError && (
<div className="bg-status-warning text-background-60 px-3 py-2 text-justify rounded-md">
<div className="flex flex-col gap-1 whitespace-normal">
<span>{firstError.label}</span>
</div>
</div>
)}
<div className="flex flex-row">
{!state.alonePage && (
<>
@@ -339,11 +337,12 @@ export function TrackersAssignPage() {
<div className="flex flex-col rounded-xl fill-background-50">
<BodyAssignment
width={isMobile ? 150 : undefined}
dotSize={isMobile ? 10 : undefined}
onlyAssigned={false}
highlightedRoles={firstError?.affectedRoles || []}
rolesWithErrors={rolesWithErrors}
advanced={advanced ?? defaultValues.advanced}
mirror={mirrorView ?? defaultValues.mirrorView}
assignMode={config?.assignMode ?? defaultConfig.assignMode}
mirror={mirrorView}
onRoleSelected={tryOpenChokerWarning}
></BodyAssignment>
</div>
@@ -2,7 +2,6 @@ import classNames from 'classnames';
import ReactModal from 'react-modal';
import { BodyPart } from 'solarxr-protocol';
import { FlatDeviceTracker } from '@/hooks/app';
import { useElemSize, useLayout } from '@/hooks/layout';
import { useTrackers } from '@/hooks/tracker';
import { Button } from '@/components/commons/Button';
import { TipBox } from '@/components/commons/TipBox';
@@ -22,12 +21,6 @@ export function TrackerSelectionMenu({
onTrackerSelected: (tracker: FlatDeviceTracker | null) => void;
}) {
const { l10n } = useLocalization();
const { ref: refTrackers, layoutHeight: trackersHeight } =
useLayout<HTMLDivElement>();
const { ref: refOptions, height: optionsHeight } =
useElemSize<HTMLDivElement>();
// This is true when the neck warning has been accepted
// It is used for showing or not showing the actual modal
const { useAssignedTrackers, useUnassignedTrackers } = useTrackers();
const unassignedTrackers = useUnassignedTrackers();
@@ -41,55 +34,28 @@ export function TrackerSelectionMenu({
shouldCloseOnEsc
onRequestClose={onClose}
overlayClassName={classNames(
'fixed top-0 right-0 left-0 bottom-0 flex flex-col items-center w-full h-full bg-black bg-opacity-90 z-20'
'fixed top-0 right-0 left-0 bottom-0 flex flex-col items-center w-full h-full bg-background-90 bg-opacity-90 z-20'
)}
className={classNames(
'focus:ring-transparent focus:ring-offset-transparent focus:outline-transparent outline-none mt-20 z-10'
'focus:ring-transparent focus:ring-offset-transparent focus:outline-transparent outline-none z-10 h-full pt-10'
)}
>
<div className="flex w-full h-full flex-col ">
<div className="flex w-full flex-col flex-grow items-center gap-3">
<Typography variant="mobile-title" bold>
<div className="flex w-full h-full flex-col px-4">
<div className="flex w-full flex-col flex-grow h-0 items-center gap-3 py-4">
<Typography variant="main-title" bold>
{l10n.getString('tracker_selection_menu-' + BodyPart[bodyPart])}
</Typography>
<div className="w-full max-w-sm">
<TipBox>{l10n.getString('tips-tap_setup')}</TipBox>
</div>
<div className="relative">
<div
className="w-full h-full xs:min-w-[700px] overflow-y-auto p-2 pt-0 flex flex-col gap-6"
ref={refTrackers}
style={{ height: trackersHeight - optionsHeight }}
>
<div className="flex flex-col gap-3">
{unassignedTrackers.length && (
<div className="flex flex-col gap-3">
<Typography>
{l10n.getString('tracker_selection_menu-unassigned')}
</Typography>
<div className="grid xs:grid-cols-2 mobile:grid-cols-1 gap-3">
{unassignedTrackers.map((fd, index) => (
<TrackerCard
key={index}
tracker={fd.tracker}
device={fd.device}
onClick={() => onTrackerSelected(fd)}
smol
interactable
outlined={
bodyPart ===
(fd.tracker.info?.bodyPart || BodyPart.NONE)
}
></TrackerCard>
))}
</div>
</div>
)}
<div className="w-full p-2 flex flex-col flex-grow h-0 gap-4 overflow-y-auto">
{unassignedTrackers.length && (
<>
<Typography>
{l10n.getString('tracker_selection_menu-assigned')}
{l10n.getString('tracker_selection_menu-unassigned')}
</Typography>
<div className=" grid xs:grid-cols-2 mobile:grid-cols-1 gap-3">
{assignedTrackers.map((fd, index) => (
<div className="grid xs:grid-cols-2 mobile:grid-cols-1 gap-3">
{unassignedTrackers.map((fd, index) => (
<TrackerCard
key={index}
tracker={fd.tracker}
@@ -104,23 +70,37 @@ export function TrackerSelectionMenu({
></TrackerCard>
))}
</div>
</div>
</>
)}
<Typography>
{l10n.getString('tracker_selection_menu-assigned')}
</Typography>
<div className=" grid xs:grid-cols-2 mobile:grid-cols-1 gap-3">
{assignedTrackers.map((fd, index) => (
<TrackerCard
key={index}
tracker={fd.tracker}
device={fd.device}
onClick={() => onTrackerSelected(fd)}
smol
interactable
outlined={
bodyPart === (fd.tracker.info?.bodyPart || BodyPart.NONE)
}
></TrackerCard>
))}
</div>
</div>
<div className="flex w-full justify-end" onClick={onClose}>
<div className="flex flex-col justify-end pointer-events-auto">
<Button
variant="primary"
onClick={() => onTrackerSelected(null)}
>
{l10n.getString('tracker_selection_menu-dont_assign')}
</Button>
</div>
</div>
</div>
</div>
<div
className="flex w-full justify-between absolute bottom-0 left-0 p-10 z-0"
onClick={onClose}
ref={refOptions}
>
<div className="w-full max-w-sm">
{/* <TipBox>{l10n.getString('tips-find_tracker')}</TipBox> */}
</div>
<div className="flex flex-col justify-end pointer-events-auto">
<Button variant="primary" onClick={() => onTrackerSelected(null)}>
{l10n.getString('tracker_selection_menu-dont_assign')}
</Button>
</div>
</div>
</ReactModal>
@@ -0,0 +1,25 @@
:root {
--settings-sidebar-w: 200px;
}
.settings-layout {
display: grid;
grid-template:
't t t' var(--topbar-h)
'n s c' calc(100% - var(--topbar-h))
/ var(--navbar-w) var(--settings-sidebar-w) calc(100% - var(--navbar-w) - var(
--settings-sidebar-w
));
@screen lg {
--settings-sidebar-w: 270px;
}
@screen mobile {
grid-template:
't' var(--topbar-h)
'c' calc(100% - var(--topbar-h) - var(--navbar-h))
'n' calc(var(--navbar-h))
/ 100%;
}
}
+18 -21
View File
@@ -1,5 +1,4 @@
import { ReactNode, useEffect } from 'react';
import { useElemSize, useLayout } from '@/hooks/layout';
import { Navbar } from '@/components/Navbar';
import { TopBar } from '@/components/TopBar';
import { SettingsSidebar } from './SettingsSidebar';
@@ -8,6 +7,7 @@ import { Dropdown } from '@/components/commons/Dropdown';
import { useForm } from 'react-hook-form';
import { useLocalization } from '@fluent/react';
import { useLocation, useNavigate } from 'react-router-dom';
import './SettingsLayout.scss';
export function SettingSelectorMobile() {
const { l10n } = useLocalization();
@@ -84,29 +84,26 @@ export function SettingSelectorMobile() {
);
}
export function SettingsLayoutRoute({ children }: { children: ReactNode }) {
const { layoutHeight, ref } = useLayout<HTMLDivElement>();
const { height, ref: navRef } = useElemSize<HTMLDivElement>();
export function SettingsLayout({ children }: { children: ReactNode }) {
const { isMobile } = useBreakpoint('mobile');
return (
<>
<TopBar></TopBar>
<div ref={ref} className="flex-grow" style={{ height: layoutHeight }}>
<div className="flex h-full xs:pb-3">
{!isMobile && <Navbar></Navbar>}
<div className="h-full w-full gap-2 flex">
{!isMobile && <SettingsSidebar></SettingsSidebar>}
<div className="w-full flex flex-col">
{isMobile && <SettingSelectorMobile></SettingSelectorMobile>}
<div
className="flex flex-col overflow-y-auto xs:pr-1 xs:mr-1 mobile:pt-7 pb-3"
style={{ minHeight: layoutHeight - height }}
>
{children}
</div>
<div ref={navRef}>{isMobile && <Navbar></Navbar>}</div>
</div>
</div>
<div className="settings-layout h-full">
<div style={{ gridArea: 't' }}>
<TopBar></TopBar>
</div>
<div style={{ gridArea: 'n' }}>
<Navbar></Navbar>
</div>
<div style={{ gridArea: 's' }} className="my-2">
<SettingsSidebar></SettingsSidebar>
</div>
<div
style={{ gridArea: 'c' }}
className="xs:pl-2 xs:pb-2 xs:mt-2 mobile:mt-7 overflow-y-auto"
>
{isMobile && <SettingSelectorMobile></SettingSelectorMobile>}
{children}
</div>
</div>
</>
@@ -29,8 +29,8 @@ export function SettingsPageLayout({
'.overflow-y-auto'
) as HTMLElement | null;
if (closestScroll) {
// The 40 is just enough padding for making the scroll look perfect
const topPadding = isMobile ? 80 : 40;
// The 45 is just enough padding for making the scroll look perfect
const topPadding = isMobile ? 80 : 45;
closestScroll.scroll({
top: elem.offsetTop - topPadding,
behavior: 'smooth',
@@ -58,7 +58,7 @@ export function SettingsPagePaneLayout({
return (
<div
className={classNames(
'mobile:scroll-mt-7 bg-background-70 rounded-lg px-4 py-8 flex xs:gap-4 w-full relative',
'bg-background-70 rounded-lg px-4 py-8 flex xs:gap-4 w-full relative',
className
)}
{...props}
@@ -42,7 +42,7 @@ export function SettingsLink({
export function SettingsSidebar() {
const { l10n } = useLocalization();
return (
<div className="flex flex-col px-5 w-[280px] min-w-[280px] py-5 gap-3 overflow-y-auto bg-background-70 rounded-lg">
<div className="flex flex-col px-5 py-5 gap-3 overflow-y-auto bg-background-70 rounded-lg h-full">
<Typography variant="main-title">
{l10n.getString('settings-sidebar-title')}
</Typography>
@@ -96,6 +96,7 @@ interface SettingsForm {
armsMountingResetMode: number;
yawResetSmoothTime: number;
saveMountingReset: boolean;
resetHmdPitch: boolean;
};
}
@@ -158,6 +159,7 @@ const defaultValues: SettingsForm = {
armsMountingResetMode: 0,
yawResetSmoothTime: 0.0,
saveMountingReset: false,
resetHmdPitch: false,
},
};
@@ -294,6 +296,7 @@ export function GeneralSettings() {
values.resetsSettings.yawResetSmoothTime;
resetsSettings.saveMountingReset =
values.resetsSettings.saveMountingReset;
resetsSettings.resetHmdPitch = values.resetsSettings.resetHmdPitch;
settings.resetsSettings = resetsSettings;
}
@@ -326,7 +329,7 @@ export function GeneralSettings() {
if (settings.steamVrTrackers) {
formData.trackers = settings.steamVrTrackers;
if (
settings.steamVrTrackers.leftHand &&
settings.steamVrTrackers.leftHand ||
settings.steamVrTrackers.rightHand
) {
setHandsWarning(false);
@@ -859,24 +862,6 @@ export function GeneralSettings() {
)}
/>
</div>
<div className="flex flex-col pt-2 pb-3">
<Typography color="secondary">
{l10n.getString(
'settings-general-fk_settings-leg_fk-reset_mounting_feet-description'
)}
</Typography>
</div>
<div className="grid sm:grid-cols-1 gap-3 pb-3">
<CheckBox
variant="toggle"
outlined
control={control}
name="resetsSettings.resetMountingFeet"
label={l10n.getString(
'settings-general-fk_settings-leg_fk-reset_mounting_feet'
)}
/>
</div>
<div className="flex flex-col pt-2 pb-3">
<Typography bold>
@@ -900,12 +885,53 @@ export function GeneralSettings() {
/>
</div>
<div className="flex flex-col pt-2">
<Typography bold>
{l10n.getString('settings-general-fk_settings-reset_settings')}
</Typography>
</div>
<div className="flex flex-col pt-2 pb-3">
<Typography color="secondary">
{l10n.getString(
'settings-general-fk_settings-reset_settings-reset_hmd_pitch-description'
)}
</Typography>
</div>
<div className="grid sm:grid-cols-1 gap-3 pb-3">
<CheckBox
variant="toggle"
outlined
control={control}
name="resetsSettings.resetHmdPitch"
label={l10n.getString(
'settings-general-fk_settings-reset_settings-reset_hmd_pitch'
)}
/>
</div>
<div className="flex flex-col pt-2 pb-3">
<Typography color="secondary">
{l10n.getString(
'settings-general-fk_settings-leg_fk-reset_mounting_feet-description'
)}
</Typography>
</div>
<div className="grid sm:grid-cols-1 gap-3 pb-3">
<CheckBox
variant="toggle"
outlined
control={control}
name="resetsSettings.resetMountingFeet"
label={l10n.getString(
'settings-general-fk_settings-leg_fk-reset_mounting_feet'
)}
/>
</div>
<Typography color="secondary">
{l10n.getString(
'settings-general-fk_settings-arm_fk-reset_mode-description'
)}
</Typography>
<div className="grid md:grid-cols-2 flex-col gap-3 pt-2">
<div className="grid md:grid-cols-2 flex-col gap-3 pt-2 pb-3">
<Radio
control={control}
name="resetsSettings.armsMountingResetMode"
@@ -951,6 +977,7 @@ export function GeneralSettings() {
value={'3'}
></Radio>
</div>
{config?.debug && (
<>
<div className="flex flex-col pt-2 pb-3">
@@ -30,6 +30,7 @@ interface InterfaceSettingsForm {
feedbackSoundVolume: number;
connectedTrackersWarning: boolean;
useTray: boolean;
discordPresence: boolean;
};
}
@@ -55,6 +56,8 @@ export function InterfaceSettings() {
config?.connectedTrackersWarning ??
defaultConfig.connectedTrackersWarning,
useTray: config?.useTray ?? defaultConfig.useTray ?? false,
discordPresence:
config?.discordPresence ?? defaultConfig.discordPresence,
},
},
});
@@ -70,6 +73,7 @@ export function InterfaceSettings() {
textSize: values.appearance.textSize,
connectedTrackersWarning: values.notifications.connectedTrackersWarning,
useTray: values.notifications.useTray,
discordPresence: values.notifications.discordPresence,
});
};
@@ -204,6 +208,28 @@ export function InterfaceSettings() {
)}
/>
</div>
<Typography bold>
{l10n.getString('settings-general-interface-discord_presence')}
</Typography>
<div className="flex flex-col pt-1 pb-2">
<Typography color="secondary">
{l10n.getString(
'settings-general-interface-discord_presence-description'
)}
</Typography>
</div>
<div className="grid sm:grid-cols-2 pb-4">
<CheckBox
variant="toggle"
control={control}
outlined
name="notifications.discordPresence"
label={l10n.getString(
'settings-general-interface-discord_presence-label'
)}
/>
</div>
</>
</SettingsPagePaneLayout>
+85 -60
View File
@@ -1,4 +1,4 @@
import { useEffect, useRef, useState } from 'react';
import { useEffect, useLayoutEffect, useRef, useState } from 'react';
import { useForm } from 'react-hook-form';
import { useLocation } from 'react-router-dom';
import {
@@ -14,7 +14,6 @@ import {
SerialUpdateResponseT,
SerialTrackerGetWifiScanRequestT,
} from 'solarxr-protocol';
import { useElemSize, useLayout } from '@/hooks/layout';
import { useWebsocketAPI } from '@/hooks/websocket-api';
import { Button } from '@/components/commons/Button';
import { Dropdown } from '@/components/commons/Dropdown';
@@ -22,27 +21,23 @@ import { Typography } from '@/components/commons/Typography';
import { Localized, useLocalization } from '@fluent/react';
import { BaseModal } from '@/components/commons/BaseModal';
import { WarningBox } from '@/components/commons/TipBox';
import { useBreakpoint } from '@/hooks/breakpoint';
import { useIsTauri } from '@/hooks/breakpoint';
import { fileSave } from 'browser-fs-access';
import { save } from '@tauri-apps/plugin-dialog';
import { writeTextFile } from '@tauri-apps/plugin-fs';
import { error } from '@/utils/logging';
import { waitUntil } from '@/utils/a11y';
export interface SerialForm {
port: string;
}
export function Serial() {
const {
layoutHeight,
layoutWidth,
ref: consoleRef,
} = useLayout<HTMLDivElement>();
const { isMobile } = useBreakpoint('mobile');
const { l10n } = useLocalization();
const { state } = useLocation();
const toolbarRef = useRef<HTMLDivElement>(null);
const { height } = useElemSize(toolbarRef);
const { useRPCPacket, sendRPCPacket } = useWebsocketAPI();
// const consoleRef = useRef<HTMLPreElement>(null);
const consoleRef = useRef<HTMLDivElement>(null);
const [consoleContent, setConsole] = useState('');
const [isSerialOpen, setSerialOpen] = useState(false);
@@ -100,7 +95,7 @@ export function Serial() {
setSerialOpen(true);
}
if (data.log && consoleRef.current) {
if (data.log) {
setConsole((console) => console + data.log);
}
}
@@ -167,6 +162,50 @@ export function Serial() {
);
};
const isTauri = useIsTauri();
const consoleContentRef = useRef(consoleContent);
useLayoutEffect(() => {
consoleContentRef.current = consoleContent;
}, [consoleContent]);
const saveLogToFile = async () => {
// Check if we have getInfos and fetch them if we don't
if (!consoleContentRef.current.includes('GET INFO')) {
getInfos();
await waitUntil(
() => consoleContentRef.current.includes('GET INFO'),
100,
10
);
}
if (isTauri) {
save({
filters: [
{
name: l10n.getString('settings-serial-file_type'),
extensions: ['txt'],
},
],
defaultPath: 'serial-logs.txt',
})
.then((path) =>
path ? writeTextFile(path, consoleContentRef.current) : undefined
)
.catch((err) => {
error(err);
});
} else {
const blob = new Blob([consoleContentRef.current], {
type: 'text/plain',
});
fileSave(blob, {
fileName: 'serial-logs.txt',
extensions: ['.txt'],
});
}
};
return (
<>
<BaseModal
@@ -191,8 +230,8 @@ export function Serial() {
</Button>
</div>
</BaseModal>
<div className="flex flex-col bg-background-70 h-full p-5 rounded-md">
<div className="flex flex-col pb-2">
<div className="flex flex-col bg-background-70 h-full p-4 mobile:p-2 rounded-md">
<div className="flex flex-col pb-2 mobile:pt-4">
<Typography variant="main-title">
{l10n.getString('settings-serial')}
</Typography>
@@ -207,16 +246,12 @@ export function Serial() {
))}
</>
</div>
<div className="bg-background-80 rounded-lg flex flex-col p-2">
<div className="bg-background-80 rounded-lg flex-grow h-0 flex flex-col p-2">
<div
className="flex-grow overflow-x-auto overflow-y-auto"
ref={consoleRef}
className="overflow-x-auto overflow-y-auto"
style={{
height: layoutHeight - height - 30 - (isMobile ? 88 : 0),
width: layoutWidth - 24,
}}
>
<div className="flex select-text px-3">
<div className="flex select-text">
<pre>
{isSerialOpen
? consoleContent
@@ -224,52 +259,42 @@ export function Serial() {
</pre>
</div>
</div>
<div className="" ref={toolbarRef}>
<div className="border-t-2 pt-2 border-background-60 border-solid m-2 gap-2 flex flex-row">
<div className="flex flex-grow flex-wrap gap-2 mobile:grid mobile:grid-cols-2 mobile:grid-rows-2">
<Button variant="quaternary" onClick={reboot}>
{l10n.getString('settings-serial-reboot')}
</Button>
<Button
variant="quaternary"
onClick={() => setTryFactoryReset(true)}
>
{l10n.getString('settings-serial-factory_reset')}
</Button>
<Button variant="quaternary" onClick={getInfos}>
{l10n.getString('settings-serial-get_infos')}
</Button>
<Button variant="quaternary" onClick={getWifiScan}>
{l10n.getString('settings-serial-get_wifi_scan')}
</Button>
{isMobile && (
<Dropdown
control={control}
name="port"
display="block"
placeholder={l10n.getString(
'settings-serial-serial_select'
)}
items={serialDevices.map((device) => ({
label: device.name?.toString() || 'error',
value: device.port?.toString() || 'error',
}))}
></Dropdown>
)}
</div>
{!isMobile && (
<div className="border-t-2 pt-2 border-background-60 border-solid gap-2 flex flex-row">
<div className="xs:flex flex-grow xs:flex-wrap gap-2 grid grid-cols-2">
<Button variant="quaternary" onClick={reboot}>
{l10n.getString('settings-serial-reboot')}
</Button>
<Button
variant="quaternary"
onClick={() => setTryFactoryReset(true)}
>
{l10n.getString('settings-serial-factory_reset')}
</Button>
<Button variant="quaternary" onClick={getInfos}>
{l10n.getString('settings-serial-get_infos')}
</Button>
<Button variant="quaternary" onClick={getWifiScan}>
{l10n.getString('settings-serial-get_wifi_scan')}
</Button>
<Button
variant="quaternary"
onClick={saveLogToFile}
disabled={!isSerialOpen || !consoleContent.trim()}
>
{l10n.getString('settings-serial-save_logs')}
</Button>
<div className="w-full mobile:col-span-2">
<Dropdown
control={control}
name="port"
display="fit"
display="block"
placeholder={l10n.getString('settings-serial-serial_select')}
items={serialDevices.map((device) => ({
label: device.name?.toString() || 'error',
value: device.port?.toString() || 'error',
}))}
></Dropdown>
)}
</div>
</div>
</div>
</div>
@@ -32,6 +32,7 @@ interface VMCSettingsForm {
};
vrmJson?: FileList;
anchorHip: boolean;
mirrorTracking: boolean;
};
}
@@ -44,6 +45,7 @@ const defaultValues = {
address: '127.0.0.1',
},
anchorHip: true,
mirrorTracking: true,
},
};
@@ -80,6 +82,7 @@ export function VMCSettings() {
}
}
vmcOsc.anchorHip = values.vmc.anchorHip;
vmcOsc.mirrorTracking = values.vmc.mirrorTracking;
settings.vmcOsc = vmcOsc;
}
@@ -115,6 +118,7 @@ export function VMCSettings() {
}
formData.vmc.anchorHip = settings.vmcOsc.anchorHip;
formData.vmc.mirrorTracking = settings.vmcOsc.mirrorTracking;
}
reset(formData);
@@ -272,6 +276,23 @@ export function VMCSettings() {
label={l10n.getString('settings-osc-vmc-anchor_hip-label')}
/>
</div>
<Typography bold>
{l10n.getString('settings-osc-vmc-mirror_tracking')}
</Typography>
<div className="flex flex-col pb-2">
<Typography color="secondary">
{l10n.getString('settings-osc-vmc-mirror_tracking-description')}
</Typography>
</div>
<div className="grid grid-cols-2 gap-3 pb-5">
<CheckBox
variant="toggle"
outlined
control={control}
name="vmc.mirrorTracking"
label={l10n.getString('settings-osc-vmc-mirror_tracking-label')}
/>
</div>
</>
</SettingsPagePaneLayout>
</form>
@@ -281,6 +302,7 @@ export function VMCSettings() {
const gltfHeaderStart = 0;
const gltfHeaderEnd = 20;
async function parseVRMFile(vrm: File): Promise<string | null> {
const headerView = new DataView(
await vrm.slice(gltfHeaderStart, gltfHeaderEnd).arrayBuffer()
@@ -131,7 +131,7 @@ export function VRCOSCSettings() {
<div className="flex flex-col pt-2 pb-4">
<>
{l10n
.getString('settings-osc-vrchat-description')
.getString('settings-osc-vrchat-description-v1')
.split('\n')
.map((line, i) => (
<Typography color="secondary" key={i}>
@@ -162,7 +162,7 @@ export function VRCOSCSettings() {
</Typography>
<div className="flex flex-col pb-2">
<Typography color="secondary">
{l10n.getString('settings-osc-vrchat-network-description')}
{l10n.getString('settings-osc-vrchat-network-description-v1')}
</Typography>
</div>
<div className="grid grid-cols-2 gap-3 pb-5">
@@ -199,7 +199,7 @@ export function VRCOSCSettings() {
<div className="flex flex-col pb-2">
<Typography color="secondary">
{l10n.getString(
'settings-osc-vrchat-network-address-description'
'settings-osc-vrchat-network-address-description-v1'
)}
</Typography>
</div>
@@ -1,9 +1,7 @@
import classNames from 'classnames';
import { useForm } from 'react-hook-form';
import ReactModal from 'react-modal';
import { BodyPart } from 'solarxr-protocol';
import { Button } from '@/components/commons/Button';
import { CheckBox } from '@/components/commons/Checkbox';
import { Typography } from '@/components/commons/Typography';
import { BodyAssignment } from '@/components/onboarding/BodyAssignment';
import { useLocalization } from '@fluent/react';
@@ -11,6 +9,7 @@ import { NeckWarningModal } from '@/components/onboarding/NeckWarningModal';
import { useChokerWarning } from '@/hooks/choker-warning';
import { useBreakpoint } from '@/hooks/breakpoint';
import { defaultConfig, useConfig } from '@/hooks/config';
import { TrackerAssignOptions } from '@/components/onboarding/pages/trackers-assign/TrackerAssignOptions';
export function SingleTrackerBodyAssignmentMenu({
isOpen,
@@ -24,9 +23,6 @@ export function SingleTrackerBodyAssignmentMenu({
const { isMobile } = useBreakpoint('mobile');
const { l10n } = useLocalization();
const { config } = useConfig();
const defaultValues = { advanced: false };
const { control, watch } = useForm<{ advanced: boolean }>({ defaultValues });
const { advanced } = watch();
const { closeChokerWarning, tryOpenChokerWarning, shouldShowChokerWarn } =
useChokerWarning({
@@ -41,7 +37,7 @@ export function SingleTrackerBodyAssignmentMenu({
shouldCloseOnEsc
onRequestClose={onClose}
overlayClassName={classNames(
'fixed top-0 right-0 left-0 bottom-0 flex flex-col items-center w-full h-full justify-center bg-black bg-opacity-90 z-20'
'fixed top-0 right-0 left-0 bottom-0 flex flex-col items-center w-full h-full justify-center bg-background-90 bg-opacity-90 z-20'
)}
className={classNames(
'focus:ring-transparent focus:ring-offset-transparent focus:outline-transparent outline-none mt-12 z-10 overflow-y-auto'
@@ -56,14 +52,6 @@ export function SingleTrackerBodyAssignmentMenu({
<Typography color="secondary">
{l10n.getString('body_assignment_menu-description')}
</Typography>
<CheckBox
control={control}
label={l10n.getString(
'body_assignment_menu-show_advanced_locations'
)}
name="advanced"
variant="toggle"
></CheckBox>
<div className="flex">
<Button
variant="secondary"
@@ -73,13 +61,14 @@ export function SingleTrackerBodyAssignmentMenu({
{l10n.getString('body_assignment_menu-manage_trackers')}
</Button>
</div>
<TrackerAssignOptions variant={isMobile ? 'dropdown' : 'radio'} />
</div>
<div className="flex flex-col xs:flex-grow gap-3 rounded-xl fill-background-50 py-2">
<BodyAssignment
mirror={config?.mirrorView ?? defaultConfig.mirrorView}
width={isMobile ? 160 : undefined}
onlyAssigned={false}
advanced={advanced ?? defaultValues.advanced}
assignMode={config?.assignMode ?? defaultConfig.assignMode}
onRoleSelected={tryOpenChokerWarning}
></BodyAssignment>
<div className="flex justify-center">
@@ -98,7 +87,7 @@ export function SingleTrackerBodyAssignmentMenu({
<NeckWarningModal
isOpen={shouldShowChokerWarn}
overlayClassName={classNames(
'fixed top-0 right-0 left-0 bottom-0 flex flex-col items-center w-full h-full justify-center bg-black bg-opacity-90 z-20'
'fixed top-0 right-0 left-0 bottom-0 flex flex-col items-center w-full h-full justify-center bg-background-90 bg-opacity-90 z-20'
)}
onClose={() => closeChokerWarning(true)}
accept={() => closeChokerWarning(false)}
+7 -3
View File
@@ -29,7 +29,9 @@ function TrackerBig({
<BodyPartIcon bodyPart={tracker.info?.bodyPart}></BodyPartIcon>
</div>
<div className="flex justify-center">
<Typography bold>{trackerName}</Typography>
<Typography bold truncate>
{trackerName}
</Typography>
</div>
<div className="flex justify-center">
<TrackerStatus status={tracker.status}></TrackerStatus>
@@ -76,8 +78,10 @@ function TrackerSmol({
<div className="flex flex-col justify-center items-center fill-background-10">
<BodyPartIcon bodyPart={tracker.info?.bodyPart}></BodyPartIcon>
</div>
<div className="flex flex-col flex-grow">
<Typography bold>{trackerName}</Typography>
<div className="flex flex-col flex-grow ">
<Typography bold truncate>
{trackerName}
</Typography>
<TrackerStatus status={tracker.status}></TrackerStatus>
</div>
{device && device.hardwareStatus && (
@@ -170,6 +170,7 @@ export function TrackerSettingsPage() {
></SingleTrackerBodyAssignmentMenu>
<MountingSelectionMenu
bodyPart={tracker?.tracker.info?.bodyPart}
currRotation={currRotation}
isOpen={selectRotation}
onClose={() => setSelectRotation(false)}
onDirectionSelected={onDirectionSelected}
@@ -307,7 +308,7 @@ export function TrackerSettingsPage() {
)}
</Typography>
<div className="flex justify-between bg-background-80 w-full p-3 rounded-lg">
<div className="flex gap-3 items-center">
<div className="flex gap-3 items-center fill-background-10">
{tracker?.tracker.info?.bodyPart !== BodyPart.NONE && (
<BodyPartIcon
bodyPart={tracker?.tracker.info?.bodyPart}
@@ -110,7 +110,7 @@ export function ToggleableSkeletonVisualizerWidget(
</Button>
)}
{enabled && (
<>
<div className="flex flex-col gap-2">
<Button
className="w-full"
variant="secondary"
@@ -121,9 +121,8 @@ export function ToggleableSkeletonVisualizerWidget(
>
{l10n.getString('widget-skeleton_visualizer-hide')}
</Button>
<SkeletonVisualizerWidget {...props} />
</>
</div>
)}
</>
);
@@ -197,7 +196,7 @@ export function SkeletonVisualizerWidget({
if (!skeleton.current) return <></>;
return (
<div className="bg-background-70 flex flex-col p-3 rounded-lg gap-2">
<div className="bg-background-60 flex flex-col p-3 rounded-lg gap-2">
<ErrorBoundary
fallback={
<Typography color="primary" textAlign="text-center">
+1 -5
View File
@@ -24,9 +24,5 @@ export function useBreakpoint<K extends BreakpointKey>(breakpointKey: K) {
}
export function useIsTauri() {
if ('__TAURI_INTERNALS__' in window) {
return true;
} else {
return false;
}
return window.isTauri;
}
+20 -8
View File
@@ -13,6 +13,14 @@ export interface WindowConfig {
y: number;
}
export enum AssignMode {
LowerBody = 'lower-body',
Core = 'core',
EnhancedCore = 'enhanced-core',
FullBody = 'full-body',
All = 'all',
}
export interface Config {
debug: boolean;
lang: string;
@@ -25,10 +33,10 @@ export interface Config {
theme: string;
textSize: number;
fonts: string[];
advancedAssign: boolean;
useTray: boolean | null;
doneManualMounting: boolean;
mirrorView: boolean;
assignMode: AssignMode;
discordPresence: boolean;
}
export interface ConfigContext {
@@ -50,10 +58,10 @@ export const defaultConfig: Omit<Config, 'devSettings'> = {
theme: 'slime',
textSize: 12,
fonts: ['poppins'],
advancedAssign: false,
useTray: null,
doneManualMounting: false,
mirrorView: true,
assignMode: AssignMode.Core,
discordPresence: false,
};
interface CrossStorage {
@@ -103,8 +111,10 @@ export function useConfigProvider(): ConfigContext {
const newConfig: Partial<Config> = JSON.parse(
(await store.get('config.json')) ?? '{}'
);
return Object.entries(config).every(
([key, value]) => newConfig[key as keyof Config] === value
return Object.entries(config).every(([key, value]) =>
typeof value === 'object'
? JSON.stringify(newConfig[key as keyof Config]) === JSON.stringify(value)
: newConfig[key as keyof Config] === value
);
},
100,
@@ -116,8 +126,10 @@ export function useConfigProvider(): ConfigContext {
const newConfig: Partial<Config> = JSON.parse(
localStorage.getItem('config.json') ?? '{}'
);
return Object.entries(config).every(
([key, value]) => newConfig[key as keyof Config] === value
return Object.entries(config).every(([key, value]) =>
typeof value === 'object'
? JSON.stringify(newConfig[key as keyof Config]) === JSON.stringify(value)
: newConfig[key as keyof Config] === value
);
},
100,
+71
View File
@@ -0,0 +1,71 @@
import { useCallback, useEffect } from 'react';
import { useConfig } from './config';
import { useInterval } from './timeout';
import { useTrackers } from './tracker';
import { invoke } from '@tauri-apps/api/core';
import { warn } from '@/utils/logging';
import { useLocalization } from '@fluent/react';
export function useDiscordPresence() {
const { config } = useConfig();
const { useConnectedIMUTrackers } = useTrackers();
const { l10n } = useLocalization();
const imuTrackers = useConnectedIMUTrackers();
const updatePresence = useCallback(() => {
(async () => {
try {
if (await checkDiscordClient()) {
// If discord client exists, try updating presence
await updateDiscordPresence({
details: l10n.getString(
'settings-general-interface-discord_presence-message',
{ amount: imuTrackers.length }
),
});
} else {
// else, try creating a discord client
await createDiscordClient();
}
} catch (e) {
warn(`failed to update presence, error: ${e}`);
}
})();
}, [imuTrackers.length, l10n]);
// Update presence every 6.9 seconds
useInterval(updatePresence, config?.discordPresence ? 6900 : null);
// Clear presence on config being disabled
useEffect(() => {
if (config?.discordPresence !== false) return;
(async () => {
if (!(await checkDiscordClient())) return;
clearDiscordPresence().catch((e) =>
warn(`failed to clear discord presence, error: ${e}`)
);
})();
}, [config?.discordPresence]);
}
export function checkDiscordClient(): Promise<boolean> {
return invoke('discord_client_exists');
}
export function createDiscordClient(): Promise<void> {
return invoke('create_discord_client');
}
export function clearDiscordPresence(): Promise<void> {
return invoke('clear_presence');
}
export function updateDiscordPresence(obj: {
details: string;
state?: string;
small_icon?: [string, string];
button?: { label: string; url: string };
}): Promise<void> {
return invoke('update_presence', obj);
}
+17 -12
View File
@@ -1,19 +1,24 @@
import { useMemo } from 'react';
import { FlatDeviceTracker } from './app';
import { ImuType } from 'solarxr-protocol';
export function useBnoExists(connectedTrackers: FlatDeviceTracker[]): boolean {
const bnoExists = useMemo(
() =>
connectedTrackers.some(
(tracker) =>
tracker.tracker.info?.imuType &&
[ImuType.BNO055, ImuType.BNO080, ImuType.BNO085].includes(
tracker.tracker.info?.imuType
)
),
export function useIsRestCalibrationTrackers(
connectedTrackers: FlatDeviceTracker[]
): boolean {
const imuExists = useMemo(
() => connectedTrackers.some((tracker) => tracker.tracker.info?.isImu),
[connectedTrackers]
);
return bnoExists;
return imuExists;
}
export function useRestCalibrationTrackers(
connectedTrackers: FlatDeviceTracker[]
): FlatDeviceTracker[] {
const restTrackers = useMemo(
() => connectedTrackers.filter((tracker) => tracker.tracker.info?.isImu),
[connectedTrackers]
);
return restTrackers;
}
-34
View File
@@ -1,39 +1,5 @@
import { MutableRefObject, useLayoutEffect, useRef, useState } from 'react';
export function useLayout<T extends HTMLElement>() {
const [layoutHeight, setLayoutHeigt] = useState(window.innerHeight);
const [layoutWidth, setLayoutWidth] = useState(window.innerWidth);
const ref = useRef<T | null>(null);
const computeLayoutHeight = (windowHeight: number, windowWidth: number) => {
if (ref.current) {
setLayoutHeigt(windowHeight - ref.current.getBoundingClientRect().top);
setLayoutWidth(windowWidth - ref.current.getBoundingClientRect().left);
}
};
const onWindowResize = () => {
computeLayoutHeight(window.innerHeight, window.innerWidth);
};
useLayoutEffect(() => {
window.addEventListener('resize', onWindowResize);
// Fix a bug where the layout would not update when the window is unfocused then focused again
window.addEventListener('focus', onWindowResize);
computeLayoutHeight(window.innerHeight, window.innerWidth);
return () => {
window.removeEventListener('focus', onWindowResize);
window.removeEventListener('resize', onWindowResize);
};
}, []);
return {
layoutHeight,
layoutWidth,
ref,
};
}
export function useElemSize<T extends HTMLElement>(
forwardRef?: MutableRefObject<T | null>
) {
+9 -2
View File
@@ -11,6 +11,7 @@ import {
StatusSystemUpdateT,
StatusTrackerErrorT,
StatusTrackerResetT,
StatusUnassignedHMDT,
TrackerDataT,
} from 'solarxr-protocol';
import { useWebsocketAPI } from './websocket-api';
@@ -122,6 +123,7 @@ export function parseStatusToLocale(
switch (status.dataType) {
case StatusData.NONE:
case StatusData.StatusTrackerReset:
case StatusData.StatusUnassignedHMD:
return {};
case StatusData.StatusSteamVRDisconnected: {
const data = status.data as StatusSteamVRDisconnectedT;
@@ -157,8 +159,6 @@ export function parseStatusToLocale(
}
return { trackerName: name };
}
case StatusData.StatusUnassignedHMD:
return { trackerName: 'Not implemented.' }; // TODO
}
}
@@ -186,6 +186,13 @@ export function trackerStatusRelated(
data.trackerId?.deviceId?.id === tracker.trackerId?.deviceId?.id
);
}
case StatusData.StatusUnassignedHMD: {
const data = status.data as StatusUnassignedHMDT;
return (
data.trackerId?.trackerNum == tracker.trackerId?.trackerNum &&
data.trackerId?.deviceId?.id === tracker.trackerId?.deviceId?.id
);
}
default:
return false;
}
+21 -7
View File
@@ -1,17 +1,31 @@
import { useEffect } from 'react';
import { useEffect, useLayoutEffect, useRef } from 'react';
export function useTimeout(fn: () => void, delay: number | null) {
const saved = useRef(fn);
useLayoutEffect(() => {
saved.current = fn;
}, [fn]);
export function useTimeout(fn: () => void, delay: number) {
useEffect(() => {
const id = setTimeout(fn, delay);
if (delay === null) return;
const id = setTimeout(() => saved.current(), delay);
return () => clearTimeout(id);
});
}, [delay]);
}
export function useInterval(fn: () => void, delay: number) {
export function useInterval(fn: () => void, delay: number | null) {
const saved = useRef(fn);
useLayoutEffect(() => {
saved.current = fn;
}, [fn]);
useEffect(() => {
const id = setInterval(fn, delay);
if (delay === null) return;
const id = setInterval(() => saved.current(), delay);
return () => clearInterval(id);
});
}, [delay]);
}
export const useDebouncedEffect = (effect: () => void, deps: any[], delay: number) => {
+10 -1
View File
@@ -12,7 +12,7 @@ body {
background: theme('colors.background.20');
/*Scrollbar for firefox */
scrollbar-color: theme('colors.background.50') theme('colors.background.60');
scrollbar-color: theme('colors.background.50') transparent;
scrollbar-width: thin;
}
@@ -86,6 +86,15 @@ body {
:root {
overflow: hidden;
background: theme('colors.background.20');
--navbar-w: 101px;
--widget-w: 274px;
--topbar-h: 38px;
@screen mobile {
--topbar-h: 44px;
--navbar-h: 90px;
}
}
/* Colors have to be in RGB format currently */
+1 -1
View File
@@ -5,7 +5,7 @@ import * as ReactDOMClient from 'react-dom/client';
import Modal from 'react-modal';
import App from './App';
import { AppLocalizationProvider } from './i18n/config';
import './index.css';
import './index.scss';
Modal.setAppElement('#root');
+6
View File
@@ -3,6 +3,12 @@ import { Vector3 } from 'three';
export type Vector3Object = { x: number; y: number; z: number };
export function averageVector(vecs: Vector3[]) {
if (vecs.length === 0) return new Vector3();
const sum = vecs.reduce((prev, curr) => prev.add(curr), new Vector3());
return sum.divideScalar(vecs.length);
}
export function Vector3FromVec3fT(vec?: Vector3Object | null) {
return vec ? new Vector3(vec.x, vec.y, vec.z) : new Vector3();
}
+4
View File
@@ -5,4 +5,8 @@ declare const __COMMIT_HASH__: string;
declare const __VERSION_TAG__: string;
declare const __GIT_CLEAN__: boolean;
interface Window {
readonly isTauri: boolean;
}
declare module 'tailwind-gradient-mask-image';
+3 -3
View File
@@ -2,7 +2,7 @@
"name": "slimevr-ui",
"version": "0.5.1",
"private": true,
"packageManager": "pnpm@8.15.5",
"packageManager": "pnpm@9.4.0",
"workspaces": [
"solarxr-protocol",
"gui"
@@ -17,7 +17,7 @@
"preinstall": "npx only-allow pnpm"
},
"devDependencies": {
"husky": "^8.0.3",
"lint-staged": "^13.3.0"
"husky": "^9.0.11",
"lint-staged": "^15.2.7"
}
}
+6484 -5499
View File
File diff suppressed because it is too large. Load diff
+2 -2
View File
@@ -1,4 +1,4 @@
[toolchain]
channel = "1.77.1"
channel = "1.79"
profile = "default"
components = ["rust-analyzer", "rust-src"]
components = ["rustc", "cargo", "clippy", "rustfmt", "rust-analyzer", "rust-src"]
@@ -3,6 +3,8 @@
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
<application
android:allowBackup="true"
@@ -2,6 +2,8 @@
package dev.slimevr.android
import android.content.Context
import android.net.wifi.WifiManager
import androidx.appcompat.app.AppCompatActivity
import dev.slimevr.Keybinding
import dev.slimevr.VRServer
@@ -28,7 +30,7 @@ val vrServerInitialized: Boolean
fun main(activity: AppCompatActivity) {
// Host the web GUI server
embeddedServer(Netty, port = 8080) {
embeddedServer(Netty, port = 34536) {
routing {
install(CachingHeaders) {
options { _, _ ->
@@ -50,6 +52,12 @@ fun main(activity: AppCompatActivity) {
vrServer = VRServer(
configPath = File(activity.filesDir, "vrconfig.yml").absolutePath,
serialHandlerProvider = { _ -> AndroidSerialHandler(activity) },
acquireMulticastLock = {
val wifi = activity.getSystemService(Context.WIFI_SERVICE) as WifiManager
val lock = wifi.createMulticastLock("slimevr-jmdns-multicast-lock")
lock.setReferenceCounted(true)
lock.acquire()
},
)
vrServer.start()
Keybinding(vrServer)
@@ -49,7 +49,7 @@ class MainActivity : AppCompatActivity() {
guiWebView.clearCache(true)
// Load GUI page
guiWebView.loadUrl("http://127.0.0.1:8080/")
guiWebView.loadUrl("http://127.0.0.1:34536/")
LogManager.info("[MainActivity] GUI WebView has been initialized and loaded.")
}
}
+2 -1
View File
@@ -36,7 +36,8 @@ configure<com.diffplug.gradle.spotless.SpotlessExtension> {
"ij_kotlin_packages_to_use_import_on_demand" to
"java.util.*,kotlin.math.*,dev.slimevr.autobone.errors.*" +
",io.github.axisangles.ktmath.*,kotlinx.atomicfu.*" +
",dev.slimevr.tracking.trackers.*,dev.slimevr.desktop.platform.ProtobufMessages.*",
",dev.slimevr.tracking.trackers.*,dev.slimevr.desktop.platform.ProtobufMessages.*" +
",com.illposed.osc.*",
"ij_kotlin_allow_trailing_comma" to true,
)
val ktlintVersion = "1.2.1"
+10 -1
View File
@@ -40,11 +40,17 @@ tasks.withType<Javadoc> {
options.encoding = "UTF-8"
}
tasks.withType<Jar> {
from("../../LICENSE-APACHE")
from("../../LICENSE-MIT")
}
allprojects {
repositories {
// Use jcenter for resolving dependencies.
// You can declare any Maven/Ivy/file repository here.
mavenCentral()
maven(url = "https://jitpack.io")
}
}
@@ -63,12 +69,15 @@ dependencies {
implementation("org.apache.commons:commons-lang3:3.12.0")
implementation("org.apache.commons:commons-collections4:4.4")
implementation("com.illposed.osc:javaosc-core:0.8")
implementation("com.illposed.osc:javaosc-core:0.9")
implementation("org.java-websocket:Java-WebSocket:1.+")
implementation("com.melloware:jintellitype:1.+")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3")
implementation("it.unimi.dsi:fastutil:8.5.12")
// Jitpack
implementation("com.github.SlimeVR:oscquery-kt:566a0cba58")
testImplementation(kotlin("test"))
// Use JUnit test framework
testImplementation(platform("org.junit:junit-bom:5.9.0"))
-21
View File
@@ -1,21 +0,0 @@
MIT License
Copyright (c) 2021 Eiren Rain, SlimeVR
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+38 -9
View File
@@ -1,17 +1,46 @@
@echo off
:: Firewall modification doesn't work w/o admin, slimes will be sad.
net session >nul 2>&1
if %errorlevel% == 0 (
echo Running with administrative privileges! - Needed for firewall modification!
) else (
echo Requesting administrative privileges - Needed for firewall modification!
:: Temp script to request admin... Works and doesn't leave a mess.
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "%~s0", "", "%~dp0", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
exit /B
)
echo Installing firewall rules...
rem Discovery default port
netsh advfirewall firewall add rule name="SlimeVR UDP 35903 incoming" dir=in action=allow protocol=UDP localport=35903
netsh advfirewall firewall add rule name="SlimeVR UDP 35903 outgoing" dir=out action=allow protocol=UDP localport=35903
rem Rotational data default port
netsh advfirewall firewall add rule name="SlimeVR UDP 6969 incoming" dir=in action=allow protocol=UDP localport=6969
netsh advfirewall firewall add rule name="SlimeVR UDP 6969 outgoing" dir=out action=allow protocol=UDP localport=6969
call :AddRule "SlimeVR UDP 6969 incoming" "dir=in action=allow protocol=UDP localport=6969 enable=yes"
call :AddRule "SlimeVR UDP 6969 outgoing" "dir=out action=allow protocol=UDP localport=6969 enable=yes"
rem WebSocket server default port
netsh advfirewall firewall add rule name="SlimeVR TCP 21110 incoming" dir=in action=allow protocol=TCP localport=21110
netsh advfirewall firewall add rule name="SlimeVR TCP 21110 outgoing" dir=out action=allow protocol=TCP localport=21110
call :AddRule "SlimeVR TCP 21110 incoming" "dir=in action=allow protocol=TCP localport=21110 enable=yes"
call :AddRule "SlimeVR TCP 21110 outgoing" "dir=out action=allow protocol=TCP localport=21110 enable=yes"
rem OpenJDK Platform Binary access
call :AddRule "SlimeVR OpenJDK Platform incoming" "dir=in action=allow program=%~dp0jre\bin\java.exe enable=yes"
call :AddRule "SlimeVR OpenJDK Platform outgoing" "dir=out action=allow program=%~dp0jre\bin\java.exe enable=yes"
echo Done!
pause
exit /B
:: Check and don't make duplicate rules :3
:AddRule
setlocal
set "ruleName=%~1"
set "ruleParams=%~2"
netsh advfirewall firewall show rule name="%ruleName%" >nul 2>&1
if %errorlevel% neq 0 (
echo Adding rule: %ruleName%
netsh advfirewall firewall add rule name="%ruleName%" %ruleParams%
) else (
echo Rule already exists: %ruleName%
)
endlocal
exit /B
+41 -10
View File
@@ -1,17 +1,48 @@
@echo off
:: Firewall modification doesn't work w/o admin, slimes will be sad.
net session >nul 2>&1
if %errorlevel% == 0 (
echo Running with administrative privileges! - Needed for firewall modification!
) else (
echo Requesting administrative privileges - Needed for firewall modification!
:: Temp script to request admin... Works and doesn't leave a mess.
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
exit /B
)
echo Uninstalling firewall rules...
rem Discovery defauly port
netsh advfirewall firewall delete rule name="SlimeVR UDP 35903 incoming"
netsh advfirewall firewall delete rule name="SlimeVR UDP 35903 outgoing"
rem Discovery default port
call :DeleteRule "SlimeVR UDP 35903 incoming"
call :DeleteRule "SlimeVR UDP 35903 outgoing"
rem Rotational data default port
netsh advfirewall firewall delete rule name="SlimeVR UDP 6969 incoming"
netsh advfirewall firewall delete rule name="SlimeVR UDP 6969 outgoing"
call :DeleteRule "SlimeVR UDP 6969 incoming"
call :DeleteRule "SlimeVR UDP 6969 outgoing"
rem WebSocket server default port
netsh advfirewall firewall delete rule name="SlimeVR TCP 21110 incoming"
netsh advfirewall firewall delete rule name="SlimeVR TCP 21110 outgoing"
call :DeleteRule "SlimeVR TCP 21110 incoming"
call :DeleteRule "SlimeVR TCP 21110 outgoing"
rem OpenJDK Platform Binary access
call :DeleteRule "SlimeVR OpenJDK Platform incoming"
call :DeleteRule "SlimeVR OpenJDK Platform outgoing"
echo Done!
pause
pause
exit /B
:: Delete rules if they exist :3
:DeleteRule
setlocal
set "ruleName=%~1"
netsh advfirewall firewall show rule name="%ruleName%" >nul 2>&1
if %errorlevel% == 0 (
echo Deleting rule: %ruleName%
netsh advfirewall firewall delete rule name="%ruleName%"
) else (
echo Rule does not exist: %ruleName%
)
endlocal
exit /B
-19
View File
@@ -1,19 +0,0 @@
@echo off
setlocal enableextensions
cd /d "%~dp0"
where java >nul 2>&1
if %errorlevel% EQU 0 (
java -Xmx512M -jar slimevr.jar
) else (
echo Java was not found in your system.
echo.
echo Either use SlimeVR Installer to install the server by following this link:
echo https://github.com/SlimeVR/SlimeVR-Installer/releases/latest/download/slimevr_web_installer.exe
echo.
echo Or download Java 17 by following this link:
echo https://adoptium.net/temurin/releases/?version=17
)
if %errorlevel% NEQ 0 (
pause
)
@@ -47,6 +47,7 @@ class VRServer @JvmOverloads constructor(
driverBridgeProvider: SteamBridgeProvider = { _, _ -> null },
feederBridgeProvider: (VRServer) -> ISteamVRBridge? = { _ -> null },
serialHandlerProvider: (VRServer) -> SerialHandler = { _ -> SerialHandlerStub() },
acquireMulticastLock: () -> Any? = { null },
configPath: String,
) : Thread("VRServer") {
@JvmField
@@ -60,6 +61,7 @@ class VRServer @JvmOverloads constructor(
private val tasks: Queue<Runnable> = LinkedBlockingQueue()
private val newTrackersConsumers: MutableList<Consumer<Tracker>> = FastList()
private val onTick: MutableList<Runnable> = FastList()
private val lock = acquireMulticastLock()
val oSCRouter: OSCRouter
@JvmField
@@ -100,6 +102,8 @@ class VRServer @JvmOverloads constructor(
init {
// UwU
instance = this
configManager = ConfigManager(configPath)
configManager.loadConfig()
deviceManager = DeviceManager(this)
@@ -141,8 +145,6 @@ class VRServer @JvmOverloads constructor(
// Initialize OSC handlers
vrcOSCHandler = VRCOSCHandler(
this,
humanPoseManager,
driverBridge,
configManager.vrConfig.vrcOSC,
computedTrackers,
)
@@ -150,7 +152,6 @@ class VRServer @JvmOverloads constructor(
this,
humanPoseManager,
configManager.vrConfig.vmc,
computedTrackers,
)
// Initialize OSC router
@@ -162,7 +163,6 @@ class VRServer @JvmOverloads constructor(
for (tracker in computedTrackers) {
registerTracker(tracker)
}
instance = this
}
fun hasBridge(bridgeClass: Class<out Bridge?>): Boolean {
@@ -283,13 +283,11 @@ class VRServer @JvmOverloads constructor(
fun updateSkeletonModel() {
queueTask {
humanPoseManager.updateSkeletonModelFromServer()
vrcOSCHandler.setHeadTracker(TrackerUtils.getTrackerForSkeleton(trackers, TrackerPosition.HEAD))
if (this.getVRBridge(ISteamVRBridge::class.java)?.updateShareSettingsAutomatically() == true) {
RPCSettingsHandler.sendSteamVRUpdatedSettings(protocolAPI, protocolAPI.rpcHandler)
}
}
vrcOSCHandler.setHeadTracker(
TrackerUtils.getTrackerForSkeleton(trackers, TrackerPosition.HEAD),
)
}
fun resetTrackersFull(resetSourceName: String?) {
@@ -151,7 +151,7 @@ class AutoBoneHandler(private val server: VRServer) {
} catch (e: Exception) {
announceProcessStatus(
AutoBoneProcessType.RECORD,
String.format("Recording failed: %s", e.message),
"Recording failed: ${e.message}",
completed = true,
success = false,
)
@@ -212,7 +212,7 @@ class AutoBoneHandler(private val server: VRServer) {
} catch (e: Exception) {
announceProcessStatus(
AutoBoneProcessType.SAVE,
String.format("Failed to save recording: %s", e.message),
"Failed to save recording: ${e.message}",
completed = true,
success = false,
)
@@ -329,7 +329,7 @@ class AutoBoneHandler(private val server: VRServer) {
} catch (e: Exception) {
announceProcessStatus(
AutoBoneProcessType.PROCESS,
String.format("Processing failed: %s", e.message),
"Processing failed: ${e.message}",
completed = true,
success = false,
)
@@ -43,11 +43,12 @@ class ResetsConfig {
// Save automatic mounting reset calibration
var saveMountingReset = false
// Reset the HMD's pitch upon full reset
var resetHmdPitch = false
fun updateTrackersResetsSettings() {
for (t in VRServer.instance.allTrackers) {
if (t.needsReset) {
t.resetsHandler.readResetConfig(this)
}
t.resetsHandler.readResetConfig(this)
}
}
}
@@ -7,4 +7,7 @@ class VMCConfig : OSCConfig() {
// JSON part of the VRM to be used
var vrmJson: String? = null
// Mirror the tracking before sending it (turn left <=> turn right, left leg <=> right leg)
var mirrorTracking = false
}
@@ -101,8 +101,8 @@ class VRConfig {
val config = getTracker(tracker)
tracker.readConfig(config)
if (tracker.isImu()) tracker.resetsHandler.readDriftCompensationConfig(driftCompensation)
tracker.resetsHandler.readResetConfig(resetsConfig)
if (tracker.needsReset) {
tracker.resetsHandler.readResetConfig(resetsConfig)
tracker.saveMountingResetOrientation(config)
}
if (tracker.allowFiltering) {
@@ -10,6 +10,10 @@ public interface OSCHandler {
public void refreshSettings(boolean refreshRouterSettings);
public void updateOscReceiver(int portIn, String[] args);
public void updateOscSender(int portOut, String address);
public void update();
public OSCPortOut getOscSender();
@@ -11,7 +11,6 @@ import com.illposed.osc.transport.OSCPortOut
import dev.slimevr.VRServer
import dev.slimevr.VRServer.Companion.currentLocalTrackerId
import dev.slimevr.VRServer.Companion.getNextLocalTrackerId
import dev.slimevr.autobone.errors.BodyProportionError
import dev.slimevr.config.VMCConfig
import dev.slimevr.osc.UnityBone.Companion.getByStringVal
import dev.slimevr.tracking.processor.BoneType
@@ -43,7 +42,6 @@ class VMCHandler(
private val server: VRServer,
private val humanPoseManager: HumanPoseManager,
private val config: VMCConfig,
computedTrackers: List<Tracker>?,
) : OSCHandler {
private var oscReceiver: OSCPortIn? = null
private var oscSender: OSCPortOut? = null
@@ -59,6 +57,7 @@ class VMCHandler(
private var timeAtLastError: Long = 0
private var timeAtLastSend: Long = 0
private var anchorHip = false
private var mirrorTracking = false
private var lastPortIn = 0
private var lastPortOut = 0
private var lastAddress: InetAddress? = null
@@ -69,12 +68,93 @@ class VMCHandler(
override fun refreshSettings(refreshRouterSettings: Boolean) {
anchorHip = config.anchorHip
mirrorTracking = config.mirrorTracking
updateOscReceiver(
config.portIn,
arrayOf(
"/VMC/Ext/Bone/Pos",
"/VMC/Ext/Hmd/Pos",
"/VMC/Ext/Con/Pos",
"/VMC/Ext/Tra/Pos",
"/VMC/Ext/Root/Pos",
),
)
updateOscSender(config.portOut, config.address)
if (config.enabled) {
// Load VRM data
if (outputUnityArmature != null && config.vrmJson != null) {
val vrmReader = VRMReader(config.vrmJson!!)
for (unityBone in UnityBone.entries) {
val node = outputUnityArmature!!.getHeadNodeOfBone(unityBone)
if (node != null) {
val offset = if (unityBone == UnityBone.HIPS) {
// For the hip bone, add average of upper leg offsets (which are negative). The hip bone's offset is global.
vrmReader.getOffsetForBone(UnityBone.HIPS) +
((vrmReader.getOffsetForBone(UnityBone.LEFT_UPPER_LEG) + vrmReader.getOffsetForBone(UnityBone.RIGHT_UPPER_LEG)) / 2f)
} else {
vrmReader.getOffsetForBone(unityBone)
}
node.localTransform.translation = offset
}
}
// Make sure to account for the upper legs because of the hip.
vrmHeight = (
vrmReader.getOffsetForBone(UnityBone.HIPS) +
((vrmReader.getOffsetForBone(UnityBone.LEFT_UPPER_LEG) + vrmReader.getOffsetForBone(UnityBone.RIGHT_UPPER_LEG))) +
vrmReader.getOffsetForBone(UnityBone.SPINE) +
vrmReader.getOffsetForBone(UnityBone.CHEST) +
vrmReader.getOffsetForBone(UnityBone.UPPER_CHEST) +
vrmReader.getOffsetForBone(UnityBone.NECK) +
vrmReader.getOffsetForBone(UnityBone.HEAD)
).y
}
}
if (refreshRouterSettings) server.oSCRouter.refreshSettings(false)
}
override fun updateOscReceiver(portIn: Int, args: Array<String>) {
// Stops listening and closes OSC port
val wasListening = oscReceiver != null && oscReceiver!!.isListening
if (wasListening) {
oscReceiver!!.stopListening()
}
if (config.enabled) {
// Instantiates the OSC receiver
try {
oscReceiver = OSCPortIn(portIn)
if (lastPortIn != portIn || !wasListening) {
LogManager.info("[VMCHandler] Listening to port $portIn")
}
lastPortIn = portIn
} catch (e: IOException) {
LogManager
.severe(
"[VMCHandler] Error listening to the port $portIn: $e",
)
}
// Starts listening for VMC messages
if (oscReceiver != null) {
val listener = OSCMessageListener { event: OSCMessageEvent -> this.handleReceivedMessage(event) }
for (address in args) {
oscReceiver!!
.dispatcher
.addListener(OSCPatternAddressMessageSelector(address), listener)
}
oscReceiver!!.startListening()
}
}
}
override fun updateOscSender(portOut: Int, ip: String) {
// Stop sending
val wasConnected = oscSender != null && oscSender!!.isConnected
if (wasConnected) {
try {
@@ -85,87 +165,28 @@ class VMCHandler(
}
if (config.enabled) {
// Instantiates the OSC receiver
try {
val port = config.portIn
oscReceiver = OSCPortIn(port)
if (lastPortIn != port || !wasListening) {
LogManager.info("[VMCHandler] Listening to port $port")
}
lastPortIn = port
} catch (e: IOException) {
LogManager
.severe(
"[VMCHandler] Error listening to the port ${config.portIn}: $e",
)
}
// Starts listening for VMC messages
if (oscReceiver != null) {
val listener = OSCMessageListener { event: OSCMessageEvent -> this.handleReceivedMessage(event) }
val listenAddresses = arrayOf(
"/VMC/Ext/Bone/Pos",
"/VMC/Ext/Hmd/Pos",
"/VMC/Ext/Con/Pos",
"/VMC/Ext/Tra/Pos",
"/VMC/Ext/Root/Pos",
)
for (address in listenAddresses) {
oscReceiver!!
.dispatcher
.addListener(OSCPatternAddressMessageSelector(address), listener)
}
oscReceiver!!.startListening()
}
// Instantiate the OSC sender
try {
val address = InetAddress.getByName(config.address)
val port = config.portOut
oscSender = OSCPortOut(InetSocketAddress(address, port))
if ((lastPortOut != port && lastAddress !== address) || !wasConnected) {
val addr = InetAddress.getByName(ip)
oscSender = OSCPortOut(InetSocketAddress(addr, portOut))
if ((lastPortOut != portOut && lastAddress !== addr) || !wasConnected) {
LogManager
.info(
"[VMCHandler] Sending to port $port at address $address",
"[VMCHandler] Sending to port $portOut at address $ip",
)
}
lastPortOut = port
lastAddress = address
lastPortOut = portOut
lastAddress = addr
oscSender!!.connect()
outputUnityArmature = UnityArmature(false)
} catch (e: IOException) {
LogManager
.severe(
"[VMCHandler] Error connecting to port ${config.portOut} at the address ${config.address}: $e",
"[VMCHandler] Error connecting to port $portOut at the address $ip: $e",
)
}
// Load VRM data
if (outputUnityArmature != null && config.vrmJson != null) {
val vrmReader = VRMReader(config.vrmJson!!)
for (unityBone in UnityBone.entries) {
val node = outputUnityArmature!!.getHeadNodeOfBone(unityBone)
if (node != null) {
node
.localTransform
.translation = vrmReader.getOffsetForBone(unityBone)
}
}
vrmHeight = vrmReader
.getOffsetForBone(UnityBone.HIPS)
.plus(vrmReader.getOffsetForBone(UnityBone.SPINE))
.plus(vrmReader.getOffsetForBone(UnityBone.CHEST))
.plus(vrmReader.getOffsetForBone(UnityBone.UPPER_CHEST))
.plus(vrmReader.getOffsetForBone(UnityBone.NECK))
.plus(vrmReader.getOffsetForBone(UnityBone.HEAD))
.len()
}
}
if (refreshRouterSettings && server.oSCRouter != null) server.oSCRouter.refreshSettings(false)
}
private fun handleReceivedMessage(event: OSCMessageEvent) {
@@ -247,7 +268,7 @@ class VMCHandler(
unityBone: UnityBone?,
) {
// Create device if it doesn't exist
var rotation: Quaternion? = rotation
var rot = rotation
if (trackerDevice == null) {
trackerDevice = server.deviceManager.createDevice("VMC receiver", "1.0", "VMC")
server.deviceManager.addDevice(trackerDevice!!)
@@ -262,19 +283,14 @@ class VMCHandler(
trackerDevice,
getNextLocalTrackerId(),
name,
"VMC Tracker #" + currentLocalTrackerId,
"VMC Tracker #$currentLocalTrackerId",
trackerPosition,
null,
position != null,
rotation != null,
false,
true,
false,
position != null,
null,
true,
false,
position != null,
hasPosition = position != null,
hasRotation = true,
userEditable = true,
isComputed = position != null,
usesTimeout = true,
needsReset = position != null,
)
trackerDevice!!.trackers[trackerDevice!!.trackers.size] = tracker
byTrackerNameTracker[name] = tracker
@@ -288,16 +304,14 @@ class VMCHandler(
}
// Set rotation
if (rotation != null) {
if (localRotation) {
// Instantiate unityHierarchy if not done
if (inputUnityArmature == null) inputUnityArmature = UnityArmature(true)
inputUnityArmature!!.setLocalRotationForBone(unityBone!!, rotation)
rotation = inputUnityArmature!!.getGlobalRotationForBone(unityBone)
rotation = yawOffset.times(rotation)
}
tracker.setRotation(rotation)
if (localRotation) {
// Instantiate unityHierarchy if not done
if (inputUnityArmature == null) inputUnityArmature = UnityArmature(true)
inputUnityArmature!!.setLocalRotationForBone(unityBone!!, rot)
rot = inputUnityArmature!!.getGlobalRotationForBone(unityBone)
rot = yawOffset.times(rot)
}
tracker.setRotation(rot)
tracker.dataTick()
}
@@ -323,81 +337,50 @@ class VMCHandler(
// Indicate tracking is available
oscArgs.clear()
oscArgs.add(1)
oscBundle
.addPacket(
OSCMessage(
"/VMC/Ext/OK",
oscArgs.clone(),
),
)
oscBundle.addPacket(OSCMessage("/VMC/Ext/OK", oscArgs.clone()))
oscArgs.clear()
oscArgs.add("root")
addTransformToArgs(
NULL,
IDENTITY,
)
oscBundle
.addPacket(
OSCMessage(
"/VMC/Ext/Root/Pos",
oscArgs.clone(),
),
)
addTransformToArgs(NULL, IDENTITY)
oscBundle.addPacket(OSCMessage("/VMC/Ext/Root/Pos", oscArgs.clone()))
for (unityBone in UnityBone.entries) {
val boneType = unityBone.boneType ?: continue
// Get SlimeVR bone
val bone = humanPoseManager.getBone(boneType)
if (unityBone.boneType == null) continue
// Update unity hierarchy from bone's global
// rotation
outputUnityArmature
?.setGlobalRotationForBone(
unityBone,
bone!!.getGlobalRotation() * bone.rotationOffset.inv(),
)
// Get opposite bone if tracking must be mirrored
val boneType = (if (mirrorTracking) tryGetOppositeArmBone(unityBone) else unityBone).boneType
// Get SlimeVR bone
val bone = humanPoseManager.getBone(boneType!!)
// Update unity hierarchy from bone's global rotation
val boneRotation = if (mirrorTracking) {
// Mirror tracking horizontally
val rotBuf = bone.getGlobalRotation() * bone.rotationOffset.inv()
Quaternion(rotBuf.w, rotBuf.x, -rotBuf.y, -rotBuf.z)
} else {
bone.getGlobalRotation() * bone.rotationOffset.inv()
}
outputUnityArmature?.setGlobalRotationForBone(unityBone, boneRotation)
}
if (!anchorHip) {
// Anchor from head
// Gets the SlimeVR head position, scales it to the VRM,
// and subtracts the difference between the VRM's
// head and hip
// FIXME this way isn't perfect, but I give up - Erimel
val upperLegsAverage = (
outputUnityArmature!!.getHeadNodeOfBone(UnityBone.LEFT_UPPER_LEG)!!.worldTransform
.translation +
outputUnityArmature!!.getHeadNodeOfBone(UnityBone.RIGHT_UPPER_LEG)!!
.worldTransform
.translation
) * 0.5f
outputUnityArmature?.let { unityArmature ->
// Scale the SlimeVR head position with the VRM model
val slimevrScaledHeadPos = humanPoseManager.getBone(BoneType.HEAD).getPosition() *
(vrmHeight / humanPoseManager.userHeightFromConfig)
val scaledHead = humanPoseManager
.getBone(BoneType.HEAD)!!
.getTailPosition() * (
vrmHeight /
(
humanPoseManager.userHeightFromConfig
* BodyProportionError.eyeHeightToHeightRatio
)
)
// Get the VRM head and hip positions
val vrmHeadPos = unityArmature.getHeadNodeOfBone(UnityBone.HEAD)!!.parent!!.worldTransform.translation
val vrmHipPos = unityArmature.getHeadNodeOfBone(UnityBone.HIPS)!!.worldTransform.translation
val pos = scaledHead
.minus(
(
outputUnityArmature!!
.getHeadNodeOfBone(UnityBone.HEAD)!!
.parent!!
.worldTransform
.translation
.minus(upperLegsAverage)
),
)
// Calculate the new VRM hip position by subtracting the difference head-hip distance from the SlimeVR head
val calculatedVrmHipPos = slimevrScaledHeadPos - (vrmHeadPos - vrmHipPos)
outputUnityArmature!!
.getHeadNodeOfBone(UnityBone.HIPS)!!
.localTransform
.translation = pos
// Set the VRM's hip position
unityArmature.getHeadNodeOfBone(UnityBone.HIPS)?.localTransform?.translation = calculatedVrmHipPos
}
}
// Update Unity skeleton
@@ -405,14 +388,9 @@ class VMCHandler(
// Add Unity humanoid bones transforms
for (bone in UnityBone.entries) {
if (bone.boneType != null && !(
humanPoseManager.isTrackingLeftArmFromController &&
isLeftArmUnityBone(bone)
) &&
!(
humanPoseManager.isTrackingRightArmFromController &&
isRightArmUnityBone(bone)
)
if (bone.boneType != null &&
!(humanPoseManager.isTrackingLeftArmFromController && isLeftArmUnityBone(bone)) &&
!(humanPoseManager.isTrackingRightArmFromController && isRightArmUnityBone(bone))
) {
oscArgs.clear()
oscArgs.add(bone.stringVal)
@@ -420,13 +398,7 @@ class VMCHandler(
outputUnityArmature!!.getLocalTranslationForBone(bone),
outputUnityArmature!!.getLocalRotationForBone(bone),
)
oscBundle
.addPacket(
OSCMessage(
"/VMC/Ext/Bone/Pos",
oscArgs.clone(),
),
)
oscBundle.addPacket(OSCMessage("/VMC/Ext/Bone/Pos", oscArgs.clone()))
}
}
}
@@ -519,9 +491,31 @@ class VMCHandler(
oscArgs.add(-rot.w)
}
private fun isLeftArmUnityBone(bone: UnityBone): Boolean = bone == UnityBone.LEFT_UPPER_ARM || bone == UnityBone.LEFT_LOWER_ARM || bone == UnityBone.LEFT_HAND
/**
* Returns the bone on the opposite limb, or the original bone if
* it not a limb bone.
*/
private fun tryGetOppositeArmBone(bone: UnityBone): UnityBone = when (bone) {
UnityBone.LEFT_SHOULDER -> UnityBone.RIGHT_SHOULDER
UnityBone.LEFT_UPPER_ARM -> UnityBone.RIGHT_UPPER_ARM
UnityBone.LEFT_LOWER_ARM -> UnityBone.RIGHT_LOWER_ARM
UnityBone.LEFT_HAND -> UnityBone.RIGHT_HAND
UnityBone.RIGHT_SHOULDER -> UnityBone.LEFT_SHOULDER
UnityBone.RIGHT_UPPER_ARM -> UnityBone.LEFT_UPPER_ARM
UnityBone.RIGHT_LOWER_ARM -> UnityBone.LEFT_LOWER_ARM
UnityBone.RIGHT_HAND -> UnityBone.LEFT_HAND
UnityBone.LEFT_UPPER_LEG -> UnityBone.RIGHT_UPPER_LEG
UnityBone.LEFT_LOWER_LEG -> UnityBone.RIGHT_LOWER_LEG
UnityBone.LEFT_FOOT -> UnityBone.RIGHT_FOOT
UnityBone.RIGHT_UPPER_LEG -> UnityBone.LEFT_UPPER_LEG
UnityBone.RIGHT_LOWER_LEG -> UnityBone.LEFT_LOWER_LEG
UnityBone.RIGHT_FOOT -> UnityBone.LEFT_FOOT
else -> bone
}
private fun isRightArmUnityBone(bone: UnityBone): Boolean = bone == UnityBone.RIGHT_UPPER_ARM || bone == UnityBone.RIGHT_LOWER_ARM || bone == UnityBone.RIGHT_HAND
private fun isLeftArmUnityBone(bone: UnityBone): Boolean = bone == UnityBone.LEFT_SHOULDER || bone == UnityBone.LEFT_UPPER_ARM || bone == UnityBone.LEFT_LOWER_ARM || bone == UnityBone.LEFT_HAND
private fun isRightArmUnityBone(bone: UnityBone): Boolean = bone == UnityBone.RIGHT_SHOULDER || bone == UnityBone.RIGHT_UPPER_ARM || bone == UnityBone.RIGHT_LOWER_ARM || bone == UnityBone.RIGHT_HAND
override fun getOscSender(): OSCPortOut = oscSender!!
@@ -1,6 +1,5 @@
package dev.slimevr.osc
import com.illposed.osc.MessageSelector
import com.illposed.osc.OSCBundle
import com.illposed.osc.OSCMessage
import com.illposed.osc.OSCMessageEvent
@@ -12,9 +11,7 @@ import com.illposed.osc.transport.OSCPortOut
import com.jme3.math.FastMath
import com.jme3.system.NanoTimer
import dev.slimevr.VRServer
import dev.slimevr.bridge.ISteamVRBridge
import dev.slimevr.config.VRCOSCConfig
import dev.slimevr.tracking.processor.HumanPoseManager
import dev.slimevr.tracking.trackers.Device
import dev.slimevr.tracking.trackers.Tracker
import dev.slimevr.tracking.trackers.TrackerPosition
@@ -28,7 +25,6 @@ import io.github.axisangles.ktmath.Vector3
import java.io.IOException
import java.net.InetAddress
import java.net.InetSocketAddress
import java.util.*
private const val OFFSET_SLERP_FACTOR = 0.5f // Guessed from eyeing VRChat
@@ -37,25 +33,36 @@ private const val OFFSET_SLERP_FACTOR = 0.5f // Guessed from eyeing VRChat
*/
class VRCOSCHandler(
private val server: VRServer,
private val humanPoseManager: HumanPoseManager,
private val steamvrBridge: ISteamVRBridge?,
private val config: VRCOSCConfig,
private val computedTrackers: List<Tracker>,
) : OSCHandler {
private val localIp = InetAddress.getLocalHost().hostAddress
private val loopbackIp = InetAddress.getLoopbackAddress().hostAddress
private val vrsystemTrackersAddresses = arrayOf(
"/tracking/vrsystem/head/pose",
"/tracking/vrsystem/leftwrist/pose",
"/tracking/vrsystem/rightwrist/pose",
)
private val oscTrackersAddresses = arrayOf(
"/tracking/trackers/*/position",
"/tracking/trackers/*/rotation",
)
private var oscReceiver: OSCPortIn? = null
private var oscSender: OSCPortOut? = null
private var oscQuerySender: OSCPortOut? = null
private var oscMessage: OSCMessage? = null
private var vrcHmd: Tracker? = null
private var headTracker: Tracker? = null
private var oscTrackersDevice: Device? = null
private var vrsystemTrackersDevice: Device? = null
private val oscArgs = FastList<Float?>(3)
private val trackersEnabled: BooleanArray = BooleanArray(computedTrackers.size)
private var lastPortIn = 0
private var lastPortOut = 0
private var lastAddress: InetAddress? = null
private var oscPortIn = 0
private var oscPortOut = 0
private var oscIp: InetAddress? = null
private var oscQuerySenderState = false
private var oscQueryPortOut = 0
private var oscQueryIp: String? = null
private var timeAtLastError: Long = 0
private val timer = Timer()
private var listenTrackers = false
private var receivingPositionOffset = Vector3.NULL
private var postReceivingPositionOffset = Vector3.NULL
private var receivingRotationOffset = Quaternion.IDENTITY
@@ -63,6 +70,7 @@ class VRCOSCHandler(
private val postReceivingOffset = EulerAngles(EulerOrder.YXZ, 0f, FastMath.PI, 0f).toQuaternion()
private var timeAtLastReceivedRotationOffset = System.currentTimeMillis()
private var fpsTimer: NanoTimer? = null
private var vrcOscQueryHandler: VRCOSCQueryHandler? = null
init {
refreshSettings(false)
@@ -82,11 +90,96 @@ class VRCOSCHandler(
}
}
// Stops listening and closes OSC port
updateOscReceiver(config.portIn, vrsystemTrackersAddresses + oscTrackersAddresses)
updateOscSender(config.portOut, config.address)
if (vrcOscQueryHandler == null && config.enabled) {
vrcOscQueryHandler = VRCOSCQueryHandler(this)
} else if (vrcOscQueryHandler != null && !config.enabled) {
vrcOscQueryHandler?.close()
vrcOscQueryHandler = null
}
if (refreshRouterSettings) {
server.oSCRouter.refreshSettings(false)
}
}
/**
* Adds an OSC Sender from OSCQuery
*/
fun addOSCQuerySender(oscPortOut: Int, oscIP: String) {
val addr = InetAddress.getByName(oscIP)
oscQuerySenderState = true
oscQueryIp = oscIP
oscQueryPortOut = oscPortOut
if (oscPortOut != portOut || (oscIP != address.hostName && !(oscIP == localIp && address.hostName == loopbackIp))) {
try {
oscQuerySender = OSCPortOut(InetSocketAddress(addr, oscPortOut))
oscQuerySender?.connect()
LogManager.info("[VRCOSCHandler] OSCQuery sender sending to port $oscPortOut at address $oscIP")
} catch (e: IOException) {
LogManager.severe("[VRCOSCHandler] Error connecting to port $oscPortOut at the address $oscIP: $e")
}
}
}
/**
* Close/remove the osc query sender
*/
fun closeOscQuerySender(newState: Boolean) {
oscQuerySender?.let {
try {
it.close()
oscQuerySender = null
oscQuerySenderState = newState
} catch (e: IOException) {
LogManager.severe("[VRCOSCHandler] Error closing the OSC sender: $e")
}
}
}
override fun updateOscReceiver(portIn: Int, args: Array<String>) {
// Stop listening
val wasListening = oscReceiver != null && oscReceiver!!.isListening
if (wasListening) {
oscReceiver!!.stopListening()
}
if (config.enabled) {
// Instantiates the OSC receiver
try {
oscReceiver = OSCPortIn(portIn)
if (oscPortIn != portIn || !wasListening) {
LogManager.info("[VRCOSCHandler] Listening to port $portIn")
}
oscPortIn = portIn
vrcOscQueryHandler?.updateOSCQuery(portIn.toUShort())
} catch (e: IOException) {
LogManager
.severe(
"[VRCOSCHandler] Error listening to the port $portIn: $e",
)
}
// Starts listening for VRC or OSCTrackers messages
oscReceiver?.let {
val listener = OSCMessageListener { event: OSCMessageEvent ->
handleReceivedMessage(event)
}
for (address in args) {
it.dispatcher.addListener(
OSCPatternAddressMessageSelector(address),
listener,
)
}
it.startListening()
}
}
}
override fun updateOscSender(portOut: Int, ip: String) {
// Stop sending
val wasConnected = oscSender != null && oscSender!!.isConnected
if (wasConnected) {
try {
@@ -95,220 +188,218 @@ class VRCOSCHandler(
LogManager.severe("[VRCOSCHandler] Error closing the OSC sender: $e")
}
}
if (config.enabled) {
// Instantiates the OSC receiver
try {
val port = config.portIn
oscReceiver = OSCPortIn(port)
if (lastPortIn != port || !wasListening) {
LogManager.info("[VRCOSCHandler] Listening to port $port")
}
lastPortIn = port
} catch (e: IOException) {
LogManager
.severe(
"[VRCOSCHandler] Error listening to the port " +
config.portIn +
": " +
e,
)
}
// Starts listening for VRC or OSCTrackers messages
if (oscReceiver != null) {
val listener = OSCMessageListener { event: OSCMessageEvent -> handleReceivedMessage(event) }
val vrcSelector: MessageSelector = OSCPatternAddressMessageSelector(
"/avatar/parameters/Upright",
)
val trackersPositionSelector: MessageSelector = OSCPatternAddressMessageSelector(
"/tracking/trackers/*/position",
)
val trackersRotationSelector: MessageSelector = OSCPatternAddressMessageSelector(
"/tracking/trackers/*/rotation",
)
oscReceiver!!.dispatcher.addListener(vrcSelector, listener)
oscReceiver!!.dispatcher.addListener(trackersPositionSelector, listener)
oscReceiver!!.dispatcher.addListener(trackersRotationSelector, listener)
listenTrackers = false
oscReceiver!!.startListening()
// Delay so we can actually detect if SteamVR is running
scheduleStartListeningSteamVR(1000)
}
// Instantiate the OSC sender
try {
val address = InetAddress.getByName(config.address)
val port = config.portOut
oscSender = OSCPortOut(InetSocketAddress(address, port))
if ((lastPortOut != port && lastAddress !== address) || !wasConnected) {
LogManager
.info(
"[VRCOSCHandler] Sending to port " +
port +
" at address " +
address.toString(),
)
val addr = InetAddress.getByName(ip)
oscSender = OSCPortOut(InetSocketAddress(addr, portOut))
if (oscPortOut != portOut && oscIp !== addr || !wasConnected) {
LogManager.info("[VRCOSCHandler] Sending to port $portOut at address $ip")
}
lastPortOut = port
lastAddress = address
oscSender!!.connect()
oscPortOut = portOut
oscIp = addr
oscSender?.connect()
} catch (e: IOException) {
LogManager
.severe(
"[VRCOSCHandler] Error connecting to port " +
config.portOut +
" at the address " +
config.address +
": " +
e,
"[VRCOSCHandler] Error connecting to port $portOut at the address $ip: $e",
)
return
}
}
if (refreshRouterSettings) server.oSCRouter.refreshSettings(false)
}
private fun scheduleStartListeningSteamVR(delay: Long) {
val resetTask: TimerTask = object : TimerTask() {
override fun run() {
listenTrackers = true
if (oscQueryPortOut == portOut && (oscQueryIp == ip || (oscQueryIp == localIp && ip == loopbackIp))) {
if (oscQuerySender != null) {
// Close the oscQuerySender if it has the same port/ip
closeOscQuerySender(true)
}
} else if (oscQuerySender == null && oscQuerySenderState) {
// Instantiate the oscQuerySender if it could not be instantiated.
addOSCQuerySender(oscQueryPortOut, oscQueryIp!!)
}
}
timer.schedule(resetTask, delay)
}
private fun handleReceivedMessage(event: OSCMessageEvent) {
if (listenTrackers) {
if (event.message.address.equals("/avatar/parameters/Upright")) {
// Receiving HMD data from VRChat
if (steamvrBridge != null && !steamvrBridge.isConnected()) {
if (vrcHmd == null) {
val vrcDevice = server.deviceManager.createDevice("VRChat OSC", null, "VRChat")
server.deviceManager.addDevice(vrcDevice)
vrcHmd = Tracker(
device = vrcDevice,
id = VRServer.getNextLocalTrackerId(),
name = "VRC HMD",
displayName = "VRC HMD",
trackerPosition = TrackerPosition.HEAD,
trackerNum = 0,
hasPosition = true,
userEditable = false,
isComputed = true,
usesTimeout = true,
)
vrcDevice.trackers[0] = vrcHmd!!
server.registerTracker(vrcHmd!!)
}
if (vrsystemTrackersAddresses.contains(event.message.address)) {
// Receiving Head and Wrist pose data thanks to OSCQuery
// Create device if it doesn't exist
if (vrsystemTrackersDevice == null) {
// Instantiate OSC Trackers device
vrsystemTrackersDevice = server.deviceManager.createDevice("VRC VRSystem", null, "VRChat")
server.deviceManager.addDevice(vrsystemTrackersDevice!!)
}
// Sets HMD status to OK
vrcHmd!!.status = TrackerStatus.OK
// Look at xxx in "/tracking/vrsystem/xxx/pose" to know TrackerPosition
var name = "VRChat "
val trackerPosition = when (event.message.address.split('/')[3]) {
"head" -> {
name += "head"
TrackerPosition.HEAD
}
// Sets the HMD y position to
// the vrc Upright parameter (0-1) * the user's height
vrcHmd!!
.position = Vector3(
0f,
event
.message
.arguments[0] as Float * humanPoseManager.userHeightFromConfig,
0f,
"leftwrist" -> {
name += "left hand"
TrackerPosition.LEFT_HAND
}
"rightwrist" -> {
name += "right hand"
TrackerPosition.RIGHT_HAND
}
else -> {
LogManager.warning("[VRCOSCHandler] Received invalid body part in message \"${event.message.address}\"")
return
}
}
// Try to get the tracker
var tracker = vrsystemTrackersDevice!!.trackers[trackerPosition.ordinal]
// Build the tracker if it doesn't exist
if (tracker == null) {
tracker = Tracker(
device = vrsystemTrackersDevice,
id = VRServer.getNextLocalTrackerId(),
name = name,
displayName = name,
trackerNum = trackerPosition.ordinal,
trackerPosition = trackerPosition,
hasRotation = true,
hasPosition = true,
userEditable = true,
isComputed = true,
needsReset = trackerPosition != TrackerPosition.HEAD,
usesTimeout = true,
)
vrsystemTrackersDevice!!.trackers[trackerPosition.ordinal] = tracker
server.registerTracker(tracker)
}
// Sets the tracker status to OK
tracker.status = TrackerStatus.OK
// Update tracker position
tracker.position = Vector3(
event.message.arguments[0] as Float,
event.message.arguments[1] as Float,
-(event.message.arguments[2] as Float),
)
// Update tracker rotation
val (w, x, y, z) = EulerAngles(
EulerOrder.YXZ,
event.message.arguments[3] as Float * FastMath.DEG_TO_RAD,
event.message.arguments[4] as Float * FastMath.DEG_TO_RAD,
event.message.arguments[5] as Float * FastMath.DEG_TO_RAD,
).toQuaternion()
val rot = Quaternion(w, -x, -y, z)
tracker.setRotation(rot)
tracker.dataTick()
} else {
// Receiving OSC Trackers data. This is not from VRChat.
if (oscTrackersDevice == null) {
// Instantiate OSC Trackers device
oscTrackersDevice = server.deviceManager.createDevice("OSC Tracker", null, "OSC Trackers")
server.deviceManager.addDevice(oscTrackersDevice!!)
}
// Extract the xxx in "/tracking/trackers/xxx/..."
val splitAddress = event.message.address.split('/')
val trackerStringValue = splitAddress[3]
val dataType = event.message.address.split('/')[4]
if (trackerStringValue == "head") {
// Head data
if (dataType == "position") {
// Position offset
receivingPositionOffset = Vector3(
event.message.arguments[0] as Float,
event.message.arguments[1] as Float,
-(event.message.arguments[2] as Float),
)
vrcHmd!!.dataTick()
}
} else {
// Receiving OSC Trackers data
if (oscTrackersDevice == null) {
// Instantiate OSC Trackers device
oscTrackersDevice = server.deviceManager.createDevice("OSC Tracker", null, "OSC Trackers")
server.deviceManager.addDevice(oscTrackersDevice!!)
}
// Extract the x in "/tracking/trackers/x.../..."
val trackerStringValue = event.message.address.toString().subSequence(19, 20)
if (trackerStringValue == "h") {
// Head data
val slimeHead = headTracker
if (event.message.address.toString() == "/tracking/trackers/head/position") {
// Position offset
receivingPositionOffset = Vector3(
event.message.arguments[0] as Float,
event.message.arguments[1] as Float,
-(event.message.arguments[2] as Float),
)
if (slimeHead != null && slimeHead.hasPosition) {
postReceivingPositionOffset = slimeHead.position
headTracker?.let {
if (it.hasPosition) {
postReceivingPositionOffset = it.position
}
} else {
// Rotation offset
val (w, x, y, z) = EulerAngles(EulerOrder.YXZ, event.message.arguments[0] as Float * FastMath.DEG_TO_RAD, event.message.arguments[1] as Float * FastMath.DEG_TO_RAD, event.message.arguments[2] as Float * FastMath.DEG_TO_RAD).toQuaternion()
receivingRotationOffsetGoal = Quaternion(w, -x, -y, z).inv()
}
} else {
// Rotation offset
val (w, x, y, z) = EulerAngles(EulerOrder.YXZ, event.message.arguments[0] as Float * FastMath.DEG_TO_RAD, event.message.arguments[1] as Float * FastMath.DEG_TO_RAD, event.message.arguments[2] as Float * FastMath.DEG_TO_RAD).toQuaternion()
receivingRotationOffsetGoal = Quaternion(w, -x, -y, z).inv()
receivingRotationOffsetGoal = if (slimeHead != null && slimeHead.hasRotation) {
slimeHead.getRotation().project(Vector3.POS_Y).unit() * receivingRotationOffsetGoal
headTracker.let {
receivingRotationOffsetGoal = if (it != null && it.hasRotation) {
it.getRotation().project(Vector3.POS_Y).unit() * receivingRotationOffsetGoal
} else {
receivingRotationOffsetGoal
}
// If greater than 300ms, snap to rotation
if (System.currentTimeMillis() - timeAtLastReceivedRotationOffset > 300) {
receivingRotationOffset = receivingRotationOffsetGoal
}
// Update time variable
timeAtLastReceivedRotationOffset = System.currentTimeMillis()
}
} else {
// Trackers data (1-8)
val trackerId = trackerStringValue[0].digitToInt()
var tracker = oscTrackersDevice!!.trackers[trackerId]
if (tracker == null) {
tracker = Tracker(
device = oscTrackersDevice,
id = VRServer.getNextLocalTrackerId(),
name = "OSC Tracker #$trackerId",
displayName = "OSC Tracker #$trackerId",
trackerNum = trackerId,
trackerPosition = null,
hasRotation = true,
hasPosition = true,
userEditable = true,
isComputed = true,
needsReset = true,
usesTimeout = true,
)
oscTrackersDevice!!.trackers[trackerId] = tracker
server.registerTracker(tracker)
}
// Sets the tracker status to OK
tracker.status = TrackerStatus.OK
if (event.message.address.toString() == "/tracking/trackers/$trackerId/position") {
tracker.position = receivingRotationOffset.sandwich(
Vector3(
event.message.arguments[0] as Float,
event.message.arguments[1] as Float,
-(event.message.arguments[2] as Float),
) - receivingPositionOffset,
) + postReceivingPositionOffset
} else {
val (w, x, y, z) = EulerAngles(EulerOrder.YXZ, event.message.arguments[0] as Float * FastMath.DEG_TO_RAD, event.message.arguments[1] as Float * FastMath.DEG_TO_RAD, event.message.arguments[2] as Float * FastMath.DEG_TO_RAD).toQuaternion()
val rot = Quaternion(w, -x, -y, z)
tracker.setRotation(receivingRotationOffset * rot * postReceivingOffset)
// If greater than 300ms, snap to rotation
if (System.currentTimeMillis() - timeAtLastReceivedRotationOffset > 300) {
receivingRotationOffset = receivingRotationOffsetGoal
}
tracker.dataTick()
// Update time variable
timeAtLastReceivedRotationOffset = System.currentTimeMillis()
}
} else {
// Trackers data (1-8)
val trackerId = trackerStringValue.toInt()
var tracker = oscTrackersDevice!!.trackers[trackerId]
if (tracker == null) {
tracker = Tracker(
device = oscTrackersDevice,
id = VRServer.getNextLocalTrackerId(),
name = "OSC Tracker #$trackerId",
displayName = "OSC Tracker #$trackerId",
trackerNum = trackerId,
trackerPosition = null,
hasRotation = true,
hasPosition = true,
userEditable = true,
isComputed = true,
needsReset = true,
usesTimeout = true,
)
oscTrackersDevice!!.trackers[trackerId] = tracker
server.registerTracker(tracker)
}
// Sets the tracker status to OK
tracker.status = TrackerStatus.OK
if (dataType == "position") {
// Update tracker position
tracker.position = receivingRotationOffset.sandwich(
Vector3(
event.message.arguments[0] as Float,
event.message.arguments[1] as Float,
-(event.message.arguments[2] as Float),
) - receivingPositionOffset,
) + postReceivingPositionOffset
} else {
// Update tracker rotation
val (w, x, y, z) = EulerAngles(
EulerOrder.YXZ,
event.message.arguments[0] as Float * FastMath.DEG_TO_RAD,
event.message.arguments[1] as Float * FastMath.DEG_TO_RAD,
event.message.arguments[2] as Float * FastMath.DEG_TO_RAD,
).toQuaternion()
val rot = Quaternion(w, -x, -y, z)
tracker.setRotation(receivingRotationOffset * rot * postReceivingOffset)
}
tracker.dataTick()
}
}
}
override fun update() {
// Update current time
val currentTime = System.currentTimeMillis().toFloat()
// Gets timer from vrServer
if (fpsTimer == null) {
fpsTimer = VRServer.instance.fpsTimer
@@ -318,6 +409,9 @@ class VRCOSCHandler(
receivingRotationOffset = receivingRotationOffset.interpR(receivingRotationOffsetGoal, OFFSET_SLERP_FACTOR * (fpsTimer?.timePerFrame ?: 1f))
}
// Update current time
val currentTime = System.currentTimeMillis().toFloat()
// Send OSC data
if (oscSender != null && oscSender!!.isConnected) {
// Create new bundle
@@ -381,7 +475,8 @@ class VRCOSCHandler(
}
try {
oscSender!!.send(bundle)
oscSender?.send(bundle)
oscQuerySender?.send(bundle)
} catch (e: IOException) {
// Avoid spamming AsynchronousCloseException too many
// times per second
@@ -399,9 +494,9 @@ class VRCOSCHandler(
}
private fun getVRCOSCTrackersId(trackerPosition: TrackerPosition?): Int {
// The order doesn't matter and changing it
// won't break anything except make debugging harder
// between different versions. They just need to range from 1-8
// Needs to range from 1-8.
// Don't change as third party applications may rely
// on this for mapping trackers to body parts.
return when (trackerPosition) {
TrackerPosition.HIP -> 1
TrackerPosition.LEFT_FOOT -> 2
@@ -434,7 +529,8 @@ class VRCOSCHandler(
oscArgs,
)
try {
oscSender!!.send(oscMessage)
oscSender?.send(oscMessage)
oscQuerySender?.send(oscMessage)
} catch (e: IOException) {
LogManager
.warning("[VRCOSCHandler] Error sending OSC message to VRChat: $e")
@@ -447,11 +543,11 @@ class VRCOSCHandler(
override fun getOscSender(): OSCPortOut = oscSender!!
override fun getPortOut(): Int = lastPortOut
override fun getPortOut(): Int = oscPortOut
override fun getAddress(): InetAddress = lastAddress!!
override fun getAddress(): InetAddress = oscIp!!
override fun getOscReceiver(): OSCPortIn = oscReceiver!!
override fun getPortIn(): Int = lastPortIn
override fun getPortIn(): Int = oscPortIn
}
Loaded 100 of 120 files, more files were not shown because too many files have changed in this diff. Show more