Skip to content

Commit

Permalink
Fix reset status on yaw reset (#730)
Browse files Browse the repository at this point in the history
  • Loading branch information
ImUrX committed Jun 15, 2023
1 parent f7b4a60 commit 28b37b7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ object RPCUtil {
@JvmStatic
fun getLocalIp(): String =
NetworkInterface.getNetworkInterfaces().asSequence().first {
it.isUp && !it.isLoopback && !it.isVirtual
it.isUp && !it.isLoopback && !it.isVirtual && it.interfaceAddresses.any { it.broadcast != null }
}.interfaceAddresses.first {
it.broadcast != null
}.address.hostAddress
Expand Down
13 changes: 13 additions & 0 deletions server/src/main/java/dev/slimevr/tracking/trackers/Tracker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,23 @@ class Tracker @JvmOverloads constructor(
var temperature: Float? = null
var customName: String? = null

/**
* If the tracker has gotten disconnected after it was initialized first time
*/
var disconnectedRecently = false
private var alreadyInitialized = false
var status = TrackerStatus.DISCONNECTED
set(value) {
if (field == value) return

field = value

if (field == TrackerStatus.DISCONNECTED && alreadyInitialized) {
disconnectedRecently = true
}
if (field.sendData) {
alreadyInitialized = true
}
if (!isInternal) {
// If the status of a non-internal tracker has changed, inform
// the VRServer to recreate the skeleton, as it may need to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,14 @@ class TrackerResetsHandler(val tracker: Tracker) {
makeIdentityAdjustmentQuatsYaw()

calculateDrift(rot)

// Let's just remove the status if you do yaw reset if the tracker was
// disconnected and then connected back
if (this.tracker.lastResetStatus != 0u && this.tracker.disconnectedRecently) {
vrServer.statusSystem.removeStatus(this.tracker.lastResetStatus)
this.tracker.disconnectedRecently = false
this.tracker.lastResetStatus = 0u
}
}

/**
Expand Down

0 comments on commit 28b37b7

Please sign in to comment.