Skip to content

Commit

Permalink
report status on missing hmd
Browse files Browse the repository at this point in the history
  • Loading branch information
ImUrX committed Mar 30, 2024
1 parent 7760604 commit 955979b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ import io.github.axisangles.ktmath.Quaternion.Companion.IDENTITY
import io.github.axisangles.ktmath.Vector3
import io.github.axisangles.ktmath.Vector3.Companion.POS_Y
import org.apache.commons.math3.util.Precision
import solarxr_protocol.rpc.StatusData
import solarxr_protocol.rpc.StatusDataUnion
import solarxr_protocol.rpc.StatusUnassignedHMD
import solarxr_protocol.rpc.StatusUnassignedHMDT
import java.util.function.Consumer
import kotlin.math.*

Expand Down Expand Up @@ -694,5 +698,35 @@ class HumanPoseManager(val server: VRServer?) {
skeleton.setPauseTracking(pauseTracking, sourceName)
}

fun togglePauseTracking(sourceName: String?): Boolean = skeleton.togglePauseTracking(sourceName) // #endregion
fun togglePauseTracking(sourceName: String?): Boolean = skeleton.togglePauseTracking(sourceName)

private var lastMissingHmdStatus = 0u
fun checkReportMissingHmd() {
if (server == null) return
if (skeleton.headTracker == null &&
lastMissingHmdStatus == 0u &&
VRServer.instance.allTrackers.any { it.isHmd }
) {
reportMissingHmd()
} else if (lastMissingHmdStatus != 0u &&
(skeleton.headTracker != null || !VRServer.instance.allTrackers.any { it.isHmd })
) {
server.statusSystem.removeStatus(lastMissingHmdStatus)
lastMissingHmdStatus = 0u
}
}

private fun reportMissingHmd() {
require(lastMissingHmdStatus == 0u) {
"${::lastMissingHmdStatus.name} must be 0u, but was $lastMissingHmdStatus"
}

val status = StatusDataUnion().apply {
type = StatusData.StatusUnassignedHMD
value = StatusUnassignedHMDT()
}
lastMissingHmdStatus = server!!.statusSystem.addStatus(status, true)
}

// #endregion
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ class HumanSkeleton(
// Input trackers
var headTracker: Tracker? by Delegates.observable(null) { _, old, new ->
if (old == new) return@observable

humanPoseManager.checkReportMissingHmd()
}
var neckTracker: Tracker? = null
var upperChestTracker: Tracker? = null
Expand Down

0 comments on commit 955979b

Please sign in to comment.