mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-11-24 02:51:20 -08:00
Compare commits
1
Commits
main
..
bugfix/1874
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aa07e4f7be |
No files matched your search
@@ -1,9 +1,9 @@
|
|||||||
if ! has nix_direnv_version || ! nix_direnv_version 3.1.1; then
|
if ! has nix_direnv_version || ! nix_direnv_version 2.2.1; then
|
||||||
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.1.1/direnvrc" "sha256-p+fzQdrms/hDa7g+soShAybJNo4bN4SIAeSfqNKgD5I="
|
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.2.1/direnvrc" "sha256-zelF0vLbEl5uaqrfIzbgNzJWGmLzCmYAkInj/LNxvKs="
|
||||||
fi
|
fi
|
||||||
|
|
||||||
watch_file package.json
|
nix_direnv_watch_file package.json
|
||||||
if ! use flake .
|
if ! use flake . --impure
|
||||||
then
|
then
|
||||||
echo "devenv could not be built. The devenv environment was not loaded. Make the necessary changes to devenv.nix and hit enter to try again." >&2
|
echo "devenv could not be built. The devenv environment was not loaded. Make the necessary changes to devenv.nix and hit enter to try again." >&2
|
||||||
fi
|
fi
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
name: Test Crowdin Sync (Dry Run)
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
dry_run:
|
|
||||||
description: 'Perform a dry run (logs changes without modifying repository)'
|
|
||||||
type: boolean
|
|
||||||
default: true
|
|
||||||
localization_branch:
|
|
||||||
description: 'Branch to target for translations'
|
|
||||||
type: string
|
|
||||||
default: 'l10n_main'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
test-crowdin:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v6
|
|
||||||
with:
|
|
||||||
submodules: recursive
|
|
||||||
|
|
||||||
- name: Test Crowdin Synchronization
|
|
||||||
uses: crowdin/github-action@v2
|
|
||||||
with:
|
|
||||||
upload_sources: true
|
|
||||||
upload_translations: false
|
|
||||||
download_translations: true
|
|
||||||
localization_branch_name: ${{ inputs.localization_branch }}
|
|
||||||
dry_run: ${{ inputs.dry_run }}
|
|
||||||
create_pull_request: false
|
|
||||||
env:
|
|
||||||
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
|
|
||||||
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
|
|
||||||
CROWDIN_API_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
|
|
||||||
@@ -3,7 +3,6 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- pontoon
|
- pontoon
|
||||||
- l10n_main
|
|
||||||
jobs:
|
jobs:
|
||||||
pull_request:
|
pull_request:
|
||||||
if: ${{ github.repository == 'SlimeVR/SlimeVR-Server' }}
|
if: ${{ github.repository == 'SlimeVR/SlimeVR-Server' }}
|
||||||
@@ -18,5 +17,5 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.PONTOON_BOT_KEY }}
|
GH_TOKEN: ${{ secrets.PONTOON_BOT_KEY }}
|
||||||
run: |
|
run: |
|
||||||
gh_pr_up() { gh pr create "$@" --draft --base main || gh pr edit "$@"; }
|
gh_pr_up() { gh pr create "$@" --label "Area: Translation" --base main || gh pr edit "$@"; }
|
||||||
gh_pr_up --title "New translations" --body "Please don't squash me 🥺"
|
gh_pr_up --title "New Pontoon translations" --body "Please don't squash me 🥺"
|
||||||
@@ -1,44 +1,14 @@
|
|||||||
# This workflow will rebase `l10n_main` and `pontoon` with `main` changes, it's for making the
|
# This workflow will rebase `pontoon` with `main` changes, it's for making the
|
||||||
# translation bots not try making commits to main
|
# Pontoon bot not try making commits to main
|
||||||
|
|
||||||
name: Rebase translation branches to main
|
name: Rebase pontoon branch to main
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
rebase-l10n:
|
rebase:
|
||||||
if: ${{ github.repository == 'SlimeVR/SlimeVR-Server' }}
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v6
|
|
||||||
with:
|
|
||||||
ref: l10n_main
|
|
||||||
submodules: recursive
|
|
||||||
# Get all the git history for rebasing
|
|
||||||
fetch-depth: 0
|
|
||||||
- name: Rebase
|
|
||||||
run: |
|
|
||||||
git config --local user.name "slimevr-bot"
|
|
||||||
git config --local user.email '[email protected]'
|
|
||||||
git fetch origin main
|
|
||||||
git rebase origin/main
|
|
||||||
git submodule update
|
|
||||||
- name: Push rebase
|
|
||||||
uses: github-actions-x/[email protected]
|
|
||||||
with:
|
|
||||||
github-token: ${{ secrets.PONTOON_BOT_KEY }}
|
|
||||||
push-branch: "l10n_main"
|
|
||||||
commit-message: "update"
|
|
||||||
force-push: "true"
|
|
||||||
name: "slimevr-bot"
|
|
||||||
email: "[email protected]"
|
|
||||||
|
|
||||||
rebase-pontoon:
|
|
||||||
if: ${{ github.repository == 'SlimeVR/SlimeVR-Server' }}
|
if: ${{ github.repository == 'SlimeVR/SlimeVR-Server' }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
|
|||||||
+1
-7
@@ -25,9 +25,7 @@
|
|||||||
.settings
|
.settings
|
||||||
|
|
||||||
# Node Stuff
|
# Node Stuff
|
||||||
node_modules/
|
/node_modules
|
||||||
dist/
|
|
||||||
stats.html
|
|
||||||
.husky
|
.husky
|
||||||
|
|
||||||
# kotlin stuff
|
# kotlin stuff
|
||||||
@@ -35,10 +33,6 @@ stats.html
|
|||||||
|
|
||||||
# ignore gradle build folder
|
# ignore gradle build folder
|
||||||
build/
|
build/
|
||||||
server/desktop/config/
|
|
||||||
|
|
||||||
# created by clangd for index cache
|
|
||||||
.cache/
|
|
||||||
|
|
||||||
# direnv has been claimed for Nix usage
|
# direnv has been claimed for Nix usage
|
||||||
.direnv/
|
.direnv/
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
# Contributing to SlimeVR
|
# Contributing to SlimeVR
|
||||||
|
|
||||||
Please follow general contribution guidelines: [CONTRIBUTING.md](https://github.com/SlimeVR/.github/blob/main/profile/CONTRIBUTING.md).
|
|
||||||
|
|
||||||
This document describes essential knowledge required to contribute to the SlimeVR Server.
|
This document describes essential knowledge required to contribute to the SlimeVR Server.
|
||||||
|
|
||||||
### Prerequisites
|
### Prerequisites
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
$ErrorActionPreference = "Stop"
|
|
||||||
|
|
||||||
if ((Get-Command "clang-format" -ErrorAction SilentlyContinue) -eq $null) {
|
|
||||||
$errorObj = New-Object System.IO.FileNotFoundException("clang-format is not installed, please install clang-format via your package manager (e.g. winget/chocolatey/scoop) and re-run the script")
|
|
||||||
throw $errorObj
|
|
||||||
}
|
|
||||||
|
|
||||||
$SourceFiles = Get-ChildItem -Path '.\src\' -Recurse -Include "*.cpp","*.hpp"
|
|
||||||
foreach ($file in $SourceFiles) {
|
|
||||||
Write-Output "Formatting $(Resolve-Path -Relative $file.FullName)"
|
|
||||||
clang-format -i "$($file.FullName)"
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
if ! command -v clang-format >/dev/null 2>&1; then
|
|
||||||
echo "clang-format is not installed, please install clang-format via your package manager (e.g. pacman/apt/dnf/winget) and re-run the script" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
find src/ \( \
|
|
||||||
-iname '*.cpp' \
|
|
||||||
-or -iname '*.hpp' \
|
|
||||||
\) \
|
|
||||||
-exec echo Formatting {} \; \
|
|
||||||
-exec clang-format -i {} \;
|
|
||||||
@@ -15,13 +15,6 @@
|
|||||||
|
|
||||||
#include "openvr.h"
|
#include "openvr.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#include <Windows.h>
|
|
||||||
#else
|
|
||||||
#include <cstdlib>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace fs = std::filesystem;
|
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
using namespace solarxr_protocol;
|
using namespace solarxr_protocol;
|
||||||
|
|
||||||
@@ -103,35 +96,6 @@ static void signal_handler(int signal) {
|
|||||||
int main() {
|
int main() {
|
||||||
auto &logger = Logger::get();
|
auto &logger = Logger::get();
|
||||||
|
|
||||||
// Steam and SteamVR respectively set these environment variables on applications that
|
|
||||||
// they spawn, which the SteamVR client library (vrclient) will then use as the
|
|
||||||
// application key when initiating the connection with vrserver. This may not
|
|
||||||
// be ideal if we are launched by another Steam or OpenVR application, as we will inherit
|
|
||||||
// their app key through the environment, which means SteamVR will load the wrong bindings.
|
|
||||||
// A real-world example of this is if someone uses an application such as OpenVR-Autostarter
|
|
||||||
// to start the SlimeVR Server. OpenVR-Autostarter installs an application manifest with the
|
|
||||||
// app key "dreiekk.openvr-autostarter", so when it starts SlimeVR Server, which then starts us,
|
|
||||||
// the STEAMVR_APPKEY="dreiekk.openvr-autostarter" environment variable will be set.
|
|
||||||
//
|
|
||||||
// We want SteamVR to use the appkey of the Steam version of our application if possible.
|
|
||||||
// Unfortunately, we cannot install an application vrmanifest to force the app key,
|
|
||||||
// as SteamVR requires a binary path in the manifest to consider it valid. We do not want to install
|
|
||||||
// a manifest with a binary path because we want the SlimeVR Server to start us when the
|
|
||||||
// driver initiates a connection, rather than getting auto-started by SteamVR.
|
|
||||||
//
|
|
||||||
// This is not documented anywhere publicly, see CVRClient::SendConnectMessage in vrclient instead.
|
|
||||||
|
|
||||||
constexpr const char *STEAM_APPID = "3245490";
|
|
||||||
constexpr const char *STEAMVR_APPKEY = "steam.overlay.3245490";
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
SetEnvironmentVariableA("SteamAppId", STEAM_APPID);
|
|
||||||
SetEnvironmentVariableA("STEAMVR_APPKEY", STEAMVR_APPKEY);
|
|
||||||
#else
|
|
||||||
setenv("SteamAppId", STEAM_APPID, 1);
|
|
||||||
setenv("STEAMVR_APPKEY", STEAMVR_APPKEY, 1);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
SolarXRConnection conn;
|
SolarXRConnection conn;
|
||||||
std::unique_ptr<vr::IVRSystem, decltype(&shutdown_vr)> sys{ nullptr,
|
std::unique_ptr<vr::IVRSystem, decltype(&shutdown_vr)> sys{ nullptr,
|
||||||
@@ -164,20 +128,14 @@ int main() {
|
|||||||
vr::IVRApplications *app = vr::VRApplications();
|
vr::IVRApplications *app = vr::VRApplications();
|
||||||
vr::IVRInput *input = vr::VRInput();
|
vr::IVRInput *input = vr::VRInput();
|
||||||
|
|
||||||
fs::path actionManifestPath;
|
auto [appManifestPath, actionManifestPath] = VRUtils::initialiseManifest();
|
||||||
std::tie(std::ignore, actionManifestPath) = VRUtils::initialiseManifest();
|
|
||||||
|
|
||||||
// We don't want our app key to randomly change if SteamVR decides to honour
|
|
||||||
// application manifests with no binary path. Instead let it generate an
|
|
||||||
// app key based on the executable name (system.generated.[lowercase executable name])
|
|
||||||
#if false
|
|
||||||
if (auto err = app->AddApplicationManifest(appManifestPath.string().data(), true);
|
if (auto err = app->AddApplicationManifest(appManifestPath.string().data(), true);
|
||||||
err != vr::VRApplicationError_None) {
|
err != vr::VRApplicationError_None) {
|
||||||
logger.error("Failed to add application manifest: {}",
|
logger.error("Failed to add application manifest: {}",
|
||||||
app->GetApplicationsErrorNameFromEnum(err));
|
app->GetApplicationsErrorNameFromEnum(err));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// SetActionManifestPath may return IPCError if vrserver is busy and takes
|
// SetActionManifestPath may return IPCError if vrserver is busy and takes
|
||||||
// too long to reply, so keep invoking until it succeeds
|
// too long to reply, so keep invoking until it succeeds
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
#include "solarxr.hpp"
|
#include "solarxr.hpp"
|
||||||
#include "logger.hpp"
|
#include "logger.hpp"
|
||||||
#include "paths.hpp"
|
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
@@ -16,24 +14,15 @@
|
|||||||
|
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
static std::string getenvSafe(const char *env) {
|
|
||||||
char *v = getenv(env);
|
|
||||||
if (v == nullptr)
|
|
||||||
return {};
|
|
||||||
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
fs::path SolarXRConnection::getSocketPath() {
|
fs::path SolarXRConnection::getSocketPath() {
|
||||||
using namespace std::string_view_literals;
|
using namespace std::string_view_literals;
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
#define MAKE_SOCKET_PATH(PATH) \
|
#define MAKE_SOCKET_PATH(PATH) \
|
||||||
std::make_pair(PATH##sv, getenvSafe(PATH))
|
std::make_pair(PATH##sv, static_cast<const char *>(getenv(PATH)))
|
||||||
|
|
||||||
constexpr std::string_view socketName = "SlimeVRRpc";
|
constexpr std::string_view socketName = "SlimeVRRpc";
|
||||||
std::array<std::pair<std::string_view, fs::path>, 5> socketPaths{
|
std::array<std::pair<std::string_view, const char *>, 4> socketPaths{
|
||||||
MAKE_SOCKET_PATH("SLIMEVR_SOCKET_DIR"),
|
MAKE_SOCKET_PATH("SLIMEVR_SOCKET_DIR"),
|
||||||
{ "Steam socket path", Paths::getDataPath() },
|
|
||||||
MAKE_SOCKET_PATH("XDG_RUNTIME_DIR"),
|
MAKE_SOCKET_PATH("XDG_RUNTIME_DIR"),
|
||||||
MAKE_SOCKET_PATH("TMPDIR"),
|
MAKE_SOCKET_PATH("TMPDIR"),
|
||||||
{ "/tmp", "/tmp" }
|
{ "/tmp", "/tmp" }
|
||||||
@@ -42,17 +31,17 @@ fs::path SolarXRConnection::getSocketPath() {
|
|||||||
#undef MAKE_SOCKET_PATH
|
#undef MAKE_SOCKET_PATH
|
||||||
|
|
||||||
for (auto [name, path] : socketPaths) {
|
for (auto [name, path] : socketPaths) {
|
||||||
if (path.empty()) {
|
if (path == nullptr) {
|
||||||
Logger::get().info(
|
Logger::get().info(
|
||||||
"Skipping socket directory '{}' because it doesn't exist", name);
|
"Skipping socket directory {} because it doesn't exist", name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
fs::path socketPath = path / socketName;
|
fs::path socketPath = fs::path(path) / socketName;
|
||||||
if (fs::exists(socketPath))
|
if (fs::exists(socketPath))
|
||||||
return socketPath;
|
return socketPath;
|
||||||
|
|
||||||
Logger::get().info(
|
Logger::get().info(
|
||||||
"Skipping socket directory '{}' because socket does not exist", name);
|
"Skipping socket directory {} because socket does not exist", name);
|
||||||
}
|
}
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
throw std::logic_error(
|
throw std::logic_error(
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
plugins {
|
||||||
|
id("org.ajoberstar.grgit")
|
||||||
|
}
|
||||||
-19
@@ -1,19 +0,0 @@
|
|||||||
# Crowdin Configuration File
|
|
||||||
# https://developer.crowdin.com/configuration-file/
|
|
||||||
|
|
||||||
project_id_env: CROWDIN_PROJECT_ID
|
|
||||||
api_token_env: CROWDIN_PERSONAL_TOKEN
|
|
||||||
|
|
||||||
files:
|
|
||||||
- source: /gui/app/public/i18n/en/translation.ftl
|
|
||||||
translation: /gui/app/public/i18n/%locale%/%original_file_name%
|
|
||||||
languages_mapping:
|
|
||||||
locale:
|
|
||||||
zh-CN: zh-Hans
|
|
||||||
zh-TW: zh-Hant
|
|
||||||
nb: nb-NO
|
|
||||||
nb-NO: nb-NO
|
|
||||||
sv: sv-SE
|
|
||||||
sv-SE: sv-SE
|
|
||||||
en-OWO: en-x-owo
|
|
||||||
owo: en-x-owo
|
|
||||||
Generated
+6
-6
@@ -5,11 +5,11 @@
|
|||||||
"nixpkgs-lib": "nixpkgs-lib"
|
"nixpkgs-lib": "nixpkgs-lib"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1778716662,
|
"lastModified": 1777988971,
|
||||||
"narHash": "sha256-m1Yf0wZ8j1OHjTc2UwHwyQRSnNeSgLJOd7q5Y45hzi4=",
|
"narHash": "sha256-qIoWPDs+0/8JecyYgE3gpKQxW/4bLW/gp45vow9ioCQ=",
|
||||||
"owner": "hercules-ci",
|
"owner": "hercules-ci",
|
||||||
"repo": "flake-parts",
|
"repo": "flake-parts",
|
||||||
"rev": "f7c1a2d347e4c52d5fb8d10cb4d94b5884e546fb",
|
"rev": "0678d8986be1661af6bb555f3489f2fdfc31f6ff",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -20,11 +20,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1781577229,
|
"lastModified": 1777954456,
|
||||||
"narHash": "sha256-lrp67w8AulE9Ks53n27I45ADSzbOCn4H+CNW1Ck8B+8=",
|
"narHash": "sha256-hGdgeU2Nk87RAuZyYjyDjFL6LK7dAZN5RE9+hrDTkDU=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "567a49d1913ce81ac6e9582e3553dd90a955875f",
|
"rev": "549bd84d6279f9852cae6225e372cc67fb91a4c1",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|||||||
@@ -14,151 +14,86 @@
|
|||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
flake-parts.lib.mkFlake { inherit inputs; } {
|
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||||
systems = [
|
systems = [ "x86_64-linux" ];
|
||||||
"aarch64-linux"
|
|
||||||
"x86_64-linux"
|
|
||||||
];
|
|
||||||
|
|
||||||
perSystem =
|
perSystem =
|
||||||
{ lib, pkgs, ... }:
|
{ pkgs, ... }:
|
||||||
let
|
let
|
||||||
runtimeLibs = [
|
runtimeLibs =
|
||||||
pkgs.alsa-lib
|
pkgs:
|
||||||
pkgs.libpulseaudio
|
(with pkgs; [
|
||||||
pkgs.at-spi2-atk
|
jdk17
|
||||||
pkgs.at-spi2-core
|
|
||||||
pkgs.cairo
|
|
||||||
pkgs.cups
|
|
||||||
pkgs.dbus
|
|
||||||
pkgs.expat
|
|
||||||
pkgs.gdk-pixbuf
|
|
||||||
pkgs.glib
|
|
||||||
pkgs.gtk3
|
|
||||||
pkgs.libdrm
|
|
||||||
pkgs.libgbm
|
|
||||||
pkgs.libglvnd
|
|
||||||
pkgs.libnotify
|
|
||||||
pkgs.libxkbcommon
|
|
||||||
pkgs.mesa
|
|
||||||
pkgs.nspr
|
|
||||||
pkgs.nss
|
|
||||||
pkgs.pango
|
|
||||||
pkgs.systemd
|
|
||||||
pkgs.vulkan-loader
|
|
||||||
pkgs.wayland
|
|
||||||
pkgs.libX11
|
|
||||||
pkgs.libXcomposite
|
|
||||||
pkgs.libXdamage
|
|
||||||
pkgs.libXext
|
|
||||||
pkgs.libXfixes
|
|
||||||
pkgs.libXrandr
|
|
||||||
pkgs.libxcb
|
|
||||||
pkgs.libxshmfence
|
|
||||||
pkgs.libusb1
|
|
||||||
pkgs.udev
|
|
||||||
pkgs.libxcrypt-legacy
|
|
||||||
];
|
|
||||||
|
|
||||||
toolDirectoryName =
|
alsa-lib
|
||||||
if pkgs.stdenv.hostPlatform.isDarwin then
|
libpulseaudio
|
||||||
"darwin"
|
at-spi2-atk
|
||||||
else if pkgs.stdenv.hostPlatform.isLinux then
|
at-spi2-core
|
||||||
{
|
cairo
|
||||||
"armv7l-linux" = "linux-arm32";
|
cups
|
||||||
"aarch64-linux" = "linux-arm64";
|
dbus
|
||||||
"i686-linux" = "linux-ia32";
|
expat
|
||||||
"x86_64-linux" = "linux-x64";
|
gdk-pixbuf
|
||||||
}
|
glib
|
||||||
."${pkgs.stdenv.hostPlatform.system}"
|
gtk3
|
||||||
else
|
libdrm
|
||||||
throw "Unsupported platform";
|
libgbm
|
||||||
|
libglvnd
|
||||||
|
libnotify
|
||||||
|
libxkbcommon
|
||||||
|
mesa
|
||||||
|
nspr
|
||||||
|
nss
|
||||||
|
pango
|
||||||
|
systemd
|
||||||
|
vulkan-loader
|
||||||
|
wayland
|
||||||
|
libX11
|
||||||
|
libXcomposite
|
||||||
|
libXdamage
|
||||||
|
libXext
|
||||||
|
libXfixes
|
||||||
|
libXrandr
|
||||||
|
libxcb
|
||||||
|
libxshmfence
|
||||||
|
libusb1
|
||||||
|
udev
|
||||||
|
libxcrypt-legacy
|
||||||
|
rpm
|
||||||
|
fpm
|
||||||
|
|
||||||
# we use fuse2
|
wineWow64Packages.stable
|
||||||
# https://github.com/electron-userland/electron-builder/blob/a6117b3011a105204af8cc2eca02a56976d1ef29/packages/app-builder-lib/src/toolsets/linux.ts#L122
|
zlib
|
||||||
runtime = pkgs.stdenvNoCC.mkDerivation {
|
squashfsTools
|
||||||
name = "electron-builder-appimage-runtime";
|
fakeroot
|
||||||
src = pkgs.fetchurl {
|
libarchive
|
||||||
url = "https://github.com/electron-userland/electron-builder-binaries/releases/download/appimage-12.0.1/appimage-12.0.1.7z";
|
icu
|
||||||
hash = "sha256-0S/3648dHsRlLKUjen+9yjOswMdYBFY2/spi3G7LjsQ=";
|
nodejs_22
|
||||||
};
|
pnpm
|
||||||
# https://github.com/NixOS/nixpkgs/blob/7890ba0a99c064446fe2178ef2f8e3abdf6ec42a/pkgs/by-name/lo/losslesscut-bin/build-from-windows.nix#L20
|
pkg-config
|
||||||
nativeBuildInputs = [ pkgs.p7zip ];
|
python3
|
||||||
unpackPhase = ''
|
gcc
|
||||||
runHook preUnpack
|
gnumake
|
||||||
7z x "$src"
|
binutils
|
||||||
runHook postUnpack
|
git
|
||||||
'';
|
node-gyp-build
|
||||||
installPhase = ''
|
]);
|
||||||
mkdir $out
|
|
||||||
cp -r -t $out/ \
|
|
||||||
lib/ \
|
|
||||||
runtime-*
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
appImageTools = pkgs.stdenvNoCC.mkDerivation {
|
slimeShell = pkgs.buildFHSEnv {
|
||||||
name = "electron-builder-appimage-tools";
|
name = "slimevr-env";
|
||||||
dontUnpack = true;
|
targetPkgs = runtimeLibs;
|
||||||
|
profile = ''
|
||||||
|
export JAVA_HOME=${pkgs.jdk17}
|
||||||
|
export PATH="${pkgs.jdk17}/bin:$PATH"
|
||||||
|
|
||||||
installPhase = ''
|
# Tell electron-builder to use system tools instead of downloading them
|
||||||
mkdir -p "$out/${toolDirectoryName}"
|
export USE_SYSTEM_FPM=true
|
||||||
ln -s -t $out/${toolDirectoryName} \
|
export USE_SYSTEM_MKSQUASHFS=true
|
||||||
"${pkgs.desktop-file-utils}/bin/desktop-file-validate" \
|
|
||||||
"${pkgs.squashfsTools}/bin/mksquashfs"
|
|
||||||
ln -s ${runtime}/runtime-* $out/
|
|
||||||
ln -s ${runtime}/lib $out/lib
|
|
||||||
'';
|
'';
|
||||||
|
runScript = "bash";
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
devShells.default = pkgs.mkShell {
|
devShells.default = slimeShell.env;
|
||||||
packages = [
|
|
||||||
# for running the jar
|
|
||||||
pkgs.jdk17
|
|
||||||
# for build
|
|
||||||
pkgs.electron
|
|
||||||
pkgs.rpm
|
|
||||||
pkgs.fpm
|
|
||||||
pkgs.p7zip
|
|
||||||
pkgs.wineWow64Packages.stable
|
|
||||||
pkgs.zlib
|
|
||||||
pkgs.squashfsTools
|
|
||||||
pkgs.desktop-file-utils
|
|
||||||
pkgs.fakeroot
|
|
||||||
pkgs.libarchive
|
|
||||||
pkgs.icu
|
|
||||||
pkgs.nodejs_22
|
|
||||||
pkgs.pnpm
|
|
||||||
pkgs.pkg-config
|
|
||||||
pkgs.python3
|
|
||||||
pkgs.gcc
|
|
||||||
pkgs.gnumake
|
|
||||||
pkgs.binutils
|
|
||||||
pkgs.git
|
|
||||||
pkgs.node-gyp-build
|
|
||||||
];
|
|
||||||
buildInputs = runtimeLibs;
|
|
||||||
|
|
||||||
JAVA_HOME = "${pkgs.jdk17}/lib/openjdk";
|
|
||||||
USE_SYSTEM_FPM = "true";
|
|
||||||
ELECTRON_BUILDER_7ZIP_PATH = "${pkgs.p7zip}/bin/7za";
|
|
||||||
APPIMAGE_TOOLS_PATH = "${appImageTools}";
|
|
||||||
#ELECTRON_SKIP_BINARY_DOWNLOAD = true;
|
|
||||||
#ELECTRON_DIST = "${pkgs.electron.dist}";
|
|
||||||
#ELECTRON_VERSION = "${pkgs.electron.version}";
|
|
||||||
|
|
||||||
# for electron-vite, so `pnpm gui` works
|
|
||||||
ELECTRON_EXEC_PATH = "${pkgs.electron}/bin/electron";
|
|
||||||
|
|
||||||
shellHook = ''
|
|
||||||
export LD_LIBRARY_PATH="${
|
|
||||||
lib.makeLibraryPath [
|
|
||||||
pkgs.systemd
|
|
||||||
pkgs.hidapi
|
|
||||||
]
|
|
||||||
}:$LD_LIBRARY_PATH"
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
+4
-1
@@ -17,7 +17,10 @@ kotlinVersion=2.3.10
|
|||||||
spotlessVersion=8.2.1
|
spotlessVersion=8.2.1
|
||||||
shadowJarVersion=9.3.1
|
shadowJarVersion=9.3.1
|
||||||
buildconfigVersion=6.0.7
|
buildconfigVersion=6.0.7
|
||||||
|
# We should probably stop using grgit, see:
|
||||||
|
# https://andrewoberstar.com/posts/2024-04-02-dont-commit-to-grgit/
|
||||||
|
grgitVersion=5.3.3
|
||||||
|
|
||||||
# Fix gradle leaving multiple java processes running that accumulate and use multiple GBs of RAM
|
# Fix gradle leaving multiple java processes running that accumulate and use multiple GBs of RAM
|
||||||
# This mostly seems to affect it when running from console, and then sending a SIGINT (Ctrl + C)
|
# This mostly seems to affect it when running from console, and then sending a SIGINT (Ctrl + C)
|
||||||
org.gradle.daemon.idletimeout=10000
|
org.gradle.daemon.idletimeout=10000
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
export default {
|
export default {
|
||||||
'**/*.{ts,tsx}': () => 'tsc -p tsconfig.json --noEmit',
|
'**/*.{ts,tsx}': () => 'tsc -p tsconfig.json --noEmit',
|
||||||
'{electron,src}/**/*.{js,jsx,ts,tsx}': 'eslint --max-warnings=0 --no-warn-ignored --cache --fix',
|
'src/**/*.{js,jsx,ts,tsx}': 'eslint --max-warnings=0 --no-warn-ignored --cache --fix',
|
||||||
'**/*.{js,jsx,ts,tsx,css,scss,md,json}': 'prettier --write',
|
'**/*.{js,jsx,ts,tsx,css,scss,md,json}': 'prettier --write',
|
||||||
};
|
};
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Option, program } from 'commander';
|
import { Option, program } from "commander";
|
||||||
|
|
||||||
program
|
program
|
||||||
.option('-p, --path <path>', 'set launch path')
|
.option('-p, --path <path>', 'set launch path')
|
||||||
@@ -12,10 +12,10 @@ program
|
|||||||
// Allow passing arguments to Electron.
|
// Allow passing arguments to Electron.
|
||||||
.allowExcessArguments();
|
.allowExcessArguments();
|
||||||
|
|
||||||
if (process.platform === 'linux') {
|
if (process.platform === "linux") {
|
||||||
const noUdevOption = new Option('--no-udev', 'disable udev warning');
|
const noUdevOption = new Option('--no-udev', 'disable udev warning');
|
||||||
noUdevOption.negate = false;
|
noUdevOption.negate = false;
|
||||||
program.addOption(noUdevOption);
|
program.addOption(noUdevOption)
|
||||||
}
|
}
|
||||||
|
|
||||||
program.parse(process.argv);
|
program.parse(process.argv);
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ import {
|
|||||||
} from './paths';
|
} from './paths';
|
||||||
import { initStores } from './store';
|
import { initStores } from './store';
|
||||||
import { closeLogger, logger } from './logger';
|
import { closeLogger, logger } from './logger';
|
||||||
|
|
||||||
import { spawn } from 'node:child_process';
|
import { spawn } from 'node:child_process';
|
||||||
import { discordPresence } from './presence';
|
import { discordPresence } from './presence';
|
||||||
import { options } from './cli';
|
import { options } from './cli';
|
||||||
@@ -127,14 +126,14 @@ handleIpc(IPC_CHANNELS.LOG, (e, type, ...args) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
handleIpc(IPC_CHANNELS.OPEN_URL, (e, url) => {
|
handleIpc(IPC_CHANNELS.OPEN_URL, (e, url) => {
|
||||||
const allowedUrls = [
|
const allowed_urls = [
|
||||||
/^steam:\/\//,
|
/^steam:\/\//,
|
||||||
/^ms-settings:network$/,
|
/^ms-settings:network$/,
|
||||||
/^https:\/\/(?:.+\.)?slimevr\.dev(?:\/.+)?$/,
|
/^https:\/\/(?:.+\.)?slimevr\.dev(?:\/.+)?$/,
|
||||||
/^https:\/\/github\.com\/SlimeVR(?:\/.+)?$/,
|
/^https:\/\/github\.com\/SlimeVR(?:\/.+)?$/,
|
||||||
/^https:\/\/discord\.gg\/slimevr$/,
|
/^https:\/\/discord\.gg\/slimevr$/,
|
||||||
];
|
];
|
||||||
if (allowedUrls.find((a) => url.match(a))) open(url);
|
if (allowed_urls.find((a) => url.match(a))) open(url);
|
||||||
else logger.error({ url }, 'attempted to open non-whitelisted URL');
|
else logger.error({ url }, 'attempted to open non-whitelisted URL');
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -371,9 +370,9 @@ function createWindow() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const checkEnvironmentVariables = () => {
|
const checkEnvironmentVariables = () => {
|
||||||
const disallowedVars = ['_JAVA_OPTIONS', 'JAVA_TOOL_OPTIONS'];
|
const to_check = ['_JAVA_OPTIONS', 'JAVA_TOOL_OPTIONS'];
|
||||||
|
|
||||||
const set = disallowedVars.filter((env) => !!process.env[env]);
|
const set = to_check.filter((env) => !!process.env[env]);
|
||||||
if (set.length > 0) {
|
if (set.length > 0) {
|
||||||
dialog.showErrorBox(
|
dialog.showErrorBox(
|
||||||
'SlimeVR',
|
'SlimeVR',
|
||||||
@@ -404,7 +403,7 @@ const spawnServer = async () => {
|
|||||||
if (!javaBin) {
|
if (!javaBin) {
|
||||||
dialog.showErrorBox(
|
dialog.showErrorBox(
|
||||||
'SlimeVR',
|
'SlimeVR',
|
||||||
'Unable to find a compatible Java version, please download Java 17 or higher'
|
`Couldn't find a compatible Java version, please download Java 17 or higher`
|
||||||
);
|
);
|
||||||
app.quit();
|
app.quit();
|
||||||
return;
|
return;
|
||||||
@@ -501,6 +500,12 @@ app.whenReady().then(async () => {
|
|||||||
|
|
||||||
logger.info('SlimeVR started!');
|
logger.info('SlimeVR started!');
|
||||||
|
|
||||||
|
process.on('exit', async (code) => {
|
||||||
|
console.log(code);
|
||||||
|
server?.close();
|
||||||
|
await server?.waitForExit();
|
||||||
|
});
|
||||||
|
|
||||||
app.on('window-all-closed', () => {
|
app.on('window-all-closed', () => {
|
||||||
app.quit();
|
app.quit();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import { access, mkdir, readFile, writeFile } from 'fs/promises';
|
import { access, mkdir, readFile, writeFile } from "fs/promises";
|
||||||
import { dirname, join } from 'path';
|
import { dirname, join } from "path";
|
||||||
import { logger } from './logger';
|
import { logger } from "./logger";
|
||||||
import { getGuiDataFolder } from './paths';
|
import { getGuiDataFolder } from "./paths";
|
||||||
|
|
||||||
|
|
||||||
export class CustomStore {
|
export class CustomStore {
|
||||||
private data: Record<string, unknown> = {};
|
private data: Record<string, unknown> = {};
|
||||||
@@ -14,10 +15,7 @@ export class CustomStore {
|
|||||||
this.debounceMs = debounceMs;
|
this.debounceMs = debounceMs;
|
||||||
}
|
}
|
||||||
|
|
||||||
static async create(
|
static async create(filePath: string, debounceMs: number = 2000): Promise<CustomStore> {
|
||||||
filePath: string,
|
|
||||||
debounceMs: number = 2000
|
|
||||||
): Promise<CustomStore> {
|
|
||||||
const store = new CustomStore(filePath, debounceMs);
|
const store = new CustomStore(filePath, debounceMs);
|
||||||
await store.load();
|
await store.load();
|
||||||
return store;
|
return store;
|
||||||
@@ -30,9 +28,7 @@ export class CustomStore {
|
|||||||
this.data = JSON.parse(raw);
|
this.data = JSON.parse(raw);
|
||||||
} catch {
|
} catch {
|
||||||
this.data = {};
|
this.data = {};
|
||||||
logger.warn(
|
logger.warn(`No existing store found at ${this.filePath}, starting with empty store.`);
|
||||||
`No existing store found at ${this.filePath}, starting with empty store.`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,10 +73,7 @@ export class CustomStore {
|
|||||||
|
|
||||||
export async function initStores() {
|
export async function initStores() {
|
||||||
return {
|
return {
|
||||||
settings: await CustomStore.create(
|
settings: await CustomStore.create(join(getGuiDataFolder(), 'gui-settings.dat'), 1000),
|
||||||
join(getGuiDataFolder(), 'gui-settings.dat'),
|
|
||||||
1000
|
|
||||||
),
|
|
||||||
cache: await CustomStore.create(join(getGuiDataFolder(), 'gui-cache.dat'), 100),
|
cache: await CustomStore.create(join(getGuiDataFolder(), 'gui-cache.dat'), 100),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
+19
-18
@@ -1,8 +1,8 @@
|
|||||||
import os from 'os';
|
import os from 'os'
|
||||||
import { OSStats } from '../preload/interface';
|
import { OSStats } from "../preload/interface";
|
||||||
import { ipcMain, IpcMainInvokeEvent } from 'electron';
|
import { ipcMain, IpcMainInvokeEvent } from 'electron';
|
||||||
import { IpcInvokeMap } from '../shared';
|
import { IpcInvokeMap } from '../shared';
|
||||||
import net from 'net';
|
import net from 'net'
|
||||||
|
|
||||||
export const getPlatform = (): OSStats['type'] => {
|
export const getPlatform = (): OSStats['type'] => {
|
||||||
switch (os.platform()) {
|
switch (os.platform()) {
|
||||||
@@ -19,21 +19,21 @@ export const getPlatform = (): OSStats['type'] => {
|
|||||||
|
|
||||||
export const isPortAvailable = (port: number) => {
|
export const isPortAvailable = (port: number) => {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
const s = net.createServer();
|
const s = net.createServer();
|
||||||
s.once('error', (err) => {
|
s.once('error', (err) => {
|
||||||
s.close();
|
s.close();
|
||||||
if ('code' in err && err['code'] == 'EADDRINUSE') {
|
if ("code" in err && err["code"] == "EADDRINUSE") {
|
||||||
resolve(false);
|
resolve(false);
|
||||||
} else {
|
} else {
|
||||||
resolve(false);
|
resolve(false);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
s.once('listening', () => {
|
||||||
|
resolve(true);
|
||||||
|
s.close();
|
||||||
|
});
|
||||||
|
s.listen(port);
|
||||||
});
|
});
|
||||||
s.once('listening', () => {
|
|
||||||
resolve(true);
|
|
||||||
s.close();
|
|
||||||
});
|
|
||||||
s.listen(port);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export function handleIpc<K extends keyof IpcInvokeMap>(
|
export function handleIpc<K extends keyof IpcInvokeMap>(
|
||||||
@@ -44,6 +44,7 @@ export function handleIpc<K extends keyof IpcInvokeMap>(
|
|||||||
) => ReturnType<IpcInvokeMap[K]>
|
) => ReturnType<IpcInvokeMap[K]>
|
||||||
) {
|
) {
|
||||||
ipcMain.handle(channel, (event, ...args) => {
|
ipcMain.handle(channel, (event, ...args) => {
|
||||||
return handler(event, ...(args as any));
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
return handler(event, ...args as any);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -41,7 +41,6 @@ SUBSYSTEMS=="usb", ATTRS{idVendor}=="303a", ATTRS{idProduct}=="0002", MODE="0660
|
|||||||
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", MODE="0660", TAG+="uaccess"
|
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", MODE="0660", TAG+="uaccess"
|
||||||
|
|
||||||
## SlimeVR
|
## SlimeVR
|
||||||
# SlimeNRF Receiver & Tracker
|
# smol slime dongle
|
||||||
SUBSYSTEM=="usb|tty", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="7690|7692", MODE="0660", TAG+="uaccess"
|
SUBSYSTEM=="usb", ATTR{idVendor}=="1209", ATTR{idProduct}=="7690", MODE="0660", TAG+="uaccess"
|
||||||
# same thing but hidraw
|
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="7690", MODE="0660", TAG+="uaccess"
|
||||||
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="7690|7692", MODE="0660", TAG+="uaccess"
|
|
||||||
@@ -39,7 +39,7 @@ export const gui = [
|
|||||||
...globals.jest,
|
...globals.jest,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
files: ['{electron,src}/**/*.{js,jsx,ts,tsx,json}'],
|
files: ['src/**/*.{js,jsx,ts,tsx,json}'],
|
||||||
plugins: {
|
plugins: {
|
||||||
'@typescript-eslint': tseslint.plugin,
|
'@typescript-eslint': tseslint.plugin,
|
||||||
'@stylistic': stylistic,
|
'@stylistic': stylistic,
|
||||||
|
|||||||
+4
-4
@@ -23,9 +23,9 @@
|
|||||||
"package:build": "pnpm build && pnpm package",
|
"package:build": "pnpm build && pnpm package",
|
||||||
"preview": "electron-vite preview --config electron.vite.config.ts",
|
"preview": "electron-vite preview --config electron.vite.config.ts",
|
||||||
"skipbundler": "vite build",
|
"skipbundler": "vite build",
|
||||||
"lint": "tsc --noEmit && eslint --max-warnings=0 \"{electron,src}/**/*.{js,jsx,ts,tsx,json}\" && prettier --check \"{electron,src}/**/*.{js,jsx,ts,tsx,css,scss,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 \"{electron,src}/**/*.{js,jsx,ts,tsx,json}\" && pnpm run format",
|
"lint:fix": "tsc --noEmit && eslint --fix --max-warnings=0 \"src/**/*.{js,jsx,ts,tsx,json}\" && pnpm run format",
|
||||||
"format": "prettier --write \"{electron,src}/**/*.{js,jsx,ts,tsx,css,scss,md,json}\"",
|
"format": "prettier --write \"src/**/*.{js,jsx,ts,tsx,css,scss,md,json}\"",
|
||||||
"javaversion-build": "cd electron/resources/java-version/ && javac JavaVersion.java && jar cvfe JavaVersion.jar JavaVersion JavaVersion.class",
|
"javaversion-build": "cd electron/resources/java-version/ && javac JavaVersion.java && jar cvfe JavaVersion.jar JavaVersion JavaVersion.class",
|
||||||
"gen:javaversion": "cd electron/resources/java-version/ && javac JavaVersion.java && jar cvfe JavaVersion.jar JavaVersion JavaVersion.class",
|
"gen:javaversion": "cd electron/resources/java-version/ && javac JavaVersion.java && jar cvfe JavaVersion.jar JavaVersion JavaVersion.class",
|
||||||
"gen:firmware-tool": "openapi-codegen gen firmwareTool"
|
"gen:firmware-tool": "openapi-codegen gen firmwareTool"
|
||||||
@@ -68,7 +68,7 @@
|
|||||||
"dmg-license": "^1.0.11",
|
"dmg-license": "^1.0.11",
|
||||||
"dotenv": "^16.4.5",
|
"dotenv": "^16.4.5",
|
||||||
"electron": "^40.3.0",
|
"electron": "^40.3.0",
|
||||||
"electron-builder": "^26.15.0",
|
"electron-builder": "^26.9.0",
|
||||||
"electron-vite": "^5.0.0",
|
"electron-vite": "^5.0.0",
|
||||||
"@eslint/eslintrc": "^3.3.5",
|
"@eslint/eslintrc": "^3.3.5",
|
||||||
"@eslint/js": "^9.39.4",
|
"@eslint/js": "^9.39.4",
|
||||||
|
|||||||
@@ -690,15 +690,17 @@ settings-general-gesture_control-trackers = { $amount ->
|
|||||||
settings-general-gesture_control-yawResetEnabled = Enable tap to yaw reset
|
settings-general-gesture_control-yawResetEnabled = Enable tap to yaw reset
|
||||||
settings-general-gesture_control-yawResetDelay = Yaw reset delay
|
settings-general-gesture_control-yawResetDelay = Yaw reset delay
|
||||||
settings-general-gesture_control-yawResetTaps = Taps for yaw reset
|
settings-general-gesture_control-yawResetTaps = Taps for yaw reset
|
||||||
settings-general-gesture_control-yawResetTracker = Yaw reset tracker
|
settings-general-gesture_control-yawResetTracker = Yaw Reset Tracker
|
||||||
settings-general-gesture_control-fullResetEnabled = Enable tap to full reset
|
settings-general-gesture_control-fullResetEnabled = Enable tap to full reset
|
||||||
settings-general-gesture_control-fullResetDelay = Full reset delay
|
settings-general-gesture_control-fullResetDelay = Full reset delay
|
||||||
settings-general-gesture_control-fullResetTaps = Taps for full reset
|
settings-general-gesture_control-fullResetTaps = Taps for full reset
|
||||||
settings-general-gesture_control-fullResetTracker = Full reset tracker
|
settings-general-gesture_control-fullResetTracker = Full Reset Tracker
|
||||||
settings-general-gesture_control-mountingResetEnabled = Enable tap to perform mounting calibration
|
settings-general-gesture_control-mountingResetEnabled = Enable tap to perform mounting calibration
|
||||||
settings-general-gesture_control-mountingResetDelay = Mounting calibration delay
|
settings-general-gesture_control-mountingResetDelay = Mounting calibration delay
|
||||||
settings-general-gesture_control-mountingResetTaps = Taps for mounting calibration
|
settings-general-gesture_control-mountingResetTaps = Taps for mounting calibration
|
||||||
settings-general-gesture_control-mountingResetTracker = Mounting reset tracker
|
settings-general-gesture_control-mountingResetTracker = Mounting Reset Tracker
|
||||||
|
settings-general-gesture_control-yawResetTracker-title = Yaw Reset Tracker
|
||||||
|
settings-general-gesture_control-fullResetTracker-title = Full Reset Tracker
|
||||||
# The number of trackers that can have higher acceleration before a tap is rejected
|
# The number of trackers that can have higher acceleration before a tap is rejected
|
||||||
settings-general-gesture_control-numberTrackersOverThreshold = Trackers over threshold
|
settings-general-gesture_control-numberTrackersOverThreshold = Trackers over threshold
|
||||||
settings-general-gesture_control-numberTrackersOverThreshold-description = Increase this value if tap detection is not working. Do not increase it above what is needed to make tap detection work as it would cause more false positives.
|
settings-general-gesture_control-numberTrackersOverThreshold-description = Increase this value if tap detection is not working. Do not increase it above what is needed to make tap detection work as it would cause more false positives.
|
||||||
@@ -788,12 +790,6 @@ settings-serial-factory_reset-warning-cancel = Cancel
|
|||||||
settings-serial-serial_select = Select a serial port
|
settings-serial-serial_select = Select a serial port
|
||||||
settings-serial-auto_dropdown_item = Auto
|
settings-serial-auto_dropdown_item = Auto
|
||||||
settings-serial-get_wifi_scan = Get WiFi Scan
|
settings-serial-get_wifi_scan = Get WiFi Scan
|
||||||
settings-serial-enter_pairing = Enter Pairing
|
|
||||||
settings-serial-exit_pairing = Exit Pairing
|
|
||||||
settings-serial-calibrate = Calibrate
|
|
||||||
settings-serial-six_side_calibrate = 6-Side Calibrate
|
|
||||||
settings-serial-dfu = Enter DFU
|
|
||||||
settings-serial-meow = Meow!
|
|
||||||
settings-serial-file_type = Plain text
|
settings-serial-file_type = Plain text
|
||||||
settings-serial-save_logs = Save To File
|
settings-serial-save_logs = Save To File
|
||||||
settings-serial-send_command = Send
|
settings-serial-send_command = Send
|
||||||
@@ -1661,20 +1657,12 @@ tracking_checklist-MOUNTING_CALIBRATION = Perform a mounting calibration
|
|||||||
tracking_checklist-FEET_MOUNTING_CALIBRATION = Perform a feet mounting calibration
|
tracking_checklist-FEET_MOUNTING_CALIBRATION = Perform a feet mounting calibration
|
||||||
tracking_checklist-FULL_RESET = Perform a full reset
|
tracking_checklist-FULL_RESET = Perform a full reset
|
||||||
tracking_checklist-FULL_RESET-desc = Some trackers need a reset to be performed.
|
tracking_checklist-FULL_RESET-desc = Some trackers need a reset to be performed.
|
||||||
tracking_checklist-STEAMVR_DISCONNECTED = SteamVR disconnected
|
tracking_checklist-STEAMVR_DISCONNECTED = SteamVR not running
|
||||||
tracking_checklist-STEAMVR_DISCONNECTED-desc = SteamVR is not running. Are you using it for VR?
|
tracking_checklist-STEAMVR_DISCONNECTED-desc = SteamVR is not running. Are you using it for VR?
|
||||||
tracking_checklist-STEAMVR_DISCONNECTED-driver_blocked-desc = The driver has been blocked by SteamVR due to a previous SteamVR crash.
|
|
||||||
tracking_checklist-STEAMVR_DISCONNECTED-driver_disabled-desc = The driver is disabled in SteamVR settings.
|
|
||||||
tracking_checklist-STEAMVR_DISCONNECTED-driver_not_installed-desc = The driver is not installed.
|
|
||||||
tracking_checklist-STEAMVR_DISCONNECTED-open = Launch SteamVR
|
tracking_checklist-STEAMVR_DISCONNECTED-open = Launch SteamVR
|
||||||
tracking_checklist-STEAMVR_DISCONNECTED-enable = Enable driver
|
|
||||||
tracking_checklist-STEAMVR_HANDS_ENABLED = Hand trackers toggled on
|
tracking_checklist-STEAMVR_HANDS_ENABLED = Hand trackers toggled on
|
||||||
tracking_checklist-STEAMVR_HANDS_ENABLED-desc = You have enabled the SteamVR virtual hand trackers. This will cause button inputs to not work in SteamVR and in games.
|
tracking_checklist-STEAMVR_HANDS_ENABLED-desc = You have enabled the SteamVR virtual hand trackers. This will cause button inputs to not work in SteamVR and in games.
|
||||||
tracking_checklist-STEAMVR_HANDS_ENABLED-go = Disable them
|
tracking_checklist-STEAMVR_HANDS_ENABLED-go = Disable them
|
||||||
tracking_checklist-STANDABLE_INSTALLED = Standable is installed
|
|
||||||
tracking_checklist-STANDABLE_INSTALLED-desc =
|
|
||||||
Standable frequently causes tracking issues when used alongside SlimeVR. Standable should be fully uninstalled in Steam to ensure no issues arise.
|
|
||||||
You must close SteamVR before uninstalling Standable in Steam.
|
|
||||||
tracking_checklist-TRACKERS_REST_CALIBRATION = Calibrate your trackers
|
tracking_checklist-TRACKERS_REST_CALIBRATION = Calibrate your trackers
|
||||||
tracking_checklist-TRACKERS_REST_CALIBRATION-desc = You didn't perform tracker calibration. Please let your trackers (highlighted in yellow) rest on a stable surface for a few seconds.
|
tracking_checklist-TRACKERS_REST_CALIBRATION-desc = You didn't perform tracker calibration. Please let your trackers (highlighted in yellow) rest on a stable surface for a few seconds.
|
||||||
tracking_checklist-TRACKER_ERROR = Trackers with Errors
|
tracking_checklist-TRACKER_ERROR = Trackers with Errors
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ export function NavButton({
|
|||||||
className={classnames(
|
className={classnames(
|
||||||
'flex flex-col justify-center xs:gap-4 mobile:gap-2',
|
'flex flex-col justify-center xs:gap-4 mobile:gap-2',
|
||||||
'mobile:w-[65px] mobile:h-[65px]',
|
'mobile:w-[65px] mobile:h-[65px]',
|
||||||
'xs:py-3 mobile:py-4 rounded-md mobile:rounded-b-none group',
|
'xs:py-3 mobile:py-4 rounded-md mobile:rounded-b-none group select-text',
|
||||||
{
|
{
|
||||||
'bg-accent-background-50 fill-accent-background-20': doesMatch,
|
'bg-accent-background-50 fill-accent-background-20': doesMatch,
|
||||||
'hover:bg-background-70': !doesMatch,
|
'hover:bg-background-70': !doesMatch,
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import {
|
|||||||
NewSerialDeviceResponseT,
|
NewSerialDeviceResponseT,
|
||||||
RpcMessage,
|
RpcMessage,
|
||||||
SerialDeviceT,
|
SerialDeviceT,
|
||||||
SerialDeviceType,
|
|
||||||
} from 'solarxr-protocol';
|
} from 'solarxr-protocol';
|
||||||
import { useConfig } from '@/hooks/config';
|
import { useConfig } from '@/hooks/config';
|
||||||
import { useWebsocketAPI } from '@/hooks/websocket-api';
|
import { useWebsocketAPI } from '@/hooks/websocket-api';
|
||||||
@@ -57,8 +56,7 @@ export function SerialDetectionModal() {
|
|||||||
'/settings/serial',
|
'/settings/serial',
|
||||||
'/onboarding/connect-trackers',
|
'/onboarding/connect-trackers',
|
||||||
'/settings/firmware-tool',
|
'/settings/firmware-tool',
|
||||||
].includes(pathname) &&
|
].includes(pathname)
|
||||||
device?.type !== SerialDeviceType.HID_RECEIVER
|
|
||||||
) {
|
) {
|
||||||
setOpen(device);
|
setOpen(device);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,13 +14,13 @@ export function InnerSystemFileInput({
|
|||||||
value,
|
value,
|
||||||
onChange,
|
onChange,
|
||||||
directory,
|
directory,
|
||||||
refCallback: refCallback,
|
ref,
|
||||||
}: {
|
}: {
|
||||||
label: string;
|
label: string;
|
||||||
value: string | null;
|
value: string | null;
|
||||||
onChange: (...event: any[]) => void;
|
onChange: (...event: any[]) => void;
|
||||||
directory: boolean;
|
directory: boolean;
|
||||||
refCallback: RefCallBack;
|
ref: RefCallBack;
|
||||||
}) {
|
}) {
|
||||||
const electron = useElectron();
|
const electron = useElectron();
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ export function InnerSystemFileInput({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div ref={refCallback} onClick={handleClick}>
|
<div ref={ref} onClick={handleClick}>
|
||||||
{value !== null
|
{value !== null
|
||||||
? FileInputContentFile({
|
? FileInputContentFile({
|
||||||
directory,
|
directory,
|
||||||
@@ -77,7 +77,7 @@ export function SystemFileInput<T extends FieldValues = FieldValues>({
|
|||||||
label={label}
|
label={label}
|
||||||
value={value}
|
value={value}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
refCallback={ref}
|
ref={ref}
|
||||||
directory={directory}
|
directory={directory}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import {
|
|||||||
NewSerialDeviceResponseT,
|
NewSerialDeviceResponseT,
|
||||||
RpcMessage,
|
RpcMessage,
|
||||||
SerialDeviceT,
|
SerialDeviceT,
|
||||||
SerialDeviceType,
|
|
||||||
SerialDevicesRequestT,
|
SerialDevicesRequestT,
|
||||||
SerialDevicesResponseT,
|
SerialDevicesResponseT,
|
||||||
TrackerStatus,
|
TrackerStatus,
|
||||||
@@ -78,14 +77,13 @@ function SerialDevicesList({
|
|||||||
RpcMessage.SerialDevicesResponse,
|
RpcMessage.SerialDevicesResponse,
|
||||||
(res: SerialDevicesResponseT) => {
|
(res: SerialDevicesResponseT) => {
|
||||||
setDevices(
|
setDevices(
|
||||||
res.devices.reduce((curr, device) => {
|
res.devices.reduce(
|
||||||
if (device?.type != SerialDeviceType.ESP_TRACKER) return curr;
|
(curr, device) => ({
|
||||||
|
|
||||||
return {
|
|
||||||
...curr,
|
...curr,
|
||||||
[device?.port?.toString() ?? 'unknown']: device,
|
[device?.port?.toString() ?? 'unknown']: device,
|
||||||
};
|
}),
|
||||||
}, {})
|
{}
|
||||||
|
)
|
||||||
);
|
);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
@@ -94,7 +92,7 @@ function SerialDevicesList({
|
|||||||
useRPCPacket(
|
useRPCPacket(
|
||||||
RpcMessage.NewSerialDeviceResponse,
|
RpcMessage.NewSerialDeviceResponse,
|
||||||
({ device }: NewSerialDeviceResponseT) => {
|
({ device }: NewSerialDeviceResponseT) => {
|
||||||
if (device?.port && device?.type === SerialDeviceType.ESP_TRACKER)
|
if (device?.port)
|
||||||
setDevices((old) => ({
|
setDevices((old) => ({
|
||||||
...old,
|
...old,
|
||||||
[device?.port?.toString() ?? 'unknown']: device,
|
[device?.port?.toString() ?? 'unknown']: device,
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ function IncrementButton({
|
|||||||
<div
|
<div
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
className={classNames(
|
className={classNames(
|
||||||
'no-user-drag p-3 rounded-lg xs:w-10 xs:h-10 flex flex-col justify-center items-center cursor-pointer',
|
'p-3 rounded-lg xs:w-10 xs:h-10 flex flex-col justify-center items-center cursor-pointer',
|
||||||
'hover:bg-opacity-50 active:bg-accent-background-30',
|
'hover:bg-opacity-50 active:bg-accent-background-30',
|
||||||
{ 'bg-background-60': bgDark, 'bg-background-40': !bgDark }
|
{ 'bg-background-60': bgDark, 'bg-background-40': !bgDark }
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ function IncrementButton({
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={classNames(
|
className={classNames(
|
||||||
'no-user-drag flex rounded-md items-center justify-center flex-row xs:flex-col w-full gap-1 p-3 xs:p-2 xs:w-[75px] xs:h-[75px]',
|
'flex rounded-md items-center justify-center flex-row xs:flex-col w-full gap-1 p-3 xs:p-2 xs:w-[75px] xs:h-[75px]',
|
||||||
{
|
{
|
||||||
'cursor-not-allowed bg-background-80 opacity-50': disabled,
|
'cursor-not-allowed bg-background-80 opacity-50': disabled,
|
||||||
'bg-background-50 hover:bg-background-40 cursor-pointer': !disabled,
|
'bg-background-50 hover:bg-background-40 cursor-pointer': !disabled,
|
||||||
@@ -74,7 +74,7 @@ function UnitSelector({
|
|||||||
'bg-accent-background-30': active,
|
'bg-accent-background-30': active,
|
||||||
'hover:bg-background-40 bg-background-40': !active,
|
'hover:bg-background-40 bg-background-40': !active,
|
||||||
},
|
},
|
||||||
'no-user-drag flex items-center justify-center rounded-md outline-background-10 cursor-pointer'
|
'flex items-center justify-center rounded-md outline-background-10 cursor-pointer'
|
||||||
)}
|
)}
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
>
|
>
|
||||||
|
|||||||
+2
-2
@@ -29,8 +29,8 @@ function PosePage({
|
|||||||
return (
|
return (
|
||||||
<div className="flex flex-col py-2">
|
<div className="flex flex-col py-2">
|
||||||
<div className="flex flex-col gap-2">
|
<div className="flex flex-col gap-2">
|
||||||
{descriptionKeys.map((descriptionKey, i) => (
|
{descriptionKeys.map((descriptionKey) => (
|
||||||
<Typography key={i}>{l10n.getString(descriptionKey)}</Typography>
|
<Typography>{l10n.getString(descriptionKey)}</Typography>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex pt-1 items-center fill-background-50 justify-center px-12">
|
<div className="flex pt-1 items-center fill-background-50 justify-center px-12">
|
||||||
|
|||||||
@@ -2,8 +2,10 @@ import { ReactNode } from 'react';
|
|||||||
import { ConfigContextC, loadConfig, useConfigProvider } from '@/hooks/config';
|
import { ConfigContextC, loadConfig, useConfigProvider } from '@/hooks/config';
|
||||||
import { getSentryOrCompute } from '@/utils/sentry';
|
import { getSentryOrCompute } from '@/utils/sentry';
|
||||||
|
|
||||||
const config = await loadConfig();
|
const [config, isSteam] = await Promise.all([
|
||||||
const isSteam = window.electronAPI ? await window.electronAPI.isSteam() : false;
|
loadConfig(),
|
||||||
|
window.electronAPI.isSteam(),
|
||||||
|
]);
|
||||||
|
|
||||||
if (config?.errorTracking !== undefined) {
|
if (config?.errorTracking !== undefined) {
|
||||||
// load sentry ASAP to catch early errors
|
// load sentry ASAP to catch early errors
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { ReactNode, useEffect, useRef } from 'react';
|
import { ReactNode, useEffect, useRef } from 'react';
|
||||||
import { useLocation } from 'react-router-dom';
|
import { useLocation } from 'react-router-dom';
|
||||||
|
import { useBreakpoint } from '@/hooks/breakpoint';
|
||||||
|
|
||||||
export function SettingsPageLayout({
|
export function SettingsPageLayout({
|
||||||
children,
|
children,
|
||||||
@@ -11,6 +12,7 @@ export function SettingsPageLayout({
|
|||||||
} & React.HTMLAttributes<HTMLDivElement>) {
|
} & React.HTMLAttributes<HTMLDivElement>) {
|
||||||
const pageRef = useRef<HTMLDivElement | null>(null);
|
const pageRef = useRef<HTMLDivElement | null>(null);
|
||||||
const { state } = useLocation();
|
const { state } = useLocation();
|
||||||
|
const { isMobile } = useBreakpoint('mobile');
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const typedState: { scrollTo: string } = state;
|
const typedState: { scrollTo: string } = state;
|
||||||
@@ -21,10 +23,19 @@ export function SettingsPageLayout({
|
|||||||
`#${typedState.scrollTo}`
|
`#${typedState.scrollTo}`
|
||||||
) as HTMLElement | null;
|
) as HTMLElement | null;
|
||||||
if (elem) {
|
if (elem) {
|
||||||
elem.scrollIntoView({
|
// stupid way of doing this, just get the closest overflow-y-auto
|
||||||
block: 'start',
|
// usually its just the parentElem
|
||||||
behavior: 'smooth',
|
const closestScroll = elem.closest(
|
||||||
});
|
'.overflow-y-auto'
|
||||||
|
) as HTMLElement | null;
|
||||||
|
if (closestScroll) {
|
||||||
|
// 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',
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, [state]);
|
}, [state]);
|
||||||
|
|
||||||
@@ -47,7 +58,7 @@ export function SettingsPagePaneLayout({
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={classNames(
|
className={classNames(
|
||||||
'bg-background-70 rounded-lg px-4 py-8 flex xs:gap-4 w-full relative scroll-mt-12 mobile:scroll-mt-20',
|
'bg-background-70 rounded-lg px-4 py-8 flex xs:gap-4 w-full relative',
|
||||||
className
|
className
|
||||||
)}
|
)}
|
||||||
{...props}
|
{...props}
|
||||||
|
|||||||
@@ -10,11 +10,8 @@ import { Button } from '@/components/commons/Button';
|
|||||||
import { SettingsResetModal } from '@/components/settings/SettingsResetModal';
|
import { SettingsResetModal } from '@/components/settings/SettingsResetModal';
|
||||||
|
|
||||||
import { error } from '@/utils/logging';
|
import { error } from '@/utils/logging';
|
||||||
import {
|
import { defaultConfig as defaultGUIConfig, useConfig } from '@/hooks/config';
|
||||||
defaultDevSettings,
|
import { defaultValues as defaultDevConfig } from '@/components/widgets/DeveloperModeWidget';
|
||||||
defaultConfig as defaultGUIConfig,
|
|
||||||
useConfig,
|
|
||||||
} from '@/hooks/config';
|
|
||||||
import { RpcMessage, SettingsResetRequestT } from 'solarxr-protocol';
|
import { RpcMessage, SettingsResetRequestT } from 'solarxr-protocol';
|
||||||
import { useWebsocketAPI } from '@/hooks/websocket-api';
|
import { useWebsocketAPI } from '@/hooks/websocket-api';
|
||||||
import { useElectron } from '@/hooks/electron';
|
import { useElectron } from '@/hooks/electron';
|
||||||
@@ -24,7 +21,7 @@ function guiDefaults() {
|
|||||||
|
|
||||||
const { lang, ...guiDefaults } = defaultGUIConfig;
|
const { lang, ...guiDefaults } = defaultGUIConfig;
|
||||||
|
|
||||||
guiDefaults.devSettings = defaultDevSettings;
|
guiDefaults.devSettings = defaultDevConfig;
|
||||||
|
|
||||||
return guiDefaults;
|
return guiDefaults;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1317,7 +1317,7 @@ export function GeneralSettings() {
|
|||||||
</div>
|
</div>
|
||||||
<div className="grid sm:grid-cols-3 gap-5 pb-2">
|
<div className="grid sm:grid-cols-3 gap-5 pb-2">
|
||||||
<div>
|
<div>
|
||||||
<Typography bold>
|
<Typography variant="section-title">
|
||||||
{l10n.getString(
|
{l10n.getString(
|
||||||
'settings-general-gesture_control-yawResetTracker'
|
'settings-general-gesture_control-yawResetTracker'
|
||||||
)}
|
)}
|
||||||
@@ -1331,21 +1331,7 @@ export function GeneralSettings() {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<Typography bold>
|
<Typography variant="section-title">
|
||||||
{l10n.getString(
|
|
||||||
'settings-general-gesture_control-fullResetTracker'
|
|
||||||
)}
|
|
||||||
</Typography>
|
|
||||||
<Dropdown
|
|
||||||
display="block"
|
|
||||||
control={control}
|
|
||||||
placeholder={''}
|
|
||||||
name="tapDetection.fullResetTracker"
|
|
||||||
items={bodyParts}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<Typography bold>
|
|
||||||
{l10n.getString(
|
{l10n.getString(
|
||||||
'settings-general-gesture_control-mountingResetTracker'
|
'settings-general-gesture_control-mountingResetTracker'
|
||||||
)}
|
)}
|
||||||
@@ -1358,6 +1344,20 @@ export function GeneralSettings() {
|
|||||||
items={bodyParts}
|
items={bodyParts}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<Typography variant="section-title">
|
||||||
|
{l10n.getString(
|
||||||
|
'settings-general-gesture_control-fullResetTracker'
|
||||||
|
)}
|
||||||
|
</Typography>
|
||||||
|
<Dropdown
|
||||||
|
display="block"
|
||||||
|
control={control}
|
||||||
|
placeholder={''}
|
||||||
|
name="tapDetection.fullResetTracker"
|
||||||
|
items={bodyParts}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="grid sm:grid-cols-3 gap-5 pb-2">
|
<div className="grid sm:grid-cols-3 gap-5 pb-2">
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import { Localized, useLocalization } from '@fluent/react';
|
import { Localized, useLocalization } from '@fluent/react';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { FieldPath, useForm } from 'react-hook-form';
|
import { useForm } from 'react-hook-form';
|
||||||
import { CheckBox } from '@/components/commons/Checkbox';
|
import { CheckBox } from '@/components/commons/Checkbox';
|
||||||
import { Typography } from '@/components/commons/Typography';
|
import { Typography } from '@/components/commons/Typography';
|
||||||
import {
|
import {
|
||||||
SettingsPageLayout,
|
SettingsPageLayout,
|
||||||
SettingsPagePaneLayout,
|
SettingsPagePaneLayout,
|
||||||
} from '@/components/settings/SettingsPageLayout';
|
} from '@/components/settings/SettingsPageLayout';
|
||||||
import { defaultConfig, DeveloperModeConfig, useConfig } from '@/hooks/config';
|
import { defaultConfig, useConfig } from '@/hooks/config';
|
||||||
import { ThemeSelector } from '@/components/commons/ThemeSelector';
|
import { ThemeSelector } from '@/components/commons/ThemeSelector';
|
||||||
import { SquaresIcon } from '@/components/commons/icon/SquaresIcon';
|
import { SquaresIcon } from '@/components/commons/icon/SquaresIcon';
|
||||||
import { NumberSelector } from '@/components/commons/NumberSelector';
|
import { NumberSelector } from '@/components/commons/NumberSelector';
|
||||||
@@ -18,6 +18,7 @@ import { Range } from '@/components/commons/Range';
|
|||||||
import { Dropdown } from '@/components/commons/Dropdown';
|
import { Dropdown } from '@/components/commons/Dropdown';
|
||||||
import { ArrowRightLeftIcon } from '@/components/commons/icon/ArrowIcons';
|
import { ArrowRightLeftIcon } from '@/components/commons/icon/ArrowIcons';
|
||||||
import { SystemFileInput } from '@/components/commons/SystemFileInput';
|
import { SystemFileInput } from '@/components/commons/SystemFileInput';
|
||||||
|
import { DeveloperModeWidget } from '@/components/widgets/DeveloperModeWidget';
|
||||||
import { useElectron } from '@/hooks/electron';
|
import { useElectron } from '@/hooks/electron';
|
||||||
|
|
||||||
interface InterfaceSettingsForm {
|
interface InterfaceSettingsForm {
|
||||||
@@ -27,6 +28,7 @@ interface InterfaceSettingsForm {
|
|||||||
fonts: string;
|
fonts: string;
|
||||||
};
|
};
|
||||||
behavior: {
|
behavior: {
|
||||||
|
devmode: boolean;
|
||||||
useTray: boolean;
|
useTray: boolean;
|
||||||
discordPresence: boolean;
|
discordPresence: boolean;
|
||||||
errorTracking: boolean;
|
errorTracking: boolean;
|
||||||
@@ -38,9 +40,6 @@ interface InterfaceSettingsForm {
|
|||||||
feedbackSoundVolume: number;
|
feedbackSoundVolume: number;
|
||||||
connectedTrackersWarning: boolean;
|
connectedTrackersWarning: boolean;
|
||||||
};
|
};
|
||||||
developer: DeveloperModeConfig & {
|
|
||||||
enabled: boolean;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function InterfaceSettings() {
|
export function InterfaceSettings() {
|
||||||
@@ -66,35 +65,13 @@ export function InterfaceSettings() {
|
|||||||
defaultConfig.connectedTrackersWarning,
|
defaultConfig.connectedTrackersWarning,
|
||||||
},
|
},
|
||||||
behavior: {
|
behavior: {
|
||||||
|
devmode: config?.debug ?? defaultConfig.debug,
|
||||||
useTray: config?.useTray ?? defaultConfig.useTray ?? false,
|
useTray: config?.useTray ?? defaultConfig.useTray ?? false,
|
||||||
discordPresence:
|
discordPresence:
|
||||||
config?.discordPresence ?? defaultConfig.discordPresence,
|
config?.discordPresence ?? defaultConfig.discordPresence,
|
||||||
errorTracking: config?.errorTracking ?? false,
|
errorTracking: config?.errorTracking ?? false,
|
||||||
bvhDirectory: config?.bvhDirectory ?? defaultConfig.bvhDirectory,
|
bvhDirectory: config?.bvhDirectory ?? defaultConfig.bvhDirectory,
|
||||||
},
|
},
|
||||||
developer: {
|
|
||||||
enabled: config?.debug ?? defaultConfig.debug,
|
|
||||||
highContrast:
|
|
||||||
config?.devSettings?.highContrast ??
|
|
||||||
defaultConfig.devSettings.highContrast,
|
|
||||||
preciseRotation:
|
|
||||||
config?.devSettings?.preciseRotation ??
|
|
||||||
defaultConfig.devSettings.preciseRotation,
|
|
||||||
fastDataFeed:
|
|
||||||
config?.devSettings?.fastDataFeed ??
|
|
||||||
defaultConfig.devSettings.fastDataFeed,
|
|
||||||
filterSlimesAndHMD:
|
|
||||||
config?.devSettings?.filterSlimesAndHMD ??
|
|
||||||
defaultConfig.devSettings.filterSlimesAndHMD,
|
|
||||||
sortByName:
|
|
||||||
config?.devSettings?.sortByName ??
|
|
||||||
defaultConfig.devSettings.sortByName,
|
|
||||||
rawSlimeRotation:
|
|
||||||
config?.devSettings?.rawSlimeRotation ??
|
|
||||||
defaultConfig.devSettings.rawSlimeRotation,
|
|
||||||
moreInfo:
|
|
||||||
config?.devSettings?.moreInfo ?? defaultConfig.devSettings.moreInfo,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -135,11 +112,9 @@ export function InterfaceSettings() {
|
|||||||
|
|
||||||
useTray: values.behavior.useTray,
|
useTray: values.behavior.useTray,
|
||||||
discordPresence: values.behavior.discordPresence,
|
discordPresence: values.behavior.discordPresence,
|
||||||
|
debug: values.behavior.devmode,
|
||||||
errorTracking: values.behavior.errorTracking,
|
errorTracking: values.behavior.errorTracking,
|
||||||
bvhDirectory: values.behavior.bvhDirectory,
|
bvhDirectory: values.behavior.bvhDirectory,
|
||||||
|
|
||||||
debug: values.developer.enabled,
|
|
||||||
devSettings: values.developer,
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -153,16 +128,6 @@ export function InterfaceSettings() {
|
|||||||
return () => subscription.unsubscribe();
|
return () => subscription.unsubscribe();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const devToggles = {
|
|
||||||
highContrast: 'high_contrast',
|
|
||||||
preciseRotation: 'precise_rotation',
|
|
||||||
fastDataFeed: 'fast_data_feed',
|
|
||||||
filterSlimesAndHMD: 'filter_slimes_and_hmd',
|
|
||||||
sortByName: 'sort_by_name',
|
|
||||||
rawSlimeRotation: 'raw_slime_rotation',
|
|
||||||
moreInfo: 'more_info',
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SettingsPageLayout>
|
<SettingsPageLayout>
|
||||||
<form
|
<form
|
||||||
@@ -334,31 +299,18 @@ export function InterfaceSettings() {
|
|||||||
</Typography>
|
</Typography>
|
||||||
</div>
|
</div>
|
||||||
<div className="grid grid-cols-1 gap-2 pb-4 w-full">
|
<div className="grid grid-cols-1 gap-2 pb-4 w-full">
|
||||||
<CheckBox
|
<div className="">
|
||||||
variant="toggle"
|
<CheckBox
|
||||||
control={control}
|
variant="toggle"
|
||||||
outlined
|
control={control}
|
||||||
name="developer.enabled"
|
outlined
|
||||||
label={l10n.getString(
|
name="behavior.devmode"
|
||||||
'settings-general-interface-dev_mode-label'
|
label={l10n.getString(
|
||||||
)}
|
'settings-general-interface-dev_mode-label'
|
||||||
/>
|
)}
|
||||||
{!!config?.debug && (
|
/>
|
||||||
<div className="grid grid-cols-2 w-full rounded-md gap-2">
|
</div>
|
||||||
{Object.entries(devToggles).map(([name, label], i) => (
|
{config?.debug && <DeveloperModeWidget />}
|
||||||
<CheckBox
|
|
||||||
key={i}
|
|
||||||
control={control}
|
|
||||||
variant="toggle"
|
|
||||||
outlined
|
|
||||||
name={
|
|
||||||
`developer.${name}` as FieldPath<InterfaceSettingsForm>
|
|
||||||
}
|
|
||||||
label={l10n.getString(`widget-developer_mode-${label}`)}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Typography variant="section-title">
|
<Typography variant="section-title">
|
||||||
|
|||||||
@@ -94,10 +94,7 @@ export function MagnetometerToggleSetting({
|
|||||||
|
|
||||||
return settingType === 'general' ? (
|
return settingType === 'general' ? (
|
||||||
<>
|
<>
|
||||||
<div
|
<div className="flex flex-col pt-5 pb-3" id={id}>
|
||||||
className="flex flex-col pt-5 pb-3 scroll-mt-12 mobile:scroll-mt-20"
|
|
||||||
id={id}
|
|
||||||
>
|
|
||||||
<Typography variant="section-title">
|
<Typography variant="section-title">
|
||||||
{l10n.getString(
|
{l10n.getString(
|
||||||
'settings-general-tracker_mechanics-use_mag_on_all_trackers'
|
'settings-general-tracker_mechanics-use_mag_on_all_trackers'
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import {
|
|||||||
SerialUpdateResponseT,
|
SerialUpdateResponseT,
|
||||||
SerialTrackerGetWifiScanRequestT,
|
SerialTrackerGetWifiScanRequestT,
|
||||||
SerialTrackerCustomCommandRequestT,
|
SerialTrackerCustomCommandRequestT,
|
||||||
SerialDeviceType,
|
|
||||||
} from 'solarxr-protocol';
|
} from 'solarxr-protocol';
|
||||||
import { useWebsocketAPI } from '@/hooks/websocket-api';
|
import { useWebsocketAPI } from '@/hooks/websocket-api';
|
||||||
import { Button } from '@/components/commons/Button';
|
import { Button } from '@/components/commons/Button';
|
||||||
@@ -42,10 +41,7 @@ export function Serial() {
|
|||||||
const consoleRef = useRef<HTMLDivElement>(null);
|
const consoleRef = useRef<HTMLDivElement>(null);
|
||||||
const [consoleContent, setConsole] = useState('');
|
const [consoleContent, setConsole] = useState('');
|
||||||
|
|
||||||
const [openedSerialDevice, setOpenedSerialDevice] = useState<Omit<
|
const [isSerialOpen, setSerialOpen] = useState(false);
|
||||||
SerialDeviceT,
|
|
||||||
'pack'
|
|
||||||
> | null>(null);
|
|
||||||
const [serialDevices, setSerialDevices] = useState<
|
const [serialDevices, setSerialDevices] = useState<
|
||||||
Omit<SerialDeviceT, 'pack'>[]
|
Omit<SerialDeviceT, 'pack'>[]
|
||||||
>([]);
|
>([]);
|
||||||
@@ -91,19 +87,11 @@ export function Serial() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
sendRPCPacket(RpcMessage.SerialDevicesRequest, new SerialDevicesRequestT());
|
||||||
const typedState: { serialPort: string } = state as any;
|
const typedState: { serialPort: string } = state as any;
|
||||||
if (typedState?.serialPort) {
|
if (typedState?.serialPort) {
|
||||||
reset({ port: typedState.serialPort });
|
reset({ port: typedState.serialPort });
|
||||||
}
|
}
|
||||||
|
|
||||||
sendRPCPacket(RpcMessage.SerialDevicesRequest, new SerialDevicesRequestT());
|
|
||||||
const interval = setInterval(() => {
|
|
||||||
sendRPCPacket(
|
|
||||||
RpcMessage.SerialDevicesRequest,
|
|
||||||
new SerialDevicesRequestT()
|
|
||||||
);
|
|
||||||
}, 3000);
|
|
||||||
return () => clearInterval(interval);
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -115,8 +103,11 @@ export function Serial() {
|
|||||||
useRPCPacket(
|
useRPCPacket(
|
||||||
RpcMessage.SerialUpdateResponse,
|
RpcMessage.SerialUpdateResponse,
|
||||||
(data: SerialUpdateResponseT) => {
|
(data: SerialUpdateResponseT) => {
|
||||||
if (data.device) setOpenedSerialDevice(data.device);
|
if (data.closed) {
|
||||||
else if (data.closed) setOpenedSerialDevice(null);
|
setSerialOpen(false);
|
||||||
|
} else {
|
||||||
|
setSerialOpen(true);
|
||||||
|
}
|
||||||
|
|
||||||
if (data.log) {
|
if (data.log) {
|
||||||
setConsole((console) => console + data.log);
|
setConsole((console) => console + data.log);
|
||||||
@@ -131,7 +122,6 @@ export function Serial() {
|
|||||||
{
|
{
|
||||||
name: l10n.getString('settings-serial-auto_dropdown_item'),
|
name: l10n.getString('settings-serial-auto_dropdown_item'),
|
||||||
port: 'Auto',
|
port: 'Auto',
|
||||||
type: SerialDeviceType.ESP_TRACKER,
|
|
||||||
},
|
},
|
||||||
...(res.devices || []),
|
...(res.devices || []),
|
||||||
]);
|
]);
|
||||||
@@ -171,7 +161,7 @@ export function Serial() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const id = setInterval(() => {
|
const id = setInterval(() => {
|
||||||
if (openedSerialDevice === null) {
|
if (!isSerialOpen) {
|
||||||
openSerial(port ?? defaultValues.port);
|
openSerial(port ?? defaultValues.port);
|
||||||
} else {
|
} else {
|
||||||
clearInterval(id);
|
clearInterval(id);
|
||||||
@@ -181,7 +171,7 @@ export function Serial() {
|
|||||||
return () => {
|
return () => {
|
||||||
clearInterval(id);
|
clearInterval(id);
|
||||||
};
|
};
|
||||||
}, [openedSerialDevice]);
|
}, [isSerialOpen]);
|
||||||
|
|
||||||
const reboot = () => {
|
const reboot = () => {
|
||||||
sendRPCPacket(
|
sendRPCPacket(
|
||||||
@@ -189,8 +179,6 @@ export function Serial() {
|
|||||||
new SerialTrackerRebootRequestT()
|
new SerialTrackerRebootRequestT()
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
// ESP
|
|
||||||
const factoryReset = () => {
|
const factoryReset = () => {
|
||||||
sendRPCPacket(
|
sendRPCPacket(
|
||||||
RpcMessage.SerialTrackerFactoryResetRequest,
|
RpcMessage.SerialTrackerFactoryResetRequest,
|
||||||
@@ -221,48 +209,6 @@ export function Serial() {
|
|||||||
setValue('customCommand', '');
|
setValue('customCommand', '');
|
||||||
};
|
};
|
||||||
|
|
||||||
// HID
|
|
||||||
const enterPairing = () => {
|
|
||||||
sendRPCPacket(
|
|
||||||
RpcMessage.SerialTrackerCustomCommandRequest,
|
|
||||||
new SerialTrackerCustomCommandRequestT('pair')
|
|
||||||
);
|
|
||||||
};
|
|
||||||
const dfu = () => {
|
|
||||||
sendRPCPacket(
|
|
||||||
RpcMessage.SerialTrackerCustomCommandRequest,
|
|
||||||
new SerialTrackerCustomCommandRequestT('dfu')
|
|
||||||
);
|
|
||||||
};
|
|
||||||
const meow = () => {
|
|
||||||
sendRPCPacket(
|
|
||||||
RpcMessage.SerialTrackerCustomCommandRequest,
|
|
||||||
new SerialTrackerCustomCommandRequestT('meow')
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
// HID receiver
|
|
||||||
const exitPairing = () => {
|
|
||||||
sendRPCPacket(
|
|
||||||
RpcMessage.SerialTrackerCustomCommandRequest,
|
|
||||||
new SerialTrackerCustomCommandRequestT('exit')
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
// HID tracker
|
|
||||||
const calibrate = () => {
|
|
||||||
sendRPCPacket(
|
|
||||||
RpcMessage.SerialTrackerCustomCommandRequest,
|
|
||||||
new SerialTrackerCustomCommandRequestT('calibrate')
|
|
||||||
);
|
|
||||||
};
|
|
||||||
const sixSideCalibrate = () => {
|
|
||||||
sendRPCPacket(
|
|
||||||
RpcMessage.SerialTrackerCustomCommandRequest,
|
|
||||||
new SerialTrackerCustomCommandRequestT('6-side')
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const consoleContentRef = useRef(consoleContent);
|
const consoleContentRef = useRef(consoleContent);
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
consoleContentRef.current = consoleContent;
|
consoleContentRef.current = consoleContent;
|
||||||
@@ -372,7 +318,7 @@ export function Serial() {
|
|||||||
>
|
>
|
||||||
<div className="flex select-text">
|
<div className="flex select-text">
|
||||||
<pre>
|
<pre>
|
||||||
{openedSerialDevice !== null
|
{isSerialOpen
|
||||||
? consoleContent
|
? consoleContent
|
||||||
: l10n.getString('settings-serial-connection_lost')}
|
: l10n.getString('settings-serial-connection_lost')}
|
||||||
</pre>
|
</pre>
|
||||||
@@ -380,115 +326,70 @@ export function Serial() {
|
|||||||
</div>
|
</div>
|
||||||
<div className="border-t-2 pt-2 border-background-60 border-solid gap-2 flex flex-row">
|
<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">
|
<div className="xs:flex flex-grow xs:flex-wrap gap-2 grid grid-cols-2">
|
||||||
{openedSerialDevice !== null && (
|
<Button variant="quaternary" onClick={reboot}>
|
||||||
<>
|
{l10n.getString('settings-serial-reboot')}
|
||||||
<Button variant="quaternary" onClick={reboot}>
|
</Button>
|
||||||
{l10n.getString('settings-serial-reboot')}
|
<Button
|
||||||
</Button>
|
variant="quaternary"
|
||||||
{openedSerialDevice?.type ===
|
onClick={() => setTryFactoryReset(true)}
|
||||||
SerialDeviceType.ESP_TRACKER && (
|
>
|
||||||
<>
|
{l10n.getString('settings-serial-factory_reset')}
|
||||||
<Button
|
</Button>
|
||||||
variant="quaternary"
|
<Button variant="quaternary" onClick={getWifiScan}>
|
||||||
onClick={() => setTryFactoryReset(true)}
|
{l10n.getString('settings-serial-get_wifi_scan')}
|
||||||
>
|
</Button>
|
||||||
{l10n.getString('settings-serial-factory_reset')}
|
<Button
|
||||||
</Button>
|
variant="quaternary"
|
||||||
<Button variant="quaternary" onClick={getWifiScan}>
|
onClick={saveLogToFile}
|
||||||
{l10n.getString('settings-serial-get_wifi_scan')}
|
disabled={!isSerialOpen || !consoleContent.trim()}
|
||||||
</Button>
|
>
|
||||||
</>
|
{l10n.getString('settings-serial-save_logs')}
|
||||||
)}
|
</Button>
|
||||||
{openedSerialDevice?.type !==
|
<div className="ml-auto">
|
||||||
SerialDeviceType.ESP_TRACKER && (
|
<Button
|
||||||
<Button variant="quaternary" onClick={enterPairing}>
|
variant="quaternary"
|
||||||
{l10n.getString('settings-serial-enter_pairing')}
|
onClick={pauseScroll}
|
||||||
</Button>
|
icon={
|
||||||
)}
|
isPaused ? (
|
||||||
{openedSerialDevice?.type ===
|
<PlayIcon width={16} />
|
||||||
SerialDeviceType.HID_RECEIVER && (
|
) : (
|
||||||
<Button variant="quaternary" onClick={exitPairing}>
|
<PauseIcon width={16} />
|
||||||
{l10n.getString('settings-serial-exit_pairing')}
|
)
|
||||||
</Button>
|
}
|
||||||
)}
|
/>
|
||||||
{openedSerialDevice?.type ===
|
</div>
|
||||||
SerialDeviceType.HID_TRACKER && (
|
<form
|
||||||
<>
|
className="w-full flex flex-row gap-2 mobile:col-span-2"
|
||||||
<Button variant="quaternary" onClick={calibrate}>
|
onSubmit={(e) => {
|
||||||
{l10n.getString('settings-serial-calibrate')}
|
if (!isSerialOpen) {
|
||||||
</Button>
|
return;
|
||||||
<Button variant="quaternary" onClick={sixSideCalibrate}>
|
}
|
||||||
{l10n.getString('settings-serial-six_side_calibrate')}
|
e.preventDefault();
|
||||||
</Button>
|
if (!acceptedCustomCommandWarning) {
|
||||||
</>
|
setTrySendCustomCommand(true);
|
||||||
)}
|
} else {
|
||||||
{openedSerialDevice?.type !==
|
sendCustomSerialCommand();
|
||||||
SerialDeviceType.ESP_TRACKER && (
|
}
|
||||||
<>
|
}}
|
||||||
<Button variant="quaternary" onClick={dfu}>
|
>
|
||||||
{l10n.getString('settings-serial-dfu')}
|
<div className="flex-grow">
|
||||||
</Button>
|
<Input
|
||||||
<Button variant="quaternary" onClick={meow}>
|
control={control}
|
||||||
{l10n.getString('settings-serial-meow')}
|
name="customCommand"
|
||||||
</Button>
|
className="flex-grow"
|
||||||
</>
|
placeholder={l10n.getString(
|
||||||
)}
|
'settings-serial-send_command-placeholder'
|
||||||
<Button
|
)}
|
||||||
variant="quaternary"
|
/>
|
||||||
onClick={saveLogToFile}
|
</div>
|
||||||
disabled={
|
<Button
|
||||||
openedSerialDevice === null || !consoleContent.trim()
|
variant="quaternary"
|
||||||
}
|
disabled={!isSerialOpen}
|
||||||
>
|
type="submit"
|
||||||
{l10n.getString('settings-serial-save_logs')}
|
>
|
||||||
</Button>
|
{l10n.getString('settings-serial-send_command')}
|
||||||
<div className="ml-auto">
|
</Button>
|
||||||
<Button
|
</form>
|
||||||
variant="quaternary"
|
|
||||||
onClick={pauseScroll}
|
|
||||||
icon={
|
|
||||||
isPaused ? (
|
|
||||||
<PlayIcon width={16} />
|
|
||||||
) : (
|
|
||||||
<PauseIcon width={16} />
|
|
||||||
)
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<form
|
|
||||||
className="w-full flex flex-row gap-2 mobile:col-span-2"
|
|
||||||
onSubmit={(e) => {
|
|
||||||
if (openedSerialDevice === null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
e.preventDefault();
|
|
||||||
if (!acceptedCustomCommandWarning) {
|
|
||||||
setTrySendCustomCommand(true);
|
|
||||||
} else {
|
|
||||||
sendCustomSerialCommand();
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div className="flex-grow">
|
|
||||||
<Input
|
|
||||||
control={control}
|
|
||||||
name="customCommand"
|
|
||||||
className="flex-grow"
|
|
||||||
placeholder={l10n.getString(
|
|
||||||
'settings-serial-send_command-placeholder'
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<Button
|
|
||||||
variant="quaternary"
|
|
||||||
disabled={openedSerialDevice === null}
|
|
||||||
type="submit"
|
|
||||||
>
|
|
||||||
{l10n.getString('settings-serial-send_command')}
|
|
||||||
</Button>
|
|
||||||
</form>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<div className="w-full mobile:col-span-2">
|
<div className="w-full mobile:col-span-2">
|
||||||
<Dropdown
|
<Dropdown
|
||||||
|
|||||||
@@ -187,12 +187,14 @@ export function VRCOSCSettings() {
|
|||||||
{l10n.getString('settings-osc-vrchat-oscqueryEnabled')}
|
{l10n.getString('settings-osc-vrchat-oscqueryEnabled')}
|
||||||
</Typography>
|
</Typography>
|
||||||
<div className="flex flex-col pb-2">
|
<div className="flex flex-col pb-2">
|
||||||
{l10n
|
<Typography>
|
||||||
.getString('settings-osc-vrchat-oscqueryEnabled-description')
|
{l10n
|
||||||
.split('\n')
|
.getString('settings-osc-vrchat-oscqueryEnabled-description')
|
||||||
.map((line, i) => (
|
.split('\n')
|
||||||
<Typography key={i}>{line}</Typography>
|
.map((line, i) => (
|
||||||
))}
|
<Typography key={i}>{line}</Typography>
|
||||||
|
))}
|
||||||
|
</Typography>
|
||||||
</div>
|
</div>
|
||||||
<div className="grid grid-cols-2 gap-3 pb-5">
|
<div className="grid grid-cols-2 gap-3 pb-5">
|
||||||
<CheckBox
|
<CheckBox
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import { useLocalization } from '@fluent/react';
|
|||||||
import { Dispatch, ReactNode, SetStateAction } from 'react';
|
import { Dispatch, ReactNode, SetStateAction } from 'react';
|
||||||
import { StayAlignedRelaxedPose } from 'solarxr-protocol';
|
import { StayAlignedRelaxedPose } from 'solarxr-protocol';
|
||||||
|
|
||||||
function StayAlignedPoseModal({
|
function StaAlignedPoseModal({
|
||||||
open,
|
open,
|
||||||
title,
|
title,
|
||||||
descriptionKeys,
|
descriptionKeys,
|
||||||
@@ -39,8 +39,8 @@ function StayAlignedPoseModal({
|
|||||||
<Typography variant="main-title">{l10n.getString(title)}</Typography>
|
<Typography variant="main-title">{l10n.getString(title)}</Typography>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-col gap-1">
|
<div className="flex flex-col gap-1">
|
||||||
{descriptionKeys.map((descriptionKey, i) => (
|
{descriptionKeys.map((descriptionKey) => (
|
||||||
<Typography key={i}>{l10n.getString(descriptionKey)}</Typography>
|
<Typography>{l10n.getString(descriptionKey)}</Typography>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex pt-1 items-center fill-background-50 justify-center px-12">
|
<div className="flex pt-1 items-center fill-background-50 justify-center px-12">
|
||||||
@@ -78,7 +78,7 @@ export const StandingRelaxedPoseModal = ({
|
|||||||
}: {
|
}: {
|
||||||
open: [boolean, Dispatch<SetStateAction<boolean>>];
|
open: [boolean, Dispatch<SetStateAction<boolean>>];
|
||||||
}) => (
|
}) => (
|
||||||
<StayAlignedPoseModal
|
<StaAlignedPoseModal
|
||||||
open={open}
|
open={open}
|
||||||
title={'onboarding-stay_aligned-relaxed_poses-standing-title'}
|
title={'onboarding-stay_aligned-relaxed_poses-standing-title'}
|
||||||
descriptionKeys={[
|
descriptionKeys={[
|
||||||
@@ -92,7 +92,7 @@ export const StandingRelaxedPoseModal = ({
|
|||||||
width={260}
|
width={260}
|
||||||
alt="Reset position"
|
alt="Reset position"
|
||||||
/>
|
/>
|
||||||
</StayAlignedPoseModal>
|
</StaAlignedPoseModal>
|
||||||
);
|
);
|
||||||
|
|
||||||
export const SittingRelaxedPoseModal = ({
|
export const SittingRelaxedPoseModal = ({
|
||||||
@@ -100,7 +100,7 @@ export const SittingRelaxedPoseModal = ({
|
|||||||
}: {
|
}: {
|
||||||
open: [boolean, Dispatch<SetStateAction<boolean>>];
|
open: [boolean, Dispatch<SetStateAction<boolean>>];
|
||||||
}) => (
|
}) => (
|
||||||
<StayAlignedPoseModal
|
<StaAlignedPoseModal
|
||||||
open={open}
|
open={open}
|
||||||
title={'onboarding-stay_aligned-relaxed_poses-sitting-title'}
|
title={'onboarding-stay_aligned-relaxed_poses-sitting-title'}
|
||||||
descriptionKeys={[
|
descriptionKeys={[
|
||||||
@@ -114,7 +114,7 @@ export const SittingRelaxedPoseModal = ({
|
|||||||
width={260}
|
width={260}
|
||||||
alt="Reset position"
|
alt="Reset position"
|
||||||
/>
|
/>
|
||||||
</StayAlignedPoseModal>
|
</StaAlignedPoseModal>
|
||||||
);
|
);
|
||||||
|
|
||||||
export const FlatRelaxedPoseModal = ({
|
export const FlatRelaxedPoseModal = ({
|
||||||
@@ -122,7 +122,7 @@ export const FlatRelaxedPoseModal = ({
|
|||||||
}: {
|
}: {
|
||||||
open: [boolean, Dispatch<SetStateAction<boolean>>];
|
open: [boolean, Dispatch<SetStateAction<boolean>>];
|
||||||
}) => (
|
}) => (
|
||||||
<StayAlignedPoseModal
|
<StaAlignedPoseModal
|
||||||
open={open}
|
open={open}
|
||||||
title={'onboarding-stay_aligned-relaxed_poses-flat-title'}
|
title={'onboarding-stay_aligned-relaxed_poses-flat-title'}
|
||||||
descriptionKeys={[
|
descriptionKeys={[
|
||||||
@@ -136,5 +136,5 @@ export const FlatRelaxedPoseModal = ({
|
|||||||
width={560}
|
width={560}
|
||||||
alt="Reset position"
|
alt="Reset position"
|
||||||
/>
|
/>
|
||||||
</StayAlignedPoseModal>
|
</StaAlignedPoseModal>
|
||||||
);
|
);
|
||||||
@@ -376,9 +376,9 @@ export function TrackersTable({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-col gap-y-0">
|
<div className="flex flex-col gap-y-0">
|
||||||
{filteredSortedTrackers.map((data, index) => (
|
{filteredSortedTrackers.map((data) => (
|
||||||
<Row
|
<Row
|
||||||
key={index}
|
key={data.tracker.trackerId?.trackerNum}
|
||||||
clickedTracker={clickedTracker}
|
clickedTracker={clickedTracker}
|
||||||
data={data}
|
data={data}
|
||||||
highlightedTrackers={highlightedTrackers}
|
highlightedTrackers={highlightedTrackers}
|
||||||
|
|||||||
@@ -7,14 +7,12 @@ import {
|
|||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import {
|
import {
|
||||||
ChangeSettingsRequestT,
|
ChangeSettingsRequestT,
|
||||||
EnableSteamVRDriverRequestT,
|
|
||||||
ResetType,
|
ResetType,
|
||||||
RpcMessage,
|
RpcMessage,
|
||||||
SettingsRequestT,
|
SettingsRequestT,
|
||||||
SettingsResponseT,
|
SettingsResponseT,
|
||||||
SteamVRTrackersSettingT,
|
SteamVRTrackersSettingT,
|
||||||
TrackingChecklistPublicNetworksT,
|
TrackingChecklistPublicNetworksT,
|
||||||
TrackingChecklistSteamVRDisconnectedT,
|
|
||||||
TrackingChecklistStepId,
|
TrackingChecklistStepId,
|
||||||
} from 'solarxr-protocol';
|
} from 'solarxr-protocol';
|
||||||
import { ReactNode, useEffect, useMemo, useState } from 'react';
|
import { ReactNode, useEffect, useMemo, useState } from 'react';
|
||||||
@@ -30,7 +28,7 @@ import {
|
|||||||
ArrowDownIcon,
|
ArrowDownIcon,
|
||||||
ArrowRightIcon,
|
ArrowRightIcon,
|
||||||
} from '@/components/commons/icon/ArrowIcons';
|
} from '@/components/commons/icon/ArrowIcons';
|
||||||
import { Localized, useLocalization } from '@fluent/react';
|
import { Localized } from '@fluent/react';
|
||||||
import { WrenchIcon } from '@/components/commons/icon/WrenchIcons';
|
import { WrenchIcon } from '@/components/commons/icon/WrenchIcons';
|
||||||
import { TrackingChecklistModal } from './TrackingChecklistModal';
|
import { TrackingChecklistModal } from './TrackingChecklistModal';
|
||||||
import { NavLink, useNavigate } from 'react-router-dom';
|
import { NavLink, useNavigate } from 'react-router-dom';
|
||||||
@@ -110,69 +108,6 @@ function Step({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function SteamVRDisconnected({
|
|
||||||
step,
|
|
||||||
context,
|
|
||||||
}: {
|
|
||||||
step: TrackingChecklistStep;
|
|
||||||
context: TrackingChecklistContext;
|
|
||||||
}) {
|
|
||||||
const { sendRPCPacket } = useWebsocketAPI();
|
|
||||||
const data = step.extraData as TrackingChecklistSteamVRDisconnectedT | null;
|
|
||||||
|
|
||||||
const enableDriver = () => {
|
|
||||||
sendRPCPacket(
|
|
||||||
RpcMessage.EnableSteamVRDriverRequest,
|
|
||||||
new EnableSteamVRDriverRequestT()
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const driverNotInstalled = data?.driverInstalled === false;
|
|
||||||
const driverBlocked = data?.driverBlockedBySafeMode === true;
|
|
||||||
const driverDisabled = data?.driverEnabled === false;
|
|
||||||
|
|
||||||
const showEnableDriverButton = driverBlocked || driverDisabled;
|
|
||||||
|
|
||||||
const getDescriptionId = () => {
|
|
||||||
if (driverBlocked)
|
|
||||||
return 'tracking_checklist-STEAMVR_DISCONNECTED-driver_blocked-desc';
|
|
||||||
if (driverDisabled)
|
|
||||||
return 'tracking_checklist-STEAMVR_DISCONNECTED-driver_disabled-desc';
|
|
||||||
if (driverNotInstalled)
|
|
||||||
return 'tracking_checklist-STEAMVR_DISCONNECTED-driver_not_installed-desc';
|
|
||||||
return 'tracking_checklist-STEAMVR_DISCONNECTED-desc';
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="space-y-2.5">
|
|
||||||
<Typography id={getDescriptionId()} />
|
|
||||||
<div className="flex justify-between sm:items-center gap-1 flex-col sm:flex-row">
|
|
||||||
{showEnableDriverButton && (
|
|
||||||
<Button
|
|
||||||
id="tracking_checklist-STEAMVR_DISCONNECTED-enable"
|
|
||||||
variant="primary"
|
|
||||||
onClick={enableDriver}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{!showEnableDriverButton && !driverNotInstalled && (
|
|
||||||
<Button
|
|
||||||
id="tracking_checklist-STEAMVR_DISCONNECTED-open"
|
|
||||||
variant="primary"
|
|
||||||
onClick={() => openUrl('steam://run/250820')}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{step.ignorable && (
|
|
||||||
<Button
|
|
||||||
id="tracking_checklist-ignore"
|
|
||||||
variant="secondary"
|
|
||||||
onClick={() => context.toggleSession(step.id)}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function SteamVRHandsEnabled() {
|
function SteamVRHandsEnabled() {
|
||||||
const { sendRPCPacket, useRPCPacket } = useWebsocketAPI();
|
const { sendRPCPacket, useRPCPacket } = useWebsocketAPI();
|
||||||
const [steamVrTrackers, setSteamVrTrackers] = useState<Omit<
|
const [steamVrTrackers, setSteamVrTrackers] = useState<Omit<
|
||||||
@@ -222,21 +157,6 @@ function SteamVRHandsEnabled() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function StandableInstalled() {
|
|
||||||
const { l10n } = useLocalization();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="space-y-2.5">
|
|
||||||
{l10n
|
|
||||||
.getString('tracking_checklist-STANDABLE_INSTALLED-desc')
|
|
||||||
.split('\n')
|
|
||||||
.map((line, i) => (
|
|
||||||
<Typography key={i}>{line}</Typography>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const stepContentLookup: Record<
|
const stepContentLookup: Record<
|
||||||
number,
|
number,
|
||||||
(
|
(
|
||||||
@@ -304,8 +224,28 @@ const stepContentLookup: Record<
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
[TrackingChecklistStepId.STEAMVR_DISCONNECTED]: (step, context) => {
|
[TrackingChecklistStepId.STEAMVR_DISCONNECTED]: (step, { toggleSession }) => {
|
||||||
return <SteamVRDisconnected step={step} context={context} />;
|
return (
|
||||||
|
<>
|
||||||
|
<div className="space-y-2.5">
|
||||||
|
<Typography id="tracking_checklist-STEAMVR_DISCONNECTED-desc" />
|
||||||
|
<div className="flex justify-between sm:items-center gap-1 flex-col sm:flex-row">
|
||||||
|
<Button
|
||||||
|
id="tracking_checklist-STEAMVR_DISCONNECTED-open"
|
||||||
|
variant="primary"
|
||||||
|
onClick={() => openUrl('steam://run/250820')}
|
||||||
|
/>
|
||||||
|
{step.ignorable && (
|
||||||
|
<Button
|
||||||
|
id="tracking_checklist-ignore"
|
||||||
|
variant="secondary"
|
||||||
|
onClick={() => toggleSession(step.id)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
},
|
},
|
||||||
[TrackingChecklistStepId.TRACKER_ERROR]: () => {
|
[TrackingChecklistStepId.TRACKER_ERROR]: () => {
|
||||||
return <Typography id="tracking_checklist-TRACKER_ERROR-desc" />;
|
return <Typography id="tracking_checklist-TRACKER_ERROR-desc" />;
|
||||||
@@ -470,9 +410,6 @@ const stepContentLookup: Record<
|
|||||||
[TrackingChecklistStepId.STEAMVR_HANDS_ENABLED]: () => {
|
[TrackingChecklistStepId.STEAMVR_HANDS_ENABLED]: () => {
|
||||||
return <SteamVRHandsEnabled />;
|
return <SteamVRHandsEnabled />;
|
||||||
},
|
},
|
||||||
[TrackingChecklistStepId.STANDABLE_INSTALLED]: () => {
|
|
||||||
return <StandableInstalled />;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export function TrackingChecklistMobile() {
|
export function TrackingChecklistMobile() {
|
||||||
|
|||||||
@@ -0,0 +1,75 @@
|
|||||||
|
import { useEffect } from 'react';
|
||||||
|
import { FieldPath, useForm } from 'react-hook-form';
|
||||||
|
import { useConfig } from '@/hooks/config';
|
||||||
|
import { CheckBox } from '@/components/commons/Checkbox';
|
||||||
|
import { useLocalization } from '@fluent/react';
|
||||||
|
|
||||||
|
export interface DeveloperModeWidgetForm {
|
||||||
|
highContrast: boolean;
|
||||||
|
preciseRotation: boolean;
|
||||||
|
fastDataFeed: boolean;
|
||||||
|
filterSlimesAndHMD: boolean;
|
||||||
|
sortByName: boolean;
|
||||||
|
rawSlimeRotation: boolean;
|
||||||
|
moreInfo: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const defaultValues: DeveloperModeWidgetForm = {
|
||||||
|
highContrast: false,
|
||||||
|
preciseRotation: false,
|
||||||
|
fastDataFeed: false,
|
||||||
|
filterSlimesAndHMD: false,
|
||||||
|
sortByName: false,
|
||||||
|
rawSlimeRotation: false,
|
||||||
|
moreInfo: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
export function DeveloperModeWidget() {
|
||||||
|
const { l10n } = useLocalization();
|
||||||
|
const { config, setConfig } = useConfig();
|
||||||
|
|
||||||
|
const onSubmit = (formData: DeveloperModeWidgetForm) => {
|
||||||
|
setConfig({ devSettings: formData });
|
||||||
|
};
|
||||||
|
|
||||||
|
const { reset, control, handleSubmit, watch } =
|
||||||
|
useForm<DeveloperModeWidgetForm>({
|
||||||
|
defaultValues: defaultValues,
|
||||||
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
reset(config?.devSettings || {});
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const subscription = watch(() => handleSubmit(onSubmit)());
|
||||||
|
return () => subscription.unsubscribe();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const makeToggle = ([name, label]: string[], index: number) => (
|
||||||
|
<CheckBox
|
||||||
|
key={index}
|
||||||
|
control={control}
|
||||||
|
variant="toggle"
|
||||||
|
outlined
|
||||||
|
name={name as FieldPath<DeveloperModeWidgetForm>}
|
||||||
|
label={l10n.getString(`widget-developer_mode-${label}`)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
|
const toggles = {
|
||||||
|
highContrast: 'high_contrast',
|
||||||
|
preciseRotation: 'precise_rotation',
|
||||||
|
fastDataFeed: 'fast_data_feed',
|
||||||
|
filterSlimesAndHMD: 'filter_slimes_and_hmd',
|
||||||
|
sortByName: 'sort_by_name',
|
||||||
|
rawSlimeRotation: 'raw_slime_rotation',
|
||||||
|
moreInfo: 'more_info',
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<form className="grid grid-cols-2 w-full rounded-md gap-2">
|
||||||
|
{Object.entries(toggles).map(makeToggle)}
|
||||||
|
</form>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -130,18 +130,14 @@ async function initializeIMUVisualizer(
|
|||||||
accelArrow.setLength(Math.sqrt(accelLength) * 2);
|
accelArrow.setLength(Math.sqrt(accelLength) * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
const magVec = Vector3FromVec3fT(mag);
|
const magVec = new Vector3(mag.x, mag.y, mag.z);
|
||||||
const magLen = magVec.length();
|
const magLen = magVec.length();
|
||||||
const magMag = Math.sqrt(magLen / 100);
|
const magMag = Math.sqrt(magLen / 100);
|
||||||
if (magLen > 0) {
|
if (magLen > 0) {
|
||||||
if (magArrow.parent === null) scene.add(magArrow);
|
|
||||||
|
|
||||||
const magDir = magVec.clone().normalize();
|
const magDir = magVec.clone().normalize();
|
||||||
magArrow.position.copy(magDir.clone().multiplyScalar(-magMag));
|
magArrow.position.copy(magDir.clone().multiplyScalar(-magMag));
|
||||||
magArrow.setDirection(magDir);
|
magArrow.setDirection(magDir);
|
||||||
magArrow.setLength(2 * magMag);
|
magArrow.setLength(2 * magMag);
|
||||||
} else {
|
|
||||||
magArrow.removeFromParent();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -211,7 +207,9 @@ function IMUVisualizerCanvas({
|
|||||||
}, [model]);
|
}, [model]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
contextRef.current?.update(quat, vec, mag);
|
if (contextRef.current) {
|
||||||
|
contextRef.current.update(quat, vec, mag);
|
||||||
|
}
|
||||||
}, [quat, vec, mag]);
|
}, [quat, vec, mag]);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import { getSentryOrCompute, updateSentryContext } from '@/utils/sentry';
|
|||||||
import { fetchCurrentFirmwareRelease, FirmwareRelease } from './firmware-update';
|
import { fetchCurrentFirmwareRelease, FirmwareRelease } from './firmware-update';
|
||||||
import { DEFAULT_LOCALE, LangContext } from '@/i18n/config';
|
import { DEFAULT_LOCALE, LangContext } from '@/i18n/config';
|
||||||
|
|
||||||
const isSteam = window.electronAPI ? await window.electronAPI.isSteam() : false;
|
const isSteam = await window.electronAPI.isSteam();
|
||||||
|
|
||||||
export interface AppContext {
|
export interface AppContext {
|
||||||
currentFirmwareRelease: FirmwareRelease | null;
|
currentFirmwareRelease: FirmwareRelease | null;
|
||||||
|
|||||||
+5
-21
@@ -1,4 +1,8 @@
|
|||||||
import { createContext, useContext, useState } from 'react';
|
import { createContext, useContext, useState } from 'react';
|
||||||
|
import {
|
||||||
|
defaultValues as defaultDevSettings,
|
||||||
|
DeveloperModeWidgetForm,
|
||||||
|
} from '@/components/widgets/DeveloperModeWidget';
|
||||||
import { error } from '@/utils/logging';
|
import { error } from '@/utils/logging';
|
||||||
import { useDebouncedEffect } from './timeout';
|
import { useDebouncedEffect } from './timeout';
|
||||||
import { waitUntil } from '@/utils/a11y';
|
import { waitUntil } from '@/utils/a11y';
|
||||||
@@ -21,33 +25,13 @@ export enum AssignMode {
|
|||||||
All = 'all',
|
All = 'all',
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DeveloperModeConfig {
|
|
||||||
highContrast: boolean;
|
|
||||||
preciseRotation: boolean;
|
|
||||||
fastDataFeed: boolean;
|
|
||||||
filterSlimesAndHMD: boolean;
|
|
||||||
sortByName: boolean;
|
|
||||||
rawSlimeRotation: boolean;
|
|
||||||
moreInfo: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const defaultDevSettings: DeveloperModeConfig = {
|
|
||||||
highContrast: false,
|
|
||||||
preciseRotation: false,
|
|
||||||
fastDataFeed: false,
|
|
||||||
filterSlimesAndHMD: false,
|
|
||||||
sortByName: false,
|
|
||||||
rawSlimeRotation: false,
|
|
||||||
moreInfo: false,
|
|
||||||
};
|
|
||||||
|
|
||||||
export interface Config {
|
export interface Config {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
debug: boolean;
|
debug: boolean;
|
||||||
lang: string;
|
lang: string;
|
||||||
doneOnboarding: boolean;
|
doneOnboarding: boolean;
|
||||||
watchNewDevices: boolean;
|
watchNewDevices: boolean;
|
||||||
devSettings: DeveloperModeConfig;
|
devSettings: DeveloperModeWidgetForm;
|
||||||
feedbackSound: boolean;
|
feedbackSound: boolean;
|
||||||
feedbackSoundVolume: number;
|
feedbackSoundVolume: number;
|
||||||
connectedTrackersWarning: boolean;
|
connectedTrackersWarning: boolean;
|
||||||
|
|||||||
@@ -426,10 +426,3 @@ div {
|
|||||||
[data-electron-drag-region='true'] {
|
[data-electron-drag-region='true'] {
|
||||||
-webkit-app-region: drag;
|
-webkit-app-region: drag;
|
||||||
}
|
}
|
||||||
|
|
||||||
a,
|
|
||||||
.no-user-drag {
|
|
||||||
-webkit-user-drag: none;
|
|
||||||
-webkit-user-select: none;
|
|
||||||
user-select: none;
|
|
||||||
}
|
|
||||||
+1
-1
@@ -6,7 +6,7 @@ import path from 'path';
|
|||||||
import { visualizer } from 'rollup-plugin-visualizer';
|
import { visualizer } from 'rollup-plugin-visualizer';
|
||||||
import jotaiReactRefresh from 'jotai/babel/plugin-react-refresh';
|
import jotaiReactRefresh from 'jotai/babel/plugin-react-refresh';
|
||||||
|
|
||||||
const commitHash = execSync('git rev-parse --verify --short=8 HEAD').toString().trim();
|
const commitHash = execSync('git rev-parse --verify --short HEAD').toString().trim();
|
||||||
const versionTag = execSync('git --no-pager tag --sort -taggerdate --points-at HEAD')
|
const versionTag = execSync('git --no-pager tag --sort -taggerdate --points-at HEAD')
|
||||||
.toString()
|
.toString()
|
||||||
.split('\n')[0]
|
.split('\n')[0]
|
||||||
|
|||||||
Generated
+472
-253
File diff suppressed because it is too large.
Load diff
@@ -17,6 +17,7 @@ plugins {
|
|||||||
id("com.github.gmazzo.buildconfig")
|
id("com.github.gmazzo.buildconfig")
|
||||||
|
|
||||||
id("com.android.application") version "8.13.2"
|
id("com.android.application") version "8.13.2"
|
||||||
|
id("org.ajoberstar.grgit")
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
@@ -123,14 +124,8 @@ dependencies {
|
|||||||
|
|
||||||
// The android block is where you configure all your Android-specific build options.
|
// The android block is where you configure all your Android-specific build options.
|
||||||
extra.apply {
|
extra.apply {
|
||||||
val tagCount = providers.exec {
|
set("gitVersionCode", grgit.tag.list().size)
|
||||||
commandLine("git", "--no-pager", "tag", "-l")
|
set("gitVersionName", grgit.describe(mapOf("tags" to true, "always" to true)))
|
||||||
}.standardOutput.asText.get().trim().split('\n').size
|
|
||||||
val description = providers.exec {
|
|
||||||
commandLine("git", "describe", "--tags", "--abbrev=8", "--always")
|
|
||||||
}.standardOutput.asText.get().trim()
|
|
||||||
set("gitVersionCode", tagCount)
|
|
||||||
set("gitVersionName", description)
|
|
||||||
}
|
}
|
||||||
android {
|
android {
|
||||||
// The app's namespace. Used primarily to access app resources.
|
// The app's namespace. Used primarily to access app resources.
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import com.hoho.android.usbserial.driver.UsbSerialProber
|
|||||||
import com.hoho.android.usbserial.util.SerialInputOutputManager
|
import com.hoho.android.usbserial.util.SerialInputOutputManager
|
||||||
import dev.slimevr.serial.SerialHandler
|
import dev.slimevr.serial.SerialHandler
|
||||||
import dev.slimevr.serial.SerialListener
|
import dev.slimevr.serial.SerialListener
|
||||||
import dev.slimevr.tracking.trackers.hid.HIDCommon
|
|
||||||
import io.eiren.util.logging.LogManager
|
import io.eiren.util.logging.LogManager
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.nio.ByteBuffer
|
import java.nio.ByteBuffer
|
||||||
@@ -58,7 +57,7 @@ class AndroidSerialHandler(val activity: AppCompatActivity) :
|
|||||||
get() = getPorts()
|
get() = getPorts()
|
||||||
.asSequence()
|
.asSequence()
|
||||||
.map { SerialPortWrapper(it.ports[0]) }
|
.map { SerialPortWrapper(it.ports[0]) }
|
||||||
.filter { isKnownBoard(it) || HIDCommon.matchesAny(it.vendorId, it.productId) }
|
.filter { isKnownBoard(it) }
|
||||||
.asStream()
|
.asStream()
|
||||||
|
|
||||||
val usbReceiver: BroadcastReceiver = object : BroadcastReceiver() {
|
val usbReceiver: BroadcastReceiver = object : BroadcastReceiver() {
|
||||||
@@ -145,11 +144,11 @@ class AndroidSerialHandler(val activity: AppCompatActivity) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
override fun openSerial(portLocation: String?, auto: Boolean, autoIncludeHid: Boolean): Boolean {
|
override fun openSerial(portLocation: String?, auto: Boolean): Boolean {
|
||||||
LogManager.info("[SerialHandler] Trying to open: $portLocation, auto: $auto")
|
LogManager.info("[SerialHandler] Trying to open: $portLocation, auto: $auto")
|
||||||
lastKnownPorts = knownPorts.asSequence().toSet()
|
lastKnownPorts = knownPorts.asSequence().toSet()
|
||||||
val newPort = lastKnownPorts.find {
|
val newPort = lastKnownPorts.find {
|
||||||
(!auto && it.portLocation == portLocation) || (auto && isKnownBoard(it)) || (auto && autoIncludeHid && HIDCommon.matchesAny(it.vendorId, it.productId))
|
(!auto && it.portLocation == portLocation) || (auto && isKnownBoard(it))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newPort == null) {
|
if (newPort == null) {
|
||||||
|
|||||||
+1
-2
@@ -71,7 +71,6 @@ class AndroidHIDManager(
|
|||||||
val serial = hidDevice.serialNumber ?: "Unknown USB Device ${hidDevice.deviceId}"
|
val serial = hidDevice.serialNumber ?: "Unknown USB Device ${hidDevice.deviceId}"
|
||||||
this.devicesBySerial[serial]?.let {
|
this.devicesBySerial[serial]?.let {
|
||||||
this.devicesByHID[hidDevice] = it
|
this.devicesByHID[hidDevice] = it
|
||||||
this.lastDataByHID[hidDevice] = 0
|
|
||||||
synchronized(this.devices) {
|
synchronized(this.devices) {
|
||||||
for (id in it) {
|
for (id in it) {
|
||||||
val device = this.devices[id]
|
val device = this.devices[id]
|
||||||
@@ -188,7 +187,7 @@ class AndroidHIDManager(
|
|||||||
}
|
}
|
||||||
// LogManager.info("[TrackerServer] HID received $packetCount tracker packets")
|
// LogManager.info("[TrackerServer] HID received $packetCount tracker packets")
|
||||||
} else {
|
} else {
|
||||||
lastDataByHID[hidDevice] = lastDataByHID.getOrDefault(hidDevice, 0) + 1 // increment last data received
|
lastDataByHID[hidDevice] = lastDataByHID[hidDevice]!! + 1 // increment last data received
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!devicesPresent) {
|
if (!devicesPresent) {
|
||||||
|
|||||||
@@ -91,10 +91,6 @@ dependencies {
|
|||||||
// Jitpack
|
// Jitpack
|
||||||
implementation("com.github.SlimeVR:oscquery-kt:566a0cba58")
|
implementation("com.github.SlimeVR:oscquery-kt:566a0cba58")
|
||||||
|
|
||||||
// For SteamVR driver detection
|
|
||||||
implementation("io.ktor:ktor-client-core:2.3.13")
|
|
||||||
implementation("io.ktor:ktor-client-cio:2.3.13")
|
|
||||||
|
|
||||||
testImplementation(kotlin("test"))
|
testImplementation(kotlin("test"))
|
||||||
// Use JUnit test framework
|
// Use JUnit test framework
|
||||||
testImplementation(platform("org.junit:junit-bom:6.0.2"))
|
testImplementation(platform("org.junit:junit-bom:6.0.2"))
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ import dev.slimevr.tracking.trackers.udp.TrackersUDPServer
|
|||||||
import dev.slimevr.trackingchecklist.TrackingChecklistManager
|
import dev.slimevr.trackingchecklist.TrackingChecklistManager
|
||||||
import dev.slimevr.util.ann.VRServerThread
|
import dev.slimevr.util.ann.VRServerThread
|
||||||
import dev.slimevr.websocketapi.WebSocketVRBridge
|
import dev.slimevr.websocketapi.WebSocketVRBridge
|
||||||
import io.eiren.util.Process
|
|
||||||
import io.eiren.util.ann.ThreadSafe
|
import io.eiren.util.ann.ThreadSafe
|
||||||
import io.eiren.util.ann.ThreadSecure
|
import io.eiren.util.ann.ThreadSecure
|
||||||
import io.eiren.util.collections.FastList
|
import io.eiren.util.collections.FastList
|
||||||
@@ -63,8 +62,6 @@ class VRServer @JvmOverloads constructor(
|
|||||||
flashingHandlerProvider: (VRServer) -> SerialFlashingHandler? = { _ -> null },
|
flashingHandlerProvider: (VRServer) -> SerialFlashingHandler? = { _ -> null },
|
||||||
vrcConfigHandlerProvider: (VRServer) -> VRCConfigHandler = { _ -> VRCConfigHandlerStub() },
|
vrcConfigHandlerProvider: (VRServer) -> VRCConfigHandler = { _ -> VRCConfigHandlerStub() },
|
||||||
networkProfileProvider: (VRServer) -> NetworkProfileChecker = { _ -> StubNetworkProfileChecker() },
|
networkProfileProvider: (VRServer) -> NetworkProfileChecker = { _ -> StubNetworkProfileChecker() },
|
||||||
val processListProvider: () -> Sequence<Process> = { emptySequence() },
|
|
||||||
val tryOpenUri: (String) -> Unit = {},
|
|
||||||
acquireMulticastLock: () -> Any? = { null },
|
acquireMulticastLock: () -> Any? = { null },
|
||||||
@JvmField val configManager: ConfigManager,
|
@JvmField val configManager: ConfigManager,
|
||||||
) : Thread("VRServer") {
|
) : Thread("VRServer") {
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class ServerConfig {
|
|||||||
// it.setMag(false)
|
// it.setMag(false)
|
||||||
// } else {
|
// } else {
|
||||||
trackers.map { (_, t) ->
|
trackers.map { (_, t) ->
|
||||||
async { it.setMag(MagnetometerStatus.DISABLED, t.trackerNum) }
|
async { it.setMag(false, t.trackerNum) }
|
||||||
}.awaitAll()
|
}.awaitAll()
|
||||||
// }
|
// }
|
||||||
return@async
|
return@async
|
||||||
@@ -51,7 +51,7 @@ class ServerConfig {
|
|||||||
.map { (_, t) ->
|
.map { (_, t) ->
|
||||||
async {
|
async {
|
||||||
// FIXME: Tracker gets restarted after each setMag, what will happen for devices with 3 trackers?
|
// FIXME: Tracker gets restarted after each setMag, what will happen for devices with 3 trackers?
|
||||||
it.setMag(MagnetometerStatus.ENABLED, t.trackerNum)
|
it.setMag(true, t.trackerNum)
|
||||||
}
|
}
|
||||||
}.awaitAll()
|
}.awaitAll()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ class VRCOSCHandler(
|
|||||||
for (netInt in NetworkInterface.getNetworkInterfaces()) {
|
for (netInt in NetworkInterface.getNetworkInterfaces()) {
|
||||||
if (netInt.isUp && !netInt.isLoopback && !netInt.isVirtual) {
|
if (netInt.isUp && !netInt.isLoopback && !netInt.isVirtual) {
|
||||||
for (netAddr in netInt.interfaceAddresses) {
|
for (netAddr in netInt.interfaceAddresses) {
|
||||||
if (a == netAddr.address || a.address.contentEquals(netAddr.address.address)) {
|
if (a == netAddr.address || a.address.contentEquals(netAddr.address.address) || a.hostName == netAddr.address.hostName) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -134,6 +134,7 @@ class VRCOSCHandler(
|
|||||||
b != null &&
|
b != null &&
|
||||||
(
|
(
|
||||||
a.address.contentEquals(b.address) ||
|
a.address.contentEquals(b.address) ||
|
||||||
|
(a.hostName == b.hostName) ||
|
||||||
(ipIsLocal(a) && ipIsLocal(b))
|
(ipIsLocal(a) && ipIsLocal(b))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -22,18 +22,14 @@ import dev.slimevr.protocol.rpc.setup.RPCUtil.getLocalIp
|
|||||||
import dev.slimevr.protocol.rpc.status.RPCStatusHandler
|
import dev.slimevr.protocol.rpc.status.RPCStatusHandler
|
||||||
import dev.slimevr.protocol.rpc.trackingchecklist.RPCTrackingChecklistHandler
|
import dev.slimevr.protocol.rpc.trackingchecklist.RPCTrackingChecklistHandler
|
||||||
import dev.slimevr.protocol.rpc.trackingpause.RPCTrackingPause
|
import dev.slimevr.protocol.rpc.trackingpause.RPCTrackingPause
|
||||||
import dev.slimevr.steamvr.SteamVRUtils
|
|
||||||
import dev.slimevr.tracking.processor.config.SkeletonConfigOffsets
|
import dev.slimevr.tracking.processor.config.SkeletonConfigOffsets
|
||||||
import dev.slimevr.tracking.processor.stayaligned.poses.RelaxedPose
|
import dev.slimevr.tracking.processor.stayaligned.poses.RelaxedPose
|
||||||
import dev.slimevr.tracking.trackers.TrackerPosition
|
import dev.slimevr.tracking.trackers.TrackerPosition
|
||||||
import dev.slimevr.tracking.trackers.TrackerPosition.Companion.getByBodyPart
|
import dev.slimevr.tracking.trackers.TrackerPosition.Companion.getByBodyPart
|
||||||
import dev.slimevr.tracking.trackers.TrackerStatus
|
import dev.slimevr.tracking.trackers.TrackerStatus
|
||||||
import dev.slimevr.tracking.trackers.TrackerUtils.getTrackerForSkeleton
|
import dev.slimevr.tracking.trackers.TrackerUtils.getTrackerForSkeleton
|
||||||
import dev.slimevr.tracking.trackers.udp.MagnetometerStatus
|
|
||||||
import io.eiren.util.logging.LogManager
|
import io.eiren.util.logging.LogManager
|
||||||
import io.github.axisangles.ktmath.Quaternion
|
import io.github.axisangles.ktmath.Quaternion
|
||||||
import io.ktor.client.HttpClient
|
|
||||||
import io.ktor.client.engine.cio.CIO
|
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import solarxr_protocol.MessageBundle
|
import solarxr_protocol.MessageBundle
|
||||||
import solarxr_protocol.datatypes.TransactionId
|
import solarxr_protocol.datatypes.TransactionId
|
||||||
@@ -155,11 +151,6 @@ class RPCHandler(private val api: ProtocolAPI) : ProtocolHandler<RpcMessageHeade
|
|||||||
RpcMessage.ResetStayAlignedRelaxedPoseRequest,
|
RpcMessage.ResetStayAlignedRelaxedPoseRequest,
|
||||||
::onResetStayAlignedRelaxedPoseRequest,
|
::onResetStayAlignedRelaxedPoseRequest,
|
||||||
)
|
)
|
||||||
|
|
||||||
registerPacketListener(
|
|
||||||
RpcMessage.EnableSteamVRDriverRequest,
|
|
||||||
::onEnableSteamVRDriverRequest,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onServerInfosRequest(
|
private fun onServerInfosRequest(
|
||||||
@@ -526,7 +517,7 @@ class RPCHandler(private val api: ProtocolAPI) : ProtocolHandler<RpcMessageHeade
|
|||||||
|
|
||||||
mainScope.launch {
|
mainScope.launch {
|
||||||
withTimeoutOrNull(MAG_TIMEOUT) {
|
withTimeoutOrNull(MAG_TIMEOUT) {
|
||||||
tracker.device.setMag(if (state) MagnetometerStatus.ENABLED else MagnetometerStatus.DISABLED, tracker.trackerNum)
|
tracker.device.setMag(state, tracker.trackerNum)
|
||||||
}
|
}
|
||||||
|
|
||||||
val fbb = FlatBufferBuilder(32)
|
val fbb = FlatBufferBuilder(32)
|
||||||
@@ -619,16 +610,6 @@ class RPCHandler(private val api: ProtocolAPI) : ProtocolHandler<RpcMessageHeade
|
|||||||
sendSettingsChangedResponse(conn, messageHeader)
|
sendSettingsChangedResponse(conn, messageHeader)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onEnableSteamVRDriverRequest(conn: GenericConnection, messageHeader: RpcMessageHeader) {
|
|
||||||
val request = messageHeader.message(EnableSteamVRDriverRequest()) as? EnableSteamVRDriverRequest ?: return
|
|
||||||
|
|
||||||
mainScope.launch {
|
|
||||||
val client = HttpClient(CIO)
|
|
||||||
SteamVRUtils.unblockDriver(client, "slimevr")
|
|
||||||
client.close()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun sendSettingsChangedResponse(conn: GenericConnection, messageHeader: RpcMessageHeader?) {
|
fun sendSettingsChangedResponse(conn: GenericConnection, messageHeader: RpcMessageHeader?) {
|
||||||
val fbb = FlatBufferBuilder(32)
|
val fbb = FlatBufferBuilder(32)
|
||||||
val settings = createSettingsResponse(fbb, api.server)
|
val settings = createSettingsResponse(fbb, api.server)
|
||||||
|
|||||||
@@ -7,24 +7,10 @@ import dev.slimevr.protocol.ProtocolAPIServer
|
|||||||
import dev.slimevr.protocol.rpc.RPCHandler
|
import dev.slimevr.protocol.rpc.RPCHandler
|
||||||
import dev.slimevr.serial.SerialListener
|
import dev.slimevr.serial.SerialListener
|
||||||
import dev.slimevr.serial.SerialPort
|
import dev.slimevr.serial.SerialPort
|
||||||
import dev.slimevr.tracking.trackers.hid.HIDCommon
|
|
||||||
import io.eiren.util.logging.LogManager
|
import io.eiren.util.logging.LogManager
|
||||||
import solarxr_protocol.rpc.*
|
import solarxr_protocol.rpc.*
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.function.Consumer
|
import java.util.function.Consumer
|
||||||
import kotlin.collections.emptyList
|
|
||||||
|
|
||||||
fun createSerialDevice(fbb: FlatBufferBuilder, port: SerialPort): Int {
|
|
||||||
val portOffset = fbb.createString(port.portLocation)
|
|
||||||
val nameOffset = fbb.createString(port.descriptivePortName)
|
|
||||||
val portType = when {
|
|
||||||
HIDCommon.matchesReceiver(port.vendorId, port.productId) -> SerialDeviceType.HID_RECEIVER
|
|
||||||
HIDCommon.matchesTracker(port.vendorId, port.productId) -> SerialDeviceType.HID_TRACKER
|
|
||||||
else -> SerialDeviceType.ESP_TRACKER
|
|
||||||
}
|
|
||||||
|
|
||||||
return SerialDevice.createSerialDevice(fbb, portOffset, nameOffset, portType)
|
|
||||||
}
|
|
||||||
|
|
||||||
class RPCSerialHandler(var rpcHandler: RPCHandler, var api: ProtocolAPI) : SerialListener {
|
class RPCSerialHandler(var rpcHandler: RPCHandler, var api: ProtocolAPI) : SerialListener {
|
||||||
init {
|
init {
|
||||||
@@ -49,36 +35,38 @@ class RPCSerialHandler(var rpcHandler: RPCHandler, var api: ProtocolAPI) : Seria
|
|||||||
val outbound = rpcHandler.createRPCMessage(fbb, RpcMessage.SerialUpdateResponse, update)
|
val outbound = rpcHandler.createRPCMessage(fbb, RpcMessage.SerialUpdateResponse, update)
|
||||||
fbb.finish(outbound)
|
fbb.finish(outbound)
|
||||||
|
|
||||||
this.forAllListeners { conn: GenericConnection ->
|
this.forAllListeners(
|
||||||
conn.send(fbb.dataBuffer())
|
Consumer { conn: GenericConnection ->
|
||||||
conn.context.useSerial = false
|
conn.send(fbb.dataBuffer())
|
||||||
}
|
conn.context.useSerial = false
|
||||||
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSerialLog(str: String, server: Boolean) {
|
override fun onSerialLog(str: String, server: Boolean) {
|
||||||
val fbb = FlatBufferBuilder(32)
|
val fbb = FlatBufferBuilder(32)
|
||||||
|
|
||||||
val logOffset = fbb.createString(str)
|
val logOffset = fbb.createString(str)
|
||||||
val portOffset = api.server.serialHandler.getCurrentPort()?.let { port ->
|
|
||||||
createSerialDevice(fbb, port)
|
|
||||||
} ?: 0
|
|
||||||
|
|
||||||
SerialUpdateResponse.startSerialUpdateResponse(fbb)
|
SerialUpdateResponse.startSerialUpdateResponse(fbb)
|
||||||
SerialUpdateResponse.addLog(fbb, logOffset)
|
SerialUpdateResponse.addLog(fbb, logOffset)
|
||||||
SerialUpdateResponse.addDevice(fbb, portOffset)
|
|
||||||
val update = SerialUpdateResponse.endSerialUpdateResponse(fbb)
|
val update = SerialUpdateResponse.endSerialUpdateResponse(fbb)
|
||||||
val outbound = rpcHandler.createRPCMessage(fbb, RpcMessage.SerialUpdateResponse, update)
|
val outbound = rpcHandler.createRPCMessage(fbb, RpcMessage.SerialUpdateResponse, update)
|
||||||
fbb.finish(outbound)
|
fbb.finish(outbound)
|
||||||
|
|
||||||
this.forAllListeners { conn ->
|
this.forAllListeners(
|
||||||
conn.send(fbb.dataBuffer())
|
Consumer { conn: GenericConnection ->
|
||||||
}
|
conn.send(fbb.dataBuffer())
|
||||||
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onNewSerialDevice(port: SerialPort) {
|
override fun onNewSerialDevice(port: SerialPort) {
|
||||||
val fbb = FlatBufferBuilder(32)
|
val fbb = FlatBufferBuilder(32)
|
||||||
|
|
||||||
val deviceOffset = createSerialDevice(fbb, port)
|
val portOffset = fbb.createString(port.portLocation)
|
||||||
|
val nameOffset = fbb.createString(port.descriptivePortName)
|
||||||
|
val deviceOffset = SerialDevice.createSerialDevice(fbb, portOffset, nameOffset)
|
||||||
val newSerialOffset = NewSerialDeviceResponse
|
val newSerialOffset = NewSerialDeviceResponse
|
||||||
.createNewSerialDeviceResponse(fbb, deviceOffset)
|
.createNewSerialDeviceResponse(fbb, deviceOffset)
|
||||||
val outbound = rpcHandler
|
val outbound = rpcHandler
|
||||||
@@ -101,17 +89,17 @@ class RPCSerialHandler(var rpcHandler: RPCHandler, var api: ProtocolAPI) : Seria
|
|||||||
override fun onSerialConnected(port: SerialPort) {
|
override fun onSerialConnected(port: SerialPort) {
|
||||||
val fbb = FlatBufferBuilder(32)
|
val fbb = FlatBufferBuilder(32)
|
||||||
|
|
||||||
val deviceOffset = createSerialDevice(fbb, port)
|
|
||||||
SerialUpdateResponse.startSerialUpdateResponse(fbb)
|
SerialUpdateResponse.startSerialUpdateResponse(fbb)
|
||||||
SerialUpdateResponse.addClosed(fbb, false)
|
SerialUpdateResponse.addClosed(fbb, false)
|
||||||
SerialUpdateResponse.addDevice(fbb, deviceOffset)
|
|
||||||
val update = SerialUpdateResponse.endSerialUpdateResponse(fbb)
|
val update = SerialUpdateResponse.endSerialUpdateResponse(fbb)
|
||||||
val outbound = rpcHandler.createRPCMessage(fbb, RpcMessage.SerialUpdateResponse, update)
|
val outbound = rpcHandler.createRPCMessage(fbb, RpcMessage.SerialUpdateResponse, update)
|
||||||
fbb.finish(outbound)
|
fbb.finish(outbound)
|
||||||
|
|
||||||
this.forAllListeners { conn ->
|
this.forAllListeners(
|
||||||
conn.send(fbb.dataBuffer())
|
Consumer { conn: GenericConnection ->
|
||||||
}
|
conn.send(fbb.dataBuffer())
|
||||||
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onSerialTrackerRebootRequest(
|
fun onSerialTrackerRebootRequest(
|
||||||
@@ -177,17 +165,20 @@ class RPCSerialHandler(var rpcHandler: RPCHandler, var api: ProtocolAPI) : Seria
|
|||||||
|
|
||||||
val fbb = FlatBufferBuilder(32)
|
val fbb = FlatBufferBuilder(32)
|
||||||
|
|
||||||
val devicesOffsets = try {
|
val devicesOffsets: MutableList<Int> = ArrayList()
|
||||||
api.server.serialHandler.knownPorts.map { port ->
|
|
||||||
createSerialDevice(fbb, port)
|
try {
|
||||||
}.toList()
|
this.api.server.serialHandler.knownPorts.forEach { port: SerialPort ->
|
||||||
|
val portOffset = fbb.createString(port.portLocation)
|
||||||
|
val nameOffset = fbb.createString(port.descriptivePortName)
|
||||||
|
devicesOffsets.add(SerialDevice.createSerialDevice(fbb, portOffset, nameOffset))
|
||||||
|
}
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
LogManager.severe("Using serial ports is not supported on this platform", e)
|
LogManager.severe("Using serial ports is not supported on this platform", e)
|
||||||
emptyList()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SerialDevicesResponse.startDevicesVector(fbb, devicesOffsets.size)
|
SerialDevicesResponse.startDevicesVector(fbb, devicesOffsets.size)
|
||||||
devicesOffsets.forEach { offset: Int -> SerialDevicesResponse.addDevices(fbb, offset) }
|
devicesOffsets.forEach(Consumer { offset: Int -> SerialDevicesResponse.addDevices(fbb, offset) })
|
||||||
val devices = fbb.endVector()
|
val devices = fbb.endVector()
|
||||||
val serialDeviceOffsets = SerialDevicesResponse.createSerialDevicesResponse(fbb, devices)
|
val serialDeviceOffsets = SerialDevicesResponse.createSerialDevicesResponse(fbb, devices)
|
||||||
val outbound = rpcHandler
|
val outbound = rpcHandler
|
||||||
@@ -197,7 +188,7 @@ class RPCSerialHandler(var rpcHandler: RPCHandler, var api: ProtocolAPI) : Seria
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun onSetWifiRequest(conn: GenericConnection, messageHeader: RpcMessageHeader) {
|
fun onSetWifiRequest(conn: GenericConnection, messageHeader: RpcMessageHeader) {
|
||||||
val req = messageHeader.message(SetWifiRequest()) as? SetWifiRequest? ?: return
|
val req = messageHeader.message(SetWifiRequest()) as SetWifiRequest? ?: return
|
||||||
|
|
||||||
if (req.password() == null || req.ssid() == null || !this.api.server.serialHandler.isConnected) {
|
if (req.password() == null || req.ssid() == null || !this.api.server.serialHandler.isConnected) {
|
||||||
return
|
return
|
||||||
@@ -207,13 +198,13 @@ class RPCSerialHandler(var rpcHandler: RPCHandler, var api: ProtocolAPI) : Seria
|
|||||||
|
|
||||||
fun onOpenSerialRequest(conn: GenericConnection, messageHeader: RpcMessageHeader) {
|
fun onOpenSerialRequest(conn: GenericConnection, messageHeader: RpcMessageHeader) {
|
||||||
val req =
|
val req =
|
||||||
messageHeader.message(OpenSerialRequest()) as? OpenSerialRequest? ?: return
|
messageHeader.message(OpenSerialRequest()) as OpenSerialRequest? ?: return
|
||||||
|
|
||||||
conn.context.useSerial = true
|
conn.context.useSerial = true
|
||||||
|
|
||||||
this.api.server.queueTask {
|
this.api.server.queueTask {
|
||||||
try {
|
try {
|
||||||
this.api.server.serialHandler.openSerial(req.port(), req.auto(), true)
|
this.api.server.serialHandler.openSerial(req.port(), req.auto())
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
LogManager.severe("Unable to open serial port", e)
|
LogManager.severe("Unable to open serial port", e)
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
@@ -254,10 +245,17 @@ class RPCSerialHandler(var rpcHandler: RPCHandler, var api: ProtocolAPI) : Seria
|
|||||||
conn.send(fbb.dataBuffer())
|
conn.send(fbb.dataBuffer())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun forAllListeners(action: (GenericConnection) -> Unit) {
|
fun forAllListeners(action: Consumer<in GenericConnection?>?) {
|
||||||
this.api.apiServers.forEach { server ->
|
this.api
|
||||||
server.apiConnections.filter { it.context.useSerial }.forEach(action)
|
.apiServers
|
||||||
}
|
.forEach(
|
||||||
|
Consumer { server: ProtocolAPIServer ->
|
||||||
|
server
|
||||||
|
.apiConnections
|
||||||
|
.filter { conn: GenericConnection -> conn.context.useSerial }
|
||||||
|
.forEach(action)
|
||||||
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSerialDeviceDeleted(port: SerialPort) {
|
override fun onSerialDeviceDeleted(port: SerialPort) {
|
||||||
|
|||||||
@@ -71,9 +71,9 @@ public class ProvisioningHandler implements SerialListener {
|
|||||||
try {
|
try {
|
||||||
boolean openResult = false;
|
boolean openResult = false;
|
||||||
if (port != null)
|
if (port != null)
|
||||||
openResult = vrServer.serialHandler.openSerial(port, false, false);
|
openResult = vrServer.serialHandler.openSerial(port, false);
|
||||||
else
|
else
|
||||||
openResult = vrServer.serialHandler.openSerial(null, true, false);
|
openResult = vrServer.serialHandler.openSerial(null, true);
|
||||||
if (!openResult)
|
if (!openResult)
|
||||||
LogManager.info("[SerialHandler] Serial port wasn't open...");
|
LogManager.info("[SerialHandler] Serial port wasn't open...");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ abstract class SerialHandler {
|
|||||||
abstract fun addListener(channel: SerialListener)
|
abstract fun addListener(channel: SerialListener)
|
||||||
abstract fun removeListener(channel: SerialListener)
|
abstract fun removeListener(channel: SerialListener)
|
||||||
|
|
||||||
abstract fun openSerial(portLocation: String?, auto: Boolean, autoIncludeHid: Boolean = false): Boolean
|
abstract fun openSerial(portLocation: String?, auto: Boolean): Boolean
|
||||||
abstract fun rebootRequest()
|
abstract fun rebootRequest()
|
||||||
abstract fun factoryResetRequest()
|
abstract fun factoryResetRequest()
|
||||||
abstract fun infoRequest()
|
abstract fun infoRequest()
|
||||||
@@ -22,7 +22,7 @@ abstract class SerialHandler {
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
// Please also update the udev rules when updating these in:
|
// Please also update the udev rules when updating these in:
|
||||||
// gui/electron/resources/69-slimevr-devices.rules
|
// gui/src-tauri/69-slimevr-devices.rules
|
||||||
val supportedSerial: Set<Pair<Int, Int>> = setOf(
|
val supportedSerial: Set<Pair<Int, Int>> = setOf(
|
||||||
// / QinHeng
|
// / QinHeng
|
||||||
// CH340
|
// CH340
|
||||||
@@ -61,7 +61,7 @@ class SerialHandlerStub : SerialHandler() {
|
|||||||
|
|
||||||
override fun removeListener(channel: SerialListener) {}
|
override fun removeListener(channel: SerialListener) {}
|
||||||
|
|
||||||
override fun openSerial(portLocation: String?, auto: Boolean, autoIncludeHid: Boolean): Boolean = false
|
override fun openSerial(portLocation: String?, auto: Boolean): Boolean = false
|
||||||
|
|
||||||
override fun rebootRequest() {}
|
override fun rebootRequest() {}
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import java.util.*
|
|||||||
abstract class SerialPort {
|
abstract class SerialPort {
|
||||||
abstract val portLocation: String
|
abstract val portLocation: String
|
||||||
abstract val descriptivePortName: String
|
abstract val descriptivePortName: String
|
||||||
abstract val vendorId: Int
|
abstract val vendorId: Int?
|
||||||
abstract val productId: Int
|
abstract val productId: Int?
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
override fun equals(other: Any?): Boolean {
|
||||||
val other: SerialPort = other as? SerialPort ?: return super.equals(other)
|
val other: SerialPort = other as? SerialPort ?: return super.equals(other)
|
||||||
|
|||||||
@@ -1,123 +0,0 @@
|
|||||||
package dev.slimevr.steamvr
|
|
||||||
|
|
||||||
import dev.slimevr.VRServer
|
|
||||||
import io.eiren.util.logging.LogManager
|
|
||||||
import io.ktor.client.HttpClient
|
|
||||||
import io.ktor.client.call.body
|
|
||||||
import io.ktor.client.request.get
|
|
||||||
import io.ktor.client.request.header
|
|
||||||
import io.ktor.client.request.parameter
|
|
||||||
import io.ktor.client.request.request
|
|
||||||
import io.ktor.client.request.setBody
|
|
||||||
import io.ktor.http.HttpMethod
|
|
||||||
import io.ktor.http.isSuccess
|
|
||||||
import kotlinx.coroutines.delay
|
|
||||||
import kotlinx.serialization.SerialName
|
|
||||||
import kotlinx.serialization.Serializable
|
|
||||||
import kotlinx.serialization.json.Json
|
|
||||||
import kotlinx.serialization.json.JsonObject
|
|
||||||
import kotlinx.serialization.json.contentOrNull
|
|
||||||
import kotlinx.serialization.json.jsonObject
|
|
||||||
import kotlinx.serialization.json.jsonPrimitive
|
|
||||||
import kotlin.time.Duration.Companion.milliseconds
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class DriverManifest(
|
|
||||||
val directory: String,
|
|
||||||
@SerialName("hmd_presence")
|
|
||||||
val hmdPresence: List<String>?,
|
|
||||||
val name: String,
|
|
||||||
)
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class Driver(
|
|
||||||
@SerialName("always_activate")
|
|
||||||
val alwaysActivate: Boolean,
|
|
||||||
@SerialName("blocked_by_safe_mode")
|
|
||||||
val blockedBySafeMode: Boolean,
|
|
||||||
val enabled: Boolean,
|
|
||||||
@SerialName("enabled_by_default")
|
|
||||||
val enabledByDefault: Boolean,
|
|
||||||
val id: Int,
|
|
||||||
@SerialName("load_priority")
|
|
||||||
val loadPriority: Int,
|
|
||||||
val manifest: DriverManifest,
|
|
||||||
@SerialName("on_safemode_whitelist")
|
|
||||||
val onSafeModeWhitelist: Boolean,
|
|
||||||
@SerialName("show_enable_in_settings")
|
|
||||||
val showEnableInSettings: Boolean,
|
|
||||||
)
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
private data class DriverListResponse(
|
|
||||||
val drivers: List<Driver>,
|
|
||||||
@SerialName("jsonid")
|
|
||||||
val jsonId: String,
|
|
||||||
)
|
|
||||||
|
|
||||||
class SteamVRUtils {
|
|
||||||
companion object {
|
|
||||||
const val SERVER_URL = "http://127.0.0.1:27062"
|
|
||||||
const val REFERER = "$SERVER_URL/dashboard/index.html"
|
|
||||||
private val jsonIgnoreUnknownKeys = Json { ignoreUnknownKeys = true }
|
|
||||||
|
|
||||||
suspend fun getDriversList(client: HttpClient): List<Driver>? {
|
|
||||||
val resp = try {
|
|
||||||
client.request("$SERVER_URL/drivers/list.json") {
|
|
||||||
header("Referer", REFERER)
|
|
||||||
}
|
|
||||||
} catch (_: Exception) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!resp.status.isSuccess()) {
|
|
||||||
LogManager.warning("[SteamVRUtils] Failed to connect to SteamVR web server (status ${resp.status})")
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
val body: String = try {
|
|
||||||
resp.body()
|
|
||||||
} catch (_: Exception) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
val driverList: DriverListResponse = try {
|
|
||||||
jsonIgnoreUnknownKeys.decodeFromString(body)
|
|
||||||
} catch (e: Exception) {
|
|
||||||
LogManager.warning("[SteamVRUtils] Failed to decode SteamVR drivers list", e)
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
if (driverList.jsonId != "vr_driver_list") {
|
|
||||||
LogManager.severe("[SteamVRUtils] SteamVR driver list response had wrong jsonId (${driverList.jsonId})")
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
return driverList.drivers
|
|
||||||
}
|
|
||||||
|
|
||||||
suspend fun unblockDriver(client: HttpClient, driver: String) {
|
|
||||||
val unblockReq = client.get("$SERVER_URL/drivers/unblock") {
|
|
||||||
method = HttpMethod.Post
|
|
||||||
header("Referer", REFERER)
|
|
||||||
setBody("""{"driver":"$driver"}""")
|
|
||||||
}
|
|
||||||
if (!unblockReq.status.isSuccess()) {
|
|
||||||
LogManager.severe("[SteamVRUtils] Failed to unblock driver: ${unblockReq.status}")
|
|
||||||
}
|
|
||||||
|
|
||||||
val enableReq = client.get("$SERVER_URL/drivers/setenable") {
|
|
||||||
method = HttpMethod.Post
|
|
||||||
header("Referer", REFERER)
|
|
||||||
setBody("""{"driver":"$driver","enable":true}""")
|
|
||||||
}
|
|
||||||
if (!enableReq.status.isSuccess()) {
|
|
||||||
LogManager.severe("[SteamVRUtils] Failed to enable driver: ${enableReq.status}")
|
|
||||||
}
|
|
||||||
|
|
||||||
delay(500.milliseconds)
|
|
||||||
|
|
||||||
VRServer.instance.tryOpenUri("vrmonitor://restartsystem")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,7 +2,6 @@ package dev.slimevr.tracking.trackers
|
|||||||
|
|
||||||
import dev.slimevr.tracking.trackers.udp.BoardType
|
import dev.slimevr.tracking.trackers.udp.BoardType
|
||||||
import dev.slimevr.tracking.trackers.udp.MCUType
|
import dev.slimevr.tracking.trackers.udp.MCUType
|
||||||
import dev.slimevr.tracking.trackers.udp.MagnetometerStatus
|
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
@@ -50,7 +49,7 @@ open class Device(val origin: DeviceOrigin, val magSupport: Boolean = false) {
|
|||||||
* if `sensorId` null or in the specified tracker
|
* if `sensorId` null or in the specified tracker
|
||||||
* @param sensorId If null, every sensor will be modified
|
* @param sensorId If null, every sensor will be modified
|
||||||
*/
|
*/
|
||||||
open suspend fun setMag(status: MagnetometerStatus, sensorId: Int = 255) {
|
open suspend fun setMag(state: Boolean, sensorId: Int = 255) {
|
||||||
TODO("Not implemented because no mag support: $magSupport")
|
TODO("Not implemented because no mag support: $magSupport")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -148,12 +148,8 @@ class Tracker @JvmOverloads constructor(
|
|||||||
var packetsLost: Int? = null
|
var packetsLost: Int? = null
|
||||||
var packetLoss: Float? = null
|
var packetLoss: Float? = null
|
||||||
var customName: String? = null
|
var customName: String? = null
|
||||||
|
|
||||||
/**
|
|
||||||
* Please don't use this and instead set it via [Device.setMag]
|
|
||||||
*/
|
|
||||||
var magStatus: MagnetometerStatus = magStatus
|
var magStatus: MagnetometerStatus = magStatus
|
||||||
internal set
|
private set
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Watch the rest calibration status
|
* Watch the rest calibration status
|
||||||
@@ -503,6 +499,17 @@ class Tracker @JvmOverloads constructor(
|
|||||||
*/
|
*/
|
||||||
fun isImu(): Boolean = imuType != null && trackerDataType == TrackerDataType.ROTATION
|
fun isImu(): Boolean = imuType != null && trackerDataType == TrackerDataType.ROTATION
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Please don't use this and instead set it via [Device.setMag]
|
||||||
|
*/
|
||||||
|
internal fun setMagPrivate(mag: Boolean) {
|
||||||
|
magStatus = if (mag) {
|
||||||
|
MagnetometerStatus.ENABLED
|
||||||
|
} else {
|
||||||
|
MagnetometerStatus.DISABLED
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the magnetic field vector, in mGauss.
|
* Gets the magnetic field vector, in mGauss.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import io.eiren.util.logging.LogManager
|
|||||||
import io.github.axisangles.ktmath.Quaternion
|
import io.github.axisangles.ktmath.Quaternion
|
||||||
import io.github.axisangles.ktmath.Quaternion.Companion.fromRotationVector
|
import io.github.axisangles.ktmath.Quaternion.Companion.fromRotationVector
|
||||||
import io.github.axisangles.ktmath.Vector3
|
import io.github.axisangles.ktmath.Vector3
|
||||||
import kotlinx.coroutines.runBlocking
|
|
||||||
import java.nio.ByteBuffer
|
import java.nio.ByteBuffer
|
||||||
import java.util.function.Consumer
|
import java.util.function.Consumer
|
||||||
import kotlin.collections.set
|
import kotlin.collections.set
|
||||||
@@ -135,10 +134,6 @@ class HIDCommon {
|
|||||||
.info(
|
.info(
|
||||||
"[TrackerServer] Added sensor $trackerId for ${device.name}, type $sensorType",
|
"[TrackerServer] Added sensor $trackerId for ${device.name}, type $sensorType",
|
||||||
)
|
)
|
||||||
} else {
|
|
||||||
runBlocking {
|
|
||||||
device.setMag(magStatus, trackerId)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,16 +5,10 @@ import dev.slimevr.tracking.trackers.DeviceOrigin
|
|||||||
import dev.slimevr.tracking.trackers.Tracker
|
import dev.slimevr.tracking.trackers.Tracker
|
||||||
import dev.slimevr.tracking.trackers.udp.BoardType
|
import dev.slimevr.tracking.trackers.udp.BoardType
|
||||||
import dev.slimevr.tracking.trackers.udp.MCUType
|
import dev.slimevr.tracking.trackers.udp.MCUType
|
||||||
import dev.slimevr.tracking.trackers.udp.MagnetometerStatus
|
|
||||||
|
|
||||||
class HIDDevice(val hidId: Int) : Device(DeviceOrigin.HID) {
|
class HIDDevice(val hidId: Int) : Device(DeviceOrigin.HID) {
|
||||||
override var hardwareIdentifier: String = "Unknown"
|
override var hardwareIdentifier: String = "Unknown"
|
||||||
override var boardType: BoardType = BoardType.UNKNOWN
|
override var boardType: BoardType = BoardType.UNKNOWN
|
||||||
override var mcuType: MCUType = MCUType.UNKNOWN
|
override var mcuType: MCUType = MCUType.UNKNOWN
|
||||||
fun getTracker(id: Int): Tracker? = trackers[id]
|
fun getTracker(id: Int): Tracker? = trackers[id]
|
||||||
|
|
||||||
override suspend fun setMag(status: MagnetometerStatus, sensorId: Int) {
|
|
||||||
val tracker = trackers[sensorId] ?: error("Tracker $sensorId not found in device $this")
|
|
||||||
tracker.magStatus = status
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -249,7 +249,7 @@ class TrackersUDPServer(private val port: Int, name: String, private val tracker
|
|||||||
) {
|
) {
|
||||||
mainScope.launch {
|
mainScope.launch {
|
||||||
withTimeoutOrNull(MAG_TIMEOUT) {
|
withTimeoutOrNull(MAG_TIMEOUT) {
|
||||||
connection.setMag(MagnetometerStatus.DISABLED, trackerId)
|
connection.setMag(false, trackerId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (magStatus == MagnetometerStatus.DISABLED &&
|
} else if (magStatus == MagnetometerStatus.DISABLED &&
|
||||||
@@ -258,7 +258,7 @@ class TrackersUDPServer(private val port: Int, name: String, private val tracker
|
|||||||
) {
|
) {
|
||||||
mainScope.launch {
|
mainScope.launch {
|
||||||
withTimeoutOrNull(MAG_TIMEOUT) {
|
withTimeoutOrNull(MAG_TIMEOUT) {
|
||||||
connection.setMag(MagnetometerStatus.ENABLED, trackerId)
|
connection.setMag(true, trackerId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -357,6 +357,13 @@ class TrackersUDPServer(private val port: Int, name: String, private val tracker
|
|||||||
LogManager.info("[TrackerServer] Tracker timed out: $conn")
|
LogManager.info("[TrackerServer] Tracker timed out: $conn")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
for (value in conn.trackers.values) {
|
||||||
|
if (value.status == TrackerStatus.DISCONNECTED ||
|
||||||
|
value.status == TrackerStatus.TIMED_OUT
|
||||||
|
) {
|
||||||
|
value.status = TrackerStatus.OK
|
||||||
|
}
|
||||||
|
}
|
||||||
conn.timedOut = false
|
conn.timedOut = false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -397,6 +404,7 @@ class TrackersUDPServer(private val port: Int, name: String, private val tracker
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun processPacket(received: DatagramPacket, packet: UDPPacket, connection: UDPDevice?) {
|
private fun processPacket(received: DatagramPacket, packet: UDPPacket, connection: UDPDevice?) {
|
||||||
|
val tracker: Tracker?
|
||||||
when (packet) {
|
when (packet) {
|
||||||
is UDPPacket0Heartbeat, is UDPPacket1Heartbeat, is UDPPacket25SetConfigFlag -> {}
|
is UDPPacket0Heartbeat, is UDPPacket1Heartbeat, is UDPPacket25SetConfigFlag -> {}
|
||||||
|
|
||||||
@@ -405,10 +413,8 @@ class TrackersUDPServer(private val port: Int, name: String, private val tracker
|
|||||||
is RotationPacket -> {
|
is RotationPacket -> {
|
||||||
var rot = packet.rotation
|
var rot = packet.rotation
|
||||||
rot = AXES_OFFSET.times(rot)
|
rot = AXES_OFFSET.times(rot)
|
||||||
val tracker = connection?.getTracker(packet.sensorId) ?: return
|
tracker = connection?.getTracker(packet.sensorId)
|
||||||
if (tracker.status == TrackerStatus.DISCONNECTED || tracker.status == TrackerStatus.TIMED_OUT) {
|
if (tracker == null) return
|
||||||
tracker.status = TrackerStatus.OK
|
|
||||||
}
|
|
||||||
tracker.setRotation(rot)
|
tracker.setRotation(rot)
|
||||||
if (packet is UDPPacket23RotationAndAcceleration) {
|
if (packet is UDPPacket23RotationAndAcceleration) {
|
||||||
// sensorOffset is applied correctly since protocol 22
|
// sensorOffset is applied correctly since protocol 22
|
||||||
@@ -423,10 +429,8 @@ class TrackersUDPServer(private val port: Int, name: String, private val tracker
|
|||||||
}
|
}
|
||||||
|
|
||||||
is UDPPacket17RotationData -> {
|
is UDPPacket17RotationData -> {
|
||||||
val tracker = connection?.getTracker(packet.sensorId) ?: return
|
tracker = connection?.getTracker(packet.sensorId)
|
||||||
if (tracker.status == TrackerStatus.DISCONNECTED || tracker.status == TrackerStatus.TIMED_OUT) {
|
if (tracker == null) return
|
||||||
tracker.status = TrackerStatus.OK
|
|
||||||
}
|
|
||||||
var rot17 = packet.rotation
|
var rot17 = packet.rotation
|
||||||
rot17 = AXES_OFFSET * rot17
|
rot17 = AXES_OFFSET * rot17
|
||||||
when (packet.dataType) {
|
when (packet.dataType) {
|
||||||
@@ -449,10 +453,8 @@ class TrackersUDPServer(private val port: Int, name: String, private val tracker
|
|||||||
is UDPPacket18MagnetometerAccuracy -> {}
|
is UDPPacket18MagnetometerAccuracy -> {}
|
||||||
|
|
||||||
is UDPPacket4Acceleration -> {
|
is UDPPacket4Acceleration -> {
|
||||||
val tracker = connection?.getTracker(packet.sensorId) ?: return
|
tracker = connection?.getTracker(packet.sensorId)
|
||||||
if (tracker.status == TrackerStatus.DISCONNECTED || tracker.status == TrackerStatus.TIMED_OUT) {
|
if (tracker == null) return
|
||||||
tracker.status = TrackerStatus.OK
|
|
||||||
}
|
|
||||||
// sensorOffset is applied correctly since protocol 22
|
// sensorOffset is applied correctly since protocol 22
|
||||||
// See: https://github.com/SlimeVR/SlimeVR-Tracker-ESP/pull/480
|
// See: https://github.com/SlimeVR/SlimeVR-Tracker-ESP/pull/480
|
||||||
if (connection.protocolVersion >= 22) {
|
if (connection.protocolVersion >= 22) {
|
||||||
@@ -502,7 +504,8 @@ class TrackersUDPServer(private val port: Int, name: String, private val tracker
|
|||||||
}
|
}
|
||||||
|
|
||||||
is UDPPacket13Tap -> {
|
is UDPPacket13Tap -> {
|
||||||
val tracker = connection?.getTracker(packet.sensorId) ?: return
|
tracker = connection?.getTracker(packet.sensorId)
|
||||||
|
if (tracker == null) return
|
||||||
LogManager.info(
|
LogManager.info(
|
||||||
"[TrackerServer] Tap packet received from ${tracker.name}: ${packet.tap}",
|
"[TrackerServer] Tap packet received from ${tracker.name}: ${packet.tap}",
|
||||||
)
|
)
|
||||||
@@ -512,7 +515,8 @@ class TrackersUDPServer(private val port: Int, name: String, private val tracker
|
|||||||
LogManager.severe(
|
LogManager.severe(
|
||||||
"[TrackerServer] Error received from ${received.socketAddress}: ${packet.errorNumber}",
|
"[TrackerServer] Error received from ${received.socketAddress}: ${packet.errorNumber}",
|
||||||
)
|
)
|
||||||
val tracker = connection?.getTracker(packet.sensorId) ?: return
|
tracker = connection?.getTracker(packet.sensorId)
|
||||||
|
if (tracker == null) return
|
||||||
tracker.status = TrackerStatus.ERROR
|
tracker.status = TrackerStatus.ERROR
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -544,7 +548,7 @@ class TrackersUDPServer(private val port: Int, name: String, private val tracker
|
|||||||
}
|
}
|
||||||
|
|
||||||
is UDPPacket20Temperature -> {
|
is UDPPacket20Temperature -> {
|
||||||
val tracker = connection?.getTracker(packet.sensorId) ?: return
|
tracker = connection?.getTracker(packet.sensorId) ?: return
|
||||||
tracker.temperature = packet.temperature
|
tracker.temperature = packet.temperature
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -612,7 +616,8 @@ class TrackersUDPServer(private val port: Int, name: String, private val tracker
|
|||||||
}
|
}
|
||||||
|
|
||||||
is UDPPacket26FlexData -> {
|
is UDPPacket26FlexData -> {
|
||||||
val tracker = connection?.getTracker(packet.sensorId) ?: return
|
tracker = connection?.getTracker(packet.sensorId)
|
||||||
|
if (tracker == null) return
|
||||||
if (tracker.trackerDataType == TrackerDataType.FLEX_RESISTANCE) {
|
if (tracker.trackerDataType == TrackerDataType.FLEX_RESISTANCE) {
|
||||||
tracker.trackerFlexHandler.setFlexResistance(packet.flexData)
|
tracker.trackerFlexHandler.setFlexResistance(packet.flexData)
|
||||||
} else if (tracker.trackerDataType == TrackerDataType.FLEX_ANGLE) {
|
} else if (tracker.trackerDataType == TrackerDataType.FLEX_ANGLE) {
|
||||||
@@ -622,7 +627,8 @@ class TrackersUDPServer(private val port: Int, name: String, private val tracker
|
|||||||
}
|
}
|
||||||
|
|
||||||
is UDPPacket27Position -> {
|
is UDPPacket27Position -> {
|
||||||
val tracker = connection?.getTracker(packet.sensorId) ?: return
|
tracker = connection?.getTracker(packet.sensorId)
|
||||||
|
if (tracker == null) return
|
||||||
tracker.position = packet.position
|
tracker.position = packet.position
|
||||||
// dont call dataTick here as this is just position update
|
// dont call dataTick here as this is just position update
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,15 +67,14 @@ class UDPDevice(
|
|||||||
var timedOut = false
|
var timedOut = false
|
||||||
override val trackers = ConcurrentHashMap<Int, Tracker>()
|
override val trackers = ConcurrentHashMap<Int, Tracker>()
|
||||||
|
|
||||||
override suspend fun setMag(magStatus: MagnetometerStatus, sensorId: Int) {
|
override suspend fun setMag(state: Boolean, sensorId: Int) {
|
||||||
val state = magStatus == MagnetometerStatus.ENABLED
|
|
||||||
if (sensorId == 255) {
|
if (sensorId == 255) {
|
||||||
VRServer.instance.trackersServer.setConfigFlag(this, ConfigTypeId(1u), state)
|
VRServer.instance.trackersServer.setConfigFlag(this, ConfigTypeId(1u), state)
|
||||||
trackers.forEach { (_, t) -> t.magStatus = magStatus }
|
trackers.forEach { (_, t) -> t.setMagPrivate(state) }
|
||||||
} else {
|
} else {
|
||||||
require(trackers[sensorId] != null) { "There is no tracker $sensorId in device ${toString()}" }
|
require(trackers[sensorId] != null) { "There is no tracker $sensorId in device ${toString()}" }
|
||||||
VRServer.instance.trackersServer.setConfigFlag(this, ConfigTypeId(1u), state, sensorId)
|
VRServer.instance.trackersServer.setConfigFlag(this, ConfigTypeId(1u), state, sensorId)
|
||||||
trackers[sensorId]!!.magStatus = magStatus
|
trackers[sensorId]!!.setMagPrivate(state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-53
@@ -7,18 +7,13 @@ import dev.slimevr.games.vrchat.VRCConfigListener
|
|||||||
import dev.slimevr.games.vrchat.VRCConfigRecommendedValues
|
import dev.slimevr.games.vrchat.VRCConfigRecommendedValues
|
||||||
import dev.slimevr.games.vrchat.VRCConfigValidity
|
import dev.slimevr.games.vrchat.VRCConfigValidity
|
||||||
import dev.slimevr.games.vrchat.VRCConfigValues
|
import dev.slimevr.games.vrchat.VRCConfigValues
|
||||||
import dev.slimevr.steamvr.SteamVRUtils
|
|
||||||
import dev.slimevr.tracking.trackers.Tracker
|
import dev.slimevr.tracking.trackers.Tracker
|
||||||
import dev.slimevr.tracking.trackers.TrackerPosition
|
import dev.slimevr.tracking.trackers.TrackerPosition
|
||||||
import dev.slimevr.tracking.trackers.TrackerRole
|
import dev.slimevr.tracking.trackers.TrackerRole
|
||||||
import dev.slimevr.tracking.trackers.TrackerStatus
|
import dev.slimevr.tracking.trackers.TrackerStatus
|
||||||
import dev.slimevr.tracking.trackers.TrackerUtils
|
import dev.slimevr.tracking.trackers.TrackerUtils
|
||||||
import dev.slimevr.tracking.trackers.udp.TrackerDataType
|
import dev.slimevr.tracking.trackers.udp.TrackerDataType
|
||||||
import io.eiren.util.OperatingSystem
|
|
||||||
import io.github.axisangles.ktmath.Quaternion
|
import io.github.axisangles.ktmath.Quaternion
|
||||||
import io.ktor.client.HttpClient
|
|
||||||
import io.ktor.client.engine.cio.CIO
|
|
||||||
import kotlinx.coroutines.runBlocking
|
|
||||||
import solarxr_protocol.datatypes.DeviceIdT
|
import solarxr_protocol.datatypes.DeviceIdT
|
||||||
import solarxr_protocol.datatypes.TrackerIdT
|
import solarxr_protocol.datatypes.TrackerIdT
|
||||||
import solarxr_protocol.rpc.*
|
import solarxr_protocol.rpc.*
|
||||||
@@ -31,7 +26,7 @@ interface TrackingChecklistListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class TrackingChecklistManager(private val vrServer: VRServer) : VRCConfigListener {
|
class TrackingChecklistManager(private val vrServer: VRServer) : VRCConfigListener {
|
||||||
private var httpClient: HttpClient? = null
|
|
||||||
private val listeners: MutableList<TrackingChecklistListener> = CopyOnWriteArrayList()
|
private val listeners: MutableList<TrackingChecklistListener> = CopyOnWriteArrayList()
|
||||||
val steps: MutableList<TrackingChecklistStepT> = mutableListOf()
|
val steps: MutableList<TrackingChecklistStepT> = mutableListOf()
|
||||||
|
|
||||||
@@ -103,16 +98,6 @@ class TrackingChecklistManager(private val vrServer: VRServer) : VRCConfigListen
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
steps.add(
|
|
||||||
TrackingChecklistStepT().apply {
|
|
||||||
id = TrackingChecklistStepId.STANDABLE_INSTALLED
|
|
||||||
enabled = false
|
|
||||||
optional = false
|
|
||||||
ignorable = true
|
|
||||||
visibility = TrackingChecklistStepVisibility.WHEN_INVALID
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
steps.add(
|
steps.add(
|
||||||
TrackingChecklistStepT().apply {
|
TrackingChecklistStepT().apply {
|
||||||
id = TrackingChecklistStepId.TRACKER_ERROR
|
id = TrackingChecklistStepId.TRACKER_ERROR
|
||||||
@@ -293,57 +278,23 @@ class TrackingChecklistManager(private val vrServer: VRServer) : VRCConfigListen
|
|||||||
} as? ISteamVRBridge
|
} as? ISteamVRBridge
|
||||||
if (steamVRBridge != null) {
|
if (steamVRBridge != null) {
|
||||||
val steamvrConnected = steamVRBridge.isConnected()
|
val steamvrConnected = steamVRBridge.isConnected()
|
||||||
val vrServerProcName = when (OperatingSystem.currentPlatform) {
|
|
||||||
OperatingSystem.WINDOWS -> "vrserver.exe"
|
|
||||||
else -> "vrserver"
|
|
||||||
}
|
|
||||||
val steamvrRunning = steamvrConnected ||
|
|
||||||
vrServer.processListProvider().any { proc ->
|
|
||||||
proc.name == vrServerProcName
|
|
||||||
}
|
|
||||||
|
|
||||||
val driverList = if (steamvrRunning) {
|
|
||||||
runBlocking {
|
|
||||||
if (httpClient == null) httpClient = HttpClient(CIO)
|
|
||||||
SteamVRUtils.getDriversList(httpClient!!)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
val driver = driverList?.firstOrNull { driver ->
|
|
||||||
driver.manifest.name == "slimevr"
|
|
||||||
}
|
|
||||||
val standableInstalled = driverList?.any { driver ->
|
|
||||||
driver.manifest.name == "standable"
|
|
||||||
} ?: false
|
|
||||||
|
|
||||||
updateValidity(
|
updateValidity(
|
||||||
TrackingChecklistStepId.STEAMVR_DISCONNECTED,
|
TrackingChecklistStepId.STEAMVR_DISCONNECTED,
|
||||||
steamvrConnected,
|
steamvrConnected,
|
||||||
) {
|
) {
|
||||||
it.enabled = true
|
it.enabled = true
|
||||||
it.extraData = if (!steamvrConnected) {
|
if (!steamvrConnected) {
|
||||||
TrackingChecklistExtraDataUnion().apply {
|
it.extraData = TrackingChecklistExtraDataUnion().apply {
|
||||||
type = TrackingChecklistExtraData.TrackingChecklistSteamVRDisconnected
|
type = TrackingChecklistExtraData.TrackingChecklistSteamVRDisconnected
|
||||||
value = TrackingChecklistSteamVRDisconnectedT().apply {
|
value = TrackingChecklistSteamVRDisconnectedT().apply {
|
||||||
bridgeSettingsName = steamVRBridge.getBridgeConfigKey()
|
bridgeSettingsName = steamVRBridge.getBridgeConfigKey()
|
||||||
driverInstalled = !steamvrRunning || driverList == null || driver != null
|
|
||||||
driverBlockedBySafeMode = driver?.blockedBySafeMode ?: false
|
|
||||||
driverEnabled = driver?.enabled ?: true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
null
|
it.extraData = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateValidity(
|
|
||||||
TrackingChecklistStepId.STANDABLE_INSTALLED,
|
|
||||||
!standableInstalled,
|
|
||||||
) {
|
|
||||||
it.enabled = true
|
|
||||||
}
|
|
||||||
|
|
||||||
val handsEnabled = steamVRBridge.getShareSetting(TrackerRole.LEFT_HAND) || steamVRBridge.getShareSetting(TrackerRole.RIGHT_HAND)
|
val handsEnabled = steamVRBridge.getShareSetting(TrackerRole.LEFT_HAND) || steamVRBridge.getShareSetting(TrackerRole.RIGHT_HAND)
|
||||||
val hasControllers = vrServer.allTrackers.any {
|
val hasControllers = vrServer.allTrackers.any {
|
||||||
(it.trackerPosition == TrackerPosition.LEFT_HAND || it.trackerPosition == TrackerPosition.RIGHT_HAND) && it.isComputed && !it.isInternal
|
(it.trackerPosition == TrackerPosition.LEFT_HAND || it.trackerPosition == TrackerPosition.RIGHT_HAND) && it.isComputed && !it.isInternal
|
||||||
|
|||||||
@@ -2,13 +2,10 @@ package io.eiren.util
|
|||||||
|
|
||||||
import dev.slimevr.SLIMEVR_IDENTIFIER
|
import dev.slimevr.SLIMEVR_IDENTIFIER
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.IOException
|
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.io.path.Path
|
import kotlin.io.path.Path
|
||||||
|
|
||||||
data class Process(val pid: ULong, val name: String)
|
|
||||||
|
|
||||||
enum class OperatingSystem(
|
enum class OperatingSystem(
|
||||||
val descriptor: String,
|
val descriptor: String,
|
||||||
private val aliases: Array<String>,
|
private val aliases: Array<String>,
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ plugins {
|
|||||||
application
|
application
|
||||||
id("com.gradleup.shadow")
|
id("com.gradleup.shadow")
|
||||||
id("com.github.gmazzo.buildconfig")
|
id("com.github.gmazzo.buildconfig")
|
||||||
|
id("org.ajoberstar.grgit")
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
@@ -88,18 +89,12 @@ buildConfig {
|
|||||||
useKotlinOutput { topLevelConstants = true }
|
useKotlinOutput { topLevelConstants = true }
|
||||||
packageName("dev.slimevr.desktop")
|
packageName("dev.slimevr.desktop")
|
||||||
|
|
||||||
val gitCommitHash = providers.exec {
|
|
||||||
commandLine("git", "rev-parse", "--short=8", "HEAD")
|
|
||||||
}.standardOutput.asText.get().trim()
|
|
||||||
val gitVersionTag = providers.exec {
|
val gitVersionTag = providers.exec {
|
||||||
commandLine("git", "--no-pager", "tag", "--sort", "-taggerdate", "--points-at", "HEAD")
|
commandLine("git", "--no-pager", "tag", "--sort", "-taggerdate", "--points-at", "HEAD")
|
||||||
}.standardOutput.asText.get().trim()
|
}.standardOutput.asText.get().split('\n').first()
|
||||||
val gitIsClean = providers.exec {
|
buildConfigField("String", "GIT_COMMIT_HASH", "\"${grgit.head().abbreviatedId}\"")
|
||||||
commandLine("git", "status", "--porcelain")
|
buildConfigField("String", "GIT_VERSION_TAG", "\"${gitVersionTag.trim()}\"")
|
||||||
}.standardOutput.asText.get().trim().isEmpty()
|
buildConfigField("boolean", "GIT_CLEAN", grgit.status().isClean.toString())
|
||||||
buildConfigField("String", "GIT_COMMIT_HASH", "\"${gitCommitHash}\"")
|
|
||||||
buildConfigField("String", "GIT_VERSION_TAG", "\"${gitVersionTag}\"")
|
|
||||||
buildConfigField("boolean", "GIT_CLEAN", gitIsClean.toString())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.run<JavaExec> {
|
tasks.run<JavaExec> {
|
||||||
|
|||||||
@@ -2,13 +2,6 @@
|
|||||||
|
|
||||||
package dev.slimevr.desktop
|
package dev.slimevr.desktop
|
||||||
|
|
||||||
import com.sun.jna.Native
|
|
||||||
import com.sun.jna.platform.win32.Kernel32
|
|
||||||
import com.sun.jna.platform.win32.Shell32
|
|
||||||
import com.sun.jna.platform.win32.Tlhelp32
|
|
||||||
import com.sun.jna.platform.win32.WinBase
|
|
||||||
import com.sun.jna.platform.win32.WinDef
|
|
||||||
import com.sun.jna.platform.win32.WinUser
|
|
||||||
import dev.slimevr.FeatureFlags
|
import dev.slimevr.FeatureFlags
|
||||||
import dev.slimevr.Keybinding
|
import dev.slimevr.Keybinding
|
||||||
import dev.slimevr.SLIMEVR_IDENTIFIER
|
import dev.slimevr.SLIMEVR_IDENTIFIER
|
||||||
@@ -27,8 +20,6 @@ import dev.slimevr.desktop.serial.DesktopSerialHandler
|
|||||||
import dev.slimevr.desktop.tracking.trackers.hid.DesktopHIDManager
|
import dev.slimevr.desktop.tracking.trackers.hid.DesktopHIDManager
|
||||||
import dev.slimevr.tracking.trackers.Tracker
|
import dev.slimevr.tracking.trackers.Tracker
|
||||||
import io.eiren.util.OperatingSystem
|
import io.eiren.util.OperatingSystem
|
||||||
import io.eiren.util.OperatingSystem.Companion.currentPlatform
|
|
||||||
import io.eiren.util.Process
|
|
||||||
import io.eiren.util.collections.FastList
|
import io.eiren.util.collections.FastList
|
||||||
import io.eiren.util.logging.LogManager
|
import io.eiren.util.logging.LogManager
|
||||||
import org.apache.commons.cli.CommandLine
|
import org.apache.commons.cli.CommandLine
|
||||||
@@ -166,8 +157,6 @@ fun main(args: Array<String>) {
|
|||||||
{ _ -> DesktopSerialFlashingHandler() },
|
{ _ -> DesktopSerialFlashingHandler() },
|
||||||
{ _ -> DesktopVRCConfigHandler() },
|
{ _ -> DesktopVRCConfigHandler() },
|
||||||
{ _ -> DesktopNetworkProfileChecker() },
|
{ _ -> DesktopNetworkProfileChecker() },
|
||||||
::getRunningProcesses,
|
|
||||||
::tryOpenUri,
|
|
||||||
configManager = configManager,
|
configManager = configManager,
|
||||||
)
|
)
|
||||||
vrServer.start()
|
vrServer.start()
|
||||||
@@ -276,68 +265,6 @@ fun provideBridges(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getRunningProcesses(): Sequence<Process> = when (currentPlatform) {
|
|
||||||
OperatingSystem.LINUX -> sequence {
|
|
||||||
val psProc = try {
|
|
||||||
ProcessBuilder("ps", "-eo", "pid,comm").redirectErrorStream(true).start()
|
|
||||||
} catch (_: IOException) {
|
|
||||||
return@sequence
|
|
||||||
}
|
|
||||||
|
|
||||||
val lines = psProc.inputStream.bufferedReader().readLines()
|
|
||||||
// skip the header
|
|
||||||
for (line in lines.slice(1 until lines.size)) {
|
|
||||||
val data = line.trimStart().split(' ')
|
|
||||||
yield(Process(data[0].toULong(), data[1]))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
OperatingSystem.WINDOWS -> sequence {
|
|
||||||
val k32 = Kernel32.INSTANCE
|
|
||||||
val snapshot = k32.CreateToolhelp32Snapshot(Tlhelp32.TH32CS_SNAPPROCESS, WinDef.DWORD(0))
|
|
||||||
if (WinBase.INVALID_HANDLE_VALUE.equals(snapshot)) {
|
|
||||||
return@sequence
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
val entry = Tlhelp32.PROCESSENTRY32()
|
|
||||||
if (!k32.Process32First(snapshot, entry)) {
|
|
||||||
LogManager.warning("[Windows] Failed to retrieve process information: " + k32.GetLastError())
|
|
||||||
return@sequence
|
|
||||||
}
|
|
||||||
|
|
||||||
do {
|
|
||||||
yield(Process(entry.th32ProcessID.toLong().toULong(), Native.toString(entry.szExeFile)))
|
|
||||||
} while (k32.Process32Next(snapshot, entry))
|
|
||||||
} finally {
|
|
||||||
k32.CloseHandle(snapshot)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
else -> emptySequence()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun tryOpenUri(uri: String) {
|
|
||||||
when (currentPlatform) {
|
|
||||||
OperatingSystem.LINUX -> {
|
|
||||||
try {
|
|
||||||
ProcessBuilder("xdg-open", uri).start()
|
|
||||||
} catch (e: Exception) {
|
|
||||||
LogManager.severe("[Linux] Failed to open URI $uri", e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
OperatingSystem.WINDOWS -> {
|
|
||||||
val ret = Shell32.INSTANCE.ShellExecute(null, null, uri, null, null, WinUser.SW_SHOWNORMAL).toLong()
|
|
||||||
if (ret <= 32) {
|
|
||||||
LogManager.severe("[Windows] Failed to open URI $uri: $ret (${Kernel32.INSTANCE.GetLastError()})")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
else -> {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const val CONFIG_FILENAME = "vrconfig.yml"
|
const val CONFIG_FILENAME = "vrconfig.yml"
|
||||||
fun resolveConfig(): String {
|
fun resolveConfig(): String {
|
||||||
// If config folder exists, then save config on relative path
|
// If config folder exists, then save config on relative path
|
||||||
|
|||||||
@@ -58,6 +58,11 @@ class BindingsProviderManager : Runnable {
|
|||||||
"BindingsProviderManager already running"
|
"BindingsProviderManager already running"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val binaryPath = getBinaryPath() ?: throw RuntimeException("Unable to find bindings provider binary")
|
||||||
|
process = ProcessBuilder(binaryPath.toString())
|
||||||
|
.redirectErrorStream(true)
|
||||||
|
.start()
|
||||||
|
LogManager.info("[BindingsProviderManager] Started process")
|
||||||
watcherThread = Thread(this, "Bindings provider watcher")
|
watcherThread = Thread(this, "Bindings provider watcher")
|
||||||
watcherThread!!.start()
|
watcherThread!!.start()
|
||||||
}
|
}
|
||||||
@@ -72,17 +77,6 @@ class BindingsProviderManager : Runnable {
|
|||||||
|
|
||||||
override fun run() {
|
override fun run() {
|
||||||
try {
|
try {
|
||||||
// Give SteamVR a bit more time to initialise everything
|
|
||||||
// For some users, starting the executable immediately may cause startup failures
|
|
||||||
// This feels like a bit of a hack, but whatever
|
|
||||||
Thread.sleep(3000L)
|
|
||||||
|
|
||||||
val binaryPath = getBinaryPath() ?: throw RuntimeException("Unable to find bindings provider binary")
|
|
||||||
process = ProcessBuilder(binaryPath.toString())
|
|
||||||
.redirectErrorStream(true)
|
|
||||||
.start()
|
|
||||||
LogManager.info("[BindingsProviderManager] Started process")
|
|
||||||
|
|
||||||
val interval = 1000L / 30L
|
val interval = 1000L / 30L
|
||||||
while (process?.isAlive == true) {
|
while (process?.isAlive == true) {
|
||||||
Thread.sleep(interval)
|
Thread.sleep(interval)
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import com.fazecast.jSerialComm.SerialPortEvent
|
|||||||
import com.fazecast.jSerialComm.SerialPortMessageListener
|
import com.fazecast.jSerialComm.SerialPortMessageListener
|
||||||
import dev.slimevr.serial.SerialHandler
|
import dev.slimevr.serial.SerialHandler
|
||||||
import dev.slimevr.serial.SerialListener
|
import dev.slimevr.serial.SerialListener
|
||||||
import dev.slimevr.tracking.trackers.hid.HIDCommon
|
|
||||||
import io.eiren.util.logging.LogManager
|
import io.eiren.util.logging.LogManager
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.io.OutputStreamWriter
|
import java.io.OutputStreamWriter
|
||||||
@@ -89,14 +88,13 @@ class DesktopSerialHandler :
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
override fun openSerial(portLocation: String?, auto: Boolean, autoIncludeHid: Boolean): Boolean {
|
override fun openSerial(portLocation: String?, auto: Boolean): Boolean {
|
||||||
LogManager.info("[SerialHandler] Trying to open: $portLocation, auto: $auto")
|
LogManager.info("[SerialHandler] Trying to open: $portLocation, auto: $auto")
|
||||||
val ports = SerialPort.getCommPorts()
|
val ports = SerialPort.getCommPorts()
|
||||||
lastKnownPorts = ports.map { SerialPortWrapper(it) }.toSet()
|
lastKnownPorts = ports.map { SerialPortWrapper(it) }.toSet()
|
||||||
val newPort: SerialPort? = ports.find {
|
val newPort: SerialPort? = ports.find {
|
||||||
(!auto && it.portLocation == portLocation) ||
|
(!auto && it.portLocation == portLocation) ||
|
||||||
(auto && isKnownBoard(SerialPortWrapper(it))) ||
|
(auto && isKnownBoard(SerialPortWrapper(it)))
|
||||||
(auto && autoIncludeHid && HIDCommon.matchesAny(it.vendorID, it.productID))
|
|
||||||
}
|
}
|
||||||
if (newPort == null) {
|
if (newPort == null) {
|
||||||
LogManager.info(
|
LogManager.info(
|
||||||
@@ -246,7 +244,7 @@ class DesktopSerialHandler :
|
|||||||
get() = SerialPort.getCommPorts()
|
get() = SerialPort.getCommPorts()
|
||||||
.asSequence()
|
.asSequence()
|
||||||
.map { SerialPortWrapper(it) }
|
.map { SerialPortWrapper(it) }
|
||||||
.filter { isKnownBoard(it) || HIDCommon.matchesAny(it.vendorId, it.productId) }
|
.filter { isKnownBoard(it) }
|
||||||
.asStream()
|
.asStream()
|
||||||
|
|
||||||
private fun detectNewPorts() {
|
private fun detectNewPorts() {
|
||||||
@@ -263,7 +261,7 @@ class DesktopSerialHandler :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getCurrentPort(): SlimeSerialPort? {
|
override fun getCurrentPort(): dev.slimevr.serial.SerialPort? {
|
||||||
val port = this.currentPort ?: return null
|
val port = this.currentPort ?: return null
|
||||||
return SerialPortWrapper(port)
|
return SerialPortWrapper(port)
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-33
@@ -54,23 +54,6 @@ class DesktopHIDManager(name: String, private val trackersConsumer: Consumer<Tra
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onHidDeviceReattached(hidDevice: HidDevice, deviceList: MutableList<Int>, serial: String) {
|
|
||||||
this.devicesByHID[hidDevice] = deviceList
|
|
||||||
this.lastDataByHID[hidDevice] = 0
|
|
||||||
synchronized(this.devices) {
|
|
||||||
for (id in deviceList) {
|
|
||||||
val device = this.devices[id]
|
|
||||||
for (value in device.trackers.values) {
|
|
||||||
if (value.status == TrackerStatus.DISCONNECTED) {
|
|
||||||
value.status = TrackerStatus.OK
|
|
||||||
}
|
|
||||||
value.heartbeat()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
LogManager.info("[TrackerServer] Linked HID device reattached: $serial")
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun checkConfigureDevice(hidDevice: HidDevice) {
|
private fun checkConfigureDevice(hidDevice: HidDevice) {
|
||||||
if (HIDCommon.matchesAny(hidDevice.vendorId, hidDevice.productId)) {
|
if (HIDCommon.matchesAny(hidDevice.vendorId, hidDevice.productId)) {
|
||||||
val serial = hidDevice.serialNumber ?: "Unknown HID Device"
|
val serial = hidDevice.serialNumber ?: "Unknown HID Device"
|
||||||
@@ -84,7 +67,16 @@ class DesktopHIDManager(name: String, private val trackersConsumer: Consumer<Tra
|
|||||||
// val product = hidDevice.product
|
// val product = hidDevice.product
|
||||||
// val manufacturer = hidDevice.manufacturer
|
// val manufacturer = hidDevice.manufacturer
|
||||||
this.devicesBySerial[serial]?.let {
|
this.devicesBySerial[serial]?.let {
|
||||||
onHidDeviceReattached(hidDevice, it, serial)
|
this.devicesByHID[hidDevice] = it
|
||||||
|
synchronized(this.devices) {
|
||||||
|
for (id in it) {
|
||||||
|
val device = this.devices[id]
|
||||||
|
for (value in device.trackers.values) {
|
||||||
|
if (value.status == TrackerStatus.DISCONNECTED) value.status = TrackerStatus.OK
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LogManager.info("[TrackerServer] Linked HID device reattached: $serial")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,11 +118,7 @@ class DesktopHIDManager(name: String, private val trackersConsumer: Consumer<Tra
|
|||||||
currentThread().interrupt()
|
currentThread().interrupt()
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
try {
|
dataRead() // not in try catch?
|
||||||
dataRead()
|
|
||||||
} catch (e: Exception) {
|
|
||||||
LogManager.severe("[TrackerServer] HID data read failed: ${e.message}", e)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,11 +138,7 @@ class DesktopHIDManager(name: String, private val trackersConsumer: Consumer<Tra
|
|||||||
currentThread().interrupt()
|
currentThread().interrupt()
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
try {
|
deviceEnumerate() // not in try catch?
|
||||||
deviceEnumerate()
|
|
||||||
} catch (e: Exception) {
|
|
||||||
LogManager.severe("[TrackerServer] HID device enumerate failed: ${e.message}", e)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,7 +198,7 @@ class DesktopHIDManager(name: String, private val trackersConsumer: Consumer<Tra
|
|||||||
}
|
}
|
||||||
// LogManager.info("[TrackerServer] HID received $packetCount tracker packets")
|
// LogManager.info("[TrackerServer] HID received $packetCount tracker packets")
|
||||||
} else {
|
} else {
|
||||||
lastDataByHID[hidDevice] = lastDataByHID.getOrDefault(hidDevice, 0) + 1
|
lastDataByHID[hidDevice] = lastDataByHID[hidDevice]!! + 1 // increment last data received
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!devicesPresent) {
|
if (!devicesPresent) {
|
||||||
@@ -258,13 +242,12 @@ class DesktopHIDManager(name: String, private val trackersConsumer: Consumer<Tra
|
|||||||
}
|
}
|
||||||
// Quickly reattaching a device may not be detected, so always try to open existing devices
|
// Quickly reattaching a device may not be detected, so always try to open existing devices
|
||||||
for (device in devicesByHID.keys) {
|
for (device in devicesByHID.keys) {
|
||||||
val lastData = lastDataByHID.getOrDefault(device, 0)
|
|
||||||
// a receiver sends keep-alive data at 10 packets/s
|
// a receiver sends keep-alive data at 10 packets/s
|
||||||
if (lastData > 100) { // try to reopen device if no data was received recently (about >100ms)
|
if (lastDataByHID[device]!! > 100) { // try to reopen device if no data was received recently (about >100ms)
|
||||||
if (lastData < 10000) {
|
if (lastDataByHID[device]!! < 10000) {
|
||||||
LogManager.info("[TrackerServer] Reopening device ${device.serialNumber} after no data received")
|
LogManager.info("[TrackerServer] Reopening device ${device.serialNumber} after no data received")
|
||||||
lastDataByHID[device] = 10000 // flag once
|
lastDataByHID[device] = 10000 // flag once
|
||||||
} else if (lastData < 20000) {
|
} else if (lastDataByHID[device]!! < 20000) {
|
||||||
LogManager.info("[TrackerServer] Repeatedly reopening device ${device.serialNumber}")
|
LogManager.info("[TrackerServer] Repeatedly reopening device ${device.serialNumber}")
|
||||||
lastDataByHID[device] = 20000 // flag twice
|
lastDataByHID[device] = 20000 // flag twice
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ pluginManagement {
|
|||||||
val spotlessVersion: String by settings
|
val spotlessVersion: String by settings
|
||||||
val shadowJarVersion: String by settings
|
val shadowJarVersion: String by settings
|
||||||
val buildconfigVersion: String by settings
|
val buildconfigVersion: String by settings
|
||||||
|
val grgitVersion: String by settings
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("plugin.serialization") version kotlinVersion
|
kotlin("plugin.serialization") version kotlinVersion
|
||||||
kotlin("jvm") version kotlinVersion
|
kotlin("jvm") version kotlinVersion
|
||||||
@@ -27,6 +28,7 @@ pluginManagement {
|
|||||||
id("com.diffplug.spotless") version spotlessVersion
|
id("com.diffplug.spotless") version spotlessVersion
|
||||||
id("com.gradleup.shadow") version shadowJarVersion
|
id("com.gradleup.shadow") version shadowJarVersion
|
||||||
id("com.github.gmazzo.buildconfig") version buildconfigVersion
|
id("com.github.gmazzo.buildconfig") version buildconfigVersion
|
||||||
|
id("org.ajoberstar.grgit") version grgitVersion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
Submodule solarxr-protocol updated: 00c38a6dc2...3ffd218a83.
Reference in new issue
Block a user