From 102c83d5b94cc6e8580de56913cfe4b38edd0ea8 Mon Sep 17 00:00:00 2001 From: imterah Date: Sat, 28 Jun 2025 19:49:12 -0400 Subject: [PATCH] fix: Adds look vector correction code This is needed for the Xreal line of devices as the reverse engineered driver works, but has... issues. One of them being normal sensor drift, the other being ~2330 units in any direction for some reason. This is a hack but I can't think of a normal person that can spin their head around fast enough to trigger anything past 7 units/pull cycle, especially considering our already high pulling rate (basically as fast as we can) --- app/renderer/renderer.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app/renderer/renderer.go b/app/renderer/renderer.go index 79cda44..6bac3a0 100644 --- a/app/renderer/renderer.go +++ b/app/renderer/renderer.go @@ -235,6 +235,24 @@ func EnterRenderLoop(config *libconfig.Config, displayMetadata *edidtools.Displa lookVector.Z = (currentRoll - previousRoll) * 6.5 } + // evil look hacks to not randomly explode + maxTrustedSize := float64(7) + + if math.Abs(float64(lookVector.X)) > maxTrustedSize { + log.Errorf("WOAH. Ignoring extreme camera movement for vector X: %.02f", lookVector.X) + lookVector.X = 0 + } + + if math.Abs(float64(lookVector.Y)) > maxTrustedSize { + log.Errorf("WOAH. Ignoring extreme camera movement for vector Y: %.02f", lookVector.Y) + lookVector.Y = 0 + } + + if !hasZVectorDisabledQuirk && math.Abs(float64(lookVector.Z)) > maxTrustedSize { + log.Errorf("WOAH. Ignoring extreme camera movement for vector Z: %.02f", lookVector.Z) + lookVector.Z = 0 + } + rl.UpdateCameraPro(&camera, movementVector, lookVector, 0) } } else {