mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-04-06 02:01:58 +02:00
Add accelDataTick
This commit is contained in:
@@ -179,6 +179,10 @@ class Tracker @JvmOverloads constructor(
|
||||
val stayAligned = StayAlignedTrackerState(this)
|
||||
val yawResetSmoothing = InterpolationHandler()
|
||||
|
||||
// Currently only used for accel resets, to add anything else, consider using a
|
||||
// subscribable event listener instead
|
||||
var accelTickCallback: ((tracker: Tracker) -> Unit)? = null
|
||||
|
||||
init {
|
||||
// IMPORTANT: Look here for the required states of inputs
|
||||
require(!allowReset || (hasRotation && allowReset)) {
|
||||
@@ -488,6 +492,13 @@ class Tracker @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells the tracker that it received new accel data
|
||||
* Accel may be (and usually is) desynced from rotation data, so if we want the
|
||||
* latest, we need to process it here
|
||||
*/
|
||||
fun accelDataTick() = accelTickCallback?.invoke(this)
|
||||
|
||||
/**
|
||||
* A way to delay the timeout of the tracker
|
||||
*/
|
||||
|
||||
@@ -378,6 +378,9 @@ class HIDCommon {
|
||||
if (packetType == 1 || packetType == 2 || packetType == 4 || packetType == 7) {
|
||||
tracker.dataTick() // only data tick if there is rotation data
|
||||
}
|
||||
if (packetType == 1 || packetType == 2 || packetType == 7) {
|
||||
tracker.accelDataTick()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -424,6 +424,7 @@ class TrackersUDPServer(private val port: Int, name: String, private val tracker
|
||||
} else {
|
||||
tracker.setAcceleration(SENSOR_OFFSET_CORRECTION.sandwich(packet.acceleration))
|
||||
}
|
||||
tracker.accelDataTick()
|
||||
}
|
||||
tracker.dataTick()
|
||||
}
|
||||
@@ -462,6 +463,7 @@ class TrackersUDPServer(private val port: Int, name: String, private val tracker
|
||||
} else {
|
||||
tracker.setAcceleration(SENSOR_OFFSET_CORRECTION.sandwich(packet.acceleration))
|
||||
}
|
||||
tracker.accelDataTick()
|
||||
}
|
||||
|
||||
is UDPPacket10PingPong -> {
|
||||
|
||||
Reference in New Issue
Block a user