This commit is contained in:
loucass003 committed 2026-03-30 11:24:49 +02:00
1 parent 02ca403e24
commit 2fc64b3e8b
7 files changed
+81 -67

No files matched your search

@@ -157,8 +157,8 @@ suspend fun doOtaFlash(
onStatus(FirmwareUpdateStatus.REBOOTING, 0)
// Wait for the device to come back online after reboot.
// which don't emit a new VRServerState, are also observed.
// flatMapLatest switches to the matched device's own state flow so that status changes,
// which don't emit a new VRServerState, are also observed.
@OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class)
val connected = withTimeoutOrNull(60_000) {
server.context.state
@@ -37,6 +37,7 @@ private fun UserHeightCalibrationStatus.isTerminal() = when (this) {
UserHeightCalibrationStatus.ERROR_TOO_HIGH,
UserHeightCalibrationStatus.ERROR_TOO_SMALL,
-> true
else -> false
}
@@ -51,13 +52,12 @@ private fun isHmdLeveled(snapshot: TrackerSnapshot): Boolean {
}
object CalibrationBehaviour : HeightCalibrationBehaviourType {
override fun reduce(state: HeightCalibrationState, action: HeightCalibrationActions) =
when (action) {
is HeightCalibrationActions.Update -> state.copy(
status = action.status,
currentHeight = action.currentHeight,
)
}
override fun reduce(state: HeightCalibrationState, action: HeightCalibrationActions) = when (action) {
is HeightCalibrationActions.Update -> state.copy(
status = action.status,
currentHeight = action.currentHeight,
)
}
}
internal suspend fun runCalibrationSession(
@@ -84,7 +84,6 @@ internal suspend fun runCalibrationSession(
dispatch(UserHeightCalibrationStatus.RECORDING_FLOOR)
withTimeoutOrNull(TIMEOUT_MS) {
// Floor phase: collect controller updates until the floor level is locked in
controllerUpdates
.sample(SAMPLE_INTERVAL_MS)
@@ -64,12 +64,14 @@ class HeightCalibrationManager(
(bodyPart == BodyPart.LEFT_HAND || bodyPart == BodyPart.RIGHT_HAND) && it.context.state.value.position != null
}
if (controllers.isEmpty()) return@flatMapLatest emptyFlow()
combine(controllers.map { controller ->
controller.context.state.map { s ->
val position = s.position ?: error("hands (or Controller) will always have a position in this case")
TrackerSnapshot(position = position, rotation = s.rawRotation)
}
}) { snapshots -> snapshots.minByOrNull { it.position.y }!! }
combine(
controllers.map { controller ->
controller.context.state.map { s ->
val position = s.position ?: error("hands (or Controller) will always have a position in this case")
TrackerSnapshot(position = position, rotation = s.rawRotation)
}
},
) { snapshots -> snapshots.minByOrNull { it.position.y }!! }
}
fun start() {
@@ -20,7 +20,7 @@ object HIDRegistrationBehaviour : HIDReceiverBehaviour {
deviceId = action.deviceId,
trackerId = null,
)
),
),
)
else -> state
@@ -55,10 +55,12 @@ class SerialServer(
if (conn is SerialConnection.Console) {
conn.handle.close()
}
context.dispatchAll(listOf(
SerialServerActions.RemoveConnection(portLocation),
SerialServerActions.PortLost(portLocation)
))
context.dispatchAll(
listOf(
SerialServerActions.RemoveConnection(portLocation),
SerialServerActions.PortLost(portLocation),
),
)
}
fun onDataReceived(portLocation: String, line: String) {