mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-12-06 08:42:32 -08:00
Settings defaults - add a way to reset any setting field individually
This commit is contained in:
1 parent
862ecbdfef
commit
e65e5ad2f9
35 files changed
+942
-492
No files matched your search
@@ -29,6 +29,7 @@ import dev.slimevr.solarxr.rpc.ResetsBehaviour
|
||||
import dev.slimevr.solarxr.rpc.SerialBehaviour
|
||||
import dev.slimevr.solarxr.rpc.ServerInfosBehaviour
|
||||
import dev.slimevr.solarxr.rpc.SessionCalibrationBehaviour
|
||||
import dev.slimevr.solarxr.rpc.SettingsDefaultsBehaviour
|
||||
import dev.slimevr.solarxr.rpc.SettingsResetBehaviour
|
||||
import dev.slimevr.solarxr.rpc.SkeletonProportionsBehaviour
|
||||
import dev.slimevr.solarxr.rpc.SkeletonSettingsBehaviour
|
||||
@@ -197,6 +198,7 @@ class SolarXRBridge(
|
||||
add(HIDSettingsBehaviour(appContext.config.settings))
|
||||
add(ErrorReportingSettingsBehaviour(appContext.config.globalConfig, appContext.errorReporting))
|
||||
add(SettingsResetBehaviour(appContext.config))
|
||||
add(SettingsDefaultsBehaviour())
|
||||
add(SkeletonSettingsBehaviour(appContext.config.settings))
|
||||
add(SkeletonProportionsBehaviour(appContext.config.userConfig, appContext.skeleton, appContext.errorReporting))
|
||||
add(TrackingChecklistBehaviour(appContext.trackingChecklist, appContext.config.settings, appContext.errorReporting))
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package dev.slimevr.solarxr.rpc
|
||||
|
||||
import dev.slimevr.AppContextProvider
|
||||
import dev.slimevr.config.DriverConfig
|
||||
import dev.slimevr.config.Settings
|
||||
import dev.slimevr.config.SettingsActions
|
||||
import dev.slimevr.routing.driverStateFlow
|
||||
@@ -20,6 +21,11 @@ import solarxr_protocol.rpc.DriverStatusChangeResponse
|
||||
import solarxr_protocol.rpc.DriverStatusRequest
|
||||
import solarxr_protocol.rpc.RoutingOutputState
|
||||
|
||||
internal fun buildDriverSettingsResponse(config: DriverConfig) = DriverSettingsResponse(
|
||||
enabled = config.enabled,
|
||||
sendVelocity = config.sendVelocity,
|
||||
)
|
||||
|
||||
class DriverSettingsBehaviour(
|
||||
private val appContext: AppContextProvider,
|
||||
) : SolarXRBridgeBehaviour {
|
||||
@@ -27,22 +33,11 @@ class DriverSettingsBehaviour(
|
||||
|
||||
override fun observe(receiver: SolarXRBridge) {
|
||||
receiver.rpcDispatcher.on<DriverSettingsRequest> {
|
||||
val config = settings.context.state.value.data.driverConfig
|
||||
receiver.sendRpc(
|
||||
DriverSettingsResponse(
|
||||
enabled = config.enabled,
|
||||
sendVelocity = config.sendVelocity,
|
||||
),
|
||||
)
|
||||
receiver.sendRpc(buildDriverSettingsResponse(settings.context.state.value.data.driverConfig))
|
||||
}.launchIn(receiver.context.scope)
|
||||
|
||||
settings.context.state
|
||||
.map {
|
||||
DriverSettingsResponse(
|
||||
enabled = it.data.driverConfig.enabled,
|
||||
sendVelocity = it.data.driverConfig.sendVelocity,
|
||||
)
|
||||
}
|
||||
.map { buildDriverSettingsResponse(it.data.driverConfig) }
|
||||
.distinctUntilChanged()
|
||||
.drop(1)
|
||||
.onEach(receiver::sendRpc)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package dev.slimevr.solarxr.rpc
|
||||
|
||||
import dev.slimevr.config.HidConfig
|
||||
import dev.slimevr.config.Settings
|
||||
import dev.slimevr.config.SettingsActions
|
||||
import dev.slimevr.solarxr.SolarXRBridge
|
||||
@@ -13,16 +14,18 @@ import solarxr_protocol.rpc.ChangeHIDSettingsRequest
|
||||
import solarxr_protocol.rpc.HIDSettingsRequest
|
||||
import solarxr_protocol.rpc.HIDSettingsResponse
|
||||
|
||||
internal fun buildHidSettingsResponse(config: HidConfig) = HIDSettingsResponse(trackersOverHid = config.trackersOverHid)
|
||||
|
||||
class HIDSettingsBehaviour(
|
||||
private val settings: Settings,
|
||||
) : SolarXRBridgeBehaviour {
|
||||
override fun observe(receiver: SolarXRBridge) {
|
||||
receiver.rpcDispatcher.on<HIDSettingsRequest> {
|
||||
receiver.sendRpc(HIDSettingsResponse(trackersOverHid = settings.context.state.value.data.hidConfig.trackersOverHid))
|
||||
receiver.sendRpc(buildHidSettingsResponse(settings.context.state.value.data.hidConfig))
|
||||
}.launchIn(receiver.context.scope)
|
||||
|
||||
settings.context.state
|
||||
.map { HIDSettingsResponse(trackersOverHid = it.data.hidConfig.trackersOverHid) }
|
||||
.map { buildHidSettingsResponse(it.data.hidConfig) }
|
||||
.distinctUntilChanged()
|
||||
.drop(1)
|
||||
.onEach(receiver::sendRpc)
|
||||
|
||||
@@ -13,7 +13,7 @@ import solarxr_protocol.rpc.ChangeResetsSettingsRequest
|
||||
import solarxr_protocol.rpc.ResetsSettingsRequest
|
||||
import solarxr_protocol.rpc.ResetsSettingsResponse
|
||||
|
||||
private fun buildResponse(config: ResetsConfig) = ResetsSettingsResponse(
|
||||
internal fun buildResetsSettingsResponse(config: ResetsConfig) = ResetsSettingsResponse(
|
||||
resetMountingFeet = config.resetMountingFeet,
|
||||
armsMountingResetMode = config.armsMountingResetMode,
|
||||
yawResetSmoothTime = config.yawResetSmoothTime,
|
||||
@@ -29,12 +29,12 @@ class ResetsBehaviour(
|
||||
settings.context.state
|
||||
.map { state -> state.data.resetsConfig }
|
||||
.distinctUntilChanged()
|
||||
.onEach { config -> receiver.sendRpc(buildResponse(config)) }
|
||||
.onEach { config -> receiver.sendRpc(buildResetsSettingsResponse(config)) }
|
||||
.launchIn(receiver.context.scope)
|
||||
|
||||
// Send config
|
||||
receiver.rpcDispatcher.on<ResetsSettingsRequest> {
|
||||
receiver.sendRpc(buildResponse(settings.context.state.value.data.resetsConfig))
|
||||
receiver.sendRpc(buildResetsSettingsResponse(settings.context.state.value.data.resetsConfig))
|
||||
}.launchIn(receiver.context.scope)
|
||||
|
||||
// Receive config
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package dev.slimevr.solarxr.rpc
|
||||
|
||||
import dev.slimevr.config.GlobalConfigState
|
||||
import dev.slimevr.config.SettingsConfigState
|
||||
import dev.slimevr.solarxr.SolarXRBridge
|
||||
import dev.slimevr.solarxr.SolarXRBridgeBehaviour
|
||||
import solarxr_protocol.rpc.BoneRoutingSettingsResponse
|
||||
import solarxr_protocol.rpc.ErrorReportingSettingsResponse
|
||||
import solarxr_protocol.rpc.MagToggleResponse
|
||||
import solarxr_protocol.rpc.SettingsDefaultsRequest
|
||||
import solarxr_protocol.rpc.SettingsDefaultsResponse
|
||||
|
||||
// Every config data class defaults its own constructor params, so one default tree
|
||||
// answers every domain at once.
|
||||
private fun buildSettingsDefaultsResponse(): SettingsDefaultsResponse {
|
||||
val settings = SettingsConfigState()
|
||||
val global = GlobalConfigState()
|
||||
return SettingsDefaultsResponse(
|
||||
skeleton = buildSkeletonSettingsResponse(settings.skeletonConfig),
|
||||
resets = buildResetsSettingsResponse(settings.resetsConfig),
|
||||
stayAligned = buildStayAlignedSettingsResponse(settings.stayAlignedConfig),
|
||||
tapDetection = buildTapDetectionSettingsResponse(settings.tapDetectionConfig),
|
||||
timeout = buildTimeoutSettingsResponse(settings.trackersConfig),
|
||||
hid = buildHidSettingsResponse(settings.hidConfig),
|
||||
driver = buildDriverSettingsResponse(settings.driverConfig),
|
||||
vrcosc = buildVrcOscSettingsResponse(settings.vrcOscConfig),
|
||||
vmcosc = buildVmcOscSettingsResponse(settings.vmcConfig),
|
||||
vrm = buildVrmSettingsResponse(settings.vmcConfig),
|
||||
// Routes and output states come from the connected trackers and the platform
|
||||
boneRouting = BoneRoutingSettingsResponse(automatic = settings.boneRoutingConfig.automatic),
|
||||
// The user id and session id identify an install and a run
|
||||
errorReporting = ErrorReportingSettingsResponse(consent = global.errorReporting.consent),
|
||||
mag = MagToggleResponse(trackerId = 0u, enable = settings.trackersConfig.globalMagEnabled),
|
||||
)
|
||||
}
|
||||
|
||||
class SettingsDefaultsBehaviour : SolarXRBridgeBehaviour {
|
||||
override fun observe(receiver: SolarXRBridge) {
|
||||
receiver.rpcDispatcher.on<SettingsDefaultsRequest> {
|
||||
receiver.sendRpc(buildSettingsDefaultsResponse())
|
||||
}.launchIn(receiver.context.scope)
|
||||
}
|
||||
}
|
||||
@@ -21,37 +21,36 @@ import solarxr_protocol.rpc.SkeletonToggles
|
||||
import solarxr_protocol.rpc.TrackingPauseStateRequest
|
||||
import solarxr_protocol.rpc.TrackingPauseStateResponse
|
||||
|
||||
internal fun buildSkeletonSettingsResponse(config: SkeletonConfig) = SkeletonSettingsResponse(
|
||||
toggles = SkeletonToggles(
|
||||
floorClip = config.toggles.floorClip,
|
||||
skatingCorrection = config.toggles.skatingCorrection,
|
||||
toeSnap = config.toggles.toeSnap,
|
||||
footPlant = config.toggles.footPlant,
|
||||
mocapMode = config.toggles.mocapMode,
|
||||
useTrackerPositions = config.toggles.useTrackerPositions,
|
||||
enforceConstraints = config.toggles.enforceConstraints,
|
||||
),
|
||||
ratios = SkeletonRatios(
|
||||
imputeSpineFromUpperToLower = config.ratios.imputeSpineFromUpperToLower,
|
||||
imputeSpineCurvature = config.ratios.imputeSpineCurvature,
|
||||
interpolateHipWithUpperLegs = config.ratios.interpolateHipWithUpperLegs,
|
||||
interpolateUpperLegsTwistWithLowerLegs = config.ratios.interpolateUpperLegsTwistWithLowerLegs,
|
||||
skatingCorrectionStrength = config.ratios.skatingCorrectionStrength,
|
||||
),
|
||||
filtering = SkeletonFiltering(
|
||||
type = config.filtering.type,
|
||||
amount = config.filtering.amount,
|
||||
),
|
||||
)
|
||||
|
||||
class SkeletonSettingsBehaviour(
|
||||
private val settings: Settings,
|
||||
) : SolarXRBridgeBehaviour {
|
||||
override fun observe(receiver: SolarXRBridge) {
|
||||
// Send config
|
||||
receiver.rpcDispatcher.on<SkeletonSettingsRequest> {
|
||||
val config = settings.context.state.value.data.skeletonConfig
|
||||
receiver.sendRpc(
|
||||
SkeletonSettingsResponse(
|
||||
toggles = SkeletonToggles(
|
||||
floorClip = config.toggles.floorClip,
|
||||
skatingCorrection = config.toggles.skatingCorrection,
|
||||
toeSnap = config.toggles.toeSnap,
|
||||
footPlant = config.toggles.footPlant,
|
||||
mocapMode = config.toggles.mocapMode,
|
||||
useTrackerPositions = config.toggles.useTrackerPositions,
|
||||
enforceConstraints = config.toggles.enforceConstraints,
|
||||
),
|
||||
ratios = SkeletonRatios(
|
||||
imputeSpineFromUpperToLower = config.ratios.imputeSpineFromUpperToLower,
|
||||
imputeSpineCurvature = config.ratios.imputeSpineCurvature,
|
||||
interpolateHipWithUpperLegs = config.ratios.interpolateHipWithUpperLegs,
|
||||
interpolateUpperLegsTwistWithLowerLegs = config.ratios.interpolateUpperLegsTwistWithLowerLegs,
|
||||
skatingCorrectionStrength = config.ratios.skatingCorrectionStrength,
|
||||
),
|
||||
filtering = SkeletonFiltering(
|
||||
type = config.filtering.type,
|
||||
amount = config.filtering.amount,
|
||||
),
|
||||
),
|
||||
)
|
||||
receiver.sendRpc(buildSkeletonSettingsResponse(settings.context.state.value.data.skeletonConfig))
|
||||
}.launchIn(receiver.context.scope)
|
||||
|
||||
// Receive config
|
||||
|
||||
@@ -17,6 +17,23 @@ import solarxr_protocol.rpc.StayAlignedRelaxedPose
|
||||
import solarxr_protocol.rpc.StayAlignedSettingsRequest
|
||||
import solarxr_protocol.rpc.StayAlignedSettingsResponse
|
||||
|
||||
internal fun buildStayAlignedSettingsResponse(config: StayAlignedConfig) = StayAlignedSettingsResponse(
|
||||
enabled = config.enabled,
|
||||
standingEnabled = config.standingRelaxedPose.enabled,
|
||||
standingUpperLegAngle = config.standingRelaxedPose.upperLegAngleInDeg,
|
||||
standingLowerLegAngle = config.standingRelaxedPose.lowerLegAngleInDeg,
|
||||
standingFootAngle = config.standingRelaxedPose.footAngleInDeg,
|
||||
sittingEnabled = config.sittingRelaxedPose.enabled,
|
||||
sittingUpperLegAngle = config.sittingRelaxedPose.upperLegAngleInDeg,
|
||||
sittingLowerLegAngle = config.sittingRelaxedPose.lowerLegAngleInDeg,
|
||||
sittingFootAngle = config.sittingRelaxedPose.footAngleInDeg,
|
||||
flatEnabled = config.flatRelaxedPose.enabled,
|
||||
flatUpperLegAngle = config.flatRelaxedPose.upperLegAngleInDeg,
|
||||
flatLowerLegAngle = config.flatRelaxedPose.lowerLegAngleInDeg,
|
||||
flatFootAngle = config.flatRelaxedPose.footAngleInDeg,
|
||||
setupComplete = config.setupComplete,
|
||||
)
|
||||
|
||||
class StayAlignedBehaviour(
|
||||
private val settings: Settings,
|
||||
private val server: VRServer,
|
||||
@@ -85,25 +102,7 @@ class StayAlignedBehaviour(
|
||||
}
|
||||
|
||||
private suspend fun sendConfig(receiver: SolarXRBridge, settings: Settings) {
|
||||
val config = settings.context.state.value.data.stayAlignedConfig
|
||||
receiver.sendRpc(
|
||||
StayAlignedSettingsResponse(
|
||||
enabled = config.enabled,
|
||||
standingEnabled = config.standingRelaxedPose.enabled,
|
||||
standingUpperLegAngle = config.standingRelaxedPose.upperLegAngleInDeg,
|
||||
standingLowerLegAngle = config.standingRelaxedPose.lowerLegAngleInDeg,
|
||||
standingFootAngle = config.standingRelaxedPose.footAngleInDeg,
|
||||
sittingEnabled = config.sittingRelaxedPose.enabled,
|
||||
sittingUpperLegAngle = config.sittingRelaxedPose.upperLegAngleInDeg,
|
||||
sittingLowerLegAngle = config.sittingRelaxedPose.lowerLegAngleInDeg,
|
||||
sittingFootAngle = config.sittingRelaxedPose.footAngleInDeg,
|
||||
flatEnabled = config.flatRelaxedPose.enabled,
|
||||
flatUpperLegAngle = config.flatRelaxedPose.upperLegAngleInDeg,
|
||||
flatLowerLegAngle = config.flatRelaxedPose.lowerLegAngleInDeg,
|
||||
flatFootAngle = config.flatRelaxedPose.footAngleInDeg,
|
||||
setupComplete = config.setupComplete,
|
||||
),
|
||||
)
|
||||
receiver.sendRpc(buildStayAlignedSettingsResponse(settings.context.state.value.data.stayAlignedConfig))
|
||||
}
|
||||
|
||||
private fun updatePoseInConfig(pose: StayAlignedRelaxedPose, poseConfig: StayAlignedRelaxedPoseConfig) {
|
||||
|
||||
@@ -12,6 +12,22 @@ import solarxr_protocol.rpc.TapDetectionSettingsRequest
|
||||
import solarxr_protocol.rpc.TapDetectionSettingsResponse
|
||||
import solarxr_protocol.rpc.TapDetectionSetupModeRequest
|
||||
|
||||
internal fun buildTapDetectionSettingsResponse(config: TapDetectionConfig) = TapDetectionSettingsResponse(
|
||||
yawResetDelay = config.yawResetDelay,
|
||||
fullResetDelay = config.fullResetDelay,
|
||||
mountingResetDelay = config.mountingResetDelay,
|
||||
yawResetEnabled = config.yawResetEnabled,
|
||||
fullResetEnabled = config.fullResetEnabled,
|
||||
mountingResetEnabled = config.mountingResetEnabled,
|
||||
yawResetTaps = config.yawResetTaps.toUByte(),
|
||||
fullResetTaps = config.fullResetTaps.toUByte(),
|
||||
mountingResetTaps = config.mountingResetTaps.toUByte(),
|
||||
yawResetTracker = config.yawResetBodyPart,
|
||||
fullResetTracker = config.fullResetBodyPart,
|
||||
mountingResetTracker = config.mountingResetBodyPart,
|
||||
numberTrackersOverThreshold = config.numberTrackersOverThreshold.toUByte(),
|
||||
)
|
||||
|
||||
class TapDetectionBehaviour(
|
||||
private val settings: Settings,
|
||||
private val tapDetectionManager: TapDetectionManager,
|
||||
@@ -19,24 +35,7 @@ class TapDetectionBehaviour(
|
||||
override fun observe(receiver: SolarXRBridge) {
|
||||
// Send config
|
||||
receiver.rpcDispatcher.on<TapDetectionSettingsRequest> {
|
||||
val config = settings.context.state.value.data.tapDetectionConfig
|
||||
receiver.sendRpc(
|
||||
TapDetectionSettingsResponse(
|
||||
yawResetDelay = config.yawResetDelay,
|
||||
fullResetDelay = config.fullResetDelay,
|
||||
mountingResetDelay = config.mountingResetDelay,
|
||||
yawResetEnabled = config.yawResetEnabled,
|
||||
fullResetEnabled = config.fullResetEnabled,
|
||||
mountingResetEnabled = config.mountingResetEnabled,
|
||||
yawResetTaps = config.yawResetTaps.toUByte(),
|
||||
fullResetTaps = config.fullResetTaps.toUByte(),
|
||||
mountingResetTaps = config.mountingResetTaps.toUByte(),
|
||||
yawResetTracker = config.yawResetBodyPart,
|
||||
fullResetTracker = config.fullResetBodyPart,
|
||||
mountingResetTracker = config.mountingResetBodyPart,
|
||||
numberTrackersOverThreshold = config.numberTrackersOverThreshold.toUByte(),
|
||||
),
|
||||
)
|
||||
receiver.sendRpc(buildTapDetectionSettingsResponse(settings.context.state.value.data.tapDetectionConfig))
|
||||
}.launchIn(receiver.context.scope)
|
||||
|
||||
// Receive config
|
||||
|
||||
@@ -2,24 +2,24 @@ package dev.slimevr.solarxr.rpc
|
||||
|
||||
import dev.slimevr.config.Settings
|
||||
import dev.slimevr.config.SettingsActions
|
||||
import dev.slimevr.config.TrackersConfig
|
||||
import dev.slimevr.solarxr.SolarXRBridge
|
||||
import dev.slimevr.solarxr.SolarXRBridgeBehaviour
|
||||
import solarxr_protocol.rpc.ChangeTimeoutSettingsRequest
|
||||
import solarxr_protocol.rpc.TimeoutSettingsRequest
|
||||
import solarxr_protocol.rpc.TimeoutSettingsResponse
|
||||
|
||||
internal fun buildTimeoutSettingsResponse(config: TrackersConfig) = TimeoutSettingsResponse(
|
||||
delay = config.timeoutDelay,
|
||||
)
|
||||
|
||||
class TimeoutSettingsBehaviour(
|
||||
private val settings: Settings,
|
||||
) : SolarXRBridgeBehaviour {
|
||||
override fun observe(receiver: SolarXRBridge) {
|
||||
// Send config
|
||||
receiver.rpcDispatcher.on<TimeoutSettingsRequest> {
|
||||
val config = settings.context.state.value.data.trackersConfig
|
||||
receiver.sendRpc(
|
||||
TimeoutSettingsResponse(
|
||||
delay = config.timeoutDelay,
|
||||
),
|
||||
)
|
||||
receiver.sendRpc(buildTimeoutSettingsResponse(settings.context.state.value.data.trackersConfig))
|
||||
}.launchIn(receiver.context.scope)
|
||||
|
||||
// Receive config
|
||||
|
||||
@@ -2,6 +2,7 @@ package dev.slimevr.solarxr.rpc
|
||||
|
||||
import dev.slimevr.config.Settings
|
||||
import dev.slimevr.config.SettingsActions
|
||||
import dev.slimevr.config.VMCConfig
|
||||
import dev.slimevr.solarxr.SolarXRBridge
|
||||
import dev.slimevr.solarxr.SolarXRBridgeBehaviour
|
||||
import dev.slimevr.vmc.VMCManager
|
||||
@@ -23,6 +24,19 @@ import solarxr_protocol.rpc.VRMSettingsResponse
|
||||
|
||||
private const val VMC_STATUS_SAMPLE_MS = 300L
|
||||
|
||||
internal fun buildVmcOscSettingsResponse(config: VMCConfig) = VMCOSCSettingsResponse(
|
||||
enabled = config.enabled,
|
||||
portIn = config.portIn.toUShort(),
|
||||
portOut = config.portOut.toUShort(),
|
||||
address = config.address,
|
||||
anchorHip = config.anchorAtHips,
|
||||
mirrorTracking = config.mirrorTracking,
|
||||
)
|
||||
|
||||
internal fun buildVrmSettingsResponse(config: VMCConfig) = VRMSettingsResponse(
|
||||
vrmJson = config.vrmJson,
|
||||
)
|
||||
|
||||
class VmcBehaviour(
|
||||
private val settings: Settings,
|
||||
private val vmcManager: VMCManager,
|
||||
@@ -38,17 +52,7 @@ class VmcBehaviour(
|
||||
|
||||
// Send VMC config
|
||||
receiver.rpcDispatcher.on<VMCOSCSettingsRequest> {
|
||||
val config = settings.context.state.value.data.vmcConfig
|
||||
receiver.sendRpc(
|
||||
VMCOSCSettingsResponse(
|
||||
enabled = config.enabled,
|
||||
portIn = config.portIn.toUShort(),
|
||||
portOut = config.portOut.toUShort(),
|
||||
address = config.address,
|
||||
anchorHip = config.anchorAtHips,
|
||||
mirrorTracking = config.mirrorTracking,
|
||||
),
|
||||
)
|
||||
receiver.sendRpc(buildVmcOscSettingsResponse(settings.context.state.value.data.vmcConfig))
|
||||
}.launchIn(receiver.context.scope)
|
||||
|
||||
receiver.rpcDispatcher.on<VMCOSCStatusRequest> {
|
||||
@@ -57,12 +61,7 @@ class VmcBehaviour(
|
||||
|
||||
// Send VRM json
|
||||
receiver.rpcDispatcher.on<VRMSettingsRequest> {
|
||||
val config = settings.context.state.value.data.vmcConfig
|
||||
receiver.sendRpc(
|
||||
VRMSettingsResponse(
|
||||
vrmJson = config.vrmJson,
|
||||
),
|
||||
)
|
||||
receiver.sendRpc(buildVrmSettingsResponse(settings.context.state.value.data.vmcConfig))
|
||||
}.launchIn(receiver.context.scope)
|
||||
|
||||
// Receive VMC config
|
||||
|
||||
@@ -22,6 +22,14 @@ import solarxr_protocol.rpc.VRCOSCDiscoveredTarget as RpcVRCOSCDiscoveredTarget
|
||||
|
||||
private const val VRC_STATUS_SAMPLE_MS = 300L
|
||||
|
||||
internal fun buildVrcOscSettingsResponse(config: VRCOSCConfig) = VRCOSCSettingsResponse(
|
||||
enabled = config.enabled,
|
||||
useManualNetwork = config.useManualNetwork,
|
||||
portIn = config.portIn.toUShort(),
|
||||
portOut = config.portOut.toUShort(),
|
||||
address = config.address,
|
||||
)
|
||||
|
||||
internal class VrcOscBehaviour(
|
||||
private val settings: Settings,
|
||||
private val vrcOscManager: VRCOSCManager,
|
||||
@@ -40,16 +48,7 @@ internal class VrcOscBehaviour(
|
||||
.launchIn(receiver.context.scope)
|
||||
|
||||
receiver.rpcDispatcher.on<VRCOSCSettingsRequest> {
|
||||
val config = settings.context.state.value.data.vrcOscConfig
|
||||
receiver.sendRpc(
|
||||
VRCOSCSettingsResponse(
|
||||
enabled = config.enabled,
|
||||
useManualNetwork = config.useManualNetwork,
|
||||
portIn = config.portIn.toUShort(),
|
||||
portOut = config.portOut.toUShort(),
|
||||
address = config.address,
|
||||
),
|
||||
)
|
||||
receiver.sendRpc(buildVrcOscSettingsResponse(settings.context.state.value.data.vrcOscConfig))
|
||||
}.launchIn(receiver.context.scope)
|
||||
|
||||
receiver.rpcDispatcher.on<VRCOSCStatusRequest> {
|
||||
|
||||
Reference in new issue
Block a user