Fix unassigned HMD step relying on the order driver trackers get added

This commit is contained in:
Sapphire committed 2026-08-26 16:18:36 -05:00
1 parent e5ecd500c8
commit cc535fbf25
5 files changed
+13 -2

No files matched your search

@@ -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,
@@ -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,
@@ -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,
@@ -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<List<ChecklistTracker>> =
class HMDCheckBehaviour(private val trackerStates: StateFlow<List<ChecklistTracker>>) : TrackingChecklistBehaviourType {
private fun computeStep(trackers: List<ChecklistTracker>): 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,
@@ -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,