mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-11-22 10:01:19 -08:00
Compare commits
20
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c11dc54ed1 | ||
|
|
554976390b | ||
|
|
ced279a867 | ||
|
|
8637d1864a | ||
|
|
c72a30aca5 | ||
|
|
d7205bb294 | ||
|
|
953ef93945 | ||
|
|
5e3395afb0 | ||
|
|
cdde0b762f | ||
|
|
fc6304d7ee | ||
|
|
563933fa90 | ||
|
|
90956a6a02 | ||
|
|
3a0dc4b922 | ||
|
|
064e22dc1a | ||
|
|
7c6151fbe5 | ||
|
|
c8c57b1511 | ||
|
|
5b45d26c2d | ||
|
|
2b82638961 | ||
|
|
8df1e3dc4c | ||
|
|
a45925bc36 |
No files matched your search
@@ -1,9 +1,9 @@
|
||||
if ! has nix_direnv_version || ! nix_direnv_version 2.2.1; then
|
||||
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.2.1/direnvrc" "sha256-zelF0vLbEl5uaqrfIzbgNzJWGmLzCmYAkInj/LNxvKs="
|
||||
if ! has nix_direnv_version || ! nix_direnv_version 3.1.1; then
|
||||
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.1.1/direnvrc" "sha256-p+fzQdrms/hDa7g+soShAybJNo4bN4SIAeSfqNKgD5I="
|
||||
fi
|
||||
|
||||
nix_direnv_watch_file package.json
|
||||
if ! use flake . --impure
|
||||
watch_file package.json
|
||||
if ! use flake .
|
||||
then
|
||||
echo "devenv could not be built. The devenv environment was not loaded. Make the necessary changes to devenv.nix and hit enter to try again." >&2
|
||||
fi
|
||||
@@ -34,6 +34,9 @@
|
||||
# ignore gradle build folder
|
||||
build/
|
||||
|
||||
# created by clangd for index cache
|
||||
.cache/
|
||||
|
||||
# direnv has been claimed for Nix usage
|
||||
.direnv/
|
||||
.devenv
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# Contributing to SlimeVR
|
||||
|
||||
Please follow general contribution guidelines: [CONTRIBUTING.md](https://github.com/SlimeVR/.github/blob/main/profile/CONTRIBUTING.md).
|
||||
|
||||
This document describes essential knowledge required to contribute to the SlimeVR Server.
|
||||
|
||||
### Prerequisites
|
||||
|
||||
Executable
+12
@@ -0,0 +1,12 @@
|
||||
$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)"
|
||||
}
|
||||
Executable
+12
@@ -0,0 +1,12 @@
|
||||
#!/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,6 +15,13 @@
|
||||
|
||||
#include "openvr.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <cstdlib>
|
||||
#endif
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
using namespace std::chrono_literals;
|
||||
using namespace solarxr_protocol;
|
||||
|
||||
@@ -96,6 +103,35 @@ static void signal_handler(int signal) {
|
||||
int main() {
|
||||
auto &logger = Logger::get();
|
||||
|
||||
// Steam and SteamVR respectively set these environment variables on applications that
|
||||
// they spawn, which the SteamVR client library (vrclient) will then use as the
|
||||
// application key when initiating the connection with vrserver. This may not
|
||||
// be ideal if we are launched by another Steam or OpenVR application, as we will inherit
|
||||
// their app key through the environment, which means SteamVR will load the wrong bindings.
|
||||
// A real-world example of this is if someone uses an application such as OpenVR-Autostarter
|
||||
// to start the SlimeVR Server. OpenVR-Autostarter installs an application manifest with the
|
||||
// app key "dreiekk.openvr-autostarter", so when it starts SlimeVR Server, which then starts us,
|
||||
// the STEAMVR_APPKEY="dreiekk.openvr-autostarter" environment variable will be set.
|
||||
//
|
||||
// We want SteamVR to use the appkey of the Steam version of our application if possible.
|
||||
// Unfortunately, we cannot install an application vrmanifest to force the app key,
|
||||
// as SteamVR requires a binary path in the manifest to consider it valid. We do not want to install
|
||||
// a manifest with a binary path because we want the SlimeVR Server to start us when the
|
||||
// driver initiates a connection, rather than getting auto-started by SteamVR.
|
||||
//
|
||||
// This is not documented anywhere publicly, see CVRClient::SendConnectMessage in vrclient instead.
|
||||
|
||||
constexpr const char *STEAM_APPID = "3245490";
|
||||
constexpr const char *STEAMVR_APPKEY = "steam.overlay.3245490";
|
||||
|
||||
#ifdef _WIN32
|
||||
SetEnvironmentVariableA("SteamAppId", STEAM_APPID);
|
||||
SetEnvironmentVariableA("STEAMVR_APPKEY", STEAMVR_APPKEY);
|
||||
#else
|
||||
setenv("SteamAppId", STEAM_APPID, 1);
|
||||
setenv("STEAMVR_APPKEY", STEAMVR_APPKEY, 1);
|
||||
#endif
|
||||
|
||||
try {
|
||||
SolarXRConnection conn;
|
||||
std::unique_ptr<vr::IVRSystem, decltype(&shutdown_vr)> sys{ nullptr,
|
||||
@@ -128,14 +164,20 @@ int main() {
|
||||
vr::IVRApplications *app = vr::VRApplications();
|
||||
vr::IVRInput *input = vr::VRInput();
|
||||
|
||||
auto [appManifestPath, actionManifestPath] = VRUtils::initialiseManifest();
|
||||
fs::path actionManifestPath;
|
||||
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);
|
||||
err != vr::VRApplicationError_None) {
|
||||
logger.error("Failed to add application manifest: {}",
|
||||
app->GetApplicationsErrorNameFromEnum(err));
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
// SetActionManifestPath may return IPCError if vrserver is busy and takes
|
||||
// too long to reply, so keep invoking until it succeeds
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#include "solarxr.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "paths.hpp"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <sys/socket.h>
|
||||
@@ -14,15 +16,24 @@
|
||||
|
||||
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() {
|
||||
using namespace std::string_view_literals;
|
||||
#if defined(__linux__)
|
||||
#define MAKE_SOCKET_PATH(PATH) \
|
||||
std::make_pair(PATH##sv, static_cast<const char *>(getenv(PATH)))
|
||||
std::make_pair(PATH##sv, getenvSafe(PATH))
|
||||
|
||||
constexpr std::string_view socketName = "SlimeVRRpc";
|
||||
std::array<std::pair<std::string_view, const char *>, 4> socketPaths{
|
||||
std::array<std::pair<std::string_view, fs::path>, 5> socketPaths{
|
||||
MAKE_SOCKET_PATH("SLIMEVR_SOCKET_DIR"),
|
||||
{ "Steam socket path", Paths::getDataPath() },
|
||||
MAKE_SOCKET_PATH("XDG_RUNTIME_DIR"),
|
||||
MAKE_SOCKET_PATH("TMPDIR"),
|
||||
{ "/tmp", "/tmp" }
|
||||
@@ -31,17 +42,17 @@ fs::path SolarXRConnection::getSocketPath() {
|
||||
#undef MAKE_SOCKET_PATH
|
||||
|
||||
for (auto [name, path] : socketPaths) {
|
||||
if (path == nullptr) {
|
||||
if (path.empty()) {
|
||||
Logger::get().info(
|
||||
"Skipping socket directory {} because it doesn't exist", name);
|
||||
"Skipping socket directory '{}' because it doesn't exist", name);
|
||||
continue;
|
||||
}
|
||||
fs::path socketPath = fs::path(path) / socketName;
|
||||
fs::path socketPath = path / socketName;
|
||||
if (fs::exists(socketPath))
|
||||
return socketPath;
|
||||
|
||||
Logger::get().info(
|
||||
"Skipping socket directory {} because socket does not exist", name);
|
||||
"Skipping socket directory '{}' because socket does not exist", name);
|
||||
}
|
||||
#elif defined(_WIN32)
|
||||
throw std::logic_error(
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
plugins {
|
||||
id("org.ajoberstar.grgit")
|
||||
}
|
||||
Generated
+6
-6
@@ -5,11 +5,11 @@
|
||||
"nixpkgs-lib": "nixpkgs-lib"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1777988971,
|
||||
"narHash": "sha256-qIoWPDs+0/8JecyYgE3gpKQxW/4bLW/gp45vow9ioCQ=",
|
||||
"lastModified": 1778716662,
|
||||
"narHash": "sha256-m1Yf0wZ8j1OHjTc2UwHwyQRSnNeSgLJOd7q5Y45hzi4=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "0678d8986be1661af6bb555f3489f2fdfc31f6ff",
|
||||
"rev": "f7c1a2d347e4c52d5fb8d10cb4d94b5884e546fb",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -20,11 +20,11 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1777954456,
|
||||
"narHash": "sha256-hGdgeU2Nk87RAuZyYjyDjFL6LK7dAZN5RE9+hrDTkDU=",
|
||||
"lastModified": 1781577229,
|
||||
"narHash": "sha256-lrp67w8AulE9Ks53n27I45ADSzbOCn4H+CNW1Ck8B+8=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "549bd84d6279f9852cae6225e372cc67fb91a4c1",
|
||||
"rev": "567a49d1913ce81ac6e9582e3553dd90a955875f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
@@ -14,86 +14,151 @@
|
||||
...
|
||||
}:
|
||||
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||
systems = [ "x86_64-linux" ];
|
||||
systems = [
|
||||
"aarch64-linux"
|
||||
"x86_64-linux"
|
||||
];
|
||||
|
||||
perSystem =
|
||||
{ pkgs, ... }:
|
||||
{ lib, pkgs, ... }:
|
||||
let
|
||||
runtimeLibs =
|
||||
pkgs:
|
||||
(with pkgs; [
|
||||
jdk17
|
||||
runtimeLibs = [
|
||||
pkgs.alsa-lib
|
||||
pkgs.libpulseaudio
|
||||
pkgs.at-spi2-atk
|
||||
pkgs.at-spi2-core
|
||||
pkgs.cairo
|
||||
pkgs.cups
|
||||
pkgs.dbus
|
||||
pkgs.expat
|
||||
pkgs.gdk-pixbuf
|
||||
pkgs.glib
|
||||
pkgs.gtk3
|
||||
pkgs.libdrm
|
||||
pkgs.libgbm
|
||||
pkgs.libglvnd
|
||||
pkgs.libnotify
|
||||
pkgs.libxkbcommon
|
||||
pkgs.mesa
|
||||
pkgs.nspr
|
||||
pkgs.nss
|
||||
pkgs.pango
|
||||
pkgs.systemd
|
||||
pkgs.vulkan-loader
|
||||
pkgs.wayland
|
||||
pkgs.libX11
|
||||
pkgs.libXcomposite
|
||||
pkgs.libXdamage
|
||||
pkgs.libXext
|
||||
pkgs.libXfixes
|
||||
pkgs.libXrandr
|
||||
pkgs.libxcb
|
||||
pkgs.libxshmfence
|
||||
pkgs.libusb1
|
||||
pkgs.udev
|
||||
pkgs.libxcrypt-legacy
|
||||
];
|
||||
|
||||
alsa-lib
|
||||
libpulseaudio
|
||||
at-spi2-atk
|
||||
at-spi2-core
|
||||
cairo
|
||||
cups
|
||||
dbus
|
||||
expat
|
||||
gdk-pixbuf
|
||||
glib
|
||||
gtk3
|
||||
libdrm
|
||||
libgbm
|
||||
libglvnd
|
||||
libnotify
|
||||
libxkbcommon
|
||||
mesa
|
||||
nspr
|
||||
nss
|
||||
pango
|
||||
systemd
|
||||
vulkan-loader
|
||||
wayland
|
||||
libX11
|
||||
libXcomposite
|
||||
libXdamage
|
||||
libXext
|
||||
libXfixes
|
||||
libXrandr
|
||||
libxcb
|
||||
libxshmfence
|
||||
libusb1
|
||||
udev
|
||||
libxcrypt-legacy
|
||||
rpm
|
||||
fpm
|
||||
toolDirectoryName =
|
||||
if pkgs.stdenv.hostPlatform.isDarwin then
|
||||
"darwin"
|
||||
else if pkgs.stdenv.hostPlatform.isLinux then
|
||||
{
|
||||
"armv7l-linux" = "linux-arm32";
|
||||
"aarch64-linux" = "linux-arm64";
|
||||
"i686-linux" = "linux-ia32";
|
||||
"x86_64-linux" = "linux-x64";
|
||||
}
|
||||
."${pkgs.stdenv.hostPlatform.system}"
|
||||
else
|
||||
throw "Unsupported platform";
|
||||
|
||||
wineWow64Packages.stable
|
||||
zlib
|
||||
squashfsTools
|
||||
fakeroot
|
||||
libarchive
|
||||
icu
|
||||
nodejs_22
|
||||
pnpm
|
||||
pkg-config
|
||||
python3
|
||||
gcc
|
||||
gnumake
|
||||
binutils
|
||||
git
|
||||
node-gyp-build
|
||||
]);
|
||||
# we use fuse2
|
||||
# https://github.com/electron-userland/electron-builder/blob/a6117b3011a105204af8cc2eca02a56976d1ef29/packages/app-builder-lib/src/toolsets/linux.ts#L122
|
||||
runtime = pkgs.stdenvNoCC.mkDerivation {
|
||||
name = "electron-builder-appimage-runtime";
|
||||
src = pkgs.fetchurl {
|
||||
url = "https://github.com/electron-userland/electron-builder-binaries/releases/download/appimage-12.0.1/appimage-12.0.1.7z";
|
||||
hash = "sha256-0S/3648dHsRlLKUjen+9yjOswMdYBFY2/spi3G7LjsQ=";
|
||||
};
|
||||
# https://github.com/NixOS/nixpkgs/blob/7890ba0a99c064446fe2178ef2f8e3abdf6ec42a/pkgs/by-name/lo/losslesscut-bin/build-from-windows.nix#L20
|
||||
nativeBuildInputs = [ pkgs.p7zip ];
|
||||
unpackPhase = ''
|
||||
runHook preUnpack
|
||||
7z x "$src"
|
||||
runHook postUnpack
|
||||
'';
|
||||
installPhase = ''
|
||||
mkdir $out
|
||||
cp -r -t $out/ \
|
||||
lib/ \
|
||||
runtime-*
|
||||
'';
|
||||
};
|
||||
|
||||
slimeShell = pkgs.buildFHSEnv {
|
||||
name = "slimevr-env";
|
||||
targetPkgs = runtimeLibs;
|
||||
profile = ''
|
||||
export JAVA_HOME=${pkgs.jdk17}
|
||||
export PATH="${pkgs.jdk17}/bin:$PATH"
|
||||
appImageTools = pkgs.stdenvNoCC.mkDerivation {
|
||||
name = "electron-builder-appimage-tools";
|
||||
dontUnpack = true;
|
||||
|
||||
# Tell electron-builder to use system tools instead of downloading them
|
||||
export USE_SYSTEM_FPM=true
|
||||
export USE_SYSTEM_MKSQUASHFS=true
|
||||
installPhase = ''
|
||||
mkdir -p "$out/${toolDirectoryName}"
|
||||
ln -s -t $out/${toolDirectoryName} \
|
||||
"${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
|
||||
{
|
||||
devShells.default = slimeShell.env;
|
||||
devShells.default = pkgs.mkShell {
|
||||
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"
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
+1
-4
@@ -17,10 +17,7 @@ kotlinVersion=2.3.10
|
||||
spotlessVersion=8.2.1
|
||||
shadowJarVersion=9.3.1
|
||||
buildconfigVersion=6.0.7
|
||||
# We should probably stop using grgit, see:
|
||||
# https://andrewoberstar.com/posts/2024-04-02-dont-commit-to-grgit/
|
||||
grgitVersion=5.3.3
|
||||
|
||||
# Fix gradle leaving multiple java processes running that accumulate and use multiple GBs of RAM
|
||||
# This mostly seems to affect it when running from console, and then sending a SIGINT (Ctrl + C)
|
||||
org.gradle.daemon.idletimeout=10000
|
||||
org.gradle.daemon.idletimeout=10000
|
||||
@@ -1,5 +1,5 @@
|
||||
export default {
|
||||
'**/*.{ts,tsx}': () => 'tsc -p tsconfig.json --noEmit',
|
||||
'src/**/*.{js,jsx,ts,tsx}': 'eslint --max-warnings=0 --no-warn-ignored --cache --fix',
|
||||
'{electron,src}/**/*.{js,jsx,ts,tsx}': 'eslint --max-warnings=0 --no-warn-ignored --cache --fix',
|
||||
'**/*.{js,jsx,ts,tsx,css,scss,md,json}': 'prettier --write',
|
||||
};
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Option, program } from "commander";
|
||||
import { Option, program } from 'commander';
|
||||
|
||||
program
|
||||
.option('-p, --path <path>', 'set launch path')
|
||||
@@ -12,10 +12,10 @@ program
|
||||
// Allow passing arguments to Electron.
|
||||
.allowExcessArguments();
|
||||
|
||||
if (process.platform === "linux") {
|
||||
if (process.platform === 'linux') {
|
||||
const noUdevOption = new Option('--no-udev', 'disable udev warning');
|
||||
noUdevOption.negate = false;
|
||||
program.addOption(noUdevOption)
|
||||
program.addOption(noUdevOption);
|
||||
}
|
||||
|
||||
program.parse(process.argv);
|
||||
|
||||
@@ -29,6 +29,7 @@ import {
|
||||
} from './paths';
|
||||
import { initStores } from './store';
|
||||
import { closeLogger, logger } from './logger';
|
||||
|
||||
import { spawn } from 'node:child_process';
|
||||
import { discordPresence } from './presence';
|
||||
import { options } from './cli';
|
||||
@@ -126,14 +127,14 @@ handleIpc(IPC_CHANNELS.LOG, (e, type, ...args) => {
|
||||
});
|
||||
|
||||
handleIpc(IPC_CHANNELS.OPEN_URL, (e, url) => {
|
||||
const allowed_urls = [
|
||||
const allowedUrls = [
|
||||
/^steam:\/\//,
|
||||
/^ms-settings:network$/,
|
||||
/^https:\/\/(?:.+\.)?slimevr\.dev(?:\/.+)?$/,
|
||||
/^https:\/\/github\.com\/SlimeVR(?:\/.+)?$/,
|
||||
/^https:\/\/discord\.gg\/slimevr$/,
|
||||
];
|
||||
if (allowed_urls.find((a) => url.match(a))) open(url);
|
||||
if (allowedUrls.find((a) => url.match(a))) open(url);
|
||||
else logger.error({ url }, 'attempted to open non-whitelisted URL');
|
||||
});
|
||||
|
||||
@@ -370,9 +371,9 @@ function createWindow() {
|
||||
}
|
||||
|
||||
const checkEnvironmentVariables = () => {
|
||||
const to_check = ['_JAVA_OPTIONS', 'JAVA_TOOL_OPTIONS'];
|
||||
const disallowedVars = ['_JAVA_OPTIONS', 'JAVA_TOOL_OPTIONS'];
|
||||
|
||||
const set = to_check.filter((env) => !!process.env[env]);
|
||||
const set = disallowedVars.filter((env) => !!process.env[env]);
|
||||
if (set.length > 0) {
|
||||
dialog.showErrorBox(
|
||||
'SlimeVR',
|
||||
@@ -403,7 +404,7 @@ const spawnServer = async () => {
|
||||
if (!javaBin) {
|
||||
dialog.showErrorBox(
|
||||
'SlimeVR',
|
||||
`Couldn't find a compatible Java version, please download Java 17 or higher`
|
||||
'Unable to find a compatible Java version, please download Java 17 or higher'
|
||||
);
|
||||
app.quit();
|
||||
return;
|
||||
@@ -500,12 +501,6 @@ app.whenReady().then(async () => {
|
||||
|
||||
logger.info('SlimeVR started!');
|
||||
|
||||
process.on('exit', async (code) => {
|
||||
console.log(code);
|
||||
server?.close();
|
||||
await server?.waitForExit();
|
||||
});
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
app.quit();
|
||||
});
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { access, mkdir, readFile, writeFile } from "fs/promises";
|
||||
import { dirname, join } from "path";
|
||||
import { logger } from "./logger";
|
||||
import { getGuiDataFolder } from "./paths";
|
||||
|
||||
import { access, mkdir, readFile, writeFile } from 'fs/promises';
|
||||
import { dirname, join } from 'path';
|
||||
import { logger } from './logger';
|
||||
import { getGuiDataFolder } from './paths';
|
||||
|
||||
export class CustomStore {
|
||||
private data: Record<string, unknown> = {};
|
||||
@@ -15,7 +14,10 @@ export class CustomStore {
|
||||
this.debounceMs = debounceMs;
|
||||
}
|
||||
|
||||
static async create(filePath: string, debounceMs: number = 2000): Promise<CustomStore> {
|
||||
static async create(
|
||||
filePath: string,
|
||||
debounceMs: number = 2000
|
||||
): Promise<CustomStore> {
|
||||
const store = new CustomStore(filePath, debounceMs);
|
||||
await store.load();
|
||||
return store;
|
||||
@@ -28,7 +30,9 @@ export class CustomStore {
|
||||
this.data = JSON.parse(raw);
|
||||
} catch {
|
||||
this.data = {};
|
||||
logger.warn(`No existing store found at ${this.filePath}, starting with empty store.`);
|
||||
logger.warn(
|
||||
`No existing store found at ${this.filePath}, starting with empty store.`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +77,10 @@ export class CustomStore {
|
||||
|
||||
export async function initStores() {
|
||||
return {
|
||||
settings: await CustomStore.create(join(getGuiDataFolder(), 'gui-settings.dat'), 1000),
|
||||
settings: await CustomStore.create(
|
||||
join(getGuiDataFolder(), 'gui-settings.dat'),
|
||||
1000
|
||||
),
|
||||
cache: await CustomStore.create(join(getGuiDataFolder(), 'gui-cache.dat'), 100),
|
||||
};
|
||||
}
|
||||
+18
-19
@@ -1,8 +1,8 @@
|
||||
import os from 'os'
|
||||
import { OSStats } from "../preload/interface";
|
||||
import os from 'os';
|
||||
import { OSStats } from '../preload/interface';
|
||||
import { ipcMain, IpcMainInvokeEvent } from 'electron';
|
||||
import { IpcInvokeMap } from '../shared';
|
||||
import net from 'net'
|
||||
import net from 'net';
|
||||
|
||||
export const getPlatform = (): OSStats['type'] => {
|
||||
switch (os.platform()) {
|
||||
@@ -19,21 +19,21 @@ export const getPlatform = (): OSStats['type'] => {
|
||||
|
||||
export const isPortAvailable = (port: number) => {
|
||||
return new Promise((resolve) => {
|
||||
const s = net.createServer();
|
||||
s.once('error', (err) => {
|
||||
s.close();
|
||||
if ("code" in err && err["code"] == "EADDRINUSE") {
|
||||
resolve(false);
|
||||
} else {
|
||||
resolve(false);
|
||||
}
|
||||
});
|
||||
s.once('listening', () => {
|
||||
resolve(true);
|
||||
s.close();
|
||||
});
|
||||
s.listen(port);
|
||||
const s = net.createServer();
|
||||
s.once('error', (err) => {
|
||||
s.close();
|
||||
if ('code' in err && err['code'] == 'EADDRINUSE') {
|
||||
resolve(false);
|
||||
} else {
|
||||
resolve(false);
|
||||
}
|
||||
});
|
||||
s.once('listening', () => {
|
||||
resolve(true);
|
||||
s.close();
|
||||
});
|
||||
s.listen(port);
|
||||
});
|
||||
};
|
||||
|
||||
export function handleIpc<K extends keyof IpcInvokeMap>(
|
||||
@@ -44,7 +44,6 @@ export function handleIpc<K extends keyof IpcInvokeMap>(
|
||||
) => ReturnType<IpcInvokeMap[K]>
|
||||
) {
|
||||
ipcMain.handle(channel, (event, ...args) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return handler(event, ...args as any);
|
||||
return handler(event, ...(args as any));
|
||||
});
|
||||
}
|
||||
@@ -41,6 +41,7 @@ SUBSYSTEMS=="usb", ATTRS{idVendor}=="303a", ATTRS{idProduct}=="0002", MODE="0660
|
||||
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", MODE="0660", TAG+="uaccess"
|
||||
|
||||
## SlimeVR
|
||||
# smol slime dongle
|
||||
SUBSYSTEM=="usb", ATTR{idVendor}=="1209", ATTR{idProduct}=="7690", MODE="0660", TAG+="uaccess"
|
||||
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="7690", MODE="0660", TAG+="uaccess"
|
||||
# SlimeNRF Receiver & Tracker
|
||||
SUBSYSTEM=="usb|tty", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="7690|7692", MODE="0660", TAG+="uaccess"
|
||||
# same thing but hidraw
|
||||
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="7690|7692", MODE="0660", TAG+="uaccess"
|
||||
@@ -39,7 +39,7 @@ export const gui = [
|
||||
...globals.jest,
|
||||
},
|
||||
},
|
||||
files: ['src/**/*.{js,jsx,ts,tsx,json}'],
|
||||
files: ['{electron,src}/**/*.{js,jsx,ts,tsx,json}'],
|
||||
plugins: {
|
||||
'@typescript-eslint': tseslint.plugin,
|
||||
'@stylistic': stylistic,
|
||||
|
||||
+4
-4
@@ -23,9 +23,9 @@
|
||||
"package:build": "pnpm build && pnpm package",
|
||||
"preview": "electron-vite preview --config electron.vite.config.ts",
|
||||
"skipbundler": "vite build",
|
||||
"lint": "tsc --noEmit && eslint --max-warnings=0 \"src/**/*.{js,jsx,ts,tsx,json}\" && prettier --check \"src/**/*.{js,jsx,ts,tsx,css,scss,md,json}\"",
|
||||
"lint:fix": "tsc --noEmit && eslint --fix --max-warnings=0 \"src/**/*.{js,jsx,ts,tsx,json}\" && pnpm run format",
|
||||
"format": "prettier --write \"src/**/*.{js,jsx,ts,tsx,css,scss,md,json}\"",
|
||||
"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:fix": "tsc --noEmit && eslint --fix --max-warnings=0 \"{electron,src}/**/*.{js,jsx,ts,tsx,json}\" && pnpm run format",
|
||||
"format": "prettier --write \"{electron,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",
|
||||
"gen:javaversion": "cd electron/resources/java-version/ && javac JavaVersion.java && jar cvfe JavaVersion.jar JavaVersion JavaVersion.class",
|
||||
"gen:firmware-tool": "openapi-codegen gen firmwareTool"
|
||||
@@ -68,7 +68,7 @@
|
||||
"dmg-license": "^1.0.11",
|
||||
"dotenv": "^16.4.5",
|
||||
"electron": "^40.3.0",
|
||||
"electron-builder": "^26.9.0",
|
||||
"electron-builder": "^26.15.0",
|
||||
"electron-vite": "^5.0.0",
|
||||
"@eslint/eslintrc": "^3.3.5",
|
||||
"@eslint/js": "^9.39.4",
|
||||
|
||||
@@ -690,17 +690,15 @@ settings-general-gesture_control-trackers = { $amount ->
|
||||
settings-general-gesture_control-yawResetEnabled = Enable tap to yaw reset
|
||||
settings-general-gesture_control-yawResetDelay = Yaw reset delay
|
||||
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-fullResetDelay = Full reset delay
|
||||
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-mountingResetDelay = Mounting calibration delay
|
||||
settings-general-gesture_control-mountingResetTaps = Taps for mounting calibration
|
||||
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
|
||||
settings-general-gesture_control-mountingResetTracker = Mounting reset tracker
|
||||
# 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-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.
|
||||
@@ -790,6 +788,12 @@ settings-serial-factory_reset-warning-cancel = Cancel
|
||||
settings-serial-serial_select = Select a serial port
|
||||
settings-serial-auto_dropdown_item = Auto
|
||||
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-save_logs = Save To File
|
||||
settings-serial-send_command = Send
|
||||
@@ -1657,12 +1661,20 @@ tracking_checklist-MOUNTING_CALIBRATION = Perform a mounting calibration
|
||||
tracking_checklist-FEET_MOUNTING_CALIBRATION = Perform a feet mounting calibration
|
||||
tracking_checklist-FULL_RESET = Perform a full reset
|
||||
tracking_checklist-FULL_RESET-desc = Some trackers need a reset to be performed.
|
||||
tracking_checklist-STEAMVR_DISCONNECTED = SteamVR not running
|
||||
tracking_checklist-STEAMVR_DISCONNECTED = SteamVR disconnected
|
||||
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-enable = Enable driver
|
||||
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-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-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
|
||||
|
||||
@@ -34,7 +34,7 @@ export function NavButton({
|
||||
className={classnames(
|
||||
'flex flex-col justify-center xs:gap-4 mobile:gap-2',
|
||||
'mobile:w-[65px] mobile:h-[65px]',
|
||||
'xs:py-3 mobile:py-4 rounded-md mobile:rounded-b-none group select-text',
|
||||
'xs:py-3 mobile:py-4 rounded-md mobile:rounded-b-none group',
|
||||
{
|
||||
'bg-accent-background-50 fill-accent-background-20': doesMatch,
|
||||
'hover:bg-background-70': !doesMatch,
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
NewSerialDeviceResponseT,
|
||||
RpcMessage,
|
||||
SerialDeviceT,
|
||||
SerialDeviceType,
|
||||
} from 'solarxr-protocol';
|
||||
import { useConfig } from '@/hooks/config';
|
||||
import { useWebsocketAPI } from '@/hooks/websocket-api';
|
||||
@@ -56,7 +57,8 @@ export function SerialDetectionModal() {
|
||||
'/settings/serial',
|
||||
'/onboarding/connect-trackers',
|
||||
'/settings/firmware-tool',
|
||||
].includes(pathname)
|
||||
].includes(pathname) &&
|
||||
device?.type !== SerialDeviceType.HID_RECEIVER
|
||||
) {
|
||||
setOpen(device);
|
||||
}
|
||||
|
||||
@@ -14,13 +14,13 @@ export function InnerSystemFileInput({
|
||||
value,
|
||||
onChange,
|
||||
directory,
|
||||
ref,
|
||||
refCallback: refCallback,
|
||||
}: {
|
||||
label: string;
|
||||
value: string | null;
|
||||
onChange: (...event: any[]) => void;
|
||||
directory: boolean;
|
||||
ref: RefCallBack;
|
||||
refCallback: RefCallBack;
|
||||
}) {
|
||||
const electron = useElectron();
|
||||
|
||||
@@ -38,7 +38,7 @@ export function InnerSystemFileInput({
|
||||
};
|
||||
|
||||
return (
|
||||
<div ref={ref} onClick={handleClick}>
|
||||
<div ref={refCallback} onClick={handleClick}>
|
||||
{value !== null
|
||||
? FileInputContentFile({
|
||||
directory,
|
||||
@@ -77,7 +77,7 @@ export function SystemFileInput<T extends FieldValues = FieldValues>({
|
||||
label={label}
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
ref={ref}
|
||||
refCallback={ref}
|
||||
directory={directory}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
NewSerialDeviceResponseT,
|
||||
RpcMessage,
|
||||
SerialDeviceT,
|
||||
SerialDeviceType,
|
||||
SerialDevicesRequestT,
|
||||
SerialDevicesResponseT,
|
||||
TrackerStatus,
|
||||
@@ -77,13 +78,14 @@ function SerialDevicesList({
|
||||
RpcMessage.SerialDevicesResponse,
|
||||
(res: SerialDevicesResponseT) => {
|
||||
setDevices(
|
||||
res.devices.reduce(
|
||||
(curr, device) => ({
|
||||
res.devices.reduce((curr, device) => {
|
||||
if (device?.type != SerialDeviceType.ESP_TRACKER) return curr;
|
||||
|
||||
return {
|
||||
...curr,
|
||||
[device?.port?.toString() ?? 'unknown']: device,
|
||||
}),
|
||||
{}
|
||||
)
|
||||
};
|
||||
}, {})
|
||||
);
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -92,7 +94,7 @@ function SerialDevicesList({
|
||||
useRPCPacket(
|
||||
RpcMessage.NewSerialDeviceResponse,
|
||||
({ device }: NewSerialDeviceResponseT) => {
|
||||
if (device?.port)
|
||||
if (device?.port && device?.type === SerialDeviceType.ESP_TRACKER)
|
||||
setDevices((old) => ({
|
||||
...old,
|
||||
[device?.port?.toString() ?? 'unknown']: device,
|
||||
|
||||
@@ -28,7 +28,7 @@ function IncrementButton({
|
||||
<div
|
||||
onClick={onClick}
|
||||
className={classNames(
|
||||
'p-3 rounded-lg xs:w-10 xs:h-10 flex flex-col justify-center items-center cursor-pointer',
|
||||
'no-user-drag 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',
|
||||
{ 'bg-background-60': bgDark, 'bg-background-40': !bgDark }
|
||||
)}
|
||||
|
||||
@@ -34,7 +34,7 @@ function IncrementButton({
|
||||
return (
|
||||
<div
|
||||
className={classNames(
|
||||
'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]',
|
||||
'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]',
|
||||
{
|
||||
'cursor-not-allowed bg-background-80 opacity-50': disabled,
|
||||
'bg-background-50 hover:bg-background-40 cursor-pointer': !disabled,
|
||||
@@ -74,7 +74,7 @@ function UnitSelector({
|
||||
'bg-accent-background-30': active,
|
||||
'hover:bg-background-40 bg-background-40': !active,
|
||||
},
|
||||
'flex items-center justify-center rounded-md outline-background-10 cursor-pointer'
|
||||
'no-user-drag flex items-center justify-center rounded-md outline-background-10 cursor-pointer'
|
||||
)}
|
||||
onClick={onClick}
|
||||
>
|
||||
|
||||
+2
-2
@@ -29,8 +29,8 @@ function PosePage({
|
||||
return (
|
||||
<div className="flex flex-col py-2">
|
||||
<div className="flex flex-col gap-2">
|
||||
{descriptionKeys.map((descriptionKey) => (
|
||||
<Typography>{l10n.getString(descriptionKey)}</Typography>
|
||||
{descriptionKeys.map((descriptionKey, i) => (
|
||||
<Typography key={i}>{l10n.getString(descriptionKey)}</Typography>
|
||||
))}
|
||||
</div>
|
||||
<div className="flex pt-1 items-center fill-background-50 justify-center px-12">
|
||||
|
||||
@@ -2,10 +2,8 @@ import { ReactNode } from 'react';
|
||||
import { ConfigContextC, loadConfig, useConfigProvider } from '@/hooks/config';
|
||||
import { getSentryOrCompute } from '@/utils/sentry';
|
||||
|
||||
const [config, isSteam] = await Promise.all([
|
||||
loadConfig(),
|
||||
window.electronAPI.isSteam(),
|
||||
]);
|
||||
const config = await loadConfig();
|
||||
const isSteam = window.electronAPI ? await window.electronAPI.isSteam() : false;
|
||||
|
||||
if (config?.errorTracking !== undefined) {
|
||||
// load sentry ASAP to catch early errors
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import classNames from 'classnames';
|
||||
import { ReactNode, useEffect, useRef } from 'react';
|
||||
import { useLocation } from 'react-router-dom';
|
||||
import { useBreakpoint } from '@/hooks/breakpoint';
|
||||
|
||||
export function SettingsPageLayout({
|
||||
children,
|
||||
@@ -12,7 +11,6 @@ export function SettingsPageLayout({
|
||||
} & React.HTMLAttributes<HTMLDivElement>) {
|
||||
const pageRef = useRef<HTMLDivElement | null>(null);
|
||||
const { state } = useLocation();
|
||||
const { isMobile } = useBreakpoint('mobile');
|
||||
|
||||
useEffect(() => {
|
||||
const typedState: { scrollTo: string } = state;
|
||||
@@ -23,19 +21,10 @@ export function SettingsPageLayout({
|
||||
`#${typedState.scrollTo}`
|
||||
) as HTMLElement | null;
|
||||
if (elem) {
|
||||
// stupid way of doing this, just get the closest overflow-y-auto
|
||||
// usually its just the parentElem
|
||||
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',
|
||||
});
|
||||
}
|
||||
elem.scrollIntoView({
|
||||
block: 'start',
|
||||
behavior: 'smooth',
|
||||
});
|
||||
}
|
||||
}, [state]);
|
||||
|
||||
@@ -58,7 +47,7 @@ export function SettingsPagePaneLayout({
|
||||
return (
|
||||
<div
|
||||
className={classNames(
|
||||
'bg-background-70 rounded-lg px-4 py-8 flex xs:gap-4 w-full relative',
|
||||
'bg-background-70 rounded-lg px-4 py-8 flex xs:gap-4 w-full relative scroll-mt-12 mobile:scroll-mt-20',
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
|
||||
@@ -10,8 +10,11 @@ import { Button } from '@/components/commons/Button';
|
||||
import { SettingsResetModal } from '@/components/settings/SettingsResetModal';
|
||||
|
||||
import { error } from '@/utils/logging';
|
||||
import { defaultConfig as defaultGUIConfig, useConfig } from '@/hooks/config';
|
||||
import { defaultValues as defaultDevConfig } from '@/components/widgets/DeveloperModeWidget';
|
||||
import {
|
||||
defaultDevSettings,
|
||||
defaultConfig as defaultGUIConfig,
|
||||
useConfig,
|
||||
} from '@/hooks/config';
|
||||
import { RpcMessage, SettingsResetRequestT } from 'solarxr-protocol';
|
||||
import { useWebsocketAPI } from '@/hooks/websocket-api';
|
||||
import { useElectron } from '@/hooks/electron';
|
||||
@@ -21,7 +24,7 @@ function guiDefaults() {
|
||||
|
||||
const { lang, ...guiDefaults } = defaultGUIConfig;
|
||||
|
||||
guiDefaults.devSettings = defaultDevConfig;
|
||||
guiDefaults.devSettings = defaultDevSettings;
|
||||
|
||||
return guiDefaults;
|
||||
}
|
||||
|
||||
@@ -1317,7 +1317,7 @@ export function GeneralSettings() {
|
||||
</div>
|
||||
<div className="grid sm:grid-cols-3 gap-5 pb-2">
|
||||
<div>
|
||||
<Typography variant="section-title">
|
||||
<Typography bold>
|
||||
{l10n.getString(
|
||||
'settings-general-gesture_control-yawResetTracker'
|
||||
)}
|
||||
@@ -1331,21 +1331,7 @@ export function GeneralSettings() {
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<Typography variant="section-title">
|
||||
{l10n.getString(
|
||||
'settings-general-gesture_control-mountingResetTracker'
|
||||
)}
|
||||
</Typography>
|
||||
<Dropdown
|
||||
display="block"
|
||||
control={control}
|
||||
placeholder={''}
|
||||
name="tapDetection.mountingResetTracker"
|
||||
items={bodyParts}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<Typography variant="section-title">
|
||||
<Typography bold>
|
||||
{l10n.getString(
|
||||
'settings-general-gesture_control-fullResetTracker'
|
||||
)}
|
||||
@@ -1358,6 +1344,20 @@ export function GeneralSettings() {
|
||||
items={bodyParts}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<Typography bold>
|
||||
{l10n.getString(
|
||||
'settings-general-gesture_control-mountingResetTracker'
|
||||
)}
|
||||
</Typography>
|
||||
<Dropdown
|
||||
display="block"
|
||||
control={control}
|
||||
placeholder={''}
|
||||
name="tapDetection.mountingResetTracker"
|
||||
items={bodyParts}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="grid sm:grid-cols-3 gap-5 pb-2">
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { Localized, useLocalization } from '@fluent/react';
|
||||
import { useEffect } from 'react';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { FieldPath, useForm } from 'react-hook-form';
|
||||
import { CheckBox } from '@/components/commons/Checkbox';
|
||||
import { Typography } from '@/components/commons/Typography';
|
||||
import {
|
||||
SettingsPageLayout,
|
||||
SettingsPagePaneLayout,
|
||||
} from '@/components/settings/SettingsPageLayout';
|
||||
import { defaultConfig, useConfig } from '@/hooks/config';
|
||||
import { defaultConfig, DeveloperModeConfig, useConfig } from '@/hooks/config';
|
||||
import { ThemeSelector } from '@/components/commons/ThemeSelector';
|
||||
import { SquaresIcon } from '@/components/commons/icon/SquaresIcon';
|
||||
import { NumberSelector } from '@/components/commons/NumberSelector';
|
||||
@@ -18,7 +18,6 @@ import { Range } from '@/components/commons/Range';
|
||||
import { Dropdown } from '@/components/commons/Dropdown';
|
||||
import { ArrowRightLeftIcon } from '@/components/commons/icon/ArrowIcons';
|
||||
import { SystemFileInput } from '@/components/commons/SystemFileInput';
|
||||
import { DeveloperModeWidget } from '@/components/widgets/DeveloperModeWidget';
|
||||
import { useElectron } from '@/hooks/electron';
|
||||
|
||||
interface InterfaceSettingsForm {
|
||||
@@ -28,7 +27,6 @@ interface InterfaceSettingsForm {
|
||||
fonts: string;
|
||||
};
|
||||
behavior: {
|
||||
devmode: boolean;
|
||||
useTray: boolean;
|
||||
discordPresence: boolean;
|
||||
errorTracking: boolean;
|
||||
@@ -40,6 +38,9 @@ interface InterfaceSettingsForm {
|
||||
feedbackSoundVolume: number;
|
||||
connectedTrackersWarning: boolean;
|
||||
};
|
||||
developer: DeveloperModeConfig & {
|
||||
enabled: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
export function InterfaceSettings() {
|
||||
@@ -65,13 +66,35 @@ export function InterfaceSettings() {
|
||||
defaultConfig.connectedTrackersWarning,
|
||||
},
|
||||
behavior: {
|
||||
devmode: config?.debug ?? defaultConfig.debug,
|
||||
useTray: config?.useTray ?? defaultConfig.useTray ?? false,
|
||||
discordPresence:
|
||||
config?.discordPresence ?? defaultConfig.discordPresence,
|
||||
errorTracking: config?.errorTracking ?? false,
|
||||
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,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -112,9 +135,11 @@ export function InterfaceSettings() {
|
||||
|
||||
useTray: values.behavior.useTray,
|
||||
discordPresence: values.behavior.discordPresence,
|
||||
debug: values.behavior.devmode,
|
||||
errorTracking: values.behavior.errorTracking,
|
||||
bvhDirectory: values.behavior.bvhDirectory,
|
||||
|
||||
debug: values.developer.enabled,
|
||||
devSettings: values.developer,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -128,6 +153,16 @@ export function InterfaceSettings() {
|
||||
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 (
|
||||
<SettingsPageLayout>
|
||||
<form
|
||||
@@ -299,18 +334,31 @@ export function InterfaceSettings() {
|
||||
</Typography>
|
||||
</div>
|
||||
<div className="grid grid-cols-1 gap-2 pb-4 w-full">
|
||||
<div className="">
|
||||
<CheckBox
|
||||
variant="toggle"
|
||||
control={control}
|
||||
outlined
|
||||
name="behavior.devmode"
|
||||
label={l10n.getString(
|
||||
'settings-general-interface-dev_mode-label'
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
{config?.debug && <DeveloperModeWidget />}
|
||||
<CheckBox
|
||||
variant="toggle"
|
||||
control={control}
|
||||
outlined
|
||||
name="developer.enabled"
|
||||
label={l10n.getString(
|
||||
'settings-general-interface-dev_mode-label'
|
||||
)}
|
||||
/>
|
||||
{!!config?.debug && (
|
||||
<div className="grid grid-cols-2 w-full rounded-md gap-2">
|
||||
{Object.entries(devToggles).map(([name, label], i) => (
|
||||
<CheckBox
|
||||
key={i}
|
||||
control={control}
|
||||
variant="toggle"
|
||||
outlined
|
||||
name={
|
||||
`developer.${name}` as FieldPath<InterfaceSettingsForm>
|
||||
}
|
||||
label={l10n.getString(`widget-developer_mode-${label}`)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<Typography variant="section-title">
|
||||
|
||||
@@ -94,7 +94,10 @@ export function MagnetometerToggleSetting({
|
||||
|
||||
return settingType === 'general' ? (
|
||||
<>
|
||||
<div className="flex flex-col pt-5 pb-3" id={id}>
|
||||
<div
|
||||
className="flex flex-col pt-5 pb-3 scroll-mt-12 mobile:scroll-mt-20"
|
||||
id={id}
|
||||
>
|
||||
<Typography variant="section-title">
|
||||
{l10n.getString(
|
||||
'settings-general-tracker_mechanics-use_mag_on_all_trackers'
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
SerialUpdateResponseT,
|
||||
SerialTrackerGetWifiScanRequestT,
|
||||
SerialTrackerCustomCommandRequestT,
|
||||
SerialDeviceType,
|
||||
} from 'solarxr-protocol';
|
||||
import { useWebsocketAPI } from '@/hooks/websocket-api';
|
||||
import { Button } from '@/components/commons/Button';
|
||||
@@ -41,7 +42,10 @@ export function Serial() {
|
||||
const consoleRef = useRef<HTMLDivElement>(null);
|
||||
const [consoleContent, setConsole] = useState('');
|
||||
|
||||
const [isSerialOpen, setSerialOpen] = useState(false);
|
||||
const [openedSerialDevice, setOpenedSerialDevice] = useState<Omit<
|
||||
SerialDeviceT,
|
||||
'pack'
|
||||
> | null>(null);
|
||||
const [serialDevices, setSerialDevices] = useState<
|
||||
Omit<SerialDeviceT, 'pack'>[]
|
||||
>([]);
|
||||
@@ -87,11 +91,19 @@ export function Serial() {
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
sendRPCPacket(RpcMessage.SerialDevicesRequest, new SerialDevicesRequestT());
|
||||
const typedState: { serialPort: string } = state as any;
|
||||
if (typedState?.serialPort) {
|
||||
reset({ port: typedState.serialPort });
|
||||
}
|
||||
|
||||
sendRPCPacket(RpcMessage.SerialDevicesRequest, new SerialDevicesRequestT());
|
||||
const interval = setInterval(() => {
|
||||
sendRPCPacket(
|
||||
RpcMessage.SerialDevicesRequest,
|
||||
new SerialDevicesRequestT()
|
||||
);
|
||||
}, 3000);
|
||||
return () => clearInterval(interval);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -103,11 +115,8 @@ export function Serial() {
|
||||
useRPCPacket(
|
||||
RpcMessage.SerialUpdateResponse,
|
||||
(data: SerialUpdateResponseT) => {
|
||||
if (data.closed) {
|
||||
setSerialOpen(false);
|
||||
} else {
|
||||
setSerialOpen(true);
|
||||
}
|
||||
if (data.device) setOpenedSerialDevice(data.device);
|
||||
else if (data.closed) setOpenedSerialDevice(null);
|
||||
|
||||
if (data.log) {
|
||||
setConsole((console) => console + data.log);
|
||||
@@ -122,6 +131,7 @@ export function Serial() {
|
||||
{
|
||||
name: l10n.getString('settings-serial-auto_dropdown_item'),
|
||||
port: 'Auto',
|
||||
type: SerialDeviceType.ESP_TRACKER,
|
||||
},
|
||||
...(res.devices || []),
|
||||
]);
|
||||
@@ -161,7 +171,7 @@ export function Serial() {
|
||||
|
||||
useEffect(() => {
|
||||
const id = setInterval(() => {
|
||||
if (!isSerialOpen) {
|
||||
if (openedSerialDevice === null) {
|
||||
openSerial(port ?? defaultValues.port);
|
||||
} else {
|
||||
clearInterval(id);
|
||||
@@ -171,7 +181,7 @@ export function Serial() {
|
||||
return () => {
|
||||
clearInterval(id);
|
||||
};
|
||||
}, [isSerialOpen]);
|
||||
}, [openedSerialDevice]);
|
||||
|
||||
const reboot = () => {
|
||||
sendRPCPacket(
|
||||
@@ -179,6 +189,8 @@ export function Serial() {
|
||||
new SerialTrackerRebootRequestT()
|
||||
);
|
||||
};
|
||||
|
||||
// ESP
|
||||
const factoryReset = () => {
|
||||
sendRPCPacket(
|
||||
RpcMessage.SerialTrackerFactoryResetRequest,
|
||||
@@ -209,6 +221,48 @@ export function Serial() {
|
||||
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);
|
||||
useLayoutEffect(() => {
|
||||
consoleContentRef.current = consoleContent;
|
||||
@@ -318,7 +372,7 @@ export function Serial() {
|
||||
>
|
||||
<div className="flex select-text">
|
||||
<pre>
|
||||
{isSerialOpen
|
||||
{openedSerialDevice !== null
|
||||
? consoleContent
|
||||
: l10n.getString('settings-serial-connection_lost')}
|
||||
</pre>
|
||||
@@ -326,70 +380,115 @@ export function Serial() {
|
||||
</div>
|
||||
<div className="border-t-2 pt-2 border-background-60 border-solid gap-2 flex flex-row">
|
||||
<div className="xs:flex flex-grow xs:flex-wrap gap-2 grid grid-cols-2">
|
||||
<Button variant="quaternary" onClick={reboot}>
|
||||
{l10n.getString('settings-serial-reboot')}
|
||||
</Button>
|
||||
<Button
|
||||
variant="quaternary"
|
||||
onClick={() => setTryFactoryReset(true)}
|
||||
>
|
||||
{l10n.getString('settings-serial-factory_reset')}
|
||||
</Button>
|
||||
<Button variant="quaternary" onClick={getWifiScan}>
|
||||
{l10n.getString('settings-serial-get_wifi_scan')}
|
||||
</Button>
|
||||
<Button
|
||||
variant="quaternary"
|
||||
onClick={saveLogToFile}
|
||||
disabled={!isSerialOpen || !consoleContent.trim()}
|
||||
>
|
||||
{l10n.getString('settings-serial-save_logs')}
|
||||
</Button>
|
||||
<div className="ml-auto">
|
||||
<Button
|
||||
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 (!isSerialOpen) {
|
||||
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={!isSerialOpen}
|
||||
type="submit"
|
||||
>
|
||||
{l10n.getString('settings-serial-send_command')}
|
||||
</Button>
|
||||
</form>
|
||||
{openedSerialDevice !== null && (
|
||||
<>
|
||||
<Button variant="quaternary" onClick={reboot}>
|
||||
{l10n.getString('settings-serial-reboot')}
|
||||
</Button>
|
||||
{openedSerialDevice?.type ===
|
||||
SerialDeviceType.ESP_TRACKER && (
|
||||
<>
|
||||
<Button
|
||||
variant="quaternary"
|
||||
onClick={() => setTryFactoryReset(true)}
|
||||
>
|
||||
{l10n.getString('settings-serial-factory_reset')}
|
||||
</Button>
|
||||
<Button variant="quaternary" onClick={getWifiScan}>
|
||||
{l10n.getString('settings-serial-get_wifi_scan')}
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
{openedSerialDevice?.type !==
|
||||
SerialDeviceType.ESP_TRACKER && (
|
||||
<Button variant="quaternary" onClick={enterPairing}>
|
||||
{l10n.getString('settings-serial-enter_pairing')}
|
||||
</Button>
|
||||
)}
|
||||
{openedSerialDevice?.type ===
|
||||
SerialDeviceType.HID_RECEIVER && (
|
||||
<Button variant="quaternary" onClick={exitPairing}>
|
||||
{l10n.getString('settings-serial-exit_pairing')}
|
||||
</Button>
|
||||
)}
|
||||
{openedSerialDevice?.type ===
|
||||
SerialDeviceType.HID_TRACKER && (
|
||||
<>
|
||||
<Button variant="quaternary" onClick={calibrate}>
|
||||
{l10n.getString('settings-serial-calibrate')}
|
||||
</Button>
|
||||
<Button variant="quaternary" onClick={sixSideCalibrate}>
|
||||
{l10n.getString('settings-serial-six_side_calibrate')}
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
{openedSerialDevice?.type !==
|
||||
SerialDeviceType.ESP_TRACKER && (
|
||||
<>
|
||||
<Button variant="quaternary" onClick={dfu}>
|
||||
{l10n.getString('settings-serial-dfu')}
|
||||
</Button>
|
||||
<Button variant="quaternary" onClick={meow}>
|
||||
{l10n.getString('settings-serial-meow')}
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
<Button
|
||||
variant="quaternary"
|
||||
onClick={saveLogToFile}
|
||||
disabled={
|
||||
openedSerialDevice === null || !consoleContent.trim()
|
||||
}
|
||||
>
|
||||
{l10n.getString('settings-serial-save_logs')}
|
||||
</Button>
|
||||
<div className="ml-auto">
|
||||
<Button
|
||||
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">
|
||||
<Dropdown
|
||||
|
||||
@@ -187,14 +187,12 @@ export function VRCOSCSettings() {
|
||||
{l10n.getString('settings-osc-vrchat-oscqueryEnabled')}
|
||||
</Typography>
|
||||
<div className="flex flex-col pb-2">
|
||||
<Typography>
|
||||
{l10n
|
||||
.getString('settings-osc-vrchat-oscqueryEnabled-description')
|
||||
.split('\n')
|
||||
.map((line, i) => (
|
||||
<Typography key={i}>{line}</Typography>
|
||||
))}
|
||||
</Typography>
|
||||
{l10n
|
||||
.getString('settings-osc-vrchat-oscqueryEnabled-description')
|
||||
.split('\n')
|
||||
.map((line, i) => (
|
||||
<Typography key={i}>{line}</Typography>
|
||||
))}
|
||||
</div>
|
||||
<div className="grid grid-cols-2 gap-3 pb-5">
|
||||
<CheckBox
|
||||
|
||||
@@ -9,7 +9,7 @@ import { useLocalization } from '@fluent/react';
|
||||
import { Dispatch, ReactNode, SetStateAction } from 'react';
|
||||
import { StayAlignedRelaxedPose } from 'solarxr-protocol';
|
||||
|
||||
function StaAlignedPoseModal({
|
||||
function StayAlignedPoseModal({
|
||||
open,
|
||||
title,
|
||||
descriptionKeys,
|
||||
@@ -39,8 +39,8 @@ function StaAlignedPoseModal({
|
||||
<Typography variant="main-title">{l10n.getString(title)}</Typography>
|
||||
</div>
|
||||
<div className="flex flex-col gap-1">
|
||||
{descriptionKeys.map((descriptionKey) => (
|
||||
<Typography>{l10n.getString(descriptionKey)}</Typography>
|
||||
{descriptionKeys.map((descriptionKey, i) => (
|
||||
<Typography key={i}>{l10n.getString(descriptionKey)}</Typography>
|
||||
))}
|
||||
</div>
|
||||
<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>>];
|
||||
}) => (
|
||||
<StaAlignedPoseModal
|
||||
<StayAlignedPoseModal
|
||||
open={open}
|
||||
title={'onboarding-stay_aligned-relaxed_poses-standing-title'}
|
||||
descriptionKeys={[
|
||||
@@ -92,7 +92,7 @@ export const StandingRelaxedPoseModal = ({
|
||||
width={260}
|
||||
alt="Reset position"
|
||||
/>
|
||||
</StaAlignedPoseModal>
|
||||
</StayAlignedPoseModal>
|
||||
);
|
||||
|
||||
export const SittingRelaxedPoseModal = ({
|
||||
@@ -100,7 +100,7 @@ export const SittingRelaxedPoseModal = ({
|
||||
}: {
|
||||
open: [boolean, Dispatch<SetStateAction<boolean>>];
|
||||
}) => (
|
||||
<StaAlignedPoseModal
|
||||
<StayAlignedPoseModal
|
||||
open={open}
|
||||
title={'onboarding-stay_aligned-relaxed_poses-sitting-title'}
|
||||
descriptionKeys={[
|
||||
@@ -114,7 +114,7 @@ export const SittingRelaxedPoseModal = ({
|
||||
width={260}
|
||||
alt="Reset position"
|
||||
/>
|
||||
</StaAlignedPoseModal>
|
||||
</StayAlignedPoseModal>
|
||||
);
|
||||
|
||||
export const FlatRelaxedPoseModal = ({
|
||||
@@ -122,7 +122,7 @@ export const FlatRelaxedPoseModal = ({
|
||||
}: {
|
||||
open: [boolean, Dispatch<SetStateAction<boolean>>];
|
||||
}) => (
|
||||
<StaAlignedPoseModal
|
||||
<StayAlignedPoseModal
|
||||
open={open}
|
||||
title={'onboarding-stay_aligned-relaxed_poses-flat-title'}
|
||||
descriptionKeys={[
|
||||
@@ -136,5 +136,5 @@ export const FlatRelaxedPoseModal = ({
|
||||
width={560}
|
||||
alt="Reset position"
|
||||
/>
|
||||
</StaAlignedPoseModal>
|
||||
</StayAlignedPoseModal>
|
||||
);
|
||||
@@ -376,9 +376,9 @@ export function TrackersTable({
|
||||
/>
|
||||
</div>
|
||||
<div className="flex flex-col gap-y-0">
|
||||
{filteredSortedTrackers.map((data) => (
|
||||
{filteredSortedTrackers.map((data, index) => (
|
||||
<Row
|
||||
key={data.tracker.trackerId?.trackerNum}
|
||||
key={index}
|
||||
clickedTracker={clickedTracker}
|
||||
data={data}
|
||||
highlightedTrackers={highlightedTrackers}
|
||||
|
||||
@@ -7,12 +7,14 @@ import {
|
||||
import classNames from 'classnames';
|
||||
import {
|
||||
ChangeSettingsRequestT,
|
||||
EnableSteamVRDriverRequestT,
|
||||
ResetType,
|
||||
RpcMessage,
|
||||
SettingsRequestT,
|
||||
SettingsResponseT,
|
||||
SteamVRTrackersSettingT,
|
||||
TrackingChecklistPublicNetworksT,
|
||||
TrackingChecklistSteamVRDisconnectedT,
|
||||
TrackingChecklistStepId,
|
||||
} from 'solarxr-protocol';
|
||||
import { ReactNode, useEffect, useMemo, useState } from 'react';
|
||||
@@ -28,7 +30,7 @@ import {
|
||||
ArrowDownIcon,
|
||||
ArrowRightIcon,
|
||||
} from '@/components/commons/icon/ArrowIcons';
|
||||
import { Localized } from '@fluent/react';
|
||||
import { Localized, useLocalization } from '@fluent/react';
|
||||
import { WrenchIcon } from '@/components/commons/icon/WrenchIcons';
|
||||
import { TrackingChecklistModal } from './TrackingChecklistModal';
|
||||
import { NavLink, useNavigate } from 'react-router-dom';
|
||||
@@ -108,6 +110,69 @@ 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() {
|
||||
const { sendRPCPacket, useRPCPacket } = useWebsocketAPI();
|
||||
const [steamVrTrackers, setSteamVrTrackers] = useState<Omit<
|
||||
@@ -157,6 +222,21 @@ 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<
|
||||
number,
|
||||
(
|
||||
@@ -224,28 +304,8 @@ const stepContentLookup: Record<
|
||||
</div>
|
||||
);
|
||||
},
|
||||
[TrackingChecklistStepId.STEAMVR_DISCONNECTED]: (step, { toggleSession }) => {
|
||||
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.STEAMVR_DISCONNECTED]: (step, context) => {
|
||||
return <SteamVRDisconnected step={step} context={context} />;
|
||||
},
|
||||
[TrackingChecklistStepId.TRACKER_ERROR]: () => {
|
||||
return <Typography id="tracking_checklist-TRACKER_ERROR-desc" />;
|
||||
@@ -410,6 +470,9 @@ const stepContentLookup: Record<
|
||||
[TrackingChecklistStepId.STEAMVR_HANDS_ENABLED]: () => {
|
||||
return <SteamVRHandsEnabled />;
|
||||
},
|
||||
[TrackingChecklistStepId.STANDABLE_INSTALLED]: () => {
|
||||
return <StandableInstalled />;
|
||||
},
|
||||
};
|
||||
|
||||
export function TrackingChecklistMobile() {
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
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,14 +130,18 @@ async function initializeIMUVisualizer(
|
||||
accelArrow.setLength(Math.sqrt(accelLength) * 2);
|
||||
}
|
||||
|
||||
const magVec = new Vector3(mag.x, mag.y, mag.z);
|
||||
const magVec = Vector3FromVec3fT(mag);
|
||||
const magLen = magVec.length();
|
||||
const magMag = Math.sqrt(magLen / 100);
|
||||
if (magLen > 0) {
|
||||
if (magArrow.parent === null) scene.add(magArrow);
|
||||
|
||||
const magDir = magVec.clone().normalize();
|
||||
magArrow.position.copy(magDir.clone().multiplyScalar(-magMag));
|
||||
magArrow.setDirection(magDir);
|
||||
magArrow.setLength(2 * magMag);
|
||||
} else {
|
||||
magArrow.removeFromParent();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -207,9 +211,7 @@ function IMUVisualizerCanvas({
|
||||
}, [model]);
|
||||
|
||||
useEffect(() => {
|
||||
if (contextRef.current) {
|
||||
contextRef.current.update(quat, vec, mag);
|
||||
}
|
||||
contextRef.current?.update(quat, vec, mag);
|
||||
}, [quat, vec, mag]);
|
||||
|
||||
if (error) {
|
||||
|
||||
@@ -16,7 +16,7 @@ import { getSentryOrCompute, updateSentryContext } from '@/utils/sentry';
|
||||
import { fetchCurrentFirmwareRelease, FirmwareRelease } from './firmware-update';
|
||||
import { DEFAULT_LOCALE, LangContext } from '@/i18n/config';
|
||||
|
||||
const isSteam = await window.electronAPI.isSteam();
|
||||
const isSteam = window.electronAPI ? await window.electronAPI.isSteam() : false;
|
||||
|
||||
export interface AppContext {
|
||||
currentFirmwareRelease: FirmwareRelease | null;
|
||||
|
||||
+21
-5
@@ -1,8 +1,4 @@
|
||||
import { createContext, useContext, useState } from 'react';
|
||||
import {
|
||||
defaultValues as defaultDevSettings,
|
||||
DeveloperModeWidgetForm,
|
||||
} from '@/components/widgets/DeveloperModeWidget';
|
||||
import { error } from '@/utils/logging';
|
||||
import { useDebouncedEffect } from './timeout';
|
||||
import { waitUntil } from '@/utils/a11y';
|
||||
@@ -25,13 +21,33 @@ export enum AssignMode {
|
||||
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 {
|
||||
uuid: string;
|
||||
debug: boolean;
|
||||
lang: string;
|
||||
doneOnboarding: boolean;
|
||||
watchNewDevices: boolean;
|
||||
devSettings: DeveloperModeWidgetForm;
|
||||
devSettings: DeveloperModeConfig;
|
||||
feedbackSound: boolean;
|
||||
feedbackSoundVolume: number;
|
||||
connectedTrackersWarning: boolean;
|
||||
|
||||
@@ -426,3 +426,10 @@ div {
|
||||
[data-electron-drag-region='true'] {
|
||||
-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 jotaiReactRefresh from 'jotai/babel/plugin-react-refresh';
|
||||
|
||||
const commitHash = execSync('git rev-parse --verify --short HEAD').toString().trim();
|
||||
const commitHash = execSync('git rev-parse --verify --short=8 HEAD').toString().trim();
|
||||
const versionTag = execSync('git --no-pager tag --sort -taggerdate --points-at HEAD')
|
||||
.toString()
|
||||
.split('\n')[0]
|
||||
|
||||
Generated
+253
-472
File diff suppressed because it is too large.
Load diff
@@ -17,7 +17,6 @@ plugins {
|
||||
id("com.github.gmazzo.buildconfig")
|
||||
|
||||
id("com.android.application") version "8.13.2"
|
||||
id("org.ajoberstar.grgit")
|
||||
}
|
||||
|
||||
kotlin {
|
||||
@@ -124,8 +123,14 @@ dependencies {
|
||||
|
||||
// The android block is where you configure all your Android-specific build options.
|
||||
extra.apply {
|
||||
set("gitVersionCode", grgit.tag.list().size)
|
||||
set("gitVersionName", grgit.describe(mapOf("tags" to true, "always" to true)))
|
||||
val tagCount = providers.exec {
|
||||
commandLine("git", "--no-pager", "tag", "-l")
|
||||
}.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 {
|
||||
// The app's namespace. Used primarily to access app resources.
|
||||
|
||||
@@ -14,6 +14,7 @@ import com.hoho.android.usbserial.driver.UsbSerialProber
|
||||
import com.hoho.android.usbserial.util.SerialInputOutputManager
|
||||
import dev.slimevr.serial.SerialHandler
|
||||
import dev.slimevr.serial.SerialListener
|
||||
import dev.slimevr.tracking.trackers.hid.HIDCommon
|
||||
import io.eiren.util.logging.LogManager
|
||||
import java.io.IOException
|
||||
import java.nio.ByteBuffer
|
||||
@@ -57,7 +58,7 @@ class AndroidSerialHandler(val activity: AppCompatActivity) :
|
||||
get() = getPorts()
|
||||
.asSequence()
|
||||
.map { SerialPortWrapper(it.ports[0]) }
|
||||
.filter { isKnownBoard(it) }
|
||||
.filter { isKnownBoard(it) || HIDCommon.matchesAny(it.vendorId, it.productId) }
|
||||
.asStream()
|
||||
|
||||
val usbReceiver: BroadcastReceiver = object : BroadcastReceiver() {
|
||||
@@ -144,11 +145,11 @@ class AndroidSerialHandler(val activity: AppCompatActivity) :
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
override fun openSerial(portLocation: String?, auto: Boolean): Boolean {
|
||||
override fun openSerial(portLocation: String?, auto: Boolean, autoIncludeHid: Boolean): Boolean {
|
||||
LogManager.info("[SerialHandler] Trying to open: $portLocation, auto: $auto")
|
||||
lastKnownPorts = knownPorts.asSequence().toSet()
|
||||
val newPort = lastKnownPorts.find {
|
||||
(!auto && it.portLocation == portLocation) || (auto && isKnownBoard(it))
|
||||
(!auto && it.portLocation == portLocation) || (auto && isKnownBoard(it)) || (auto && autoIncludeHid && HIDCommon.matchesAny(it.vendorId, it.productId))
|
||||
}
|
||||
|
||||
if (newPort == null) {
|
||||
|
||||
+2
-1
@@ -71,6 +71,7 @@ class AndroidHIDManager(
|
||||
val serial = hidDevice.serialNumber ?: "Unknown USB Device ${hidDevice.deviceId}"
|
||||
this.devicesBySerial[serial]?.let {
|
||||
this.devicesByHID[hidDevice] = it
|
||||
this.lastDataByHID[hidDevice] = 0
|
||||
synchronized(this.devices) {
|
||||
for (id in it) {
|
||||
val device = this.devices[id]
|
||||
@@ -187,7 +188,7 @@ class AndroidHIDManager(
|
||||
}
|
||||
// LogManager.info("[TrackerServer] HID received $packetCount tracker packets")
|
||||
} else {
|
||||
lastDataByHID[hidDevice] = lastDataByHID[hidDevice]!! + 1 // increment last data received
|
||||
lastDataByHID[hidDevice] = lastDataByHID.getOrDefault(hidDevice, 0) + 1 // increment last data received
|
||||
}
|
||||
}
|
||||
if (!devicesPresent) {
|
||||
|
||||
@@ -91,6 +91,10 @@ dependencies {
|
||||
// Jitpack
|
||||
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"))
|
||||
// Use JUnit test framework
|
||||
testImplementation(platform("org.junit:junit-bom:6.0.2"))
|
||||
|
||||
@@ -35,6 +35,7 @@ import dev.slimevr.tracking.trackers.udp.TrackersUDPServer
|
||||
import dev.slimevr.trackingchecklist.TrackingChecklistManager
|
||||
import dev.slimevr.util.ann.VRServerThread
|
||||
import dev.slimevr.websocketapi.WebSocketVRBridge
|
||||
import io.eiren.util.Process
|
||||
import io.eiren.util.ann.ThreadSafe
|
||||
import io.eiren.util.ann.ThreadSecure
|
||||
import io.eiren.util.collections.FastList
|
||||
@@ -62,6 +63,8 @@ class VRServer @JvmOverloads constructor(
|
||||
flashingHandlerProvider: (VRServer) -> SerialFlashingHandler? = { _ -> null },
|
||||
vrcConfigHandlerProvider: (VRServer) -> VRCConfigHandler = { _ -> VRCConfigHandlerStub() },
|
||||
networkProfileProvider: (VRServer) -> NetworkProfileChecker = { _ -> StubNetworkProfileChecker() },
|
||||
val processListProvider: () -> Sequence<Process> = { emptySequence() },
|
||||
val tryOpenUri: (String) -> Unit = {},
|
||||
acquireMulticastLock: () -> Any? = { null },
|
||||
@JvmField val configManager: ConfigManager,
|
||||
) : Thread("VRServer") {
|
||||
|
||||
@@ -31,7 +31,7 @@ class ServerConfig {
|
||||
// it.setMag(false)
|
||||
// } else {
|
||||
trackers.map { (_, t) ->
|
||||
async { it.setMag(false, t.trackerNum) }
|
||||
async { it.setMag(MagnetometerStatus.DISABLED, t.trackerNum) }
|
||||
}.awaitAll()
|
||||
// }
|
||||
return@async
|
||||
@@ -51,7 +51,7 @@ class ServerConfig {
|
||||
.map { (_, t) ->
|
||||
async {
|
||||
// FIXME: Tracker gets restarted after each setMag, what will happen for devices with 3 trackers?
|
||||
it.setMag(true, t.trackerNum)
|
||||
it.setMag(MagnetometerStatus.ENABLED, t.trackerNum)
|
||||
}
|
||||
}.awaitAll()
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ class VRCOSCHandler(
|
||||
for (netInt in NetworkInterface.getNetworkInterfaces()) {
|
||||
if (netInt.isUp && !netInt.isLoopback && !netInt.isVirtual) {
|
||||
for (netAddr in netInt.interfaceAddresses) {
|
||||
if (a == netAddr.address || a.address.contentEquals(netAddr.address.address) || a.hostName == netAddr.address.hostName) {
|
||||
if (a == netAddr.address || a.address.contentEquals(netAddr.address.address)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -134,7 +134,6 @@ class VRCOSCHandler(
|
||||
b != null &&
|
||||
(
|
||||
a.address.contentEquals(b.address) ||
|
||||
(a.hostName == b.hostName) ||
|
||||
(ipIsLocal(a) && ipIsLocal(b))
|
||||
)
|
||||
)
|
||||
|
||||
@@ -22,14 +22,18 @@ import dev.slimevr.protocol.rpc.setup.RPCUtil.getLocalIp
|
||||
import dev.slimevr.protocol.rpc.status.RPCStatusHandler
|
||||
import dev.slimevr.protocol.rpc.trackingchecklist.RPCTrackingChecklistHandler
|
||||
import dev.slimevr.protocol.rpc.trackingpause.RPCTrackingPause
|
||||
import dev.slimevr.steamvr.SteamVRUtils
|
||||
import dev.slimevr.tracking.processor.config.SkeletonConfigOffsets
|
||||
import dev.slimevr.tracking.processor.stayaligned.poses.RelaxedPose
|
||||
import dev.slimevr.tracking.trackers.TrackerPosition
|
||||
import dev.slimevr.tracking.trackers.TrackerPosition.Companion.getByBodyPart
|
||||
import dev.slimevr.tracking.trackers.TrackerStatus
|
||||
import dev.slimevr.tracking.trackers.TrackerUtils.getTrackerForSkeleton
|
||||
import dev.slimevr.tracking.trackers.udp.MagnetometerStatus
|
||||
import io.eiren.util.logging.LogManager
|
||||
import io.github.axisangles.ktmath.Quaternion
|
||||
import io.ktor.client.HttpClient
|
||||
import io.ktor.client.engine.cio.CIO
|
||||
import kotlinx.coroutines.*
|
||||
import solarxr_protocol.MessageBundle
|
||||
import solarxr_protocol.datatypes.TransactionId
|
||||
@@ -151,6 +155,11 @@ class RPCHandler(private val api: ProtocolAPI) : ProtocolHandler<RpcMessageHeade
|
||||
RpcMessage.ResetStayAlignedRelaxedPoseRequest,
|
||||
::onResetStayAlignedRelaxedPoseRequest,
|
||||
)
|
||||
|
||||
registerPacketListener(
|
||||
RpcMessage.EnableSteamVRDriverRequest,
|
||||
::onEnableSteamVRDriverRequest,
|
||||
)
|
||||
}
|
||||
|
||||
private fun onServerInfosRequest(
|
||||
@@ -517,7 +526,7 @@ class RPCHandler(private val api: ProtocolAPI) : ProtocolHandler<RpcMessageHeade
|
||||
|
||||
mainScope.launch {
|
||||
withTimeoutOrNull(MAG_TIMEOUT) {
|
||||
tracker.device.setMag(state, tracker.trackerNum)
|
||||
tracker.device.setMag(if (state) MagnetometerStatus.ENABLED else MagnetometerStatus.DISABLED, tracker.trackerNum)
|
||||
}
|
||||
|
||||
val fbb = FlatBufferBuilder(32)
|
||||
@@ -610,6 +619,16 @@ class RPCHandler(private val api: ProtocolAPI) : ProtocolHandler<RpcMessageHeade
|
||||
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?) {
|
||||
val fbb = FlatBufferBuilder(32)
|
||||
val settings = createSettingsResponse(fbb, api.server)
|
||||
|
||||
@@ -7,10 +7,24 @@ import dev.slimevr.protocol.ProtocolAPIServer
|
||||
import dev.slimevr.protocol.rpc.RPCHandler
|
||||
import dev.slimevr.serial.SerialListener
|
||||
import dev.slimevr.serial.SerialPort
|
||||
import dev.slimevr.tracking.trackers.hid.HIDCommon
|
||||
import io.eiren.util.logging.LogManager
|
||||
import solarxr_protocol.rpc.*
|
||||
import java.util.*
|
||||
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 {
|
||||
init {
|
||||
@@ -35,38 +49,36 @@ class RPCSerialHandler(var rpcHandler: RPCHandler, var api: ProtocolAPI) : Seria
|
||||
val outbound = rpcHandler.createRPCMessage(fbb, RpcMessage.SerialUpdateResponse, update)
|
||||
fbb.finish(outbound)
|
||||
|
||||
this.forAllListeners(
|
||||
Consumer { conn: GenericConnection ->
|
||||
conn.send(fbb.dataBuffer())
|
||||
conn.context.useSerial = false
|
||||
},
|
||||
)
|
||||
this.forAllListeners { conn: GenericConnection ->
|
||||
conn.send(fbb.dataBuffer())
|
||||
conn.context.useSerial = false
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSerialLog(str: String, server: Boolean) {
|
||||
val fbb = FlatBufferBuilder(32)
|
||||
|
||||
val logOffset = fbb.createString(str)
|
||||
val portOffset = api.server.serialHandler.getCurrentPort()?.let { port ->
|
||||
createSerialDevice(fbb, port)
|
||||
} ?: 0
|
||||
|
||||
SerialUpdateResponse.startSerialUpdateResponse(fbb)
|
||||
SerialUpdateResponse.addLog(fbb, logOffset)
|
||||
SerialUpdateResponse.addDevice(fbb, portOffset)
|
||||
val update = SerialUpdateResponse.endSerialUpdateResponse(fbb)
|
||||
val outbound = rpcHandler.createRPCMessage(fbb, RpcMessage.SerialUpdateResponse, update)
|
||||
fbb.finish(outbound)
|
||||
|
||||
this.forAllListeners(
|
||||
Consumer { conn: GenericConnection ->
|
||||
conn.send(fbb.dataBuffer())
|
||||
},
|
||||
)
|
||||
this.forAllListeners { conn ->
|
||||
conn.send(fbb.dataBuffer())
|
||||
}
|
||||
}
|
||||
|
||||
override fun onNewSerialDevice(port: SerialPort) {
|
||||
val fbb = FlatBufferBuilder(32)
|
||||
|
||||
val portOffset = fbb.createString(port.portLocation)
|
||||
val nameOffset = fbb.createString(port.descriptivePortName)
|
||||
val deviceOffset = SerialDevice.createSerialDevice(fbb, portOffset, nameOffset)
|
||||
val deviceOffset = createSerialDevice(fbb, port)
|
||||
val newSerialOffset = NewSerialDeviceResponse
|
||||
.createNewSerialDeviceResponse(fbb, deviceOffset)
|
||||
val outbound = rpcHandler
|
||||
@@ -89,17 +101,17 @@ class RPCSerialHandler(var rpcHandler: RPCHandler, var api: ProtocolAPI) : Seria
|
||||
override fun onSerialConnected(port: SerialPort) {
|
||||
val fbb = FlatBufferBuilder(32)
|
||||
|
||||
val deviceOffset = createSerialDevice(fbb, port)
|
||||
SerialUpdateResponse.startSerialUpdateResponse(fbb)
|
||||
SerialUpdateResponse.addClosed(fbb, false)
|
||||
SerialUpdateResponse.addDevice(fbb, deviceOffset)
|
||||
val update = SerialUpdateResponse.endSerialUpdateResponse(fbb)
|
||||
val outbound = rpcHandler.createRPCMessage(fbb, RpcMessage.SerialUpdateResponse, update)
|
||||
fbb.finish(outbound)
|
||||
|
||||
this.forAllListeners(
|
||||
Consumer { conn: GenericConnection ->
|
||||
conn.send(fbb.dataBuffer())
|
||||
},
|
||||
)
|
||||
this.forAllListeners { conn ->
|
||||
conn.send(fbb.dataBuffer())
|
||||
}
|
||||
}
|
||||
|
||||
fun onSerialTrackerRebootRequest(
|
||||
@@ -165,20 +177,17 @@ class RPCSerialHandler(var rpcHandler: RPCHandler, var api: ProtocolAPI) : Seria
|
||||
|
||||
val fbb = FlatBufferBuilder(32)
|
||||
|
||||
val devicesOffsets: MutableList<Int> = ArrayList()
|
||||
|
||||
try {
|
||||
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))
|
||||
}
|
||||
val devicesOffsets = try {
|
||||
api.server.serialHandler.knownPorts.map { port ->
|
||||
createSerialDevice(fbb, port)
|
||||
}.toList()
|
||||
} catch (e: Throwable) {
|
||||
LogManager.severe("Using serial ports is not supported on this platform", e)
|
||||
emptyList()
|
||||
}
|
||||
|
||||
SerialDevicesResponse.startDevicesVector(fbb, devicesOffsets.size)
|
||||
devicesOffsets.forEach(Consumer { offset: Int -> SerialDevicesResponse.addDevices(fbb, offset) })
|
||||
devicesOffsets.forEach { offset: Int -> SerialDevicesResponse.addDevices(fbb, offset) }
|
||||
val devices = fbb.endVector()
|
||||
val serialDeviceOffsets = SerialDevicesResponse.createSerialDevicesResponse(fbb, devices)
|
||||
val outbound = rpcHandler
|
||||
@@ -188,7 +197,7 @@ class RPCSerialHandler(var rpcHandler: RPCHandler, var api: ProtocolAPI) : Seria
|
||||
}
|
||||
|
||||
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) {
|
||||
return
|
||||
@@ -198,13 +207,13 @@ class RPCSerialHandler(var rpcHandler: RPCHandler, var api: ProtocolAPI) : Seria
|
||||
|
||||
fun onOpenSerialRequest(conn: GenericConnection, messageHeader: RpcMessageHeader) {
|
||||
val req =
|
||||
messageHeader.message(OpenSerialRequest()) as OpenSerialRequest? ?: return
|
||||
messageHeader.message(OpenSerialRequest()) as? OpenSerialRequest? ?: return
|
||||
|
||||
conn.context.useSerial = true
|
||||
|
||||
this.api.server.queueTask {
|
||||
try {
|
||||
this.api.server.serialHandler.openSerial(req.port(), req.auto())
|
||||
this.api.server.serialHandler.openSerial(req.port(), req.auto(), true)
|
||||
} catch (e: Exception) {
|
||||
LogManager.severe("Unable to open serial port", e)
|
||||
} catch (e: Throwable) {
|
||||
@@ -245,17 +254,10 @@ class RPCSerialHandler(var rpcHandler: RPCHandler, var api: ProtocolAPI) : Seria
|
||||
conn.send(fbb.dataBuffer())
|
||||
}
|
||||
|
||||
fun forAllListeners(action: Consumer<in GenericConnection?>?) {
|
||||
this.api
|
||||
.apiServers
|
||||
.forEach(
|
||||
Consumer { server: ProtocolAPIServer ->
|
||||
server
|
||||
.apiConnections
|
||||
.filter { conn: GenericConnection -> conn.context.useSerial }
|
||||
.forEach(action)
|
||||
},
|
||||
)
|
||||
fun forAllListeners(action: (GenericConnection) -> Unit) {
|
||||
this.api.apiServers.forEach { server ->
|
||||
server.apiConnections.filter { it.context.useSerial }.forEach(action)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSerialDeviceDeleted(port: SerialPort) {
|
||||
|
||||
@@ -71,9 +71,9 @@ public class ProvisioningHandler implements SerialListener {
|
||||
try {
|
||||
boolean openResult = false;
|
||||
if (port != null)
|
||||
openResult = vrServer.serialHandler.openSerial(port, false);
|
||||
openResult = vrServer.serialHandler.openSerial(port, false, false);
|
||||
else
|
||||
openResult = vrServer.serialHandler.openSerial(null, true);
|
||||
openResult = vrServer.serialHandler.openSerial(null, true, false);
|
||||
if (!openResult)
|
||||
LogManager.info("[SerialHandler] Serial port wasn't open...");
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -9,7 +9,7 @@ abstract class SerialHandler {
|
||||
abstract fun addListener(channel: SerialListener)
|
||||
abstract fun removeListener(channel: SerialListener)
|
||||
|
||||
abstract fun openSerial(portLocation: String?, auto: Boolean): Boolean
|
||||
abstract fun openSerial(portLocation: String?, auto: Boolean, autoIncludeHid: Boolean = false): Boolean
|
||||
abstract fun rebootRequest()
|
||||
abstract fun factoryResetRequest()
|
||||
abstract fun infoRequest()
|
||||
@@ -22,7 +22,7 @@ abstract class SerialHandler {
|
||||
|
||||
companion object {
|
||||
// Please also update the udev rules when updating these in:
|
||||
// gui/src-tauri/69-slimevr-devices.rules
|
||||
// gui/electron/resources/69-slimevr-devices.rules
|
||||
val supportedSerial: Set<Pair<Int, Int>> = setOf(
|
||||
// / QinHeng
|
||||
// CH340
|
||||
@@ -61,7 +61,7 @@ class SerialHandlerStub : SerialHandler() {
|
||||
|
||||
override fun removeListener(channel: SerialListener) {}
|
||||
|
||||
override fun openSerial(portLocation: String?, auto: Boolean): Boolean = false
|
||||
override fun openSerial(portLocation: String?, auto: Boolean, autoIncludeHid: Boolean): Boolean = false
|
||||
|
||||
override fun rebootRequest() {}
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@ import java.util.*
|
||||
abstract class SerialPort {
|
||||
abstract val portLocation: String
|
||||
abstract val descriptivePortName: String
|
||||
abstract val vendorId: Int?
|
||||
abstract val productId: Int?
|
||||
abstract val vendorId: Int
|
||||
abstract val productId: Int
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
val other: SerialPort = other as? SerialPort ?: return super.equals(other)
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
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,6 +2,7 @@ package dev.slimevr.tracking.trackers
|
||||
|
||||
import dev.slimevr.tracking.trackers.udp.BoardType
|
||||
import dev.slimevr.tracking.trackers.udp.MCUType
|
||||
import dev.slimevr.tracking.trackers.udp.MagnetometerStatus
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.delay
|
||||
@@ -49,7 +50,7 @@ open class Device(val origin: DeviceOrigin, val magSupport: Boolean = false) {
|
||||
* if `sensorId` null or in the specified tracker
|
||||
* @param sensorId If null, every sensor will be modified
|
||||
*/
|
||||
open suspend fun setMag(state: Boolean, sensorId: Int = 255) {
|
||||
open suspend fun setMag(status: MagnetometerStatus, sensorId: Int = 255) {
|
||||
TODO("Not implemented because no mag support: $magSupport")
|
||||
}
|
||||
|
||||
|
||||
@@ -148,8 +148,12 @@ class Tracker @JvmOverloads constructor(
|
||||
var packetsLost: Int? = null
|
||||
var packetLoss: Float? = null
|
||||
var customName: String? = null
|
||||
|
||||
/**
|
||||
* Please don't use this and instead set it via [Device.setMag]
|
||||
*/
|
||||
var magStatus: MagnetometerStatus = magStatus
|
||||
private set
|
||||
internal set
|
||||
|
||||
/**
|
||||
* Watch the rest calibration status
|
||||
@@ -499,17 +503,6 @@ class Tracker @JvmOverloads constructor(
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
|
||||
@@ -12,6 +12,7 @@ import io.eiren.util.logging.LogManager
|
||||
import io.github.axisangles.ktmath.Quaternion
|
||||
import io.github.axisangles.ktmath.Quaternion.Companion.fromRotationVector
|
||||
import io.github.axisangles.ktmath.Vector3
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import java.nio.ByteBuffer
|
||||
import java.util.function.Consumer
|
||||
import kotlin.collections.set
|
||||
@@ -134,6 +135,10 @@ class HIDCommon {
|
||||
.info(
|
||||
"[TrackerServer] Added sensor $trackerId for ${device.name}, type $sensorType",
|
||||
)
|
||||
} else {
|
||||
runBlocking {
|
||||
device.setMag(magStatus, trackerId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,10 +5,16 @@ import dev.slimevr.tracking.trackers.DeviceOrigin
|
||||
import dev.slimevr.tracking.trackers.Tracker
|
||||
import dev.slimevr.tracking.trackers.udp.BoardType
|
||||
import dev.slimevr.tracking.trackers.udp.MCUType
|
||||
import dev.slimevr.tracking.trackers.udp.MagnetometerStatus
|
||||
|
||||
class HIDDevice(val hidId: Int) : Device(DeviceOrigin.HID) {
|
||||
override var hardwareIdentifier: String = "Unknown"
|
||||
override var boardType: BoardType = BoardType.UNKNOWN
|
||||
override var mcuType: MCUType = MCUType.UNKNOWN
|
||||
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 {
|
||||
withTimeoutOrNull(MAG_TIMEOUT) {
|
||||
connection.setMag(false, trackerId)
|
||||
connection.setMag(MagnetometerStatus.DISABLED, trackerId)
|
||||
}
|
||||
}
|
||||
} else if (magStatus == MagnetometerStatus.DISABLED &&
|
||||
@@ -258,7 +258,7 @@ class TrackersUDPServer(private val port: Int, name: String, private val tracker
|
||||
) {
|
||||
mainScope.launch {
|
||||
withTimeoutOrNull(MAG_TIMEOUT) {
|
||||
connection.setMag(true, trackerId)
|
||||
connection.setMag(MagnetometerStatus.ENABLED, trackerId)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -357,13 +357,6 @@ class TrackersUDPServer(private val port: Int, name: String, private val tracker
|
||||
LogManager.info("[TrackerServer] Tracker timed out: $conn")
|
||||
}
|
||||
} else {
|
||||
for (value in conn.trackers.values) {
|
||||
if (value.status == TrackerStatus.DISCONNECTED ||
|
||||
value.status == TrackerStatus.TIMED_OUT
|
||||
) {
|
||||
value.status = TrackerStatus.OK
|
||||
}
|
||||
}
|
||||
conn.timedOut = false
|
||||
}
|
||||
|
||||
@@ -404,7 +397,6 @@ class TrackersUDPServer(private val port: Int, name: String, private val tracker
|
||||
}
|
||||
|
||||
private fun processPacket(received: DatagramPacket, packet: UDPPacket, connection: UDPDevice?) {
|
||||
val tracker: Tracker?
|
||||
when (packet) {
|
||||
is UDPPacket0Heartbeat, is UDPPacket1Heartbeat, is UDPPacket25SetConfigFlag -> {}
|
||||
|
||||
@@ -413,8 +405,10 @@ class TrackersUDPServer(private val port: Int, name: String, private val tracker
|
||||
is RotationPacket -> {
|
||||
var rot = packet.rotation
|
||||
rot = AXES_OFFSET.times(rot)
|
||||
tracker = connection?.getTracker(packet.sensorId)
|
||||
if (tracker == null) return
|
||||
val tracker = connection?.getTracker(packet.sensorId) ?: return
|
||||
if (tracker.status == TrackerStatus.DISCONNECTED || tracker.status == TrackerStatus.TIMED_OUT) {
|
||||
tracker.status = TrackerStatus.OK
|
||||
}
|
||||
tracker.setRotation(rot)
|
||||
if (packet is UDPPacket23RotationAndAcceleration) {
|
||||
// sensorOffset is applied correctly since protocol 22
|
||||
@@ -429,8 +423,10 @@ class TrackersUDPServer(private val port: Int, name: String, private val tracker
|
||||
}
|
||||
|
||||
is UDPPacket17RotationData -> {
|
||||
tracker = connection?.getTracker(packet.sensorId)
|
||||
if (tracker == null) return
|
||||
val tracker = connection?.getTracker(packet.sensorId) ?: return
|
||||
if (tracker.status == TrackerStatus.DISCONNECTED || tracker.status == TrackerStatus.TIMED_OUT) {
|
||||
tracker.status = TrackerStatus.OK
|
||||
}
|
||||
var rot17 = packet.rotation
|
||||
rot17 = AXES_OFFSET * rot17
|
||||
when (packet.dataType) {
|
||||
@@ -453,8 +449,10 @@ class TrackersUDPServer(private val port: Int, name: String, private val tracker
|
||||
is UDPPacket18MagnetometerAccuracy -> {}
|
||||
|
||||
is UDPPacket4Acceleration -> {
|
||||
tracker = connection?.getTracker(packet.sensorId)
|
||||
if (tracker == null) return
|
||||
val tracker = connection?.getTracker(packet.sensorId) ?: return
|
||||
if (tracker.status == TrackerStatus.DISCONNECTED || tracker.status == TrackerStatus.TIMED_OUT) {
|
||||
tracker.status = TrackerStatus.OK
|
||||
}
|
||||
// sensorOffset is applied correctly since protocol 22
|
||||
// See: https://github.com/SlimeVR/SlimeVR-Tracker-ESP/pull/480
|
||||
if (connection.protocolVersion >= 22) {
|
||||
@@ -504,8 +502,7 @@ class TrackersUDPServer(private val port: Int, name: String, private val tracker
|
||||
}
|
||||
|
||||
is UDPPacket13Tap -> {
|
||||
tracker = connection?.getTracker(packet.sensorId)
|
||||
if (tracker == null) return
|
||||
val tracker = connection?.getTracker(packet.sensorId) ?: return
|
||||
LogManager.info(
|
||||
"[TrackerServer] Tap packet received from ${tracker.name}: ${packet.tap}",
|
||||
)
|
||||
@@ -515,8 +512,7 @@ class TrackersUDPServer(private val port: Int, name: String, private val tracker
|
||||
LogManager.severe(
|
||||
"[TrackerServer] Error received from ${received.socketAddress}: ${packet.errorNumber}",
|
||||
)
|
||||
tracker = connection?.getTracker(packet.sensorId)
|
||||
if (tracker == null) return
|
||||
val tracker = connection?.getTracker(packet.sensorId) ?: return
|
||||
tracker.status = TrackerStatus.ERROR
|
||||
}
|
||||
|
||||
@@ -548,7 +544,7 @@ class TrackersUDPServer(private val port: Int, name: String, private val tracker
|
||||
}
|
||||
|
||||
is UDPPacket20Temperature -> {
|
||||
tracker = connection?.getTracker(packet.sensorId) ?: return
|
||||
val tracker = connection?.getTracker(packet.sensorId) ?: return
|
||||
tracker.temperature = packet.temperature
|
||||
}
|
||||
|
||||
@@ -616,8 +612,7 @@ class TrackersUDPServer(private val port: Int, name: String, private val tracker
|
||||
}
|
||||
|
||||
is UDPPacket26FlexData -> {
|
||||
tracker = connection?.getTracker(packet.sensorId)
|
||||
if (tracker == null) return
|
||||
val tracker = connection?.getTracker(packet.sensorId) ?: return
|
||||
if (tracker.trackerDataType == TrackerDataType.FLEX_RESISTANCE) {
|
||||
tracker.trackerFlexHandler.setFlexResistance(packet.flexData)
|
||||
} else if (tracker.trackerDataType == TrackerDataType.FLEX_ANGLE) {
|
||||
@@ -627,8 +622,7 @@ class TrackersUDPServer(private val port: Int, name: String, private val tracker
|
||||
}
|
||||
|
||||
is UDPPacket27Position -> {
|
||||
tracker = connection?.getTracker(packet.sensorId)
|
||||
if (tracker == null) return
|
||||
val tracker = connection?.getTracker(packet.sensorId) ?: return
|
||||
tracker.position = packet.position
|
||||
// dont call dataTick here as this is just position update
|
||||
}
|
||||
|
||||
@@ -67,14 +67,15 @@ class UDPDevice(
|
||||
var timedOut = false
|
||||
override val trackers = ConcurrentHashMap<Int, Tracker>()
|
||||
|
||||
override suspend fun setMag(state: Boolean, sensorId: Int) {
|
||||
override suspend fun setMag(magStatus: MagnetometerStatus, sensorId: Int) {
|
||||
val state = magStatus == MagnetometerStatus.ENABLED
|
||||
if (sensorId == 255) {
|
||||
VRServer.instance.trackersServer.setConfigFlag(this, ConfigTypeId(1u), state)
|
||||
trackers.forEach { (_, t) -> t.setMagPrivate(state) }
|
||||
trackers.forEach { (_, t) -> t.magStatus = magStatus }
|
||||
} else {
|
||||
require(trackers[sensorId] != null) { "There is no tracker $sensorId in device ${toString()}" }
|
||||
VRServer.instance.trackersServer.setConfigFlag(this, ConfigTypeId(1u), state, sensorId)
|
||||
trackers[sensorId]!!.setMagPrivate(state)
|
||||
trackers[sensorId]!!.magStatus = magStatus
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+53
-4
@@ -7,13 +7,18 @@ import dev.slimevr.games.vrchat.VRCConfigListener
|
||||
import dev.slimevr.games.vrchat.VRCConfigRecommendedValues
|
||||
import dev.slimevr.games.vrchat.VRCConfigValidity
|
||||
import dev.slimevr.games.vrchat.VRCConfigValues
|
||||
import dev.slimevr.steamvr.SteamVRUtils
|
||||
import dev.slimevr.tracking.trackers.Tracker
|
||||
import dev.slimevr.tracking.trackers.TrackerPosition
|
||||
import dev.slimevr.tracking.trackers.TrackerRole
|
||||
import dev.slimevr.tracking.trackers.TrackerStatus
|
||||
import dev.slimevr.tracking.trackers.TrackerUtils
|
||||
import dev.slimevr.tracking.trackers.udp.TrackerDataType
|
||||
import io.eiren.util.OperatingSystem
|
||||
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.TrackerIdT
|
||||
import solarxr_protocol.rpc.*
|
||||
@@ -26,7 +31,7 @@ interface TrackingChecklistListener {
|
||||
}
|
||||
|
||||
class TrackingChecklistManager(private val vrServer: VRServer) : VRCConfigListener {
|
||||
|
||||
private var httpClient: HttpClient? = null
|
||||
private val listeners: MutableList<TrackingChecklistListener> = CopyOnWriteArrayList()
|
||||
val steps: MutableList<TrackingChecklistStepT> = mutableListOf()
|
||||
|
||||
@@ -98,6 +103,16 @@ 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(
|
||||
TrackingChecklistStepT().apply {
|
||||
id = TrackingChecklistStepId.TRACKER_ERROR
|
||||
@@ -278,23 +293,57 @@ class TrackingChecklistManager(private val vrServer: VRServer) : VRCConfigListen
|
||||
} as? ISteamVRBridge
|
||||
if (steamVRBridge != null) {
|
||||
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(
|
||||
TrackingChecklistStepId.STEAMVR_DISCONNECTED,
|
||||
steamvrConnected,
|
||||
) {
|
||||
it.enabled = true
|
||||
if (!steamvrConnected) {
|
||||
it.extraData = TrackingChecklistExtraDataUnion().apply {
|
||||
it.extraData = if (!steamvrConnected) {
|
||||
TrackingChecklistExtraDataUnion().apply {
|
||||
type = TrackingChecklistExtraData.TrackingChecklistSteamVRDisconnected
|
||||
value = TrackingChecklistSteamVRDisconnectedT().apply {
|
||||
bridgeSettingsName = steamVRBridge.getBridgeConfigKey()
|
||||
driverInstalled = !steamvrRunning || driverList == null || driver != null
|
||||
driverBlockedBySafeMode = driver?.blockedBySafeMode ?: false
|
||||
driverEnabled = driver?.enabled ?: true
|
||||
}
|
||||
}
|
||||
} else {
|
||||
it.extraData = null
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
updateValidity(
|
||||
TrackingChecklistStepId.STANDABLE_INSTALLED,
|
||||
!standableInstalled,
|
||||
) {
|
||||
it.enabled = true
|
||||
}
|
||||
|
||||
val handsEnabled = steamVRBridge.getShareSetting(TrackerRole.LEFT_HAND) || steamVRBridge.getShareSetting(TrackerRole.RIGHT_HAND)
|
||||
val hasControllers = vrServer.allTrackers.any {
|
||||
(it.trackerPosition == TrackerPosition.LEFT_HAND || it.trackerPosition == TrackerPosition.RIGHT_HAND) && it.isComputed && !it.isInternal
|
||||
|
||||
@@ -2,10 +2,13 @@ package io.eiren.util
|
||||
|
||||
import dev.slimevr.SLIMEVR_IDENTIFIER
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import java.nio.file.Path
|
||||
import java.util.*
|
||||
import kotlin.io.path.Path
|
||||
|
||||
data class Process(val pid: ULong, val name: String)
|
||||
|
||||
enum class OperatingSystem(
|
||||
val descriptor: String,
|
||||
private val aliases: Array<String>,
|
||||
|
||||
@@ -13,7 +13,6 @@ plugins {
|
||||
application
|
||||
id("com.gradleup.shadow")
|
||||
id("com.github.gmazzo.buildconfig")
|
||||
id("org.ajoberstar.grgit")
|
||||
}
|
||||
|
||||
kotlin {
|
||||
@@ -89,12 +88,18 @@ buildConfig {
|
||||
useKotlinOutput { topLevelConstants = true }
|
||||
packageName("dev.slimevr.desktop")
|
||||
|
||||
val gitCommitHash = providers.exec {
|
||||
commandLine("git", "rev-parse", "--short=8", "HEAD")
|
||||
}.standardOutput.asText.get().trim()
|
||||
val gitVersionTag = providers.exec {
|
||||
commandLine("git", "--no-pager", "tag", "--sort", "-taggerdate", "--points-at", "HEAD")
|
||||
}.standardOutput.asText.get().split('\n').first()
|
||||
buildConfigField("String", "GIT_COMMIT_HASH", "\"${grgit.head().abbreviatedId}\"")
|
||||
buildConfigField("String", "GIT_VERSION_TAG", "\"${gitVersionTag.trim()}\"")
|
||||
buildConfigField("boolean", "GIT_CLEAN", grgit.status().isClean.toString())
|
||||
}.standardOutput.asText.get().trim()
|
||||
val gitIsClean = providers.exec {
|
||||
commandLine("git", "status", "--porcelain")
|
||||
}.standardOutput.asText.get().trim().isEmpty()
|
||||
buildConfigField("String", "GIT_COMMIT_HASH", "\"${gitCommitHash}\"")
|
||||
buildConfigField("String", "GIT_VERSION_TAG", "\"${gitVersionTag}\"")
|
||||
buildConfigField("boolean", "GIT_CLEAN", gitIsClean.toString())
|
||||
}
|
||||
|
||||
tasks.run<JavaExec> {
|
||||
|
||||
@@ -2,6 +2,13 @@
|
||||
|
||||
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.Keybinding
|
||||
import dev.slimevr.SLIMEVR_IDENTIFIER
|
||||
@@ -20,6 +27,8 @@ import dev.slimevr.desktop.serial.DesktopSerialHandler
|
||||
import dev.slimevr.desktop.tracking.trackers.hid.DesktopHIDManager
|
||||
import dev.slimevr.tracking.trackers.Tracker
|
||||
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.logging.LogManager
|
||||
import org.apache.commons.cli.CommandLine
|
||||
@@ -157,6 +166,8 @@ fun main(args: Array<String>) {
|
||||
{ _ -> DesktopSerialFlashingHandler() },
|
||||
{ _ -> DesktopVRCConfigHandler() },
|
||||
{ _ -> DesktopNetworkProfileChecker() },
|
||||
::getRunningProcesses,
|
||||
::tryOpenUri,
|
||||
configManager = configManager,
|
||||
)
|
||||
vrServer.start()
|
||||
@@ -265,6 +276,68 @@ 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"
|
||||
fun resolveConfig(): String {
|
||||
// If config folder exists, then save config on relative path
|
||||
|
||||
@@ -58,11 +58,6 @@ class BindingsProviderManager : Runnable {
|
||||
"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!!.start()
|
||||
}
|
||||
@@ -77,6 +72,17 @@ class BindingsProviderManager : Runnable {
|
||||
|
||||
override fun run() {
|
||||
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
|
||||
while (process?.isAlive == true) {
|
||||
Thread.sleep(interval)
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.fazecast.jSerialComm.SerialPortEvent
|
||||
import com.fazecast.jSerialComm.SerialPortMessageListener
|
||||
import dev.slimevr.serial.SerialHandler
|
||||
import dev.slimevr.serial.SerialListener
|
||||
import dev.slimevr.tracking.trackers.hid.HIDCommon
|
||||
import io.eiren.util.logging.LogManager
|
||||
import java.io.IOException
|
||||
import java.io.OutputStreamWriter
|
||||
@@ -88,13 +89,14 @@ class DesktopSerialHandler :
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
override fun openSerial(portLocation: String?, auto: Boolean): Boolean {
|
||||
override fun openSerial(portLocation: String?, auto: Boolean, autoIncludeHid: Boolean): Boolean {
|
||||
LogManager.info("[SerialHandler] Trying to open: $portLocation, auto: $auto")
|
||||
val ports = SerialPort.getCommPorts()
|
||||
lastKnownPorts = ports.map { SerialPortWrapper(it) }.toSet()
|
||||
val newPort: SerialPort? = ports.find {
|
||||
(!auto && it.portLocation == portLocation) ||
|
||||
(auto && isKnownBoard(SerialPortWrapper(it)))
|
||||
(auto && isKnownBoard(SerialPortWrapper(it))) ||
|
||||
(auto && autoIncludeHid && HIDCommon.matchesAny(it.vendorID, it.productID))
|
||||
}
|
||||
if (newPort == null) {
|
||||
LogManager.info(
|
||||
@@ -244,7 +246,7 @@ class DesktopSerialHandler :
|
||||
get() = SerialPort.getCommPorts()
|
||||
.asSequence()
|
||||
.map { SerialPortWrapper(it) }
|
||||
.filter { isKnownBoard(it) }
|
||||
.filter { isKnownBoard(it) || HIDCommon.matchesAny(it.vendorId, it.productId) }
|
||||
.asStream()
|
||||
|
||||
private fun detectNewPorts() {
|
||||
@@ -261,7 +263,7 @@ class DesktopSerialHandler :
|
||||
}
|
||||
}
|
||||
|
||||
override fun getCurrentPort(): dev.slimevr.serial.SerialPort? {
|
||||
override fun getCurrentPort(): SlimeSerialPort? {
|
||||
val port = this.currentPort ?: return null
|
||||
return SerialPortWrapper(port)
|
||||
}
|
||||
|
||||
+33
-16
@@ -54,6 +54,23 @@ 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) {
|
||||
if (HIDCommon.matchesAny(hidDevice.vendorId, hidDevice.productId)) {
|
||||
val serial = hidDevice.serialNumber ?: "Unknown HID Device"
|
||||
@@ -67,16 +84,7 @@ class DesktopHIDManager(name: String, private val trackersConsumer: Consumer<Tra
|
||||
// val product = hidDevice.product
|
||||
// val manufacturer = hidDevice.manufacturer
|
||||
this.devicesBySerial[serial]?.let {
|
||||
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")
|
||||
onHidDeviceReattached(hidDevice, it, serial)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -118,7 +126,11 @@ class DesktopHIDManager(name: String, private val trackersConsumer: Consumer<Tra
|
||||
currentThread().interrupt()
|
||||
break
|
||||
}
|
||||
dataRead() // not in try catch?
|
||||
try {
|
||||
dataRead()
|
||||
} catch (e: Exception) {
|
||||
LogManager.severe("[TrackerServer] HID data read failed: ${e.message}", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,7 +150,11 @@ class DesktopHIDManager(name: String, private val trackersConsumer: Consumer<Tra
|
||||
currentThread().interrupt()
|
||||
break
|
||||
}
|
||||
deviceEnumerate() // not in try catch?
|
||||
try {
|
||||
deviceEnumerate()
|
||||
} catch (e: Exception) {
|
||||
LogManager.severe("[TrackerServer] HID device enumerate failed: ${e.message}", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,7 +214,7 @@ class DesktopHIDManager(name: String, private val trackersConsumer: Consumer<Tra
|
||||
}
|
||||
// LogManager.info("[TrackerServer] HID received $packetCount tracker packets")
|
||||
} else {
|
||||
lastDataByHID[hidDevice] = lastDataByHID[hidDevice]!! + 1 // increment last data received
|
||||
lastDataByHID[hidDevice] = lastDataByHID.getOrDefault(hidDevice, 0) + 1
|
||||
}
|
||||
}
|
||||
if (!devicesPresent) {
|
||||
@@ -242,12 +258,13 @@ class DesktopHIDManager(name: String, private val trackersConsumer: Consumer<Tra
|
||||
}
|
||||
// Quickly reattaching a device may not be detected, so always try to open existing devices
|
||||
for (device in devicesByHID.keys) {
|
||||
val lastData = lastDataByHID.getOrDefault(device, 0)
|
||||
// a receiver sends keep-alive data at 10 packets/s
|
||||
if (lastDataByHID[device]!! > 100) { // try to reopen device if no data was received recently (about >100ms)
|
||||
if (lastDataByHID[device]!! < 10000) {
|
||||
if (lastData > 100) { // try to reopen device if no data was received recently (about >100ms)
|
||||
if (lastData < 10000) {
|
||||
LogManager.info("[TrackerServer] Reopening device ${device.serialNumber} after no data received")
|
||||
lastDataByHID[device] = 10000 // flag once
|
||||
} else if (lastDataByHID[device]!! < 20000) {
|
||||
} else if (lastData < 20000) {
|
||||
LogManager.info("[TrackerServer] Repeatedly reopening device ${device.serialNumber}")
|
||||
lastDataByHID[device] = 20000 // flag twice
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ pluginManagement {
|
||||
val spotlessVersion: String by settings
|
||||
val shadowJarVersion: String by settings
|
||||
val buildconfigVersion: String by settings
|
||||
val grgitVersion: String by settings
|
||||
plugins {
|
||||
kotlin("plugin.serialization") version kotlinVersion
|
||||
kotlin("jvm") version kotlinVersion
|
||||
@@ -28,7 +27,6 @@ pluginManagement {
|
||||
id("com.diffplug.spotless") version spotlessVersion
|
||||
id("com.gradleup.shadow") version shadowJarVersion
|
||||
id("com.github.gmazzo.buildconfig") version buildconfigVersion
|
||||
id("org.ajoberstar.grgit") version grgitVersion
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
Submodule solarxr-protocol updated: 3ffd218a83...00c38a6dc2.
Reference in new issue
Block a user