Fit VR games on the glasses: full view, seated origin at the head, pad hands reach with the d-pad

This commit is contained in:
maxjivi05 committed 2026-10-13 11:24:01 -04:00
1 parent a746d56dc8
commit 7c8fa679bd
6 files changed
+51 -8

No files matched your search

@@ -2725,7 +2725,11 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
}
private fun pushCardboard(c: Cardboard) {
val fov = if (c.viewer == Cardboard.Viewer.VITURE.id) glasses.verticalFovDeg else 0f
val fov = when {
c.viewer != Cardboard.Viewer.VITURE.id -> 0f
c.source == Cardboard.SOURCE_SBS -> GLASSES_VR_FOV_DEG
else -> glasses.verticalFovDeg
}
panelSizeMm().let { (w, h) -> c.push(w, h, fov, refreshHz()) }
}
@@ -2997,6 +3001,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
private const val DRAWER_SLOW_REPEAT_FLOOR_MS = 240L
private const val DRAWER_FAST_REPEAT_INTERVAL_MS = 90L
private const val DRAWER_REPEAT_ACCELERATION_MS = 1_400L
private const val GLASSES_VR_FOV_DEG = 70f
/** Compositor scale modes (Container.FULLSCREEN_* values): 1 = fit with bars, centred. */
private const val SCALE_FIT = 1
private const val ALIGN_CENTER = 0
@@ -136,7 +136,10 @@ class AgentBridgeProvider : ContentProvider() {
else -> return error("INVALID_KEY", "Unknown glasses setting '$key'")
}
}
"simulate" -> if (!g.simulate(request.optInt("seconds", 20).coerceIn(1, 600))) return error("BUSY", "Already simulating")
"simulate" -> {
fun angle(key: String) = if (request.has(key)) request.optDouble(key).takeIf { it.isFinite() }?.coerceIn(-90.0, 90.0) else null
if (!g.simulate(request.optInt("seconds", 20).coerceIn(1, 600), angle("yaw"), angle("pitch"))) return error("BUSY", "Already simulating")
}
"stop-simulate" -> g.stopSimulation()
"query" -> { g.query(); Thread.sleep(600) }
"mode" -> { g.sendMode(request.optString("mode").removePrefix("0x").toInt(16)); Thread.sleep(600) }
@@ -211,16 +211,17 @@ object Glasses {
post { updateImu() }
}
fun simulate(seconds: Int): Boolean {
fun simulate(seconds: Int, holdYaw: Double? = null, holdPitch: Double? = null): Boolean {
val hold = holdYaw != null || holdPitch != null
val t = Thread({
val start = SystemClock.elapsedRealtimeNanos()
val end = start + seconds * 1_000_000_000L
while (SystemClock.elapsedRealtimeNanos() < end && simulating.get() === Thread.currentThread()) {
val now = SystemClock.elapsedRealtimeNanos()
val t = (now - start) / 1e9
val yaw = 40.0 * sin(t * 2 * Math.PI / 6.0)
val pitch = 15.0 * sin(t * 2 * Math.PI / 4.0)
val roll = 5.0 * sin(t * 2 * Math.PI / 5.0)
val yaw = if (hold) holdYaw ?: 0.0 else 40.0 * sin(t * 2 * Math.PI / 6.0)
val pitch = if (hold) holdPitch ?: 0.0 else 15.0 * sin(t * 2 * Math.PI / 4.0)
val roll = if (hold) 0.0 else 5.0 * sin(t * 2 * Math.PI / 5.0)
val q = VitureProtocol.eulerZxy(roll.toFloat(), pitch.toFloat(), yaw.toFloat())
deliver(q, now)
SystemClock.sleep(4)