Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite the configuration to use kotlinx.serialization #706

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions server/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build
/bin/

MagnetoLib.dll
vrconfig.yml
vrconfig.yml*

# BVH
BVH Recordings
Expand All @@ -18,4 +18,4 @@ Load AutoBone Recordings
*.log.*
*.log.lck
*.log
logs/
logs/
2 changes: 2 additions & 0 deletions server/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ dependencies {
implementation("org.java-websocket:Java-WebSocket:1.+")
implementation("com.melloware:jintellitype:1.+")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0-RC")
implementation("com.charleskorn.kaml:kaml:0.54.0")
implementation("it.unimi.dsi:fastutil:8.5.12")
implementation("com.squareup.okio:okio:3.3.0")

testImplementation(kotlin("test"))
// Use JUnit test framework
Expand Down
14 changes: 7 additions & 7 deletions server/src/main/java/dev/slimevr/Keybinding.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class Keybinding implements HotkeyListener {
public Keybinding(VRServer server) {
this.server = server;

this.config = server.getConfigManager().getVrConfig().getKeybindings();
this.config = server.getConfigManager().getVrConfig().keybindings;

if (OperatingSystem.getCurrentPlatform() != OperatingSystem.WINDOWS) {
LogManager
Expand All @@ -36,15 +36,15 @@ public Keybinding(VRServer server) {
if (JIntellitype.getInstance() instanceof JIntellitype) {
JIntellitype.getInstance().addHotKeyListener(this);

String fullResetBinding = this.config.getFullResetBinding();
String fullResetBinding = this.config.fullResetBinding;
JIntellitype.getInstance().registerHotKey(FULL_RESET, fullResetBinding);
LogManager.info("[Keybinding] Bound full reset to " + fullResetBinding);

String yawResetBinding = this.config.getYawResetBinding();
String yawResetBinding = this.config.yawResetBinding;
JIntellitype.getInstance().registerHotKey(YAW_RESET, yawResetBinding);
LogManager.info("[Keybinding] Bound yaw reset to " + yawResetBinding);

String mountingResetBinding = this.config.getMountingResetBinding();
String mountingResetBinding = this.config.mountingResetBinding;
JIntellitype.getInstance().registerHotKey(MOUNTING_RESET, mountingResetBinding);
LogManager.info("[Keybinding] Bound reset mounting to " + mountingResetBinding);
}
Expand All @@ -62,18 +62,18 @@ public void onHotKey(int identifier) {
switch (identifier) {
case FULL_RESET -> {
server.getResetHandler().sendStarted(ResetType.Full);
server.scheduleResetTrackersFull(resetSourceName, this.config.getFullResetDelay());
server.scheduleResetTrackersFull(resetSourceName, this.config.fullResetDelay);
}
case YAW_RESET -> {
server.getResetHandler().sendStarted(ResetType.Yaw);
server.scheduleResetTrackersYaw(resetSourceName, this.config.getYawResetDelay());
server.scheduleResetTrackersYaw(resetSourceName, this.config.yawResetDelay);
}
case MOUNTING_RESET -> {
server.getResetHandler().sendStarted(ResetType.Mounting);
server
.scheduleResetTrackersMounting(
resetSourceName,
this.config.getMountingResetDelay()
this.config.mountingResetDelay
);
}
}
Expand Down
8 changes: 4 additions & 4 deletions server/src/main/java/dev/slimevr/VRServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public VRServer(String configPath) {
List<Tracker> computedTrackers = humanPoseManager.getComputedTrackers();

// Start server for SlimeVR trackers
int trackerPort = configManager.getVrConfig().getServer().getTrackerPort();
int trackerPort = configManager.getVrConfig().server.trackerPort;
LogManager.info("Starting the tracker server on port " + trackerPort + "...");
trackersServer = new TrackersUDPServer(
trackerPort,
Expand Down Expand Up @@ -211,21 +211,21 @@ public VRServer(String configPath) {
this,
humanPoseManager,
driverBridge,
getConfigManager().getVrConfig().getVrcOSC(),
getConfigManager().getVrConfig().vrcOSC,
computedTrackers
);
vmcHandler = new VMCHandler(
this,
humanPoseManager,
getConfigManager().getVrConfig().getVMC(),
getConfigManager().getVrConfig().getVmc(),
computedTrackers
);

// Initialize OSC router
FastList<OSCHandler> oscHandlers = new FastList<>();
oscHandlers.add(vrcOSCHandler);
oscHandlers.add(vmcHandler);
oscRouter = new OSCRouter(getConfigManager().getVrConfig().getOscRouter(), oscHandlers);
oscRouter = new OSCRouter(getConfigManager().getVrConfig().oscRouter, oscHandlers);

bvhRecorder = new BVHRecorder(this);

Expand Down
5 changes: 4 additions & 1 deletion server/src/main/java/dev/slimevr/config/AutoBoneConfig.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package dev.slimevr.config

import kotlinx.serialization.Serializable

@Serializable
class AutoBoneConfig {
var cursorIncrement = 2
var minDataDistance = 1
Expand All @@ -20,6 +23,6 @@ class AutoBoneConfig {
var randomizeFrameOrder = true
var scaleEachStep = true
var sampleCount = 1000
var sampleRateMs: Long = 20
var sampleRateMs = 20L
var saveRecordings = false
}
32 changes: 0 additions & 32 deletions server/src/main/java/dev/slimevr/config/BridgeConfig.java

This file was deleted.

23 changes: 23 additions & 0 deletions server/src/main/java/dev/slimevr/config/BridgeConfig.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
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 BridgeConfig {
@JsonDeserialize(using = BooleanMapDeserializer::class)
@JsonSerialize(keyUsing = StdKeySerializers.StringKeySerializer::class)
var trackers: MutableMap<String, Boolean> = HashMap()
fun getBridgeTrackerRole(role: TrackerRole, def: Boolean): Boolean {
return trackers.getOrDefault(role.name.lowercase(Locale.getDefault()), def)
}

fun setBridgeTrackerRole(role: TrackerRole, `val`: Boolean) {
trackers[role.name.lowercase(Locale.getDefault())] = `val`
}
}
139 changes: 0 additions & 139 deletions server/src/main/java/dev/slimevr/config/ConfigManager.java

This file was deleted.

Loading