mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-11-26 03:46:28 -08:00
Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
abb8c9b66c | ||
|
|
9614abea08 | ||
|
|
2c125b2540 | ||
|
|
6974122c99 | ||
|
|
a7ffbd9ea8 | ||
|
|
d04c7796bf | ||
|
|
1829e4e234 | ||
|
|
1caa2a5049 |
No files matched your search
+5
-1
@@ -44,5 +44,9 @@ build/
|
||||
# Ignore Android local properties
|
||||
local.properties
|
||||
|
||||
# Ignore temporary config
|
||||
# Ignore vrconfig
|
||||
vrconfig.yml
|
||||
vrconfig.yml.tmp
|
||||
vrconfig.yml.bak
|
||||
vrconfig.yml.*.bak.tmp
|
||||
vrconfig.yml.*.bak
|
||||
@@ -5,7 +5,6 @@ build
|
||||
*/bin/
|
||||
|
||||
MagnetoLib.dll
|
||||
vrconfig.yml
|
||||
|
||||
# BVH
|
||||
BVH Recordings
|
||||
|
||||
@@ -64,10 +64,7 @@ dependencies {
|
||||
// and not exposed to consumers on their own compile classpath.
|
||||
implementation("com.google.flatbuffers:flatbuffers-java:22.10.26")
|
||||
implementation("commons-cli:commons-cli:1.8.0")
|
||||
implementation("com.fasterxml.jackson.core:jackson-databind:2.15.1")
|
||||
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.15.1")
|
||||
|
||||
implementation("com.github.jonpeterson:jackson-module-model-versioning:1.2.2")
|
||||
implementation("org.apache.commons:commons-math3:3.6.1")
|
||||
implementation("org.apache.commons:commons-lang3:3.15.0")
|
||||
implementation("org.apache.commons:commons-collections4:4.4")
|
||||
@@ -75,7 +72,11 @@ dependencies {
|
||||
implementation("com.illposed.osc:javaosc-core:0.8")
|
||||
implementation("org.java-websocket:Java-WebSocket:1.+")
|
||||
implementation("com.melloware:jintellitype:1.+")
|
||||
|
||||
implementation("com.squareup.okio:okio:3.10.2")
|
||||
implementation("net.mamoe.yamlkt:yamlkt:0.13.0")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:1.7.3")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1")
|
||||
implementation("com.mayakapps.kache:kache:2.1.0")
|
||||
|
||||
|
||||
@@ -51,7 +51,6 @@ class Keybinding @AWTThread constructor(val server: VRServer) : HotkeyListener {
|
||||
}
|
||||
}
|
||||
|
||||
@AWTThread
|
||||
override fun onHotKey(identifier: Int) {
|
||||
when (identifier) {
|
||||
FULL_RESET -> server.scheduleResetTrackersFull(RESET_SOURCE_NAME, config.fullResetDelay)
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package dev.slimevr.config
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
class AutoBoneConfig {
|
||||
var cursorIncrement = 2
|
||||
var minDataDistance = 1
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
package dev.slimevr.config;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.StdKeySerializers;
|
||||
import dev.slimevr.config.serializers.BooleanMapDeserializer;
|
||||
import dev.slimevr.tracking.trackers.TrackerRole;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class BridgeConfig {
|
||||
|
||||
@JsonDeserialize(using = BooleanMapDeserializer.class)
|
||||
@JsonSerialize(keyUsing = StdKeySerializers.StringKeySerializer.class)
|
||||
public Map<String, Boolean> trackers = new HashMap<>();
|
||||
public boolean automaticSharedTrackersToggling = true;
|
||||
|
||||
public BridgeConfig() {
|
||||
}
|
||||
|
||||
public boolean getBridgeTrackerRole(TrackerRole role, boolean def) {
|
||||
return trackers.getOrDefault(role.name().toLowerCase(), def);
|
||||
}
|
||||
|
||||
public void setBridgeTrackerRole(TrackerRole role, boolean val) {
|
||||
this.trackers.put(role.name().toLowerCase(), val);
|
||||
}
|
||||
|
||||
public Map<String, Boolean> getTrackers() {
|
||||
return trackers;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package dev.slimevr.config
|
||||
|
||||
import dev.slimevr.tracking.trackers.TrackerRole
|
||||
import kotlinx.serialization.Serializable
|
||||
import java.util.*
|
||||
|
||||
@Serializable
|
||||
class BridgeConfig {
|
||||
var trackers: MutableMap<String, Boolean> = HashMap<String, Boolean>()
|
||||
var automaticSharedTrackersToggling: Boolean = true
|
||||
|
||||
fun getBridgeTrackerRole(role: TrackerRole, def: Boolean): Boolean = trackers.getOrDefault(role.name.lowercase(Locale.getDefault()), def)!!
|
||||
|
||||
fun setBridgeTrackerRole(role: TrackerRole, `val`: Boolean) {
|
||||
this.trackers[role.name.lowercase(Locale.getDefault())] = `val`
|
||||
}
|
||||
}
|
||||
@@ -1,176 +0,0 @@
|
||||
package dev.slimevr.config;
|
||||
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
|
||||
import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator;
|
||||
import com.github.jonpeterson.jackson.module.versioning.VersioningModule;
|
||||
import dev.slimevr.config.serializers.QuaternionDeserializer;
|
||||
import dev.slimevr.config.serializers.QuaternionSerializer;
|
||||
import io.eiren.util.ann.ThreadSafe;
|
||||
import io.eiren.util.logging.LogManager;
|
||||
import io.github.axisangles.ktmath.ObjectQuaternion;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.*;
|
||||
import java.util.Comparator;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
|
||||
public class ConfigManager {
|
||||
|
||||
private final String configPath;
|
||||
|
||||
private final ObjectMapper om;
|
||||
|
||||
private VRConfig vrConfig;
|
||||
|
||||
|
||||
public ConfigManager(String configPath) {
|
||||
this.configPath = configPath;
|
||||
om = new ObjectMapper(new YAMLFactory().disable(YAMLGenerator.Feature.SPLIT_LINES));
|
||||
om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
om.registerModule(new VersioningModule());
|
||||
SimpleModule quaternionModule = new SimpleModule();
|
||||
quaternionModule.addSerializer(ObjectQuaternion.class, new QuaternionSerializer());
|
||||
quaternionModule.addDeserializer(ObjectQuaternion.class, new QuaternionDeserializer());
|
||||
om.registerModule(quaternionModule);
|
||||
}
|
||||
|
||||
public void loadConfig() {
|
||||
try {
|
||||
this.vrConfig = om
|
||||
.readValue(new FileInputStream(configPath), VRConfig.class);
|
||||
} catch (FileNotFoundException e) {
|
||||
// Config file didn't exist, is not an error
|
||||
} catch (IOException e) {
|
||||
// Log the exception
|
||||
LogManager.severe("Config failed to load: " + e);
|
||||
// Make a backup of the erroneous config
|
||||
backupConfig();
|
||||
}
|
||||
|
||||
if (this.vrConfig == null) {
|
||||
this.vrConfig = new VRConfig();
|
||||
}
|
||||
}
|
||||
|
||||
static public void atomicMove(Path from, Path to) throws IOException {
|
||||
try {
|
||||
// Atomic move to overwrite
|
||||
Files.move(from, to, StandardCopyOption.ATOMIC_MOVE);
|
||||
} catch (AtomicMoveNotSupportedException | FileAlreadyExistsException e) {
|
||||
// Atomic move not supported or does not replace, try just replacing
|
||||
Files.move(from, to, StandardCopyOption.REPLACE_EXISTING);
|
||||
}
|
||||
}
|
||||
|
||||
public void backupConfig() {
|
||||
Path cfgFile = Paths.get(configPath);
|
||||
Path tmpBakCfgFile = Paths.get(configPath + ".bak.tmp");
|
||||
Path bakCfgFile = Paths.get(configPath + ".bak");
|
||||
|
||||
try {
|
||||
Files
|
||||
.copy(
|
||||
cfgFile,
|
||||
tmpBakCfgFile,
|
||||
StandardCopyOption.REPLACE_EXISTING,
|
||||
StandardCopyOption.COPY_ATTRIBUTES
|
||||
);
|
||||
LogManager.info("Made a backup copy of config to \"" + tmpBakCfgFile + "\"");
|
||||
} catch (IOException e) {
|
||||
LogManager
|
||||
.severe(
|
||||
"Unable to make backup copy of config from \""
|
||||
+ cfgFile
|
||||
+ "\" to \""
|
||||
+ tmpBakCfgFile
|
||||
+ "\"",
|
||||
e
|
||||
);
|
||||
return; // Abort write
|
||||
}
|
||||
|
||||
try {
|
||||
atomicMove(tmpBakCfgFile, bakCfgFile);
|
||||
} catch (IOException e) {
|
||||
LogManager
|
||||
.severe(
|
||||
"Unable to move backup config from \""
|
||||
+ tmpBakCfgFile
|
||||
+ "\" to \""
|
||||
+ bakCfgFile
|
||||
+ "\"",
|
||||
e
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ThreadSafe
|
||||
public synchronized void saveConfig() {
|
||||
Path tmpCfgFile = Paths.get(configPath + ".tmp");
|
||||
Path cfgFile = Paths.get(configPath);
|
||||
|
||||
// Serialize config
|
||||
try {
|
||||
// delete accidental folder caused by PR
|
||||
// https://github.com/SlimeVR/SlimeVR-Server/pull/1176
|
||||
var cfgFileMaybeFolder = cfgFile.toFile();
|
||||
if (cfgFileMaybeFolder.isDirectory()) {
|
||||
try (Stream<Path> pathStream = Files.walk(cfgFile)) {
|
||||
// Can't use .toList() on Android
|
||||
var list = pathStream
|
||||
.sorted(Comparator.reverseOrder())
|
||||
.collect(Collectors.toList());
|
||||
for (var path : list) {
|
||||
Files.delete(path);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
LogManager
|
||||
.severe(
|
||||
"Unable to delete folder that has same name as the config file on path \""
|
||||
+ cfgFile
|
||||
+ "\""
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
var cfgFolder = cfgFile.toAbsolutePath().getParent().toFile();
|
||||
if (!cfgFolder.exists() && !cfgFolder.mkdirs()) {
|
||||
LogManager
|
||||
.severe("Unable to create folders for config on path \"" + cfgFile + "\"");
|
||||
return;
|
||||
}
|
||||
om.writeValue(tmpCfgFile.toFile(), this.vrConfig);
|
||||
} catch (IOException e) {
|
||||
LogManager.severe("Unable to write serialized config to \"" + tmpCfgFile + "\"", e);
|
||||
return; // Abort write
|
||||
}
|
||||
|
||||
// Overwrite old config
|
||||
try {
|
||||
atomicMove(tmpCfgFile, cfgFile);
|
||||
} catch (IOException e) {
|
||||
LogManager
|
||||
.severe(
|
||||
"Unable to move new config from \"" + tmpCfgFile + "\" to \"" + cfgFile + "\"",
|
||||
e
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public void resetConfig() {
|
||||
this.vrConfig = new VRConfig();
|
||||
saveConfig();
|
||||
}
|
||||
|
||||
public VRConfig getVrConfig() {
|
||||
return vrConfig;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,342 @@
|
||||
package dev.slimevr.config
|
||||
|
||||
import io.eiren.util.ann.ThreadSafe
|
||||
import io.eiren.util.logging.LogManager
|
||||
import net.mamoe.yamlkt.Yaml
|
||||
import net.mamoe.yamlkt.YamlElement
|
||||
import net.mamoe.yamlkt.YamlList
|
||||
import net.mamoe.yamlkt.YamlLiteral
|
||||
import net.mamoe.yamlkt.YamlMap
|
||||
import okio.FileSystem
|
||||
import okio.Path.Companion.toPath
|
||||
import java.io.IOException
|
||||
import java.nio.file.AtomicMoveNotSupportedException
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.Paths
|
||||
import java.nio.file.StandardCopyOption
|
||||
import java.util.regex.Pattern
|
||||
import kotlin.io.FileAlreadyExistsException
|
||||
|
||||
// The yaml object api is very primitive as it is normally supposed to be only used by kotlinx.serialization
|
||||
// ive added some extensions to make our lives easier
|
||||
private fun YamlMap.toMutable() = this.entries.associate { it.key to it.value }.toMutableMap()
|
||||
|
||||
private operator fun Map<YamlElement, YamlElement>.get(key: String): YamlElement? = this[YamlLiteral(key)]
|
||||
|
||||
private operator fun MutableMap<YamlElement, YamlElement>.set(key: String, value: Any?) {
|
||||
if (value == null) {
|
||||
this.remove(key)
|
||||
return
|
||||
}
|
||||
this[YamlLiteral(key)] = when (value) {
|
||||
is YamlElement -> value
|
||||
is Number, is Boolean -> YamlLiteral(value.toString())
|
||||
else -> YamlLiteral(value.toString())
|
||||
}
|
||||
}
|
||||
|
||||
private fun MutableMap<YamlElement, YamlElement>.remove(key: String) = this.remove(YamlLiteral(key))
|
||||
|
||||
private fun YamlElement?.asFloat(default: Float = 0f): Float = (this as? YamlLiteral)?.content?.toFloatOrNull() ?: default
|
||||
private fun YamlElement?.asInt(default: Int = 0): Int = (this as? YamlLiteral)?.content?.toIntOrNull() ?: default
|
||||
|
||||
private fun MutableMap<YamlElement, YamlElement>.updateMap(key: String, block: MutableMap<YamlElement, YamlElement>.() -> Unit) {
|
||||
val nestedMap = (this[YamlLiteral(key)] as? YamlMap)?.toMutable() ?: mutableMapOf()
|
||||
nestedMap.block()
|
||||
this[YamlLiteral(key)] = YamlMap(nestedMap)
|
||||
}
|
||||
|
||||
fun migrateYamlConfig(modelData: YamlMap, version: Int): YamlMap {
|
||||
val config = modelData.toMutable()
|
||||
|
||||
try {
|
||||
if (version < 7) error("Config version $version is too old to be migrated.")
|
||||
|
||||
if (version < 8) {
|
||||
config.updateMap("keybindings") {
|
||||
val renaming = mapOf(
|
||||
"resetBinding" to "fullResetBinding",
|
||||
"quickResetBinding" to "yawResetBinding",
|
||||
"resetMountingBinding" to "mountingResetBinding",
|
||||
"resetDelay" to "fullResetDelay",
|
||||
"quickResetDelay" to "yawResetDelay",
|
||||
"resetMountingDelay" to "mountingResetDelay",
|
||||
)
|
||||
renaming.forEach { (old, new) ->
|
||||
this[old]?.let { value ->
|
||||
this[new] = value
|
||||
remove(old)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
config.updateMap("tapDetection") {
|
||||
listOf(
|
||||
"quickResetDelay" to "yawResetDelay",
|
||||
"resetDelay" to "fullResetDelay",
|
||||
"quickResetEnabled" to "yawResetEnabled",
|
||||
"resetEnabled" to "fullResetEnabled",
|
||||
"quickResetTaps" to "yawResetTaps",
|
||||
"resetTaps" to "fullResetTaps",
|
||||
).forEach { (old, new) ->
|
||||
this[old]?.let { this[new] = it }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (version < 9) {
|
||||
config.updateMap("skeleton") {
|
||||
this.updateMap("offsets") {
|
||||
this["chestLength"] = this["chestLength"].asFloat() / 2f
|
||||
this["upperChestLength"] = this["chestLength"].asFloat() / 2f
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (version < 10) {
|
||||
// Change default AutoBone recording length from 20 to 30
|
||||
// seconds
|
||||
config.updateMap("autoBone") {
|
||||
if (this["sampleCount"].asInt() == 1000) {
|
||||
this["sampleCount"] = 1500
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (version < 11) {
|
||||
config.updateMap("trackers") {
|
||||
updateMap("HMD") {
|
||||
this["designation"] = "body:head"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (version < 12) {
|
||||
// Update AutoBone defaults
|
||||
config.updateMap("autoBone") {
|
||||
if (this["offsetSlideErrorFactor"].asFloat() == 2.0f) {
|
||||
this["offsetSlideErrorFactor"] = 1f
|
||||
}
|
||||
if (this["bodyProportionErrorFactor"].asFloat() == 0.825f) {
|
||||
this["bodyProportionErrorFactor"] = 0.25f
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (version < 13) {
|
||||
config.updateMap("trackers") {
|
||||
val macAddressRegex = "udp://((?:[a-zA-Z\\d]{2}:){5}[a-zA-Z\\d]{2})/0"
|
||||
val pattern: Pattern = Pattern.compile(macAddressRegex)
|
||||
val devices = (config["knownDevices"] as? YamlList)?.toMutableList() ?: ArrayList()
|
||||
this.keys.forEach {
|
||||
val trackerId = it.toString()
|
||||
val matcher = pattern.matcher(trackerId)
|
||||
if (matcher.find()) {
|
||||
devices.add(YamlLiteral(matcher.group(1)))
|
||||
}
|
||||
}
|
||||
config["knownDevices"] = YamlList(devices)
|
||||
}
|
||||
}
|
||||
|
||||
if (version < 14) {
|
||||
val autoBone = config["autoBone"] as? YamlMap
|
||||
if (autoBone != null) {
|
||||
// Move HMD height from AutoBone to Skeleton
|
||||
autoBone["targetHmdHeight"]?.let { height ->
|
||||
config.updateMap("skeleton") {
|
||||
this["hmdHeight"] = height
|
||||
}
|
||||
}
|
||||
|
||||
config.updateMap("autoBone") {
|
||||
if (this["offsetSlideErrorFactor"].asFloat() == 1.0f && this["slideErrorFactor"].asFloat() == 0.0f) {
|
||||
this["offsetSlideErrorFactor"] = 0.0f
|
||||
this["slideErrorFactor"] = 1.0f
|
||||
}
|
||||
if (this["bodyProportionErrorFactor"].asFloat() == 0.25f) {
|
||||
this["bodyProportionErrorFactor"] = 0.05f
|
||||
}
|
||||
if (this["numEpochs"].asInt() == 100) {
|
||||
this["numEpochs"] = 50
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (version < 15) {
|
||||
config.updateMap("trackingChecklist") {
|
||||
this["ignoredStepsIds"] = null
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
error("Migration error: ${e.message}")
|
||||
}
|
||||
|
||||
config["modelVersion"] = VRConfig.CONFIG_VERSION.toString()
|
||||
|
||||
return YamlMap(config)
|
||||
}
|
||||
|
||||
fun fixTrackerKeys(input: String): String {
|
||||
val regex = """^(\s*)(udp://.*):(\s*)$""".toRegex(RegexOption.MULTILINE)
|
||||
|
||||
return input.replace(regex) { match ->
|
||||
val indent = match.groupValues[1]
|
||||
val keyPart = match.groupValues[2]
|
||||
val trailing = match.groupValues[3]
|
||||
"""$indent"$keyPart":$trailing"""
|
||||
}
|
||||
}
|
||||
|
||||
class ConfigManager(private val configPath: String) {
|
||||
lateinit var vrConfig: VRConfig
|
||||
private set
|
||||
|
||||
val tmpCfgFile = Paths.get("$configPath.tmp")!!
|
||||
val cfgFile = Paths.get(configPath)!!
|
||||
|
||||
fun handleMigrations() {
|
||||
val configString = FileSystem.SYSTEM.read(configPath.toPath()) {
|
||||
readUtf8()
|
||||
}
|
||||
val cleanedYaml = configString
|
||||
.removePrefix("---")
|
||||
.trim()
|
||||
val quotedYaml = fixTrackerKeys(cleanedYaml)
|
||||
val configRoot = Yaml.decodeYamlFromString(quotedYaml) as YamlMap
|
||||
|
||||
val currentVersion = configRoot["modelVersion"].toString().toIntOrNull() ?: error("unable to get config version")
|
||||
if (currentVersion < VRConfig.CONFIG_VERSION) {
|
||||
backupConfig(".v$currentVersion")
|
||||
|
||||
LogManager.info("Migrating config from version \"$currentVersion\" to \"${VRConfig.CONFIG_VERSION}\"")
|
||||
val migratedElement = migrateYamlConfig(configRoot, currentVersion)
|
||||
val configStr = Yaml.encodeToString(migratedElement)
|
||||
writeToTmp(configStr)
|
||||
|
||||
try {
|
||||
atomicMove(tmpCfgFile, cfgFile)
|
||||
} catch (e: IOException) {
|
||||
error(
|
||||
"Unable to move migrated config from \"$tmpCfgFile\" to \"$cfgFile\", reason: ${e.message}",
|
||||
)
|
||||
}
|
||||
LogManager.info("VRConfig migrated to the latest version \"${VRConfig.CONFIG_VERSION}\"")
|
||||
}
|
||||
}
|
||||
|
||||
fun loadConfig() {
|
||||
if (!configPath.toPath().toFile().exists()) {
|
||||
this.vrConfig = VRConfig()
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
handleMigrations()
|
||||
|
||||
val configString = FileSystem.SYSTEM.read(configPath.toPath()) {
|
||||
readUtf8()
|
||||
}
|
||||
val cleanedYaml = configString
|
||||
.removePrefix("---")
|
||||
.trim()
|
||||
val quotedYaml = fixTrackerKeys(cleanedYaml)
|
||||
this.vrConfig = Yaml.decodeFromString(VRConfig.serializer(), quotedYaml)
|
||||
} catch (e: Exception) {
|
||||
// Log the exception
|
||||
LogManager.severe("Config failed to load: $e")
|
||||
// Make a backup of the erroneous config
|
||||
backupConfig()
|
||||
this.vrConfig = VRConfig()
|
||||
}
|
||||
}
|
||||
|
||||
fun backupConfig(suffix: String = "") {
|
||||
val tmpBakCfgFile = Paths.get("$configPath$suffix.bak.tmp")
|
||||
val bakCfgFile = Paths.get("$configPath$suffix.bak")
|
||||
|
||||
try {
|
||||
Files
|
||||
.copy(
|
||||
cfgFile,
|
||||
tmpBakCfgFile,
|
||||
StandardCopyOption.REPLACE_EXISTING,
|
||||
StandardCopyOption.COPY_ATTRIBUTES,
|
||||
)
|
||||
LogManager.info("Made a backup copy of config to \"$tmpBakCfgFile\"")
|
||||
} catch (e: IOException) {
|
||||
LogManager
|
||||
.severe(
|
||||
("Unable to make backup copy of config from \"$cfgFile\" to \"$tmpBakCfgFile\""),
|
||||
e,
|
||||
)
|
||||
return // Abort write
|
||||
}
|
||||
|
||||
try {
|
||||
atomicMove(tmpBakCfgFile, bakCfgFile)
|
||||
} catch (e: IOException) {
|
||||
LogManager
|
||||
.severe(
|
||||
("Unable to move backup config from \"$tmpBakCfgFile\" to \"$bakCfgFile\""),
|
||||
e,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun writeToTmp(config: String) {
|
||||
try {
|
||||
val cfgFolder = cfgFile.toAbsolutePath().parent.toFile()
|
||||
if (!cfgFolder.exists() && !cfgFolder.mkdirs()) {
|
||||
error("Unable to create folders for config on path \"$cfgFile\"")
|
||||
}
|
||||
tmpCfgFile.toFile().writeText(config)
|
||||
} catch (e: IOException) {
|
||||
error("Unable to write serialized config to \"$tmpCfgFile\", reason: ${e.message}")
|
||||
}
|
||||
}
|
||||
|
||||
@ThreadSafe
|
||||
@Synchronized
|
||||
fun saveConfig() {
|
||||
// Serialize config
|
||||
try {
|
||||
val configStr = Yaml.encodeToString(VRConfig.serializer(), this.vrConfig)
|
||||
writeToTmp(configStr)
|
||||
} catch (e: Exception) {
|
||||
LogManager.severe("Unable to write serialized config to \"$tmpCfgFile\"", e)
|
||||
return // Abort write
|
||||
}
|
||||
|
||||
// Overwrite old config
|
||||
try {
|
||||
atomicMove(tmpCfgFile, cfgFile)
|
||||
} catch (e: IOException) {
|
||||
LogManager
|
||||
.severe(
|
||||
"Unable to move new config from \"$tmpCfgFile\" to \"$cfgFile\"",
|
||||
e,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun resetConfig() {
|
||||
this.vrConfig = VRConfig()
|
||||
saveConfig()
|
||||
}
|
||||
|
||||
@Throws(IOException::class)
|
||||
fun atomicMove(from: Path, to: Path) {
|
||||
try {
|
||||
// Atomic move to overwrite
|
||||
Files.move(from, to, StandardCopyOption.ATOMIC_MOVE)
|
||||
} catch (e: AtomicMoveNotSupportedException) {
|
||||
// Atomic move not supported or does not replace, try just replacing
|
||||
Files.move(from, to, StandardCopyOption.REPLACE_EXISTING)
|
||||
} catch (e: FileAlreadyExistsException) {
|
||||
Files.move(from, to, StandardCopyOption.REPLACE_EXISTING)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,357 +0,0 @@
|
||||
package dev.slimevr.config;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.node.*;
|
||||
import com.github.jonpeterson.jackson.module.versioning.VersionedModelConverter;
|
||||
import dev.slimevr.tracking.processor.config.SkeletonConfigOffsets;
|
||||
import dev.slimevr.tracking.trackers.TrackerPosition;
|
||||
import io.eiren.util.logging.LogManager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
||||
public class CurrentVRConfigConverter implements VersionedModelConverter {
|
||||
|
||||
@Override
|
||||
public ObjectNode convert(
|
||||
ObjectNode modelData,
|
||||
String modelVersion,
|
||||
String targetModelVersion,
|
||||
JsonNodeFactory nodeFactory
|
||||
) {
|
||||
try {
|
||||
int version = Integer.parseInt(modelVersion);
|
||||
|
||||
// Configs with old versions need a migration to the latest config
|
||||
if (version < 2) {
|
||||
// Move zoom to the window config
|
||||
ObjectNode windowNode = (ObjectNode) modelData.get("window");
|
||||
DoubleNode zoomNode = (DoubleNode) modelData.get("zoom");
|
||||
if (windowNode != null && zoomNode != null) {
|
||||
windowNode.set("zoom", zoomNode);
|
||||
modelData.remove("zoom");
|
||||
}
|
||||
|
||||
// Change trackers list to map
|
||||
ArrayNode oldTrackersNode = modelData.withArray("trackers");
|
||||
if (oldTrackersNode != null) {
|
||||
var trackersIter = oldTrackersNode.iterator();
|
||||
ObjectNode trackersNode = nodeFactory.objectNode();
|
||||
while (trackersIter.hasNext()) {
|
||||
JsonNode node = trackersIter.next();
|
||||
JsonNode resultNode = TrackerConfig.toV2(node, nodeFactory);
|
||||
trackersNode.set(node.get("name").asText(), resultNode);
|
||||
}
|
||||
modelData.set("trackers", trackersNode);
|
||||
}
|
||||
|
||||
// Rename bridge to bridges
|
||||
ObjectNode bridgeNode = (ObjectNode) modelData.get("bridge");
|
||||
if (bridgeNode != null) {
|
||||
modelData.set("bridges", bridgeNode);
|
||||
modelData.remove("bridge");
|
||||
}
|
||||
|
||||
// Move body to skeleton (and merge it to current skeleton)
|
||||
ObjectNode bodyNode = (ObjectNode) modelData.get("body");
|
||||
if (bodyNode != null) {
|
||||
var bodyIter = bodyNode.fields();
|
||||
ObjectNode skeletonNode = (ObjectNode) modelData.get("skeleton");
|
||||
if (skeletonNode == null) {
|
||||
skeletonNode = nodeFactory.objectNode();
|
||||
}
|
||||
|
||||
ObjectNode offsetsNode = nodeFactory.objectNode();
|
||||
while (bodyIter.hasNext()) {
|
||||
Map.Entry<String, JsonNode> node = bodyIter.next();
|
||||
// Filter only number values because other types would
|
||||
// be stuff that didn't get migrated correctly before
|
||||
if (node.getValue().isNumber()) {
|
||||
offsetsNode.set(node.getKey(), node.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
// Fix calibration wolf typos
|
||||
offsetsNode.set("shouldersWidth", bodyNode.get("shoulersWidth"));
|
||||
offsetsNode.set("shouldersDistance", bodyNode.get("shoulersDistance"));
|
||||
offsetsNode.remove("shoulersWidth");
|
||||
offsetsNode.remove("shoulersDistance");
|
||||
skeletonNode.set("offsets", offsetsNode);
|
||||
modelData.set("skeleton", skeletonNode);
|
||||
modelData.remove("body");
|
||||
}
|
||||
}
|
||||
if (version < 3) {
|
||||
// Check for out-of-bound filtering amount
|
||||
ObjectNode filtersNode = (ObjectNode) modelData.get("filters");
|
||||
if (filtersNode != null && filtersNode.get("amount").floatValue() > 2f) {
|
||||
filtersNode.set("amount", new FloatNode(0.2f));
|
||||
}
|
||||
}
|
||||
if (version < 4) {
|
||||
// Change mountingRotation to mountingOrientation
|
||||
ObjectNode oldTrackersNode = (ObjectNode) modelData.get("trackers");
|
||||
if (oldTrackersNode != null) {
|
||||
var trackersIter = oldTrackersNode.iterator();
|
||||
var fieldNamesIter = oldTrackersNode.fieldNames();
|
||||
ObjectNode trackersNode = nodeFactory.objectNode();
|
||||
String fieldName;
|
||||
while (trackersIter.hasNext()) {
|
||||
ObjectNode node = (ObjectNode) trackersIter.next();
|
||||
fieldName = fieldNamesIter.next();
|
||||
node.set("mountingOrientation", node.get("mountingRotation"));
|
||||
node.remove("mountingRotation");
|
||||
trackersNode.set(fieldName, node);
|
||||
}
|
||||
modelData.set("trackers", trackersNode);
|
||||
}
|
||||
}
|
||||
if (version < 5) {
|
||||
// Migrate old skeleton offsets to new ones
|
||||
ObjectNode skeletonNode = (ObjectNode) modelData.get("skeleton");
|
||||
if (skeletonNode != null) {
|
||||
ObjectNode offsetsNode = (ObjectNode) skeletonNode.get("offsets");
|
||||
if (offsetsNode != null) {
|
||||
// torsoLength, chestDistance and waistDistance become
|
||||
// chestLength, waistLength and hipLength.
|
||||
float torsoLength = SkeletonConfigOffsets.CHEST.defaultValue
|
||||
+ SkeletonConfigOffsets.WAIST.defaultValue
|
||||
+ SkeletonConfigOffsets.HIP.defaultValue;
|
||||
float chestDistance = SkeletonConfigOffsets.CHEST.defaultValue;
|
||||
float waistDistance = SkeletonConfigOffsets.HIP.defaultValue;
|
||||
JsonNode torsoNode = offsetsNode.get("torsoLength");
|
||||
if (torsoNode != null)
|
||||
torsoLength = torsoNode.floatValue();
|
||||
JsonNode chestNode = offsetsNode.get("chestDistance");
|
||||
if (chestNode != null)
|
||||
chestDistance = chestNode.floatValue();
|
||||
JsonNode waistNode = offsetsNode.get("waistDistance");
|
||||
if (waistNode != null)
|
||||
waistDistance = waistNode.floatValue();
|
||||
offsetsNode.set("chestLength", offsetsNode.get("chestDistance"));
|
||||
offsetsNode
|
||||
.set(
|
||||
"waistLength",
|
||||
new FloatNode(torsoLength - chestDistance - waistDistance)
|
||||
);
|
||||
offsetsNode.set("hipLength", offsetsNode.get("waistDistance"));
|
||||
offsetsNode.remove("torsoLength");
|
||||
offsetsNode.remove("chestDistance");
|
||||
offsetsNode.remove("waistDistance");
|
||||
|
||||
// legsLength and kneeHeight become
|
||||
// upperLegLength and lowerLegLength
|
||||
float legsLength = SkeletonConfigOffsets.UPPER_LEG.defaultValue
|
||||
+ SkeletonConfigOffsets.LOWER_LEG.defaultValue;
|
||||
float kneeHeight = SkeletonConfigOffsets.LOWER_LEG.defaultValue;
|
||||
JsonNode legsNode = offsetsNode.get("legsLength");
|
||||
if (legsNode != null)
|
||||
legsLength = legsNode.floatValue();
|
||||
JsonNode kneesNode = offsetsNode.get("kneeHeight");
|
||||
if (kneesNode != null)
|
||||
kneeHeight = kneesNode.floatValue();
|
||||
offsetsNode.set("upperLegLength", new FloatNode(legsLength - kneeHeight));
|
||||
offsetsNode.set("lowerLegLength", new FloatNode(kneeHeight));
|
||||
offsetsNode.remove("legsLength");
|
||||
offsetsNode.remove("kneeHeight");
|
||||
|
||||
skeletonNode.set("offsets", offsetsNode);
|
||||
modelData.set("skeleton", skeletonNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (version < 6) {
|
||||
// Migrate controllers offsets to hands offsets
|
||||
ObjectNode skeletonNode = (ObjectNode) modelData.get("skeleton");
|
||||
if (skeletonNode != null) {
|
||||
ObjectNode offsetsNode = (ObjectNode) skeletonNode.get("offsets");
|
||||
if (offsetsNode != null) {
|
||||
offsetsNode.set("handDistanceY", offsetsNode.get("controllerDistanceY"));
|
||||
offsetsNode.set("handDistanceZ", offsetsNode.get("controllerDistanceZ"));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (version < 7) {
|
||||
// Chest, hip, and elbow offsets now go the opposite direction
|
||||
ObjectNode skeletonNode = (ObjectNode) modelData.get("skeleton");
|
||||
if (skeletonNode != null) {
|
||||
ObjectNode offsetsNode = (ObjectNode) skeletonNode.get("offsets");
|
||||
if (offsetsNode != null) {
|
||||
JsonNode chestNode = offsetsNode.get("chestOffset");
|
||||
if (chestNode != null)
|
||||
offsetsNode.set("chestOffset", new FloatNode(-chestNode.floatValue()));
|
||||
JsonNode hipNode = offsetsNode.get("hipOffset");
|
||||
if (hipNode != null)
|
||||
offsetsNode.set("hipOffset", new FloatNode(-hipNode.floatValue()));
|
||||
JsonNode elbowNode = offsetsNode.get("elbowOffset");
|
||||
if (elbowNode != null)
|
||||
offsetsNode.set("elbowOffset", new FloatNode(-elbowNode.floatValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (version < 8) {
|
||||
// reset > fullReset, quickReset > yawReset
|
||||
ObjectNode keybindingsNode = (ObjectNode) modelData.get("keybindings");
|
||||
if (keybindingsNode != null) {
|
||||
JsonNode fullResetNode = keybindingsNode.get("resetBinding");
|
||||
if (fullResetNode != null)
|
||||
keybindingsNode.set("fullResetBinding", fullResetNode);
|
||||
JsonNode yawResetNode = keybindingsNode.get("quickResetBinding");
|
||||
if (yawResetNode != null)
|
||||
keybindingsNode.set("yawResetBinding", yawResetNode);
|
||||
JsonNode mountingResetNode = keybindingsNode.get("resetMountingBinding");
|
||||
if (mountingResetNode != null)
|
||||
keybindingsNode.set("mountingResetBinding", mountingResetNode);
|
||||
|
||||
JsonNode fullDelayNode = keybindingsNode.get("resetDelay");
|
||||
if (fullDelayNode != null)
|
||||
keybindingsNode.set("fullResetDelay", fullDelayNode);
|
||||
JsonNode yawDelayNode = keybindingsNode.get("quickResetDelay");
|
||||
if (yawDelayNode != null)
|
||||
keybindingsNode.set("yawResetDelay", yawDelayNode);
|
||||
JsonNode mountingDelayNode = keybindingsNode.get("resetMountingDelay");
|
||||
if (mountingDelayNode != null)
|
||||
keybindingsNode.set("mountingResetDelay", mountingDelayNode);
|
||||
}
|
||||
|
||||
ObjectNode tapDetectionNode = (ObjectNode) modelData.get("tapDetection");
|
||||
if (tapDetectionNode != null) {
|
||||
tapDetectionNode.set("yawResetDelay", tapDetectionNode.get("quickResetDelay"));
|
||||
tapDetectionNode.set("fullResetDelay", tapDetectionNode.get("resetDelay"));
|
||||
tapDetectionNode
|
||||
.set("yawResetEnabled", tapDetectionNode.get("quickResetEnabled"));
|
||||
tapDetectionNode.set("fullResetEnabled", tapDetectionNode.get("resetEnabled"));
|
||||
tapDetectionNode.set("yawResetTaps", tapDetectionNode.get("quickResetTaps"));
|
||||
tapDetectionNode.set("fullResetTaps", tapDetectionNode.get("resetTaps"));
|
||||
}
|
||||
}
|
||||
if (version < 9) {
|
||||
// split chest into 2 offsets
|
||||
ObjectNode skeletonNode = (ObjectNode) modelData.get("skeleton");
|
||||
if (skeletonNode != null) {
|
||||
ObjectNode offsetsNode = (ObjectNode) skeletonNode.get("offsets");
|
||||
if (offsetsNode != null) {
|
||||
JsonNode chestNode = offsetsNode.get("chestLength");
|
||||
if (chestNode != null) {
|
||||
offsetsNode
|
||||
.set("chestLength", new FloatNode(chestNode.floatValue() / 2f));
|
||||
offsetsNode
|
||||
.set(
|
||||
"upperChestLength",
|
||||
new FloatNode(chestNode.floatValue() / 2f)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (version < 10) {
|
||||
// Change default AutoBone recording length from 20 to 30
|
||||
// seconds
|
||||
ObjectNode autoBoneNode = (ObjectNode) modelData.get("autoBone");
|
||||
if (autoBoneNode != null) {
|
||||
JsonNode sampleCountNode = autoBoneNode.get("sampleCount");
|
||||
if (sampleCountNode != null && sampleCountNode.intValue() == 1000) {
|
||||
autoBoneNode.set("sampleCount", new IntNode(1500));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (version < 11) {
|
||||
// Sets HMD's designation to "body:head"
|
||||
ObjectNode trackersNode = (ObjectNode) modelData.get("trackers");
|
||||
if (trackersNode != null) {
|
||||
ObjectNode HMDNode = (ObjectNode) trackersNode.get("HMD");
|
||||
if (HMDNode != null) {
|
||||
HMDNode
|
||||
.set(
|
||||
"designation",
|
||||
new TextNode(TrackerPosition.HEAD.getDesignation())
|
||||
);
|
||||
trackersNode.set("HMD", HMDNode);
|
||||
modelData.set("trackers", trackersNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (version < 12) {
|
||||
// Update AutoBone defaults
|
||||
ObjectNode autoBoneNode = (ObjectNode) modelData.get("autoBone");
|
||||
if (autoBoneNode != null) {
|
||||
JsonNode offsetSlideNode = autoBoneNode.get("offsetSlideErrorFactor");
|
||||
if (offsetSlideNode != null && offsetSlideNode.floatValue() == 2.0f) {
|
||||
autoBoneNode.set("offsetSlideErrorFactor", new FloatNode(1.0f));
|
||||
}
|
||||
JsonNode bodyProportionsNode = autoBoneNode.get("bodyProportionErrorFactor");
|
||||
if (bodyProportionsNode != null && bodyProportionsNode.floatValue() == 0.825f) {
|
||||
autoBoneNode.set("bodyProportionErrorFactor", new FloatNode(0.25f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (version < 13) {
|
||||
ObjectNode oldTrackersNode = (ObjectNode) modelData.get("trackers");
|
||||
if (oldTrackersNode != null) {
|
||||
var fieldNamesIter = oldTrackersNode.fieldNames();
|
||||
String trackerId;
|
||||
final String macAddressRegex = "udp://((?:[a-zA-Z\\d]{2}:){5}[a-zA-Z\\d]{2})/0";
|
||||
final Pattern pattern = Pattern.compile(macAddressRegex);
|
||||
while (fieldNamesIter.hasNext()) {
|
||||
trackerId = fieldNamesIter.next();
|
||||
var matcher = pattern.matcher(trackerId);
|
||||
if (!matcher.find())
|
||||
continue;
|
||||
|
||||
modelData.withArray("knownDevices").add(matcher.group(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (version < 14) {
|
||||
// Update AutoBone defaults
|
||||
ObjectNode autoBoneNode = (ObjectNode) modelData.get("autoBone");
|
||||
if (autoBoneNode != null) {
|
||||
// Move HMD height to skeleton
|
||||
ObjectNode skeletonNode = (ObjectNode) modelData.get("skeleton");
|
||||
if (skeletonNode != null) {
|
||||
JsonNode targetHmdHeight = autoBoneNode.get("targetHmdHeight");
|
||||
if (targetHmdHeight != null) {
|
||||
skeletonNode.set("hmdHeight", targetHmdHeight);
|
||||
}
|
||||
}
|
||||
|
||||
JsonNode offsetSlideNode = autoBoneNode.get("offsetSlideErrorFactor");
|
||||
JsonNode slideNode = autoBoneNode.get("slideErrorFactor");
|
||||
if (
|
||||
offsetSlideNode != null
|
||||
&& slideNode != null
|
||||
&& offsetSlideNode.floatValue() == 1.0f
|
||||
&& slideNode.floatValue() == 0.0f
|
||||
) {
|
||||
autoBoneNode.set("offsetSlideErrorFactor", new FloatNode(0.0f));
|
||||
autoBoneNode.set("slideErrorFactor", new FloatNode(1.0f));
|
||||
}
|
||||
JsonNode bodyProportionsNode = autoBoneNode.get("bodyProportionErrorFactor");
|
||||
if (bodyProportionsNode != null && bodyProportionsNode.floatValue() == 0.25f) {
|
||||
autoBoneNode.set("bodyProportionErrorFactor", new FloatNode(0.05f));
|
||||
}
|
||||
JsonNode numEpochsNode = autoBoneNode.get("numEpochs");
|
||||
if (numEpochsNode != null && numEpochsNode.intValue() == 100) {
|
||||
autoBoneNode.set("numEpochs", new IntNode(50));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (version < 15) {
|
||||
ObjectNode checklistNode = (ObjectNode) modelData.get("trackingChecklist");
|
||||
if (checklistNode != null) {
|
||||
ArrayNode ignoredStepsArray = (ArrayNode) checklistNode.get("ignoredStepsIds");
|
||||
if (ignoredStepsArray != null)
|
||||
ignoredStepsArray.removeAll();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogManager.severe("Error during config migration: " + e);
|
||||
}
|
||||
|
||||
return modelData;
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package dev.slimevr.config
|
||||
|
||||
import dev.slimevr.VRServer
|
||||
|
||||
class DriftCompensationConfig {
|
||||
|
||||
// Is drift compensation enabled
|
||||
var enabled = false
|
||||
|
||||
// Is drift prediction enabled
|
||||
var prediction = false
|
||||
|
||||
// Amount of drift compensation applied
|
||||
var amount = 0.8f
|
||||
|
||||
// Max resets for the calculated average drift
|
||||
var maxResets = 6
|
||||
|
||||
fun updateTrackersDriftCompensation() {
|
||||
for (t in VRServer.instance.allTrackers) {
|
||||
if (t.isImu()) {
|
||||
t.resetsHandler.readDriftCompensationConfig(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
package dev.slimevr.config
|
||||
|
||||
import dev.slimevr.VRServer
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
class FiltersConfig {
|
||||
|
||||
// Type of filtering applied (none, smoothing or prediction)
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
package dev.slimevr.config;
|
||||
|
||||
public class KeybindingsConfig {
|
||||
|
||||
private String fullResetBinding = "CTRL+ALT+SHIFT+Y";
|
||||
|
||||
private String yawResetBinding = "CTRL+ALT+SHIFT+U";
|
||||
|
||||
private String mountingResetBinding = "CTRL+ALT+SHIFT+I";
|
||||
|
||||
private String pauseTrackingBinding = "CTRL+ALT+SHIFT+O";
|
||||
|
||||
private long fullResetDelay = 0L;
|
||||
|
||||
private long yawResetDelay = 0L;
|
||||
|
||||
private long mountingResetDelay = 0L;
|
||||
|
||||
private long pauseTrackingDelay = 0L;
|
||||
|
||||
|
||||
public KeybindingsConfig() {
|
||||
}
|
||||
|
||||
public String getFullResetBinding() {
|
||||
return fullResetBinding;
|
||||
}
|
||||
|
||||
public String getYawResetBinding() {
|
||||
return yawResetBinding;
|
||||
}
|
||||
|
||||
public String getMountingResetBinding() {
|
||||
return mountingResetBinding;
|
||||
}
|
||||
|
||||
public String getPauseTrackingBinding() {
|
||||
return pauseTrackingBinding;
|
||||
}
|
||||
|
||||
public long getFullResetDelay() {
|
||||
return fullResetDelay;
|
||||
}
|
||||
|
||||
public void setFullResetDelay(long delay) {
|
||||
fullResetDelay = delay;
|
||||
}
|
||||
|
||||
public long getYawResetDelay() {
|
||||
return yawResetDelay;
|
||||
}
|
||||
|
||||
public void setYawResetDelay(long delay) {
|
||||
yawResetDelay = delay;
|
||||
}
|
||||
|
||||
public long getMountingResetDelay() {
|
||||
return mountingResetDelay;
|
||||
}
|
||||
|
||||
public void setMountingResetDelay(long delay) {
|
||||
mountingResetDelay = delay;
|
||||
}
|
||||
|
||||
public long getPauseTrackingDelay() {
|
||||
return pauseTrackingDelay;
|
||||
}
|
||||
|
||||
public void setPauseTrackingDelay(long delay) {
|
||||
pauseTrackingDelay = delay;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package dev.slimevr.config
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
class KeybindingsConfig {
|
||||
val fullResetBinding: String = "CTRL+ALT+SHIFT+Y"
|
||||
|
||||
val yawResetBinding: String = "CTRL+ALT+SHIFT+U"
|
||||
|
||||
val mountingResetBinding: String = "CTRL+ALT+SHIFT+I"
|
||||
|
||||
val pauseTrackingBinding: String = "CTRL+ALT+SHIFT+O"
|
||||
|
||||
var fullResetDelay: Long = 0L
|
||||
|
||||
var yawResetDelay: Long = 0L
|
||||
|
||||
var mountingResetDelay: Long = 0L
|
||||
|
||||
var pauseTrackingDelay: Long = 0L
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
package dev.slimevr.config
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
class LegTweaksConfig {
|
||||
var correctionStrength = 0.3f
|
||||
var alwaysUseFloorclip = false
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
package dev.slimevr.config
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
open class OSCConfig {
|
||||
|
||||
// Are the OSC receiver and sender enabled?
|
||||
var enabled = false
|
||||
|
||||
// Port to receive OSC messages from
|
||||
var portIn = 0
|
||||
var portIn = 9002
|
||||
|
||||
// Port to send out OSC messages at
|
||||
var portOut = 0
|
||||
var portOut = 9000
|
||||
|
||||
// Address to send out OSC messages at
|
||||
var address = "127.0.0.1"
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
package dev.slimevr.config;
|
||||
|
||||
public class OverlayConfig {
|
||||
|
||||
private boolean isMirrored = false;
|
||||
private boolean isVisible = false;
|
||||
|
||||
|
||||
public boolean isMirrored() {
|
||||
return isMirrored;
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return isVisible;
|
||||
}
|
||||
|
||||
public void setMirrored(boolean mirrored) {
|
||||
isMirrored = mirrored;
|
||||
}
|
||||
|
||||
public void setVisible(boolean visible) {
|
||||
isVisible = visible;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package dev.slimevr.config
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
class OverlayConfig {
|
||||
var isMirrored: Boolean = false
|
||||
var isVisible: Boolean = false
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package dev.slimevr.config
|
||||
|
||||
import dev.slimevr.VRServer
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
enum class ArmsResetModes(val id: Int) {
|
||||
// Upper arm going back and forearm going forward
|
||||
@@ -47,6 +48,7 @@ enum class MountingMethods(val id: Int) {
|
||||
}
|
||||
}
|
||||
|
||||
@Serializable
|
||||
class ResetsConfig {
|
||||
|
||||
// Always reset mounting for feet
|
||||
|
||||
@@ -6,13 +6,17 @@ import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.awaitAll
|
||||
import kotlinx.coroutines.coroutineScope
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.Transient
|
||||
|
||||
@Serializable
|
||||
class ServerConfig {
|
||||
val trackerPort: Int = 6969
|
||||
|
||||
var useMagnetometerOnAllTrackers: Boolean = false
|
||||
private set
|
||||
|
||||
@Transient
|
||||
private val magMutex = Mutex()
|
||||
suspend fun defineMagOnAllTrackers(state: Boolean) = coroutineScope {
|
||||
magMutex.lock()
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
package dev.slimevr.config;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.StdKeySerializers;
|
||||
import dev.slimevr.config.serializers.BooleanMapDeserializer;
|
||||
import dev.slimevr.config.serializers.FloatMapDeserializer;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class SkeletonConfig {
|
||||
|
||||
@JsonDeserialize(using = BooleanMapDeserializer.class)
|
||||
@JsonSerialize(keyUsing = StdKeySerializers.StringKeySerializer.class)
|
||||
public Map<String, Boolean> toggles = new HashMap<>();
|
||||
|
||||
@JsonDeserialize(using = FloatMapDeserializer.class)
|
||||
@JsonSerialize(keyUsing = StdKeySerializers.StringKeySerializer.class)
|
||||
public Map<String, Float> values = new HashMap<>();
|
||||
|
||||
@JsonDeserialize(using = FloatMapDeserializer.class)
|
||||
@JsonSerialize(keyUsing = StdKeySerializers.StringKeySerializer.class)
|
||||
public Map<String, Float> offsets = new HashMap<>();
|
||||
|
||||
private float hmdHeight = 0f;
|
||||
private float floorHeight = 0f;
|
||||
|
||||
public Map<String, Boolean> getToggles() {
|
||||
return toggles;
|
||||
}
|
||||
|
||||
public Map<String, Float> getOffsets() {
|
||||
return offsets;
|
||||
}
|
||||
|
||||
public Map<String, Float> getValues() {
|
||||
return values;
|
||||
}
|
||||
|
||||
public float getHmdHeight() {
|
||||
return hmdHeight;
|
||||
}
|
||||
|
||||
public void setHmdHeight(float hmdHeight) {
|
||||
this.hmdHeight = hmdHeight;
|
||||
}
|
||||
|
||||
public float getFloorHeight() {
|
||||
return floorHeight;
|
||||
}
|
||||
|
||||
public void setFloorHeight(float hmdHeight) {
|
||||
this.floorHeight = hmdHeight;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public float getUserHeight() {
|
||||
return hmdHeight - floorHeight;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package dev.slimevr.config
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.Transient
|
||||
@Serializable
|
||||
class SkeletonConfig {
|
||||
var toggles: MutableMap<String, Boolean> = HashMap()
|
||||
|
||||
var values: MutableMap<String, Float> = HashMap()
|
||||
|
||||
var offsets: MutableMap<String, Float> = HashMap()
|
||||
|
||||
@JvmField
|
||||
var hmdHeight: Float = 0f
|
||||
|
||||
@JvmField
|
||||
var floorHeight: Float = 0f
|
||||
|
||||
@Transient
|
||||
val userHeight: Float
|
||||
get() = hmdHeight - floorHeight
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
package dev.slimevr.config
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.Transient
|
||||
@Serializable
|
||||
class StayAlignedConfig {
|
||||
|
||||
/**
|
||||
@@ -19,7 +20,7 @@ class StayAlignedConfig {
|
||||
*
|
||||
* Do not serialize to config so that when the server restarts, it is always false.
|
||||
*/
|
||||
@JsonIgnore
|
||||
@Transient
|
||||
var hideYawCorrection = false
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package dev.slimevr.config
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
class StayAlignedRelaxedPoseConfig {
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package dev.slimevr.config
|
||||
|
||||
import com.jme3.math.FastMath
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
// handles the tap detection config
|
||||
// this involves the number of taps, the delay, and whether or not the feature is enabled
|
||||
// for each reset type
|
||||
@Serializable
|
||||
class TapDetectionConfig {
|
||||
var yawResetDelay = 0.2f
|
||||
var fullResetDelay = 1.0f
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
package dev.slimevr.config
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode
|
||||
import com.fasterxml.jackson.databind.node.JsonNodeFactory
|
||||
import dev.slimevr.VRServer
|
||||
import dev.slimevr.config.serializers.QuaternionSerializer
|
||||
import dev.slimevr.tracking.trackers.Tracker
|
||||
import io.github.axisangles.ktmath.ObjectQuaternion
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
class TrackerConfig {
|
||||
var customName: String? = null
|
||||
var designation: String? = null
|
||||
|
||||
@get:JvmName("isHide")
|
||||
var hide: Boolean = false
|
||||
var adjustment: ObjectQuaternion? = null
|
||||
@Serializable(with = QuaternionSerializer::class)
|
||||
var mountingOrientation: ObjectQuaternion? = null
|
||||
|
||||
@Serializable(with = QuaternionSerializer::class)
|
||||
var mountingResetOrientation: ObjectQuaternion? = null
|
||||
var allowDriftCompensation: Boolean? = null
|
||||
|
||||
@@ -22,27 +23,12 @@ class TrackerConfig {
|
||||
*/
|
||||
var shouldHaveMagEnabled: Boolean? = null
|
||||
|
||||
constructor()
|
||||
|
||||
constructor(tracker: Tracker) {
|
||||
this.designation = if (tracker.trackerPosition != null) tracker.trackerPosition!!.designation else null
|
||||
this.customName = tracker.customName
|
||||
allowDriftCompensation = tracker.isImu()
|
||||
shouldHaveMagEnabled = tracker.isImu()
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun toV2(v1: JsonNode, factory: JsonNodeFactory): JsonNode {
|
||||
val node = factory.objectNode()
|
||||
if (v1.has("customName")) node.set<JsonNode>("customName", v1["customName"])
|
||||
if (v1.has("designation")) node.set<JsonNode>("designation", v1["designation"])
|
||||
if (v1.has("hide")) node.set<JsonNode>("hide", v1["hide"])
|
||||
if (v1.has("mountingRotation")) node.set<JsonNode>("mountingRotation", v1["mountingRotation"])
|
||||
if (v1.has("adjustment")) node.set<JsonNode>("adjustment", v1["adjustment"])
|
||||
return node
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val Tracker.config: TrackerConfig
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package dev.slimevr.config
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
class TrackingChecklistConfig {
|
||||
val ignoredStepsIds: MutableList<Int> = mutableListOf()
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
package dev.slimevr.config
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
class VMCConfig : OSCConfig() {
|
||||
|
||||
// Anchor the tracking at the hip?
|
||||
@@ -10,4 +13,9 @@ class VMCConfig : OSCConfig() {
|
||||
|
||||
// Mirror the tracking before sending it (turn left <=> turn right, left leg <=> right leg)
|
||||
var mirrorTracking = false
|
||||
|
||||
init {
|
||||
portIn = 39540
|
||||
portOut = 39539
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
package dev.slimevr.config
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
class VRCConfig {
|
||||
// List of fields ignored in vrc warnings - @see VRCConfigValidity
|
||||
val mutedWarnings: MutableList<String> = mutableListOf()
|
||||
|
||||
@@ -1,24 +1,40 @@
|
||||
package dev.slimevr.config
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize
|
||||
import com.fasterxml.jackson.databind.ser.std.StdKeySerializers
|
||||
import dev.slimevr.config.serializers.BooleanMapDeserializer
|
||||
import dev.slimevr.tracking.trackers.TrackerRole
|
||||
import kotlinx.serialization.Serializable
|
||||
import java.util.*
|
||||
|
||||
@Serializable
|
||||
class VRCOSCConfig : OSCConfig() {
|
||||
|
||||
// Which trackers' data to send
|
||||
@JsonDeserialize(using = BooleanMapDeserializer::class)
|
||||
@JsonSerialize(keyUsing = StdKeySerializers.StringKeySerializer::class)
|
||||
// @JsonDeserialize(using = BooleanMapDeserializer::class)
|
||||
// @JsonSerialize(keyUsing = StdKeySerializers.StringKeySerializer::class)
|
||||
var trackers: MutableMap<String, Boolean> = HashMap()
|
||||
|
||||
var oscqueryEnabled: Boolean = true
|
||||
|
||||
fun getOSCTrackerRole(role: TrackerRole, def: Boolean): Boolean = trackers.getOrDefault(role.name.lowercase(Locale.getDefault()), def)
|
||||
|
||||
fun setOSCTrackerRole(role: TrackerRole, `val`: Boolean) {
|
||||
trackers[role.name.lowercase(Locale.getDefault())] = `val`
|
||||
fun setOSCTrackerRole(role: TrackerRole, value: Boolean) {
|
||||
trackers[role.name.lowercase(Locale.getDefault())] = value
|
||||
}
|
||||
|
||||
init {
|
||||
portIn = 9001
|
||||
portOut = 9000
|
||||
|
||||
setOSCTrackerRole(
|
||||
TrackerRole.WAIST,
|
||||
getOSCTrackerRole(TrackerRole.WAIST, true),
|
||||
)
|
||||
setOSCTrackerRole(
|
||||
TrackerRole.LEFT_FOOT,
|
||||
getOSCTrackerRole(TrackerRole.WAIST, true),
|
||||
)
|
||||
setOSCTrackerRole(
|
||||
TrackerRole.RIGHT_FOOT,
|
||||
getOSCTrackerRole(TrackerRole.WAIST, true),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,31 +1,18 @@
|
||||
package dev.slimevr.config
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize
|
||||
import com.fasterxml.jackson.databind.ser.std.StdKeySerializers
|
||||
import com.github.jonpeterson.jackson.module.versioning.JsonVersionedModel
|
||||
import dev.slimevr.config.serializers.BridgeConfigMapDeserializer
|
||||
import dev.slimevr.config.serializers.TrackerConfigMapDeserializer
|
||||
import dev.slimevr.tracking.trackers.Tracker
|
||||
import dev.slimevr.tracking.trackers.TrackerRole
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@JsonVersionedModel(
|
||||
currentVersion = "15",
|
||||
defaultDeserializeToVersion = "15",
|
||||
toCurrentConverterClass = CurrentVRConfigConverter::class,
|
||||
)
|
||||
@Serializable
|
||||
class VRConfig {
|
||||
val server: ServerConfig = ServerConfig()
|
||||
|
||||
val filters: FiltersConfig = FiltersConfig()
|
||||
|
||||
val driftCompensation: DriftCompensationConfig = DriftCompensationConfig()
|
||||
|
||||
val oscRouter: OSCConfig = OSCConfig()
|
||||
|
||||
val vrcOSC: VRCOSCConfig = VRCOSCConfig()
|
||||
|
||||
@get:JvmName("getVMC")
|
||||
val vmc: VMCConfig = VMCConfig()
|
||||
|
||||
val autoBone: AutoBoneConfig = AutoBoneConfig()
|
||||
@@ -42,12 +29,8 @@ class VRConfig {
|
||||
|
||||
val stayAlignedConfig = StayAlignedConfig()
|
||||
|
||||
@JsonDeserialize(using = TrackerConfigMapDeserializer::class)
|
||||
@JsonSerialize(keyUsing = StdKeySerializers.StringKeySerializer::class)
|
||||
private val trackers: MutableMap<String, TrackerConfig> = HashMap()
|
||||
|
||||
@JsonDeserialize(using = BridgeConfigMapDeserializer::class)
|
||||
@JsonSerialize(keyUsing = StdKeySerializers.StringKeySerializer::class)
|
||||
private val bridges: MutableMap<String, BridgeConfig> = HashMap()
|
||||
|
||||
val knownDevices: MutableSet<String> = mutableSetOf()
|
||||
@@ -58,40 +41,7 @@ class VRConfig {
|
||||
|
||||
val vrcConfig: VRCConfig = VRCConfig()
|
||||
|
||||
init {
|
||||
// Initialize default settings for OSC Router
|
||||
oscRouter.portIn = 9002
|
||||
oscRouter.portOut = 9000
|
||||
|
||||
// Initialize default settings for VRC OSC
|
||||
vrcOSC.portIn = 9001
|
||||
vrcOSC.portOut = 9000
|
||||
vrcOSC
|
||||
.setOSCTrackerRole(
|
||||
TrackerRole.WAIST,
|
||||
vrcOSC.getOSCTrackerRole(TrackerRole.WAIST, true),
|
||||
)
|
||||
vrcOSC
|
||||
.setOSCTrackerRole(
|
||||
TrackerRole.LEFT_FOOT,
|
||||
vrcOSC.getOSCTrackerRole(TrackerRole.WAIST, true),
|
||||
)
|
||||
vrcOSC
|
||||
.setOSCTrackerRole(
|
||||
TrackerRole.RIGHT_FOOT,
|
||||
vrcOSC.getOSCTrackerRole(TrackerRole.WAIST, true),
|
||||
)
|
||||
|
||||
// Initialize default settings for VMC
|
||||
vmc.portIn = 39540
|
||||
vmc.portOut = 39539
|
||||
}
|
||||
|
||||
fun getTrackers(): Map<String, TrackerConfig> = trackers
|
||||
|
||||
fun getBridges(): Map<String, BridgeConfig> = bridges
|
||||
|
||||
fun hasTrackerByName(name: String): Boolean = trackers.containsKey(name)
|
||||
val modelVersion: String = CONFIG_VERSION.toString()
|
||||
|
||||
fun getTracker(tracker: Tracker): TrackerConfig {
|
||||
var config = trackers[tracker.name]
|
||||
@@ -106,7 +56,6 @@ class VRConfig {
|
||||
if (tracker.userEditable) {
|
||||
val config = getTracker(tracker)
|
||||
tracker.readConfig(config)
|
||||
if (tracker.isImu()) tracker.resetsHandler.readDriftCompensationConfig(driftCompensation)
|
||||
tracker.resetsHandler.readResetConfig(resetsConfig)
|
||||
if (tracker.allowReset) {
|
||||
tracker.saveMountingResetOrientation(config)
|
||||
@@ -140,4 +89,8 @@ class VRConfig {
|
||||
fun addKnownDevice(mac: String): Boolean = knownDevices.add(mac)
|
||||
|
||||
fun forgetKnownDevice(mac: String): Boolean = knownDevices.remove(mac)
|
||||
|
||||
companion object {
|
||||
const val CONFIG_VERSION = 15
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package dev.slimevr.config.serializers;
|
||||
|
||||
/**
|
||||
* This class allows the use of the utility super class MapDeserializer that
|
||||
* takes the Value of a map as its Generic parameter. It is so you can use that
|
||||
* class in a @JsonDeserialize annotation on the Map field inside the config
|
||||
* instance
|
||||
*
|
||||
* @see dev.slimevr.config.VRConfig
|
||||
*/
|
||||
public class BooleanMapDeserializer extends MapDeserializer<Boolean> {
|
||||
public BooleanMapDeserializer() {
|
||||
super(Boolean.class);
|
||||
}
|
||||
}
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
package dev.slimevr.config.serializers;
|
||||
|
||||
import dev.slimevr.config.BridgeConfig;
|
||||
|
||||
|
||||
/**
|
||||
* This class allows the use of the utility super class MapDeserializer that
|
||||
* takes the Value of a map as its Generic parameter. It is so you can use that
|
||||
* class in a @JsonDeserialize annotation on the Map field inside the config
|
||||
* instance
|
||||
*
|
||||
* @see dev.slimevr.config.VRConfig
|
||||
*/
|
||||
public class BridgeConfigMapDeserializer extends MapDeserializer<BridgeConfig> {
|
||||
public BridgeConfigMapDeserializer() {
|
||||
super(BridgeConfig.class);
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package dev.slimevr.config.serializers;
|
||||
|
||||
/**
|
||||
* This class allows the use of the utility super class MapDeserializer that
|
||||
* takes the Value of a map as its Generic parameter. It is so you can use that
|
||||
* class in a @JsonDeserialize annotation on the Map field inside the config
|
||||
* instance
|
||||
*
|
||||
* @see dev.slimevr.config.VRConfig
|
||||
*/
|
||||
public class FloatMapDeserializer extends MapDeserializer<Float> {
|
||||
public FloatMapDeserializer() {
|
||||
super(Float.class);
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package dev.slimevr.config.serializers;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
import com.fasterxml.jackson.databind.JsonDeserializer;
|
||||
import com.fasterxml.jackson.databind.type.MapType;
|
||||
import com.fasterxml.jackson.databind.type.TypeFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
/**
|
||||
* This class is a utility class that allows to write Map serializers easily to
|
||||
* be used in the VRConfig (@see {@link dev.slimevr.config.VRConfig})
|
||||
*
|
||||
* @see BooleanMapDeserializer to see how it is used
|
||||
*/
|
||||
public abstract class MapDeserializer<T> extends JsonDeserializer<HashMap<String, T>> {
|
||||
|
||||
private final Class<T> valueClass;
|
||||
|
||||
public MapDeserializer(Class<T> valueClass) {
|
||||
super();
|
||||
this.valueClass = valueClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<String, T> deserialize(JsonParser p, DeserializationContext dc)
|
||||
throws IOException {
|
||||
TypeFactory typeFactory = dc.getTypeFactory();
|
||||
MapType mapType = typeFactory
|
||||
.constructMapType(HashMap.class, String.class, valueClass);
|
||||
return dc.readValue(p, mapType);
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package dev.slimevr.config.serializers;
|
||||
|
||||
import com.fasterxml.jackson.core.JacksonException;
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
import com.fasterxml.jackson.databind.JsonDeserializer;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import io.github.axisangles.ktmath.ObjectQuaternion;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
public class QuaternionDeserializer extends JsonDeserializer<ObjectQuaternion> {
|
||||
@Override
|
||||
public ObjectQuaternion deserialize(JsonParser p, DeserializationContext ctxt)
|
||||
throws IOException, JacksonException {
|
||||
JsonNode node = p.getCodec().readTree(p);
|
||||
|
||||
return new ObjectQuaternion(
|
||||
(float) node.get("w").asDouble(),
|
||||
(float) node.get("x").asDouble(),
|
||||
(float) node.get("y").asDouble(),
|
||||
(float) node.get("z").asDouble()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package dev.slimevr.config.serializers;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.JsonSerializer;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import io.github.axisangles.ktmath.ObjectQuaternion;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
public class QuaternionSerializer extends JsonSerializer<ObjectQuaternion> {
|
||||
|
||||
@Override
|
||||
public void serialize(ObjectQuaternion value, JsonGenerator gen, SerializerProvider serializers)
|
||||
throws IOException {
|
||||
gen.writeStartObject();
|
||||
gen.writeNumberField("x", value.getX());
|
||||
gen.writeNumberField("y", value.getY());
|
||||
gen.writeNumberField("z", value.getZ());
|
||||
gen.writeNumberField("w", value.getW());
|
||||
gen.writeEndObject();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package dev.slimevr.config.serializers
|
||||
|
||||
import io.github.axisangles.ktmath.ObjectQuaternion
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
|
||||
object QuaternionSerializer : KSerializer<ObjectQuaternion> {
|
||||
@Serializable
|
||||
private data class QuaternionSurrogate(val x: Float, val y: Float, val z: Float, val w: Float)
|
||||
|
||||
override val descriptor: SerialDescriptor = QuaternionSurrogate.serializer().descriptor
|
||||
|
||||
override fun serialize(encoder: Encoder, value: ObjectQuaternion) {
|
||||
val surrogate = QuaternionSurrogate(value.x, value.y, value.z, value.w)
|
||||
encoder.encodeSerializableValue(QuaternionSurrogate.serializer(), surrogate)
|
||||
}
|
||||
|
||||
override fun deserialize(decoder: Decoder): ObjectQuaternion {
|
||||
val surrogate = decoder.decodeSerializableValue(QuaternionSurrogate.serializer())
|
||||
return ObjectQuaternion(surrogate.x, surrogate.y, surrogate.z, surrogate.w)
|
||||
}
|
||||
}
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
package dev.slimevr.config.serializers;
|
||||
|
||||
import dev.slimevr.config.TrackerConfig;
|
||||
|
||||
|
||||
/**
|
||||
* This class allows the use of the utility super class MapDeserializer that
|
||||
* takes the Value of a map as its Generic parameter. It is so you can use that
|
||||
* class in a @JsonDeserialize annotation on the Map field inside the config
|
||||
* instance
|
||||
*
|
||||
* @see dev.slimevr.config.VRConfig
|
||||
*/
|
||||
public class TrackerConfigMapDeserializer extends MapDeserializer<TrackerConfig> {
|
||||
public TrackerConfigMapDeserializer() {
|
||||
super(TrackerConfig.class);
|
||||
}
|
||||
}
|
||||
+4
-22
@@ -113,20 +113,6 @@ public class RPCSettingsBuilder {
|
||||
);
|
||||
}
|
||||
|
||||
public static int createDriftCompensationSettings(
|
||||
FlatBufferBuilder fbb,
|
||||
DriftCompensationConfig driftCompensationConfig
|
||||
) {
|
||||
return DriftCompensationSettings
|
||||
.createDriftCompensationSettings(
|
||||
fbb,
|
||||
driftCompensationConfig.getEnabled(),
|
||||
driftCompensationConfig.getPrediction(),
|
||||
driftCompensationConfig.getAmount(),
|
||||
driftCompensationConfig.getMaxResets()
|
||||
);
|
||||
}
|
||||
|
||||
public static int createTapDetectionSettings(
|
||||
FlatBufferBuilder fbb,
|
||||
TapDetectionConfig tapDetectionConfig
|
||||
@@ -212,8 +198,8 @@ public class RPCSettingsBuilder {
|
||||
int skeletonConfigOffset = SkeletonHeight
|
||||
.createSkeletonHeight(
|
||||
fbb,
|
||||
skeletonConfig.getHmdHeight(),
|
||||
skeletonConfig.getFloorHeight()
|
||||
skeletonConfig.hmdHeight,
|
||||
skeletonConfig.floorHeight
|
||||
);
|
||||
return ModelSettings
|
||||
.createModelSettings(
|
||||
@@ -366,11 +352,7 @@ public class RPCSettingsBuilder {
|
||||
fbb,
|
||||
server.configManager.getVrConfig().getFilters()
|
||||
),
|
||||
RPCSettingsBuilder
|
||||
.createDriftCompensationSettings(
|
||||
fbb,
|
||||
server.configManager.getVrConfig().getDriftCompensation()
|
||||
),
|
||||
0,
|
||||
RPCSettingsBuilder
|
||||
.createOSCRouterSettings(
|
||||
fbb,
|
||||
@@ -384,7 +366,7 @@ public class RPCSettingsBuilder {
|
||||
RPCSettingsBuilder
|
||||
.createVMCOSCSettings(
|
||||
fbb,
|
||||
server.configManager.getVrConfig().getVMC()
|
||||
server.configManager.getVrConfig().getVmc()
|
||||
),
|
||||
RPCSettingsBuilder
|
||||
.createModelSettings(
|
||||
|
||||
@@ -77,17 +77,6 @@ class RPCSettingsHandler(var rpcHandler: RPCHandler, var api: ProtocolAPI) {
|
||||
}
|
||||
}
|
||||
|
||||
if (req.driftCompensation() != null) {
|
||||
val driftCompensationConfig = api.server.configManager
|
||||
.vrConfig
|
||||
.driftCompensation
|
||||
driftCompensationConfig.enabled = req.driftCompensation().enabled()
|
||||
driftCompensationConfig.prediction = req.driftCompensation().prediction()
|
||||
driftCompensationConfig.amount = req.driftCompensation().amount()
|
||||
driftCompensationConfig.maxResets = req.driftCompensation().maxResets()
|
||||
driftCompensationConfig.updateTrackersDriftCompensation()
|
||||
}
|
||||
|
||||
if (req.oscRouter() != null) {
|
||||
val oscRouterConfig = api.server.configManager
|
||||
.vrConfig
|
||||
|
||||
@@ -605,7 +605,7 @@ class HumanPoseManager(val server: VRServer?) {
|
||||
server.configManager
|
||||
.vrConfig
|
||||
.skeleton
|
||||
.getToggles()[SkeletonConfigToggles.FLOOR_CLIP.configKey] = value
|
||||
.toggles[SkeletonConfigToggles.FLOOR_CLIP.configKey] = value
|
||||
server.configManager.saveConfig()
|
||||
}
|
||||
}
|
||||
@@ -617,7 +617,7 @@ class HumanPoseManager(val server: VRServer?) {
|
||||
server.configManager
|
||||
.vrConfig
|
||||
.skeleton
|
||||
.getToggles()[SkeletonConfigToggles.SKATING_CORRECTION.configKey] = value
|
||||
.toggles[SkeletonConfigToggles.SKATING_CORRECTION.configKey] = value
|
||||
server.configManager.saveConfig()
|
||||
}
|
||||
}
|
||||
|
||||
+8
-8
@@ -422,7 +422,7 @@ class SkeletonConfigManager(
|
||||
instance.configManager
|
||||
.vrConfig
|
||||
.skeleton
|
||||
.getToggles()
|
||||
.toggles
|
||||
.remove(value.configKey)
|
||||
}
|
||||
}
|
||||
@@ -445,7 +445,7 @@ class SkeletonConfigManager(
|
||||
instance.configManager
|
||||
.vrConfig
|
||||
.skeleton
|
||||
.getValues()
|
||||
.values
|
||||
.remove(value.configKey)
|
||||
}
|
||||
}
|
||||
@@ -479,7 +479,7 @@ class SkeletonConfigManager(
|
||||
val skeletonConfig = configManager.vrConfig.skeleton
|
||||
|
||||
// Load offsets
|
||||
val offsets = skeletonConfig.getOffsets()
|
||||
val offsets = skeletonConfig.offsets
|
||||
for (configValue in SkeletonConfigOffsets.values) {
|
||||
val offset = offsets[configValue.configKey]
|
||||
if (offset != null) {
|
||||
@@ -490,7 +490,7 @@ class SkeletonConfigManager(
|
||||
}
|
||||
|
||||
// Load toggles
|
||||
val toggles = skeletonConfig.getToggles()
|
||||
val toggles = skeletonConfig.toggles
|
||||
for (configValue in SkeletonConfigToggles.values) {
|
||||
val toggle = toggles[configValue.configKey]
|
||||
if (toggle != null) {
|
||||
@@ -501,7 +501,7 @@ class SkeletonConfigManager(
|
||||
}
|
||||
|
||||
// Load values
|
||||
val values = skeletonConfig.getValues()
|
||||
val values = skeletonConfig.values
|
||||
for (configValue in SkeletonConfigValues.values) {
|
||||
val value = values[configValue.configKey]
|
||||
if (value != null) {
|
||||
@@ -526,17 +526,17 @@ class SkeletonConfigManager(
|
||||
|
||||
// Write all possible values to keep consistent even if defaults changed
|
||||
for (value in SkeletonConfigOffsets.values) {
|
||||
skeletonConfig.getOffsets()[value.configKey] = getOffset(value)
|
||||
skeletonConfig.offsets[value.configKey] = getOffset(value)
|
||||
}
|
||||
|
||||
// Only write changed values to keep using defaults if not changed
|
||||
for (value in SkeletonConfigToggles.values) {
|
||||
if (changedToggles[value.ordinal]) skeletonConfig.getToggles()[value.configKey] = getToggle(value)
|
||||
if (changedToggles[value.ordinal]) skeletonConfig.toggles[value.configKey] = getToggle(value)
|
||||
}
|
||||
|
||||
// Only write changed values to keep using defaults if not changed
|
||||
for (value in SkeletonConfigValues.values) {
|
||||
if (changedValues[value.ordinal]) skeletonConfig.getValues()[value.configKey] = getValue(value)
|
||||
if (changedValues[value.ordinal]) skeletonConfig.values[value.configKey] = getValue(value)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package dev.slimevr.tracking.trackers
|
||||
import com.jme3.math.FastMath
|
||||
import dev.slimevr.VRServer
|
||||
import dev.slimevr.config.ArmsResetModes
|
||||
import dev.slimevr.config.DriftCompensationConfig
|
||||
import dev.slimevr.config.ResetsConfig
|
||||
import dev.slimevr.filtering.CircularArrayList
|
||||
import dev.slimevr.tracking.trackers.udp.TrackerDataType
|
||||
@@ -108,23 +107,6 @@ class TrackerResetsHandler(val tracker: Tracker) {
|
||||
*/
|
||||
private var tposeDownFix = Quaternion.IDENTITY
|
||||
|
||||
/**
|
||||
* Reads/loads drift compensation settings from given config
|
||||
*/
|
||||
fun readDriftCompensationConfig(config: DriftCompensationConfig) {
|
||||
compensateDrift = false
|
||||
driftPrediction = config.prediction
|
||||
driftAmount = config.amount
|
||||
val maxResets = config.maxResets
|
||||
|
||||
if (compensateDrift && maxResets != driftQuats.capacity()) {
|
||||
driftQuats = CircularArrayList<Quaternion>(maxResets)
|
||||
driftTimes = CircularArrayList<Long>(maxResets)
|
||||
}
|
||||
|
||||
refreshDriftCompensationEnabled()
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears drift compensation data
|
||||
*/
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package dev.slimevr.websocketapi
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode
|
||||
import dev.slimevr.VRServer
|
||||
import dev.slimevr.VRServer.Companion.getNextLocalTrackerId
|
||||
import dev.slimevr.VRServer.Companion.instance
|
||||
@@ -13,20 +11,68 @@ import io.eiren.util.collections.FastList
|
||||
import io.eiren.util.logging.LogManager
|
||||
import io.github.axisangles.ktmath.Quaternion
|
||||
import io.github.axisangles.ktmath.Vector3
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import kotlinx.serialization.json.decodeFromJsonElement
|
||||
import kotlinx.serialization.json.float
|
||||
import kotlinx.serialization.json.intOrNull
|
||||
import kotlinx.serialization.json.jsonObject
|
||||
import kotlinx.serialization.json.jsonPrimitive
|
||||
import org.java_websocket.WebSocket
|
||||
import org.java_websocket.handshake.ClientHandshake
|
||||
import java.util.*
|
||||
import java.util.Locale
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
|
||||
// --- Data Models for Serialization ---
|
||||
|
||||
@Serializable
|
||||
data class OutgoingConfigMessage(
|
||||
val type: String = "config",
|
||||
@SerialName("tracker_id") val trackerId: String,
|
||||
val location: String?,
|
||||
@SerialName("tracker_type") val trackerType: String?,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class OutgoingPositionMessage(
|
||||
val type: String = "pos",
|
||||
val src: String = "full",
|
||||
@SerialName("tracker_id") val trackerId: String,
|
||||
val x: Float,
|
||||
val y: Float,
|
||||
val z: Float,
|
||||
val qx: Float,
|
||||
val qy: Float,
|
||||
val qz: Float,
|
||||
val qw: Float,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class IncomingActionMessage(
|
||||
val name: String,
|
||||
)
|
||||
|
||||
// --- Bridge Implementation ---
|
||||
|
||||
class WebSocketVRBridge(
|
||||
computedTrackers: List<Tracker>,
|
||||
server: VRServer,
|
||||
) : WebsocketAPI(server, server.protocolAPI),
|
||||
Bridge {
|
||||
|
||||
private val computedTrackers: List<Tracker> = FastList(computedTrackers)
|
||||
private val internalTrackers: MutableList<Tracker> = FastList(computedTrackers.size)
|
||||
private val newHMDData = AtomicBoolean(false)
|
||||
private val mapper = ObjectMapper()
|
||||
|
||||
// Global Json configuration
|
||||
private val json = Json {
|
||||
ignoreUnknownKeys = true
|
||||
encodeDefaults = true
|
||||
}
|
||||
|
||||
private val internalHMDTracker = Tracker(
|
||||
null,
|
||||
0,
|
||||
@@ -61,9 +107,7 @@ class WebSocketVRBridge(
|
||||
override fun dataRead() {
|
||||
if (newHMDData.compareAndSet(true, false)) {
|
||||
if (hmdTracker == null) {
|
||||
// Create HMD for websocket
|
||||
val hmdDevice = server.deviceManager
|
||||
.createDevice("WebSocketVRBridge", null, null)
|
||||
val hmdDevice = server.deviceManager.createDevice("WebSocketVRBridge", null, null)
|
||||
hmdTracker = Tracker(
|
||||
null,
|
||||
getNextLocalTrackerId(),
|
||||
@@ -97,112 +141,76 @@ class WebSocketVRBridge(
|
||||
|
||||
override fun onOpen(conn: WebSocket, handshake: ClientHandshake) {
|
||||
super.onOpen(conn, handshake)
|
||||
// Register trackers
|
||||
for (i in internalTrackers.indices) {
|
||||
val message = mapper.nodeFactory.objectNode()
|
||||
message.put("type", "config")
|
||||
message.put("tracker_id", "SlimeVR Tracker " + (i + 1))
|
||||
message
|
||||
.put(
|
||||
"location",
|
||||
computedTrackers[i]
|
||||
.trackerPosition
|
||||
?.trackerRole
|
||||
?.name
|
||||
?.lowercase(Locale.getDefault()),
|
||||
)
|
||||
message.put("tracker_type", message["location"].asText())
|
||||
conn.send(message.toString())
|
||||
val loc = computedTrackers[i].trackerPosition?.trackerRole?.name?.lowercase(Locale.getDefault())
|
||||
val message = OutgoingConfigMessage(
|
||||
trackerId = "SlimeVR Tracker ${i + 1}",
|
||||
location = loc,
|
||||
trackerType = loc,
|
||||
)
|
||||
conn.send(json.encodeToString(message))
|
||||
}
|
||||
}
|
||||
|
||||
override fun onMessage(conn: WebSocket, message: String) {
|
||||
// LogManager.info(message);
|
||||
try {
|
||||
val json = mapper.readTree(message) as ObjectNode
|
||||
if (json.has("type")) {
|
||||
when (json["type"].asText()) {
|
||||
"pos" -> {
|
||||
parsePosition(json, conn)
|
||||
return
|
||||
}
|
||||
val root = json.parseToJsonElement(message).jsonObject
|
||||
val type = root["type"]?.jsonPrimitive?.content ?: return
|
||||
|
||||
"action" -> {
|
||||
parseAction(json, conn)
|
||||
return
|
||||
}
|
||||
|
||||
// TODO Ignore it for now, it should only register HMD in our test case with id 0
|
||||
"config" -> {
|
||||
LogManager.info("[WebSocket] Config received: $json")
|
||||
return
|
||||
}
|
||||
}
|
||||
when (type) {
|
||||
"pos" -> parsePosition(root, conn)
|
||||
"action" -> parseAction(root)
|
||||
"config" -> LogManager.info("[WebSocket] Config received: $message")
|
||||
else -> LogManager.warning("[WebSocket] Unrecognized message: $message")
|
||||
}
|
||||
LogManager
|
||||
.warning(
|
||||
"[WebSocket] Unrecognized message from " +
|
||||
conn.remoteSocketAddress.address.hostAddress +
|
||||
": " +
|
||||
message,
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
LogManager
|
||||
.severe(
|
||||
"[WebSocket] Exception parsing message from " +
|
||||
conn.remoteSocketAddress.address.hostAddress +
|
||||
". Message: " +
|
||||
message,
|
||||
e,
|
||||
)
|
||||
LogManager.severe("[WebSocket] Exception parsing message: $message", e)
|
||||
}
|
||||
}
|
||||
|
||||
private fun parsePosition(json: ObjectNode, conn: WebSocket) {
|
||||
if (json["tracker_id"].asInt() == 0) {
|
||||
// Read HMD information
|
||||
internalHMDTracker
|
||||
.position = Vector3(
|
||||
json["x"].asDouble().toFloat(),
|
||||
json["y"].asDouble().toFloat() + 0.2f,
|
||||
json["z"].asDouble().toFloat(),
|
||||
private fun parsePosition(jsonObj: JsonObject, conn: WebSocket) {
|
||||
// HMD usually sends tracker_id as 0 (number)
|
||||
val trackerId = jsonObj["tracker_id"]?.jsonPrimitive?.intOrNull ?: -1
|
||||
|
||||
if (trackerId == 0) {
|
||||
internalHMDTracker.position = Vector3(
|
||||
jsonObj["x"]?.jsonPrimitive?.float ?: 0f,
|
||||
(jsonObj["y"]?.jsonPrimitive?.float ?: 0f) + 0.2f,
|
||||
jsonObj["z"]?.jsonPrimitive?.float ?: 0f,
|
||||
)
|
||||
internalHMDTracker.setRotation(
|
||||
Quaternion(
|
||||
jsonObj["qw"]?.jsonPrimitive?.float ?: 1f,
|
||||
jsonObj["qx"]?.jsonPrimitive?.float ?: 0f,
|
||||
jsonObj["qy"]?.jsonPrimitive?.float ?: 0f,
|
||||
jsonObj["qz"]?.jsonPrimitive?.float ?: 0f,
|
||||
),
|
||||
)
|
||||
// TODO Wtf is this hack? VRWorkout issue?
|
||||
internalHMDTracker
|
||||
.setRotation(
|
||||
Quaternion(
|
||||
json["qw"].asDouble().toFloat(),
|
||||
json["qx"].asDouble().toFloat(),
|
||||
json["qy"].asDouble().toFloat(),
|
||||
json["qz"].asDouble().toFloat(),
|
||||
),
|
||||
)
|
||||
internalHMDTracker.dataTick()
|
||||
newHMDData.set(true)
|
||||
|
||||
// Send tracker info in reply
|
||||
for (i in internalTrackers.indices) {
|
||||
val message = mapper.nodeFactory.objectNode()
|
||||
message.put("type", "pos")
|
||||
message.put("src", "full")
|
||||
message.put("tracker_id", "SlimeVR Tracker ${i + 1}")
|
||||
|
||||
val t = internalTrackers[i]
|
||||
message.put("x", t.position.x)
|
||||
message.put("y", t.position.y)
|
||||
message.put("z", t.position.z)
|
||||
message.put("qx", t.getRotation().x)
|
||||
message.put("qy", t.getRotation().y)
|
||||
message.put("qz", t.getRotation().z)
|
||||
message.put("qw", t.getRotation().w)
|
||||
|
||||
conn.send(message.toString())
|
||||
val rot = t.getRotation()
|
||||
val reply = OutgoingPositionMessage(
|
||||
trackerId = "SlimeVR Tracker ${i + 1}",
|
||||
x = t.position.x,
|
||||
y = t.position.y,
|
||||
z = t.position.z,
|
||||
qx = rot.x,
|
||||
qy = rot.y,
|
||||
qz = rot.z,
|
||||
qw = rot.w,
|
||||
)
|
||||
conn.send(json.encodeToString(reply))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun parseAction(json: ObjectNode, conn: WebSocket) {
|
||||
when (json["name"].asText()) {
|
||||
private fun parseAction(jsonObj: JsonObject) {
|
||||
val action = json.decodeFromJsonElement<IncomingActionMessage>(jsonObj)
|
||||
when (action.name) {
|
||||
"calibrate" -> instance.resetTrackersYaw(RESET_SOURCE_NAME)
|
||||
"full_calibrate" -> instance.resetTrackersFull(RESET_SOURCE_NAME)
|
||||
"mounting_calibrate" -> instance.resetTrackersMounting(RESET_SOURCE_NAME)
|
||||
@@ -213,25 +221,13 @@ class WebSocketVRBridge(
|
||||
|
||||
override fun onStart() {
|
||||
LogManager.info("[WebSocket] Web Socket VR Bridge started on port $port")
|
||||
connectionLostTimeout = 0
|
||||
connectionLostTimeout = 1
|
||||
// This has to be removed for Android
|
||||
// (keepalive did not work for me @mgschwan)
|
||||
}
|
||||
|
||||
override fun addSharedTracker(tracker: Tracker?) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
override fun removeSharedTracker(tracker: Tracker?) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
override fun startBridge() {
|
||||
start()
|
||||
}
|
||||
|
||||
override fun isConnected(): Boolean = super.getConnections().isNotEmpty()
|
||||
override fun addSharedTracker(tracker: Tracker?) {}
|
||||
override fun removeSharedTracker(tracker: Tracker?) {}
|
||||
override fun startBridge() = start()
|
||||
override fun isConnected(): Boolean = connections.isNotEmpty()
|
||||
|
||||
companion object {
|
||||
private const val RESET_SOURCE_NAME = "WebSocketVRBridge"
|
||||
|
||||
@@ -31,7 +31,7 @@ abstract class SteamVRBridge(
|
||||
@VRServerThread
|
||||
override fun startBridge() {
|
||||
for (tr in shareableTrackers) {
|
||||
val role = tr.trackerPosition?.trackerRole
|
||||
val role = tr.trackerPosition?.trackerRole ?: error("invalid state")
|
||||
changeShareSettings(
|
||||
role,
|
||||
config.getBridgeTrackerRole(role, false),
|
||||
|
||||
Reference in new issue
Block a user