diff --git a/server/core/src/main/java/dev/slimevr/driver/behaviours.kt b/server/core/src/main/java/dev/slimevr/driver/behaviours.kt index e5039b802..69b258e45 100644 --- a/server/core/src/main/java/dev/slimevr/driver/behaviours.kt +++ b/server/core/src/main/java/dev/slimevr/driver/behaviours.kt @@ -175,6 +175,7 @@ class DriverIncomingTrackersBehaviour : DriverBridgeBehaviour { val (device, tracker) = if (existingTracker != null) { val device = server.getDevice(existingTracker.context.state.value.deviceId) ?: error("could not find existing device for serial $serial") + existingTracker.context.dispatch(TrackerActions.Update { copy(intendedBodyPart = bodyPart) }) Pair(device, existingTracker) } else { val deviceId = server.nextHandle() @@ -197,6 +198,7 @@ class DriverIncomingTrackersBehaviour : DriverBridgeBehaviour { id = trackerId, name = name, bodyPart = bodyPart, + intendedBodyPart = bodyPart, deviceId = deviceId, hardwareId = serial, origin = DeviceOrigin.DRIVER, diff --git a/server/core/src/main/java/dev/slimevr/solarxr/driver/incoming.kt b/server/core/src/main/java/dev/slimevr/solarxr/driver/incoming.kt index 6075c6123..6b8054a01 100644 --- a/server/core/src/main/java/dev/slimevr/solarxr/driver/incoming.kt +++ b/server/core/src/main/java/dev/slimevr/solarxr/driver/incoming.kt @@ -44,7 +44,7 @@ class DriverIncomingTrackersBehaviour( return@onDriverMessage } - existing.context.dispatch(TrackerActions.SetDriverName(driverName)) + existing.context.dispatchAll(listOf(TrackerActions.SetDriverName(driverName), TrackerActions.Update { copy(intendedBodyPart = req.bodyPart) })) receiver.sendDriverMessage( AddTrackerResponse( status = AddTrackerStatus.ALREADY_EXISTS, @@ -77,6 +77,7 @@ class DriverIncomingTrackersBehaviour( id = trackerId, name = req.displayName ?: "Tracker #$trackerId", bodyPart = req.bodyPart, + intendedBodyPart = req.bodyPart, deviceId = deviceId, hardwareId = hardwareId, origin = DeviceOrigin.DRIVER, diff --git a/server/core/src/main/java/dev/slimevr/tracker/module.kt b/server/core/src/main/java/dev/slimevr/tracker/module.kt index 772cbd1e9..cbd1c6660 100644 --- a/server/core/src/main/java/dev/slimevr/tracker/module.kt +++ b/server/core/src/main/java/dev/slimevr/tracker/module.kt @@ -58,6 +58,8 @@ data class TrackerState( val name: String, val imuType: ImuType?, val bodyPart: BodyPart?, + // The default body part given by e.g. driver, VMC, etc. + val intendedBodyPart: BodyPart?, val customName: String?, val trackerDataType: TrackerDataType, // TODO val lastMountingMethod: MountingMethod, @@ -170,6 +172,7 @@ class Tracker( id: Int, name: String = "Tracker #$id", bodyPart: BodyPart? = null, + intendedBodyPart: BodyPart? = null, deviceId: Int, imuType: ImuType? = null, hardwareId: String, @@ -189,6 +192,7 @@ class Tracker( name = name, imuType = imuType, bodyPart = bodyPart, + intendedBodyPart = intendedBodyPart, stayAlignedData = DEFAULT_STATE.stayAlignedData.copy(enabled = settings.context.state.value.data.stayAlignedConfig.enabled), ) val trackerState = if (savedConfig != null) { @@ -232,6 +236,7 @@ class Tracker( name = "defaultTracker", imuType = ImuType.BNO085, bodyPart = null, + intendedBodyPart = null, customName = null, trackerDataType = TrackerDataType.ROTATION, lastMountingMethod = MountingMethod.MANUAL, diff --git a/server/core/src/main/java/dev/slimevr/trackingchecklist/behaviours.kt b/server/core/src/main/java/dev/slimevr/trackingchecklist/behaviours.kt index 48112a30e..8fd03e6be 100644 --- a/server/core/src/main/java/dev/slimevr/trackingchecklist/behaviours.kt +++ b/server/core/src/main/java/dev/slimevr/trackingchecklist/behaviours.kt @@ -76,6 +76,7 @@ data class ChecklistTracker( val origin: DeviceOrigin, val status: TrackerStatus, val bodyPart: BodyPart?, + val intendedBodyPart: BodyPart?, val imuType: ImuType?, val completedRestCalibration: Boolean?, // Deliberately not the position itself: the checks only ask whether there is one, and carrying the @@ -88,6 +89,7 @@ internal fun checklistTracker(tracker: TrackerState) = ChecklistTracker( origin = tracker.origin, status = tracker.status, bodyPart = tracker.bodyPart, + intendedBodyPart = tracker.intendedBodyPart, imuType = tracker.imuType, completedRestCalibration = tracker.completedRestCalibration, hasPosition = tracker.position != null, @@ -99,7 +101,7 @@ internal fun trackerStatesFlow(server: VRServer): Flow> = class HMDCheckBehaviour(private val trackerStates: StateFlow>) : TrackingChecklistBehaviourType { private fun computeStep(trackers: List): TrackingChecklistStep { - val hmdTracker = trackers.firstOrNull { tracker -> tracker.origin == DeviceOrigin.DRIVER } + val hmdTracker = trackers.firstOrNull { tracker -> tracker.origin == DeviceOrigin.DRIVER && tracker.intendedBodyPart == BodyPart.HEAD } val isAssigned = hmdTracker?.bodyPart == BodyPart.HEAD return TrackingChecklistStep( valid = isAssigned, diff --git a/server/core/src/main/java/dev/slimevr/vrcosc/input.kt b/server/core/src/main/java/dev/slimevr/vrcosc/input.kt index 4201af5f9..e003eb054 100644 --- a/server/core/src/main/java/dev/slimevr/vrcosc/input.kt +++ b/server/core/src/main/java/dev/slimevr/vrcosc/input.kt @@ -56,6 +56,7 @@ private class VRSystemTrackerRegistry( id = trackerId, name = trackerName, bodyPart = bodyPart, + intendedBodyPart = bodyPart, deviceId = device.context.state.value.id, hardwareId = "vrcosc:vrsystem:${tracker.name.lowercase()}", origin = DeviceOrigin.VRC,