diff --git a/.gitignore b/.gitignore index 30eaf86c0..f05241779 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,9 @@ # ignore gradle build folder build/ +# created by clangd for index cache +.cache/ + # direnv has been claimed for Nix usage .direnv/ .devenv diff --git a/bindings-provider/fmt.ps1 b/bindings-provider/fmt.ps1 new file mode 100755 index 000000000..ca60910f4 --- /dev/null +++ b/bindings-provider/fmt.ps1 @@ -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)" +} diff --git a/bindings-provider/fmt.sh b/bindings-provider/fmt.sh new file mode 100755 index 000000000..7a820193b --- /dev/null +++ b/bindings-provider/fmt.sh @@ -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 {} \; diff --git a/bindings-provider/src/main.cpp b/bindings-provider/src/main.cpp index fe487d6d2..3ce2e1758 100644 --- a/bindings-provider/src/main.cpp +++ b/bindings-provider/src/main.cpp @@ -102,19 +102,34 @@ static void signal_handler(int signal) { int main() { auto &logger = Logger::get(); - // Steam and SteamVR sets these environment variables on applications that it - // spawns, but if an app spawned by Steam then spawns a child that initialises - // OpenVR, SteamVR will give the child the appkey of the root application it - // is a descendant of, e.g. if SteamVR launches SlimeVR as an overlay, - // it will set SteamAppId="3245490" and STEAMVR_APPKEY="steam.overlay.3245490" - // which breaks our bindings. We want SteamVR to use a generated appkey if - // possible. + + // 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", nullptr); - SetEnvironmentVariableA("STEAMVR_APPKEY", nullptr); + SetEnvironmentVariableA("SteamAppId", STEAM_APPID); + SetEnvironmentVariableA("STEAMVR_APPKEY", STEAMVR_APPKEY); #else - unsetenv("SteamAppId"); - unsetenv("STEAMVR_APPKEY"); + setenv("SteamAppId", STEAM_APPID, 1); + setenv("STEAMVR_APPKEY", STEAMVR_APPKEY, 1); #endif try { diff --git a/bindings-provider/src/solarxr.cpp b/bindings-provider/src/solarxr.cpp index 58f6ca4fe..b2c3ab8ff 100644 --- a/bindings-provider/src/solarxr.cpp +++ b/bindings-provider/src/solarxr.cpp @@ -1,7 +1,9 @@ #include "solarxr.hpp" #include "logger.hpp" +#include "paths.hpp" #include +#include #if defined(__linux__) #include @@ -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(getenv(PATH))) + std::make_pair(PATH##sv, getenvSafe(PATH)) constexpr std::string_view socketName = "SlimeVRRpc"; - std::array, 4> socketPaths{ + std::array, 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( diff --git a/gui/app/public/i18n/en/translation.ftl b/gui/app/public/i18n/en/translation.ftl index c864569dc..545e8f051 100644 --- a/gui/app/public/i18n/en/translation.ftl +++ b/gui/app/public/i18n/en/translation.ftl @@ -731,17 +731,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-mountingResetEnabled = Enable tap to mounting reset +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. diff --git a/gui/app/src/components/settings/pages/components/TapDetectionSettings.tsx b/gui/app/src/components/settings/pages/components/TapDetectionSettings.tsx index a61243db5..662b47250 100644 --- a/gui/app/src/components/settings/pages/components/TapDetectionSettings.tsx +++ b/gui/app/src/components/settings/pages/components/TapDetectionSettings.tsx @@ -203,7 +203,7 @@ export function TapDetectionSettings() {
- + {l10n.getString( 'settings-general-gesture_control-yawResetTracker' )} @@ -217,7 +217,7 @@ export function TapDetectionSettings() { />
- + {l10n.getString( 'settings-general-gesture_control-fullResetTracker' )} @@ -231,7 +231,7 @@ export function TapDetectionSettings() { />
- + {l10n.getString( 'settings-general-gesture_control-mountingResetTracker' )} diff --git a/server/desktop/src/main/java/dev/slimevr/desktop/ipc/protocol.kt b/server/desktop/src/main/java/dev/slimevr/desktop/ipc/protocol.kt index e2333dc8c..6939320e4 100644 --- a/server/desktop/src/main/java/dev/slimevr/desktop/ipc/protocol.kt +++ b/server/desktop/src/main/java/dev/slimevr/desktop/ipc/protocol.kt @@ -23,6 +23,7 @@ import io.github.axisangles.ktmath.Vector3 import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.cancelChildren import kotlinx.coroutines.coroutineScope +import kotlinx.coroutines.delay import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.launch import kotlinx.coroutines.sync.Mutex @@ -86,6 +87,9 @@ suspend fun startBindingProvider() = withContext(Dispatchers.IO) { } AppLogger.steamvr.info("Found bindings provider at $path") + // Give SteamVR a bit more time to initialise everything + // For some users, starting the executable immediately may cause startup failures + delay(3000L) val proc = try { ProcessBuilder(path.toString()).start() } catch (e: Exception) {