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 f75eea103..b0e61a381 100644 --- a/server/core/src/main/java/dev/slimevr/driver/behaviours.kt +++ b/server/core/src/main/java/dev/slimevr/driver/behaviours.kt @@ -30,7 +30,9 @@ object DriverBaseBehaviour : DriverBridgeBehaviour { receiver.inbound.on { event -> val tracker = receiver.context.state.value.trackers[event.trackerId] if (tracker != null) { - tracker.context.dispatch(TrackerActions.SetRotation(rotation = event.rotation)) + tracker.context.dispatch(TrackerActions.Update { + copy(rawRotation = event.rotation, position = event.position) + }) } else { AppLogger.steamvr.warn("Failed to find tracker ${event.trackerId}") } diff --git a/server/desktop/src/main/java/dev/slimevr/desktop/ipc/protocol.kt b/server/desktop/src/main/java/dev/slimevr/desktop/ipc/protocol.kt index 2da678ef0..5707771e6 100644 --- a/server/desktop/src/main/java/dev/slimevr/desktop/ipc/protocol.kt +++ b/server/desktop/src/main/java/dev/slimevr/desktop/ipc/protocol.kt @@ -12,6 +12,7 @@ import dev.slimevr.driver.DriverBridge import dev.slimevr.driver.DriverBridgeInbound import dev.slimevr.driver.DriverBridgeOutbound import io.github.axisangles.ktmath.Quaternion +import io.github.axisangles.ktmath.Vector3 import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.flow.Flow @@ -104,13 +105,22 @@ suspend fun handleDriverConnection( } } msg.tracker_added?.let { ta -> - bridge.inbound.emit(DriverBridgeInbound.TrackerAdded(id = ta.tracker_id, name = ta.tracker_name, manufacturer = ta.manufacturer.ifEmpty { "SlimeVR" }, serial = ta.tracker_serial)) + bridge.inbound.emit(DriverBridgeInbound.TrackerAdded( + id = ta.tracker_id, + name = ta.tracker_name, + manufacturer = ta.manufacturer.ifEmpty { "SlimeVR" }, + serial = ta.tracker_serial + )) } msg.battery?.let { bat -> bridge.inbound.emit(DriverBridgeInbound.TrackerBattery(id = bat.tracker_id, batteryLevel = bat.battery_level, charging = bat.is_charging)) } msg.position?.let { pos -> - bridge.inbound.emit(DriverBridgeInbound.TrackerPosition(trackerId = pos.tracker_id, rotation = Quaternion(w = pos.qw, x = pos.qx, y = pos.qy, z = pos.qz), position = null)) + bridge.inbound.emit(DriverBridgeInbound.TrackerPosition( + trackerId = pos.tracker_id, + rotation = Quaternion(w = pos.qw, x = pos.qx, y = pos.qy, z = pos.qz), + position = if (pos.x != null && pos.y != null && pos.z != null) Vector3(pos.x, pos.y, pos.z) else null, + )) } } } finally {