mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-22 06:15:58 +00:00
feat: add SDK-free 3DoF tracking for VITURE Pro 2 (#1115)
* feat: itch.io store, library and installs for DRM-free Windows builds (#1064) * feat: add experimental SDK-free VITURE Pro 2 tracking * docs: record full-app Pro 2 hardware validation * docs: record successful Pro 2 user game test * fix: translate Pro 2 tracking notice for all supported locales * fix: respect model capabilities for glasses controls * fix: handle fold configuration during glasses probe --------- Co-authored-by: kingokksa <47888451+kingokksa@users.noreply.github.com> Co-authored-by: xXJsonDeruloXx <danielhimebauch@gmail.com>
This commit is contained in:
1 parent
7482f797c7
commit
3d9f200a7e
66 files changed
+2974
-19
No files matched your search
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 Holger Bartnick
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -43,6 +43,7 @@ data class GlassesState(
|
||||
val volumeMax: Int = 8,
|
||||
val sunblock: Boolean = false,
|
||||
val hardwareControls: Boolean = true,
|
||||
val supportsDisplayModeControl: Boolean = true,
|
||||
val hasSunblock: Boolean = true,
|
||||
val controlError: String? = null,
|
||||
val tracking: Boolean = false,
|
||||
@@ -64,7 +65,7 @@ data class GlassesState(
|
||||
val spatialConnected: Boolean get() = canControl && supportsSpatial
|
||||
fun usesSpatialControllers(settings: GlassesSettings) = spatialConnected && settings.positionalTracking &&
|
||||
(settings.handControllers || settings.joyConTracking)
|
||||
val can3d: Boolean get() = canControl && !noSignal && sbsSupport != SBS_FAILS
|
||||
val can3d: Boolean get() = canControl && supportsDisplayModeControl && !noSignal && sbsSupport != SBS_FAILS
|
||||
val verticalFovDeg: Float get() {
|
||||
val half = Math.toRadians(diagonalFovDeg / 2.0)
|
||||
val aspect = if (width > 0 && height > 0)
|
||||
@@ -213,7 +214,7 @@ object Glasses {
|
||||
}
|
||||
|
||||
fun sendMode(mode: Int) = post {
|
||||
if (!_state.value.canControl) return@post
|
||||
if (!_state.value.canControl || !_state.value.supportsDisplayModeControl) return@post
|
||||
if (link?.send(VitureProtocol.MSG_DISPLAY, byteArrayOf(mode.toByte())) == true) lastModeSentAt = SystemClock.uptimeMillis()
|
||||
}
|
||||
|
||||
@@ -470,6 +471,7 @@ object Glasses {
|
||||
.put("controlError", s.controlError ?: JSONObject.NULL)
|
||||
.put("experimental", s.experimental)
|
||||
.put("supportsScreen3dof", s.supportsScreen3dof)
|
||||
.put("supportsDisplayModeControl", s.supportsDisplayModeControl)
|
||||
.put("supportsSpatial", s.supportsSpatial)
|
||||
.put("firmware", (link as? VitureSdkLink)?.firmware ?: JSONObject.NULL)
|
||||
.put("spatialSdk", (link as? VitureSdkLink)?.spatialDiagnostics()?.let {
|
||||
@@ -614,14 +616,16 @@ object Glasses {
|
||||
switching3d = modeState.pendingStereo,
|
||||
brightnessMax = m?.brightnessMax ?: 8, volumeMax = m?.volumeMax ?: 8,
|
||||
sunblock = if (m === XrealModel) it.sunblock else _settings.value.sunblock ?: it.sunblock,
|
||||
hardwareControls = device?.vendorId == VitureProtocol.VENDOR_ID || m === XrealModel || m is RokidModel,
|
||||
hardwareControls = m?.hardwareControls == true &&
|
||||
(device?.vendorId == VitureProtocol.VENDOR_ID || m === XrealModel || m is RokidModel),
|
||||
supportsDisplayModeControl = m?.supportsDisplayModeControl == true,
|
||||
hasSunblock = m?.hasSunblock == true,
|
||||
diagonalFovDeg = m?.diagonalFovDeg ?: 46f,
|
||||
tracking = it.tracking && link != null,
|
||||
noSignal = noSignal,
|
||||
sbs90 = m?.sbs90 == true,
|
||||
rates2d = m?.rates2d ?: listOf(60, 90, 120),
|
||||
experimental = m === XrealModel,
|
||||
experimental = m === XrealModel || (m is VitureProtocol.Model && m.family == VitureProtocol.Family.PRO2 && !m.needsSdk),
|
||||
supportsScreen3dof = link?.hasImu == true,
|
||||
supports30Hz = display?.let(::supports30Hz) == true,
|
||||
supportsSpatial = (link as? VitureSdkLink)?.isCarina == true,
|
||||
@@ -653,7 +657,8 @@ object Glasses {
|
||||
internal fun deviceModel(device: UsbDevice): GlassesModel? {
|
||||
val name = runCatching { device.productName }.getOrNull()
|
||||
return if (device.vendorId == VitureProtocol.VENDOR_ID) {
|
||||
VitureSdk.marketName(device.productId)?.let(VitureProtocol::sdkModel)
|
||||
if (device.productId == VitureProtocol.PRO2_PRODUCT_ID) VitureProtocol.model(device.productId, name)
|
||||
else VitureSdk.marketName(device.productId)?.let(VitureProtocol::sdkModel)
|
||||
?: VitureProtocol.model(device.productId, name)
|
||||
}
|
||||
else if (XrealModel.matches(device.vendorId, device.productId)) XrealModel
|
||||
@@ -720,7 +725,9 @@ object Glasses {
|
||||
calibrationKey = calibrationStore.key(device.vendorId, device.productId,
|
||||
runCatching { device.serialNumber }.getOrNull(), model?.name.orEmpty())
|
||||
val l = if (device.vendorId == VitureProtocol.VENDOR_ID) {
|
||||
if ((model as? VitureProtocol.Model)?.needsSdk == true) {
|
||||
if (device.productId == VitureProtocol.PRO2_PRODUCT_ID) {
|
||||
VitureV2Link.open(usb, device, v2Listener(generation))
|
||||
} else if ((model as? VitureProtocol.Model)?.needsSdk == true) {
|
||||
// Android can evict cacheDir while the SDK is running.
|
||||
Log.i(TAG, "opening VITURE SDK pid=0x%04X spatial=%s".format(device.productId, spatial))
|
||||
VitureSdkLink.open(usb, device, File(app.noBackupFilesDir, "viture"), sdkListener(generation),
|
||||
@@ -851,6 +858,40 @@ object Glasses {
|
||||
}
|
||||
}
|
||||
|
||||
private fun v2Listener(generation: Long) = object : VitureV2Link.Listener {
|
||||
override fun onReady() = post {
|
||||
if (generation != linkGeneration) return@post
|
||||
val current = link as? VitureV2Link ?: return@post
|
||||
publish { it.copy(connected = current.ready, supportsScreen3dof = current.hasImu,
|
||||
tracking = current.trackingActive, controlError = null) }
|
||||
updateImu()
|
||||
}
|
||||
override fun onValue(msgId: Int, value: Int) = post {
|
||||
if (generation != linkGeneration) return@post
|
||||
when (msgId) {
|
||||
VitureProtocol.MSG_GET_DISPLAY -> glassesMode = value
|
||||
VitureProtocol.MSG_GET_BRIGHTNESS -> publish { it.copy(brightness = value) }
|
||||
VitureProtocol.MSG_GET_VOLUME -> publish { it.copy(volume = value) }
|
||||
}
|
||||
}
|
||||
override fun onPose(raw: ByteArray, q: FloatArray, timeNs: Long) {
|
||||
if (generation != linkGeneration) return
|
||||
imuPackets++
|
||||
probe?.invoke(raw, q)
|
||||
if (simulating.get() == null) deliver(q, timeNs)
|
||||
}
|
||||
override fun onTracking(active: Boolean) = post {
|
||||
if (generation != linkGeneration) return@post
|
||||
val current = link as? VitureV2Link ?: return@post
|
||||
publish { it.copy(tracking = active && current.trackingActive) }
|
||||
}
|
||||
override fun onLost() = post {
|
||||
if (generation != linkGeneration) return@post
|
||||
closeLink()
|
||||
publish { it.copy(controlError = app.getString(R.string.glasses_connection_failed)) }
|
||||
}
|
||||
}
|
||||
|
||||
private fun rayNeoListener(generation: Long) = object : RayNeoLink.Listener {
|
||||
override fun onDeviceInfo(boardId: Int, calibrationSaved: Boolean) = post {
|
||||
if (generation != linkGeneration) return@post
|
||||
@@ -926,7 +967,7 @@ object Glasses {
|
||||
private fun applyMode(force: Boolean) {
|
||||
val s = _state.value
|
||||
val m = model ?: return
|
||||
if (!s.canControl) return
|
||||
if (!s.canControl || !s.supportsDisplayModeControl) return
|
||||
if (modeState.restorePending) {
|
||||
sendMode(false)
|
||||
return
|
||||
@@ -948,6 +989,7 @@ object Glasses {
|
||||
|
||||
private fun sendMode(sbs: Boolean): Boolean {
|
||||
val m = model ?: return false
|
||||
if (!m.supportsDisplayModeControl) return false
|
||||
if (sbs && !_settings.value.gameOnGlasses) update { it.copy(gameOnGlasses = true) }
|
||||
val g = _settings.value
|
||||
val resolution = GlassesDisplayModes.selected(g, _state.value, sbs)
|
||||
@@ -980,11 +1022,11 @@ object Glasses {
|
||||
val l = link ?: return
|
||||
if (!l.ready) return
|
||||
val want = (sink != null || poseObservers.isNotEmpty() || probe != null || _calibration.value.running || SpatialTracking.enabled) && l.hasImu
|
||||
if (want == _state.value.tracking) return
|
||||
if (l !is VitureV2Link && want == _state.value.tracking) return
|
||||
val accepted = l.send(VitureProtocol.MSG_IMU, byteArrayOf(if (want) 1 else 0))
|
||||
if (want && !accepted) return
|
||||
if (want) l.send(VitureProtocol.MSG_IMU_RATE, byteArrayOf(VitureProtocol.IMU_RATE_240.toByte()))
|
||||
publish { it.copy(tracking = want) }
|
||||
publish { it.copy(tracking = if (l is VitureV2Link) l.trackingActive else want) }
|
||||
}
|
||||
|
||||
private fun linkListener(generation: Long) = object : VitureLink.Listener {
|
||||
|
||||
@@ -4,6 +4,8 @@ package com.droiddeck.launcher.glasses
|
||||
interface GlassesModel {
|
||||
val name: String
|
||||
val controllable: Boolean
|
||||
val hardwareControls: Boolean get() = true
|
||||
val supportsDisplayModeControl: Boolean get() = true
|
||||
val brightnessMax: Int
|
||||
val volumeMax: Int
|
||||
val diagonalFovDeg: Float
|
||||
|
||||
@@ -6,6 +6,7 @@ import kotlin.math.sqrt
|
||||
|
||||
object VitureProtocol {
|
||||
const val VENDOR_ID = 0x35CA
|
||||
const val PRO2_PRODUCT_ID = 0x1301
|
||||
const val PACKET_SIZE = 64
|
||||
private const val HEADER = 0x12
|
||||
|
||||
@@ -33,13 +34,19 @@ object VitureProtocol {
|
||||
|
||||
enum class Family { ONE, PRO, LUMA, ULTRA, BEAST, PRO2 }
|
||||
|
||||
class Model(override val name: String, val family: Family) : GlassesModel {
|
||||
class Model(
|
||||
override val name: String,
|
||||
val family: Family,
|
||||
val needsSdk: Boolean = family == Family.ULTRA || family == Family.BEAST || family == Family.PRO2,
|
||||
) : GlassesModel {
|
||||
override val controllable: Boolean get() = true
|
||||
val needsSdk: Boolean get() = family == Family.ULTRA || family == Family.BEAST || family == Family.PRO2
|
||||
private val directPro2: Boolean get() = family == Family.PRO2 && !needsSdk
|
||||
override val hardwareControls: Boolean get() = !directPro2
|
||||
override val supportsDisplayModeControl: Boolean get() = !directPro2
|
||||
val tall: Boolean get() = family == Family.LUMA || family == Family.ULTRA || family == Family.BEAST
|
||||
override val sbs90: Boolean get() = family == Family.ULTRA
|
||||
override val brightnessMax: Int get() = 8
|
||||
override val volumeMax: Int get() = if (family == Family.BEAST) 15 else 8
|
||||
override val brightnessMax: Int get() = if (directPro2) 0 else 8
|
||||
override val volumeMax: Int get() = if (directPro2) 0 else if (family == Family.BEAST) 15 else 8
|
||||
override val hasSunblock: Boolean get() = family != Family.PRO2
|
||||
override val diagonalFovDeg: Float get() = when (family) {
|
||||
Family.ONE -> 43f
|
||||
@@ -89,6 +96,7 @@ object VitureProtocol {
|
||||
}
|
||||
|
||||
fun model(productId: Int, productName: String?): Model? {
|
||||
if (productId == PRO2_PRODUCT_ID) return Model("VITURE Pro 2", Family.PRO2, needsSdk = false)
|
||||
val family = when (productId) {
|
||||
0x1011, 0x1013, 0x1015, 0x1017, 0x101b -> Family.ONE
|
||||
0x1019, 0x101d -> Family.PRO
|
||||
|
||||
@@ -0,0 +1,288 @@
|
||||
package com.droiddeck.launcher.glasses
|
||||
|
||||
import android.hardware.usb.UsbConstants
|
||||
import android.hardware.usb.UsbDevice
|
||||
import android.hardware.usb.UsbDeviceConnection
|
||||
import android.hardware.usb.UsbEndpoint
|
||||
import android.hardware.usb.UsbInterface
|
||||
import android.hardware.usb.UsbManager
|
||||
import android.hardware.usb.UsbRequest
|
||||
import android.util.Log
|
||||
import java.io.IOException
|
||||
import java.nio.ByteBuffer
|
||||
import java.util.concurrent.ArrayBlockingQueue
|
||||
import java.util.concurrent.TimeoutException
|
||||
import java.util.concurrent.atomic.AtomicLong
|
||||
|
||||
internal class VitureV2Link internal constructor(
|
||||
private val transport: Transport,
|
||||
private val listener: Listener,
|
||||
) : GlassesLink {
|
||||
interface Listener {
|
||||
fun onReady()
|
||||
fun onValue(msgId: Int, value: Int)
|
||||
fun onPose(raw: ByteArray, q: FloatArray, timeNs: Long)
|
||||
fun onTracking(active: Boolean)
|
||||
fun onLost()
|
||||
}
|
||||
|
||||
internal data class Received(val bytes: ByteArray, val timeNs: Long)
|
||||
internal interface Transport {
|
||||
fun write(packet: ByteArray): Boolean
|
||||
fun read(timeoutMs: Long): Received?
|
||||
fun close()
|
||||
}
|
||||
|
||||
private data class Command(val packet: ByteArray, val stream: Boolean? = null)
|
||||
private val commands = ArrayBlockingQueue<Command>(16)
|
||||
private val stateLock = Any()
|
||||
private val bad = AtomicLong()
|
||||
@Volatile private var running = true
|
||||
@Volatile private var wanted = true
|
||||
@Volatile override var ready = false
|
||||
private set
|
||||
@Volatile var trackingActive = false
|
||||
private set
|
||||
override val hasImu: Boolean get() = ready
|
||||
override val badFrames: Long get() = bad.get()
|
||||
@Volatile private var streamOn = false
|
||||
private var lastPoseAt = 0L
|
||||
private var lastTick: Long? = null
|
||||
private var poseNotBefore = 0L
|
||||
private val worker = Thread(::run, "viture-v2").apply { isDaemon = true; start() }
|
||||
|
||||
override fun send(msgId: Int, payload: ByteArray): Boolean {
|
||||
synchronized(stateLock) {
|
||||
if (!running || !ready) return false
|
||||
if (msgId == VitureProtocol.MSG_IMU) {
|
||||
if (payload.size != 1 || payload[0].toInt() !in 0..1) return false
|
||||
val enabled = payload[0].toInt() == 1
|
||||
if (wanted == enabled) return true
|
||||
val command = Command(VitureV2Protocol.imuControl(
|
||||
if (enabled) VitureV2Protocol.STREAM_POSE else VitureV2Protocol.STREAM_OFF), enabled)
|
||||
if (!commands.offer(command)) return false
|
||||
wanted = enabled
|
||||
if (!enabled) {
|
||||
streamOn = false
|
||||
tracking(false)
|
||||
}
|
||||
return true
|
||||
}
|
||||
if (msgId == VitureProtocol.MSG_GET_IMU) return true
|
||||
// Keep the measured 120 Hz mode; the generic controller requests 240 Hz.
|
||||
if (msgId == VitureProtocol.MSG_IMU_RATE) return false
|
||||
val query = when (msgId) {
|
||||
VitureProtocol.MSG_GET_BRIGHTNESS -> VitureV2Protocol.MSG_GET_BRIGHTNESS
|
||||
VitureProtocol.MSG_GET_VOLUME -> VitureV2Protocol.MSG_GET_VOLUME
|
||||
VitureProtocol.MSG_GET_DISPLAY -> VitureV2Protocol.MSG_GET_DISPLAY
|
||||
else -> return false
|
||||
}
|
||||
return payload.isEmpty() && commands.offer(Command(VitureV2Protocol.packet(query)))
|
||||
}
|
||||
}
|
||||
|
||||
private fun tracking(active: Boolean) {
|
||||
if (trackingActive != active) {
|
||||
trackingActive = active
|
||||
listener.onTracking(active)
|
||||
}
|
||||
}
|
||||
|
||||
private fun run() {
|
||||
try {
|
||||
if (!transport.write(VitureV2Protocol.imuControl(VitureV2Protocol.STREAM_POSE)))
|
||||
throw IOException("Could not start pose stream")
|
||||
poseNotBefore = System.nanoTime()
|
||||
streamOn = true
|
||||
lastPoseAt = System.nanoTime()
|
||||
while (running) {
|
||||
commands.poll()?.let { command ->
|
||||
if (!transport.write(command.packet)) throw IOException("USB command failed")
|
||||
val completedAt = System.nanoTime()
|
||||
synchronized(stateLock) {
|
||||
command.stream?.let {
|
||||
streamOn = it
|
||||
lastTick = null
|
||||
poseNotBefore = completedAt
|
||||
lastPoseAt = System.nanoTime()
|
||||
}
|
||||
}
|
||||
}
|
||||
transport.read(100)?.let(::receive)
|
||||
if (streamOn && System.nanoTime() - lastPoseAt > POSE_TIMEOUT_NS)
|
||||
throw IOException("No fresh valid pose samples")
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
if (running) {
|
||||
ready = false
|
||||
tracking(false)
|
||||
Log.w(TAG, "V2 connection lost: ${e.message}")
|
||||
listener.onLost()
|
||||
}
|
||||
} finally {
|
||||
running = false
|
||||
ready = false
|
||||
tracking(false)
|
||||
runCatching { transport.write(VitureV2Protocol.imuControl(VitureV2Protocol.STREAM_OFF)) }
|
||||
transport.close()
|
||||
}
|
||||
}
|
||||
|
||||
private fun receive(received: Received) = synchronized(stateLock) {
|
||||
if (!running) return
|
||||
val frame = VitureV2Protocol.parse(received.bytes) ?: run { bad.incrementAndGet(); return }
|
||||
if (frame.msgId == VitureV2Protocol.EVENT_POSE) {
|
||||
val pose = VitureV2Protocol.pose(frame) ?: run { bad.incrementAndGet(); return }
|
||||
if (!streamOn || !wanted || received.timeNs < poseNotBefore) return
|
||||
val previous = lastTick
|
||||
if (previous != null) {
|
||||
val delta = (pose.deviceTick - previous) and 0xffffffffL
|
||||
if (delta == 0L || delta >= 0x80000000L) return
|
||||
}
|
||||
lastTick = pose.deviceTick
|
||||
lastPoseAt = System.nanoTime()
|
||||
val becameReady = !ready
|
||||
ready = true
|
||||
tracking(true)
|
||||
if (becameReady) listener.onReady()
|
||||
val q = pose.quaternion
|
||||
// Upstream right/up/back pose converted to the shared VITURE legacy basis.
|
||||
val shared = floatArrayOf(-q[2], -q[0], q[1], q[3])
|
||||
// Upstream does not establish device tick units; use host monotonic receipt time.
|
||||
if (running && wanted && streamOn) listener.onPose(received.bytes, shared, received.timeNs)
|
||||
return
|
||||
}
|
||||
VitureV2Protocol.reply(frame, VitureV2Protocol.MSG_IMU_CONTROL)?.let {
|
||||
if (!it.success) throw IOException("Pose stream rejected with status ${it.status}")
|
||||
}
|
||||
val queries = arrayOf(
|
||||
VitureV2Protocol.MSG_GET_BRIGHTNESS to VitureProtocol.MSG_GET_BRIGHTNESS,
|
||||
VitureV2Protocol.MSG_GET_VOLUME to VitureProtocol.MSG_GET_VOLUME,
|
||||
VitureV2Protocol.MSG_GET_DISPLAY to VitureProtocol.MSG_GET_DISPLAY,
|
||||
)
|
||||
for ((query, internalId) in queries) {
|
||||
val reply = VitureV2Protocol.reply(frame, query) ?: continue
|
||||
if (reply.success && reply.body.size == 1) listener.onValue(internalId, reply.body[0].toInt() and 255)
|
||||
}
|
||||
}
|
||||
|
||||
override fun close() {
|
||||
synchronized(stateLock) {
|
||||
running = false
|
||||
ready = false
|
||||
wanted = false
|
||||
commands.clear()
|
||||
}
|
||||
if (Thread.currentThread() !== worker) worker.join(1500)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val TAG = "VitureV2Link"
|
||||
private const val POSE_TIMEOUT_NS = 3_000_000_000L
|
||||
const val PRODUCT_ID = 0x1301
|
||||
|
||||
fun open(usb: UsbManager, device: UsbDevice, listener: Listener): VitureV2Link? {
|
||||
if (device.vendorId != VitureProtocol.VENDOR_ID || device.productId != PRODUCT_ID) return null
|
||||
val candidates = (0 until device.interfaceCount).map(device::getInterface).filter {
|
||||
it.interfaceClass == UsbConstants.USB_CLASS_HID && it.alternateSetting == 0 && it.endpointCount == 2
|
||||
}.mapNotNull { intf ->
|
||||
val endpoints = (0 until intf.endpointCount).map(intf::getEndpoint)
|
||||
val input = endpoints.singleOrNull { it.direction == UsbConstants.USB_DIR_IN &&
|
||||
it.type == UsbConstants.USB_ENDPOINT_XFER_INT && it.maxPacketSize == 64 }
|
||||
val output = endpoints.singleOrNull { it.direction == UsbConstants.USB_DIR_OUT &&
|
||||
it.type == UsbConstants.USB_ENDPOINT_XFER_INT && it.maxPacketSize == 64 }
|
||||
if (input != null && output != null) Triple(intf, input, output) else null
|
||||
}
|
||||
val (intf, input, output) = candidates.singleOrNull() ?: return null
|
||||
val connection = usb.openDevice(device) ?: return null
|
||||
if (!connection.claimInterface(intf, true)) { connection.close(); return null }
|
||||
return try {
|
||||
VitureV2Link(AndroidTransport(connection, intf, input, output), listener)
|
||||
} catch (e: Exception) {
|
||||
connection.releaseInterface(intf)
|
||||
connection.close()
|
||||
Log.w(TAG, "Could not initialize USB requests", e)
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class AndroidTransport(
|
||||
private val connection: UsbDeviceConnection,
|
||||
private val intf: UsbInterface,
|
||||
input: UsbEndpoint,
|
||||
output: UsbEndpoint,
|
||||
) : Transport {
|
||||
private val inputRequest = UsbRequest()
|
||||
private val outputRequest = UsbRequest()
|
||||
private val inputBuffer = ByteBuffer.allocateDirect(64)
|
||||
private var outputBuffer: ByteBuffer? = null
|
||||
private var outputPending = false
|
||||
private val received = ArrayDeque<Received>()
|
||||
|
||||
init {
|
||||
try {
|
||||
if (!inputRequest.initialize(connection, input) || !outputRequest.initialize(connection, output))
|
||||
throw IOException("USB request initialization failed")
|
||||
queueInput()
|
||||
} catch (e: Exception) {
|
||||
inputRequest.close()
|
||||
outputRequest.close()
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
private fun queueInput() {
|
||||
inputBuffer.clear()
|
||||
if (!inputRequest.queue(inputBuffer)) throw IOException("USB input queue failed")
|
||||
}
|
||||
|
||||
private fun await(timeoutMs: Long) {
|
||||
val completed = try { connection.requestWait(timeoutMs) } catch (_: TimeoutException) { return }
|
||||
?: throw IOException("USB device disconnected")
|
||||
if (completed === outputRequest) {
|
||||
outputPending = false
|
||||
} else if (completed === inputRequest) {
|
||||
val count = inputBuffer.position()
|
||||
if (count > 0) {
|
||||
val bytes = ByteArray(count)
|
||||
inputBuffer.flip()
|
||||
inputBuffer.get(bytes)
|
||||
if (received.size >= 512) throw IOException("USB input backlog overflow")
|
||||
received.addLast(Received(bytes, System.nanoTime()))
|
||||
}
|
||||
queueInput()
|
||||
}
|
||||
}
|
||||
|
||||
override fun write(packet: ByteArray): Boolean {
|
||||
if (outputPending) throw IOException("Previous USB output has not completed")
|
||||
val buffer = ByteBuffer.allocateDirect(packet.size).apply { put(packet); flip() }
|
||||
outputBuffer = buffer
|
||||
outputPending = outputRequest.queue(buffer)
|
||||
if (!outputPending) return false
|
||||
val deadline = System.nanoTime() + 250_000_000L
|
||||
while (outputPending && System.nanoTime() < deadline) await(25)
|
||||
if (outputPending) {
|
||||
outputRequest.cancel()
|
||||
throw IOException("USB output timed out")
|
||||
}
|
||||
return buffer.position() == packet.size
|
||||
}
|
||||
|
||||
override fun read(timeoutMs: Long): Received? {
|
||||
if (received.isEmpty()) await(timeoutMs)
|
||||
return received.removeFirstOrNull()
|
||||
}
|
||||
|
||||
override fun close() {
|
||||
inputRequest.cancel()
|
||||
if (outputPending) outputRequest.cancel()
|
||||
connection.releaseInterface(intf)
|
||||
connection.close()
|
||||
inputRequest.close()
|
||||
outputRequest.close()
|
||||
outputBuffer = null
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
// Adapted from elasticjava/viture-v2, MIT, Copyright (c) 2026 Holger Bartnick.
|
||||
// Source: ece8c30485f7d357fefa362ae74f3eabac9b3899; see docs/third-party/viture-v2/.
|
||||
package com.droiddeck.launcher.glasses
|
||||
|
||||
import kotlin.math.sqrt
|
||||
|
||||
object VitureV2Protocol {
|
||||
const val PACKET_SIZE = 64
|
||||
const val HEADER_SIZE = 8
|
||||
const val RESPONSE_OFFSET = 0x2000
|
||||
private const val PREAMBLE = 0x0010
|
||||
private const val MAX_PAYLOAD_SIZE = PACKET_SIZE - HEADER_SIZE
|
||||
|
||||
const val MSG_IMU_CONTROL = 0x0301
|
||||
const val MSG_GET_SERIAL = 0x3002
|
||||
const val MSG_GET_VERSION = 0x3003
|
||||
const val MSG_GET_BRIGHTNESS = 0x3122
|
||||
const val MSG_GET_DUTY_CYCLE = 0x3125
|
||||
const val MSG_GET_DISPLAY = 0x3141
|
||||
const val MSG_GET_VOLUME = 0x3201
|
||||
const val MSG_GET_WEAR = 0x3321
|
||||
const val EVENT_POSE = 0x7308
|
||||
const val EVENT_RAW = 0x7309
|
||||
|
||||
const val STREAM_OFF = 0
|
||||
const val STREAM_POSE = 1
|
||||
const val STREAM_RAW = 2
|
||||
|
||||
enum class Rate(val wireValue: Int, val hz: Int) {
|
||||
HZ_60(0, 60), HZ_90(1, 90), HZ_120(2, 120),
|
||||
HZ_240(3, 240), HZ_500(4, 500), HZ_1000(5, 1000),
|
||||
}
|
||||
|
||||
class Frame internal constructor(val msgId: Int, val payload: ByteArray)
|
||||
|
||||
class Reply internal constructor(val status: Int, val body: ByteArray) {
|
||||
val success: Boolean get() = status == 0
|
||||
}
|
||||
|
||||
// Device ticks have no established time unit; quaternion is xyzw with no axis remapping.
|
||||
class Pose internal constructor(
|
||||
val deviceTick: Long,
|
||||
val quaternion: FloatArray,
|
||||
val unknown: Long,
|
||||
)
|
||||
|
||||
class RawSample internal constructor(
|
||||
val deviceTick: Long,
|
||||
val gyroRadPerSec: FloatArray,
|
||||
val accelG: FloatArray,
|
||||
val payload: ByteArray,
|
||||
)
|
||||
|
||||
fun packet(msgId: Int, payload: ByteArray = ByteArray(0)): ByteArray {
|
||||
require(msgId in 0..0xFFFF)
|
||||
require(payload.size <= MAX_PAYLOAD_SIZE)
|
||||
return ByteArray(HEADER_SIZE + payload.size).also { buffer ->
|
||||
putU16(buffer, 0, PREAMBLE)
|
||||
putU16(buffer, 2, msgId)
|
||||
putU16(buffer, 4, payload.size)
|
||||
putU16(buffer, 6, checksum(payload, 0, payload.size))
|
||||
payload.copyInto(buffer, HEADER_SIZE)
|
||||
}
|
||||
}
|
||||
|
||||
fun imuControl(streams: Int, rate: Rate = Rate.HZ_120): ByteArray {
|
||||
// Upstream measured that stream mask 3 ACKs but produces no events on Pro 2.
|
||||
require(streams == STREAM_OFF || streams == STREAM_POSE || streams == STREAM_RAW)
|
||||
require(streams != STREAM_POSE || rate.hz <= 240)
|
||||
val wireRate = if (streams == STREAM_OFF) 0 else rate.wireValue
|
||||
return packet(MSG_IMU_CONTROL, byteArrayOf(streams.toByte(), wireRate.toByte()))
|
||||
}
|
||||
|
||||
fun parse(buffer: ByteArray, size: Int = buffer.size): Frame? {
|
||||
if (size < HEADER_SIZE || size > PACKET_SIZE || size > buffer.size) return null
|
||||
if (u16(buffer, 0) != PREAMBLE) return null
|
||||
val payloadSize = u16(buffer, 4)
|
||||
if (payloadSize > MAX_PAYLOAD_SIZE || HEADER_SIZE + payloadSize > size) return null
|
||||
if (checksum(buffer, HEADER_SIZE, payloadSize) != u16(buffer, 6)) return null
|
||||
return Frame(u16(buffer, 2), buffer.copyOfRange(HEADER_SIZE, HEADER_SIZE + payloadSize))
|
||||
}
|
||||
|
||||
fun reply(frame: Frame, requestMsgId: Int): Reply? {
|
||||
if (requestMsgId !in 0..0xFFFF || frame.msgId != ((requestMsgId + RESPONSE_OFFSET) and 0xFFFF)) return null
|
||||
if (frame.payload.isEmpty()) return null
|
||||
return Reply(u8(frame.payload[0]), frame.payload.copyOfRange(1, frame.payload.size))
|
||||
}
|
||||
|
||||
fun pose(frame: Frame): Pose? {
|
||||
if (frame.msgId != EVENT_POSE || frame.payload.size != 24) return null
|
||||
val payload = frame.payload
|
||||
val w = float(payload, 8)
|
||||
val x = float(payload, 12)
|
||||
val y = float(payload, 16)
|
||||
val z = float(payload, 20)
|
||||
if (!w.isFinite() || !x.isFinite() || !y.isFinite() || !z.isFinite()) return null
|
||||
val norm = sqrt(w.toDouble() * w + x.toDouble() * x + y.toDouble() * y + z.toDouble() * z)
|
||||
if (norm !in 0.9..1.1) return null
|
||||
val n = norm.toFloat()
|
||||
return Pose(u32(payload, 4), floatArrayOf(x / n, y / n, z / n, w / n), u32(payload, 0))
|
||||
}
|
||||
|
||||
fun raw(frame: Frame): RawSample? {
|
||||
if (frame.msgId != EVENT_RAW || frame.payload.size != 56) return null
|
||||
val payload = frame.payload
|
||||
val gyro = floatArrayOf(float(payload, 10), float(payload, 14), float(payload, 18))
|
||||
val accel = floatArrayOf(float(payload, 22), float(payload, 26), float(payload, 30))
|
||||
if (gyro.any { !it.isFinite() } || accel.any { !it.isFinite() }) return null
|
||||
return RawSample(u32(payload, 4), gyro, accel, payload.copyOf())
|
||||
}
|
||||
|
||||
private fun checksum(buffer: ByteArray, offset: Int, size: Int): Int {
|
||||
var sum = 0
|
||||
for (i in offset until offset + size) sum += u8(buffer[i])
|
||||
return sum and 0xFFFF
|
||||
}
|
||||
|
||||
private fun u8(value: Byte) = value.toInt() and 0xFF
|
||||
|
||||
private fun u16(buffer: ByteArray, offset: Int) =
|
||||
u8(buffer[offset]) or (u8(buffer[offset + 1]) shl 8)
|
||||
|
||||
private fun u32(buffer: ByteArray, offset: Int): Long =
|
||||
u16(buffer, offset).toLong() or (u16(buffer, offset + 2).toLong() shl 16)
|
||||
|
||||
private fun float(buffer: ByteArray, offset: Int): Float = Float.fromBits(u32(buffer, offset).toInt())
|
||||
|
||||
private fun putU16(buffer: ByteArray, offset: Int, value: Int) {
|
||||
buffer[offset] = value.toByte()
|
||||
buffer[offset + 1] = (value ushr 8).toByte()
|
||||
}
|
||||
}
|
||||
@@ -149,7 +149,8 @@ internal fun GlassesGroups(
|
||||
}
|
||||
}
|
||||
if (display) SettingsGroup(g.model) {
|
||||
if (g.experimental) SettingsRow(stringResource(R.string.glasses_control), stringResource(R.string.glasses_xreal_experimental)) {}
|
||||
if (g.experimental) SettingsRow(stringResource(R.string.glasses_control), stringResource(
|
||||
if (g.supportsDisplayModeControl) R.string.glasses_xreal_experimental else R.string.glasses_pro2_experimental)) {}
|
||||
val status = if (g.hasDisplay) stringResource(R.string.glasses_status, g.width, g.height, kotlin.math.round(g.hz).toInt(),
|
||||
stringResource(if (g.sbs) R.string.glasses_mode_3d else R.string.glasses_mode_2d)) else null
|
||||
when {
|
||||
@@ -168,7 +169,7 @@ internal fun GlassesGroups(
|
||||
ToggleRow(host, "glasses-game", stringResource(R.string.glasses_game_on), stringResource(R.string.glasses_game_on_hint),
|
||||
s.gameOnGlasses, chipModifier = track("glasses-game")) { Glasses.setGameOnGlasses(it) }
|
||||
}
|
||||
if (display && g.canControl && (inSession || g.sbs || g.sbsSupport == GlassesState.SBS_FAILS)) {
|
||||
if (display && g.canControl && g.supportsDisplayModeControl && (inSession || g.sbs || g.sbsSupport == GlassesState.SBS_FAILS)) {
|
||||
SettingsGroup(stringResource(R.string.glasses_display_mode)) {
|
||||
if (g.sbsSupport == GlassesState.SBS_FAILS && !g.sbs) {
|
||||
ActionRow(stringResource(R.string.glasses_3d), stringResource(R.string.glasses_3d_failed),
|
||||
@@ -177,7 +178,7 @@ internal fun GlassesGroups(
|
||||
g.sbs, chipModifier = track("glasses-3d")) { Glasses.set3d(it) }
|
||||
}
|
||||
}
|
||||
if (display && g.canControl) {
|
||||
if (display && g.canControl && g.supportsDisplayModeControl) {
|
||||
val profiles = if (inSession) listOf(GlassesDisplayModes.profile(g.sbs, false))
|
||||
else listOf(GlassesDisplayProfile.TWO_D, GlassesDisplayProfile.THREE_D)
|
||||
for (profile in profiles) SettingsGroup(stringResource(if (profile == GlassesDisplayProfile.TWO_D)
|
||||
@@ -214,9 +215,9 @@ internal fun GlassesGroups(
|
||||
}
|
||||
if (vr && (g.canControl || g.hasDisplay)) SettingsGroup(stringResource(R.string.cardboard_steamvr)) {
|
||||
steamVr()
|
||||
ToggleRow(host, "glasses-auto3d", stringResource(R.string.glasses_auto3d), stringResource(R.string.glasses_auto3d_hint),
|
||||
s.auto3d, chipModifier = track("glasses-auto3d")) { Glasses.setAuto3d(it) }
|
||||
if (g.canControl) {
|
||||
if (g.supportsDisplayModeControl) ToggleRow(host, "glasses-auto3d", stringResource(R.string.glasses_auto3d),
|
||||
stringResource(R.string.glasses_auto3d_hint), s.auto3d, chipModifier = track("glasses-auto3d")) { Glasses.setAuto3d(it) }
|
||||
if (g.canControl && g.supportsDisplayModeControl) {
|
||||
GlassesResolutionRow(host, g, s, GlassesDisplayProfile.VR, track)
|
||||
if (steamVrRunning && tab != null) GlassesRefreshRow(host, g, s, track)
|
||||
}
|
||||
|
||||
@@ -2607,6 +2607,7 @@
|
||||
<string name="glasses_xreal_network_missing">في انتظار اتصال USB Ethernet الخاص بالنظارة. قد لا يتيحه هذا الهاتف للتطبيقات.</string>
|
||||
<string name="glasses_xreal_connection_failed">انقطع اتصال XREAL أو أعاد استجابة غير مدعومة. جارٍ إعادة المحاولة…</string>
|
||||
<string name="glasses_xreal_experimental">دعم تجريبي لـ 1S. استخدم وضع Follow وعطّل تثبيت الصورة من قائمة النظارة. لا تزال اتجاهات التتبّع وأوضاع العرض بحاجة إلى اختبار على الجهاز.</string>
|
||||
<string name="glasses_pro2_experimental">تتبّع تجريبي لحركة الرأس لنظارة Pro 2. لا يُدعم بعد ضبط السطوع ومستوى الصوت أو تبديل وضع العرض.</string>
|
||||
<string name="cardboard_title">Cardboard VR</string>
|
||||
<string name="cardboard_mode">وضع Cardboard</string>
|
||||
<string name="cardboard_mode_hint">عرض للعين اليسرى وآخر لليمنى لنظارة واقع افتراضي للهاتف.</string>
|
||||
|
||||
@@ -1029,6 +1029,7 @@
|
||||
<string name="glasses_xreal_network_missing">Esperando la conexión Ethernet por USB de las gafas. Puede que este teléfono no la ofrezca a las apps.</string>
|
||||
<string name="glasses_xreal_connection_failed">La conexión con las XREAL se interrumpió o devolvió una respuesta no compatible. Reintentando…</string>
|
||||
<string name="glasses_xreal_experimental">Compatibilidad experimental con las 1S. Usa el modo Follow y desactiva la estabilización en el menú de las gafas. Aún falta probar en el dispositivo las direcciones del seguimiento y los modos de pantalla.</string>
|
||||
<string name="glasses_pro2_experimental">Seguimiento de cabeza experimental para Pro 2. Los ajustes de brillo y volumen y el cambio de modo de pantalla aún no son compatibles.</string>
|
||||
<string name="ctrl_select_steam_hint">En lugar de View/Select.</string>
|
||||
<string name="setup_animations">Animaciones</string>
|
||||
<string name="ctrl_adaptive_hint">Los sticks aparecen donde tocas y se ocultan al soltar</string>
|
||||
|
||||
@@ -2507,6 +2507,7 @@
|
||||
<string name="glasses_xreal_network_missing">Изчаква се USB Ethernet връзката на очилата. Този телефон може да не я предоставя на приложенията.</string>
|
||||
<string name="glasses_xreal_connection_failed">Връзката с XREAL беше прекъсната или върна неподдържан отговор. Нов опит…</string>
|
||||
<string name="glasses_xreal_experimental">Експериментална поддръжка на 1S. Използвайте режим Follow и изключете стабилизацията в менюто на очилата. Посоките на проследяване и режимите на показване все още трябва да се тестват на устройство.</string>
|
||||
<string name="glasses_pro2_experimental">Експериментално проследяване на движенията на главата за Pro 2. Регулирането на яркостта и силата на звука и превключването на режима на показване все още не се поддържат.</string>
|
||||
<string name="cardboard_title">Cardboard VR</string>
|
||||
<string name="cardboard_mode">Режим Cardboard</string>
|
||||
<string name="cardboard_mode_hint">Изображения за лявото и дясното око за VR очила за телефон.</string>
|
||||
|
||||
@@ -2557,6 +2557,7 @@
|
||||
<string name="glasses_xreal_network_missing">Čeká se na připojení USB Ethernet brýlí. Tento telefon ho možná aplikacím nezpřístupňuje.</string>
|
||||
<string name="glasses_xreal_connection_failed">Připojení XREAL bylo přerušeno nebo vrátilo nepodporovanou odpověď. Zkouší se to znovu…</string>
|
||||
<string name="glasses_xreal_experimental">Experimentální podpora 1S. V nabídce brýlí použijte režim Follow a vypněte stabilizaci. Směry sledování a režimy zobrazení je ještě třeba otestovat na zařízení.</string>
|
||||
<string name="glasses_pro2_experimental">Experimentální sledování pohybu hlavy pro Pro 2. Nastavení jasu, hlasitosti a přepínání režimů zobrazení zatím nejsou podporovány.</string>
|
||||
<string name="cardboard_title">Cardboard VR</string>
|
||||
<string name="cardboard_mode">Režim Cardboard</string>
|
||||
<string name="cardboard_mode_hint">Obraz pro levé a pravé oko pro VR brýle pro telefon.</string>
|
||||
|
||||
@@ -2507,6 +2507,7 @@
|
||||
<string name="glasses_xreal_network_missing">Venter på brillens USB-Ethernet-forbindelse. Denne telefon gør den muligvis ikke tilgængelig for apps.</string>
|
||||
<string name="glasses_xreal_connection_failed">XREAL-forbindelsen blev afbrudt eller returnerede et svar, der ikke understøttes. Prøver igen…</string>
|
||||
<string name="glasses_xreal_experimental">Eksperimentel understøttelse af 1S. Brug Follow-tilstand, og slå stabilisering fra i brillens menu. Sporingsretninger og visningstilstande mangler stadig test på enheden.</string>
|
||||
<string name="glasses_pro2_experimental">Eksperimentel hovedsporing til Pro 2. Justering af lysstyrke og lydstyrke samt skift af visningstilstand understøttes endnu ikke.</string>
|
||||
<string name="cardboard_title">Cardboard VR</string>
|
||||
<string name="cardboard_mode">Cardboard-tilstand</string>
|
||||
<string name="cardboard_mode_hint">Billeder til venstre og højre øje til en VR-brille til telefonen.</string>
|
||||
|
||||
@@ -2493,6 +2493,7 @@
|
||||
<string name="glasses_xreal_network_missing">Warte auf die USB-Ethernet-Verbindung der Brille. Dieses Smartphone stellt sie Apps möglicherweise nicht bereit.</string>
|
||||
<string name="glasses_xreal_connection_failed">Die XREAL-Verbindung wurde unterbrochen oder hat eine nicht unterstützte Antwort geliefert. Neuer Versuch …</string>
|
||||
<string name="glasses_xreal_experimental">Experimentelle Unterstützung für die 1S. Nutze den Follow-Modus und deaktiviere die Stabilisierung im Menü der Brille. Tracking-Richtungen und Anzeigemodi müssen noch auf Geräten getestet werden.</string>
|
||||
<string name="glasses_pro2_experimental">Experimentelles Kopftracking für Pro 2. Das Einstellen von Helligkeit und Lautstärke sowie das Umschalten des Anzeigemodus werden noch nicht unterstützt.</string>
|
||||
<string name="cardboard_title">Cardboard VR</string>
|
||||
<string name="cardboard_mode">Cardboard-Modus</string>
|
||||
<string name="cardboard_mode_hint">Bilder für linkes und rechtes Auge für eine Smartphone-VR-Brille.</string>
|
||||
|
||||
@@ -2507,6 +2507,7 @@
|
||||
<string name="glasses_xreal_network_missing">Αναμονή για τη σύνδεση USB Ethernet των γυαλιών. Αυτό το τηλέφωνο ίσως δεν τη διαθέτει στις εφαρμογές.</string>
|
||||
<string name="glasses_xreal_connection_failed">Η σύνδεση XREAL διακόπηκε ή επέστρεψε μη υποστηριζόμενη απόκριση. Νέα προσπάθεια…</string>
|
||||
<string name="glasses_xreal_experimental">Πειραματική υποστήριξη για 1S. Χρησιμοποιήστε τη λειτουργία Follow και απενεργοποιήστε τη σταθεροποίηση στο μενού των γυαλιών. Οι κατευθύνσεις παρακολούθησης και οι λειτουργίες οθόνης χρειάζονται ακόμα δοκιμή σε συσκευή.</string>
|
||||
<string name="glasses_pro2_experimental">Πειραματική παρακολούθηση κεφαλής για Pro 2. Η ρύθμιση της φωτεινότητας και της έντασης ήχου και η αλλαγή λειτουργίας οθόνης δεν υποστηρίζονται ακόμη.</string>
|
||||
<string name="cardboard_title">Cardboard VR</string>
|
||||
<string name="cardboard_mode">Λειτουργία Cardboard</string>
|
||||
<string name="cardboard_mode_hint">Εικόνες για το αριστερό και το δεξί μάτι, για γυαλιά VR κινητού.</string>
|
||||
|
||||
@@ -2517,6 +2517,7 @@
|
||||
<string name="glasses_xreal_network_missing">Esperando la conexión Ethernet por USB de las gafas. Puede que este teléfono no la ofrezca a las apps.</string>
|
||||
<string name="glasses_xreal_connection_failed">La conexión con las XREAL se interrumpió o devolvió una respuesta no compatible. Reintentando…</string>
|
||||
<string name="glasses_xreal_experimental">Compatibilidad experimental con las 1S. Usa el modo Follow y desactiva la estabilización en el menú de las gafas. Aún falta probar en el dispositivo las direcciones del seguimiento y los modos de pantalla.</string>
|
||||
<string name="glasses_pro2_experimental">Seguimiento de cabeza experimental para Pro 2. Los ajustes de brillo y volumen y el cambio de modo de pantalla aún no son compatibles.</string>
|
||||
<string name="stores_fact_developer">Desarrollador</string>
|
||||
<string name="stores_fact_publisher">Distribuidor</string>
|
||||
<string name="stores_fact_released">Lanzamiento</string>
|
||||
|
||||
@@ -2507,6 +2507,7 @@
|
||||
<string name="glasses_xreal_network_missing">Odotetaan lasien USB-Ethernet-yhteyttä. Tämä puhelin ei ehkä tarjoa sitä sovelluksille.</string>
|
||||
<string name="glasses_xreal_connection_failed">XREAL-yhteys katkesi tai palautti vastauksen, jota ei tueta. Yritetään uudelleen…</string>
|
||||
<string name="glasses_xreal_experimental">Kokeellinen 1S-tuki. Käytä Follow-tilaa ja poista vakautus käytöstä lasien valikosta. Seurannan suunnat ja näyttötilat vaativat vielä testausta laitteella.</string>
|
||||
<string name="glasses_pro2_experimental">Kokeellinen päänliikkeiden seuranta Pro 2:lle. Kirkkauden ja äänenvoimakkuuden säätöä sekä näyttötilan vaihtamista ei vielä tueta.</string>
|
||||
<string name="cardboard_title">Cardboard VR</string>
|
||||
<string name="cardboard_mode">Cardboard-tila</string>
|
||||
<string name="cardboard_mode_hint">Vasemman ja oikean silmän kuvat puhelimen VR-laseille.</string>
|
||||
|
||||
@@ -2528,6 +2528,7 @@
|
||||
<string name="glasses_xreal_network_missing">En attente de la connexion Ethernet USB des lunettes. Ce téléphone ne la rend peut-être pas accessible aux applications.</string>
|
||||
<string name="glasses_xreal_connection_failed">La connexion XREAL a été interrompue ou a renvoyé une réponse non prise en charge. Nouvelle tentative…</string>
|
||||
<string name="glasses_xreal_experimental">Prise en charge expérimentale des 1S. Utilisez le mode Follow et désactivez la stabilisation dans le menu des lunettes. Le sens du suivi et les modes d\'affichage restent à tester sur l\'appareil.</string>
|
||||
<string name="glasses_pro2_experimental">Suivi expérimental des mouvements de la tête pour Pro 2. Le réglage de la luminosité et du volume ainsi que le changement de mode d\'affichage ne sont pas encore pris en charge.</string>
|
||||
<string name="stores_fact_developer">Développeur</string>
|
||||
<string name="stores_fact_publisher">Éditeur</string>
|
||||
<string name="stores_fact_released">Sortie</string>
|
||||
|
||||
@@ -2507,6 +2507,7 @@
|
||||
<string name="glasses_xreal_network_missing">चश्मे के USB Ethernet कनेक्शन का इंतज़ार है। हो सकता है यह फ़ोन इसे ऐप्स को उपलब्ध न कराए।</string>
|
||||
<string name="glasses_xreal_connection_failed">XREAL कनेक्शन टूट गया या उसने ऐसा जवाब दिया जो समर्थित नहीं है। फिर से कोशिश हो रही है…</string>
|
||||
<string name="glasses_xreal_experimental">1S के लिए प्रायोगिक सपोर्ट। चश्मे के मेनू में Follow मोड चुनें और स्टेबिलाइज़ेशन बंद करें। ट्रैकिंग की दिशाएं और डिस्प्ले मोड अभी डिवाइस पर टेस्ट होने बाकी हैं।</string>
|
||||
<string name="glasses_pro2_experimental">Pro 2 के लिए प्रायोगिक हेड ट्रैकिंग। चमक और वॉल्यूम बदलना और डिस्प्ले मोड स्विच करना अभी समर्थित नहीं है।</string>
|
||||
<string name="cardboard_title">Cardboard VR</string>
|
||||
<string name="cardboard_mode">Cardboard मोड</string>
|
||||
<string name="cardboard_mode_hint">फ़ोन VR व्यूअर के लिए बाईं और दाईं आंख के व्यू।</string>
|
||||
|
||||
@@ -2507,6 +2507,7 @@
|
||||
<string name="glasses_xreal_network_missing">Várakozás a szemüveg USB-s Ethernet-kapcsolatára. Lehet, hogy ez a telefon nem teszi elérhetővé az alkalmazások számára.</string>
|
||||
<string name="glasses_xreal_connection_failed">Az XREAL-kapcsolat megszakadt, vagy nem támogatott választ adott. Újrapróbálkozás…</string>
|
||||
<string name="glasses_xreal_experimental">Kísérleti 1S-támogatás. Használja a Follow módot, és kapcsolja ki a stabilizálást a szemüveg menüjében. A követési irányokat és a megjelenítési módokat még tesztelni kell az eszközön.</string>
|
||||
<string name="glasses_pro2_experimental">Kísérleti fejkövetés a Pro 2-höz. A fényerő és a hangerő beállítása, valamint a megjelenítési mód váltása még nem támogatott.</string>
|
||||
<string name="cardboard_title">Cardboard VR</string>
|
||||
<string name="cardboard_mode">Cardboard mód</string>
|
||||
<string name="cardboard_mode_hint">Bal és jobb szem képe telefonos VR-szemüveghez.</string>
|
||||
|
||||
@@ -2482,6 +2482,7 @@
|
||||
<string name="glasses_xreal_network_missing">Menunggu koneksi Ethernet USB dari kacamata. Ponsel ini mungkin tidak menyediakannya untuk aplikasi.</string>
|
||||
<string name="glasses_xreal_connection_failed">Koneksi XREAL terputus atau memberikan respons yang tidak didukung. Mencoba lagi…</string>
|
||||
<string name="glasses_xreal_experimental">Dukungan 1S eksperimental. Gunakan mode Follow dan nonaktifkan stabilisasi di menu kacamata. Arah pelacakan dan mode tampilan masih perlu diuji di perangkat.</string>
|
||||
<string name="glasses_pro2_experimental">Pelacakan kepala Pro 2 eksperimental. Pengaturan kecerahan, volume, dan pergantian mode tampilan belum didukung.</string>
|
||||
<string name="cardboard_title">Cardboard VR</string>
|
||||
<string name="cardboard_mode">Mode Cardboard</string>
|
||||
<string name="cardboard_mode_hint">Tampilan mata kiri dan kanan untuk kacamata VR ponsel.</string>
|
||||
|
||||
@@ -2518,6 +2518,7 @@
|
||||
<string name="glasses_xreal_network_missing">In attesa della connessione USB Ethernet degli occhiali. Questo telefono potrebbe non renderla disponibile alle app.</string>
|
||||
<string name="glasses_xreal_connection_failed">La connessione XREAL si è interrotta o ha restituito una risposta non supportata. Nuovo tentativo…</string>
|
||||
<string name="glasses_xreal_experimental">Supporto sperimentale per 1S. Usa la modalità Follow e disattiva la stabilizzazione nel menu degli occhiali. Direzioni del tracciamento e modalità di visualizzazione devono ancora essere testate sul dispositivo.</string>
|
||||
<string name="glasses_pro2_experimental">Tracciamento sperimentale della testa per Pro 2. La regolazione di luminosità e volume e il cambio della modalità di visualizzazione non sono ancora supportati.</string>
|
||||
<string name="cardboard_title">Cardboard VR</string>
|
||||
<string name="cardboard_mode">Modalità Cardboard</string>
|
||||
<string name="cardboard_mode_hint">Immagini per l\'occhio sinistro e destro, per un visore VR per telefono.</string>
|
||||
|
||||
@@ -2484,6 +2484,7 @@
|
||||
<string name="glasses_xreal_network_missing">グラスの USB Ethernet 接続を待っています。このスマートフォンでは、アプリがこの接続を利用できない場合があります。</string>
|
||||
<string name="glasses_xreal_connection_failed">XREAL との接続が中断されたか、サポートされていない応答が返されました。再試行しています…</string>
|
||||
<string name="glasses_xreal_experimental">1S のサポートは試験運用中です。グラスのメニューで Follow モードを使い、安定化をオフにしてください。トラッキングの方向と表示モードは、まだ実機でのテストが必要です。</string>
|
||||
<string name="glasses_pro2_experimental">Pro 2 のヘッドトラッキングは試験運用中です。明るさと音量の調整、および表示モードの切り替えにはまだ対応していません。</string>
|
||||
<string name="stores_fact_developer">開発元</string>
|
||||
<string name="stores_fact_publisher">パブリッシャー</string>
|
||||
<string name="stores_fact_released">発売日</string>
|
||||
|
||||
@@ -2484,6 +2484,7 @@
|
||||
<string name="glasses_xreal_network_missing">안경의 USB Ethernet 연결을 기다리는 중입니다. 이 휴대폰은 앱에 이 연결을 제공하지 않을 수 있습니다.</string>
|
||||
<string name="glasses_xreal_connection_failed">XREAL 연결이 중단되었거나 지원되지 않는 응답을 받았습니다. 다시 시도하는 중…</string>
|
||||
<string name="glasses_xreal_experimental">1S 지원은 실험 단계입니다. 안경 메뉴에서 Follow 모드를 사용하고 안정화를 끄세요. 트래킹 방향과 디스플레이 모드는 아직 기기에서 테스트가 필요합니다.</string>
|
||||
<string name="glasses_pro2_experimental">Pro 2 헤드 트래킹은 실험 단계입니다. 밝기와 음량 조절 및 디스플레이 모드 전환은 아직 지원되지 않습니다.</string>
|
||||
<string name="stores_fact_developer">개발사</string>
|
||||
<string name="stores_fact_publisher">배급사</string>
|
||||
<string name="stores_fact_released">출시일</string>
|
||||
|
||||
@@ -2482,6 +2482,7 @@
|
||||
<string name="glasses_xreal_network_missing">Menunggu sambungan USB Ethernet cermin mata. Telefon ini mungkin tidak mendedahkannya kepada apl.</string>
|
||||
<string name="glasses_xreal_connection_failed">Sambungan XREAL terganggu atau memberikan respons yang tidak disokong. Mencuba semula…</string>
|
||||
<string name="glasses_xreal_experimental">Sokongan eksperimen untuk 1S. Gunakan mod Follow dan matikan penstabilan dalam menu cermin mata. Arah penjejakan dan mod paparan masih perlu diuji pada peranti.</string>
|
||||
<string name="glasses_pro2_experimental">Penjejakan kepala Pro 2 secara eksperimen. Pelarasan kecerahan, kelantangan dan pertukaran mod paparan belum disokong.</string>
|
||||
<string name="cardboard_title">Cardboard VR</string>
|
||||
<string name="cardboard_mode">Mod Cardboard</string>
|
||||
<string name="cardboard_mode_hint">Paparan mata kiri dan kanan untuk kaca mata VR telefon.</string>
|
||||
|
||||
@@ -2507,6 +2507,7 @@
|
||||
<string name="glasses_xreal_network_missing">Venter på USB Ethernet-tilkoblingen til brillene. Denne telefonen gjør den kanskje ikke tilgjengelig for apper.</string>
|
||||
<string name="glasses_xreal_connection_failed">XREAL-tilkoblingen ble avbrutt eller ga et svar som ikke støttes. Prøver igjen…</string>
|
||||
<string name="glasses_xreal_experimental">Eksperimentell støtte for 1S. Bruk Follow-modus og slå av stabilisering i brillemenyen. Sporingsretninger og visningsmoduser må fortsatt testes på enheten.</string>
|
||||
<string name="glasses_pro2_experimental">Eksperimentell hodesporing for Pro 2. Justering av lysstyrke og volum samt bytte av visningsmodus støttes ikke ennå.</string>
|
||||
<string name="cardboard_title">Cardboard VR</string>
|
||||
<string name="cardboard_mode">Cardboard-modus</string>
|
||||
<string name="cardboard_mode_hint">Bilder for venstre og høyre øye til en VR-brille for mobil.</string>
|
||||
|
||||
@@ -2507,6 +2507,7 @@
|
||||
<string name="glasses_xreal_network_missing">Wachten op de USB Ethernet-verbinding van de bril. Deze telefoon maakt die mogelijk niet beschikbaar voor apps.</string>
|
||||
<string name="glasses_xreal_connection_failed">De XREAL-verbinding is onderbroken of gaf een niet-ondersteund antwoord. Opnieuw proberen…</string>
|
||||
<string name="glasses_xreal_experimental">Experimentele ondersteuning voor 1S. Gebruik de Follow-modus en schakel stabilisatie uit in het menu van de bril. Trackingrichtingen en weergavemodi moeten nog op een apparaat worden getest.</string>
|
||||
<string name="glasses_pro2_experimental">Experimentele hoofdtracking voor Pro 2. Het aanpassen van helderheid en volume en het wisselen van weergavemodus worden nog niet ondersteund.</string>
|
||||
<string name="cardboard_title">Cardboard VR</string>
|
||||
<string name="cardboard_mode">Cardboard-modus</string>
|
||||
<string name="cardboard_mode_hint">Beelden voor linker- en rechteroog voor een VR-bril voor je telefoon.</string>
|
||||
|
||||
@@ -2560,6 +2560,7 @@
|
||||
<string name="glasses_xreal_network_missing">Oczekiwanie na połączenie USB Ethernet okularów. Ten telefon może nie udostępniać go aplikacjom.</string>
|
||||
<string name="glasses_xreal_connection_failed">Połączenie z XREAL zostało przerwane lub zwróciło nieobsługiwaną odpowiedź. Ponawianie…</string>
|
||||
<string name="glasses_xreal_experimental">Eksperymentalna obsługa 1S. Użyj trybu Follow i wyłącz stabilizację w menu okularów. Kierunki śledzenia i tryby wyświetlania wymagają jeszcze testów na urządzeniu.</string>
|
||||
<string name="glasses_pro2_experimental">Eksperymentalne śledzenie ruchów głowy dla Pro 2. Regulacja jasności i głośności oraz przełączanie trybu wyświetlania nie są jeszcze obsługiwane.</string>
|
||||
<string name="cardboard_title">Cardboard VR</string>
|
||||
<string name="cardboard_mode">Tryb Cardboard</string>
|
||||
<string name="cardboard_mode_hint">Obraz dla lewego i prawego oka do gogli VR na telefon.</string>
|
||||
|
||||
@@ -2518,6 +2518,7 @@
|
||||
<string name="glasses_xreal_network_missing">A aguardar a ligação Ethernet por USB dos óculos. Este telemóvel pode não a disponibilizar às apps.</string>
|
||||
<string name="glasses_xreal_connection_failed">A ligação aos óculos XREAL foi interrompida ou devolveu uma resposta não suportada. A tentar novamente…</string>
|
||||
<string name="glasses_xreal_experimental">Suporte experimental para os 1S. Utilize o modo Follow e desative a estabilização no menu dos óculos. As direções de seguimento e os modos de ecrã ainda têm de ser testados no dispositivo.</string>
|
||||
<string name="glasses_pro2_experimental">Seguimento experimental dos movimentos da cabeça para Pro 2. O ajuste do brilho e do volume e a mudança do modo de ecrã ainda não são suportados.</string>
|
||||
<string name="cardboard_title">Cardboard VR</string>
|
||||
<string name="cardboard_mode">Modo Cardboard</string>
|
||||
<string name="cardboard_mode_hint">Imagens para o olho esquerdo e o direito, para uns óculos de RV para telemóvel.</string>
|
||||
|
||||
@@ -2518,6 +2518,7 @@
|
||||
<string name="glasses_xreal_network_missing">Aguardando a conexão Ethernet por USB dos óculos. Este celular pode não disponibilizá-la para os apps.</string>
|
||||
<string name="glasses_xreal_connection_failed">A conexão com os óculos XREAL foi interrompida ou retornou uma resposta incompatível. Tentando novamente…</string>
|
||||
<string name="glasses_xreal_experimental">Suporte experimental ao 1S. Use o modo Follow e desative a estabilização no menu dos óculos. As direções do rastreamento e os modos de exibição ainda precisam de testes no dispositivo.</string>
|
||||
<string name="glasses_pro2_experimental">Rastreamento experimental da cabeça para Pro 2. Os ajustes de brilho e volume e a troca do modo de exibição ainda não são compatíveis.</string>
|
||||
<string name="cardboard_title">Cardboard VR</string>
|
||||
<string name="cardboard_mode">Modo Cardboard</string>
|
||||
<string name="cardboard_mode_hint">Imagens para o olho esquerdo e o direito, para um óculos de RV de celular.</string>
|
||||
|
||||
@@ -2532,6 +2532,7 @@
|
||||
<string name="glasses_xreal_network_missing">Se așteaptă conexiunea USB Ethernet a ochelarilor. Este posibil ca acest telefon să nu o expună aplicațiilor.</string>
|
||||
<string name="glasses_xreal_connection_failed">Conexiunea XREAL a fost întreruptă sau a returnat un răspuns neacceptat. Se reîncearcă…</string>
|
||||
<string name="glasses_xreal_experimental">Suport experimental pentru 1S. Folosește modul Follow și dezactivează stabilizarea din meniul ochelarilor. Direcțiile de urmărire și modurile de afișare trebuie încă testate pe dispozitiv.</string>
|
||||
<string name="glasses_pro2_experimental">Urmărire experimentală a mișcărilor capului pentru Pro 2. Reglarea luminozității și a volumului și schimbarea modului de afișare nu sunt încă acceptate.</string>
|
||||
<string name="cardboard_title">Cardboard VR</string>
|
||||
<string name="cardboard_mode">Mod Cardboard</string>
|
||||
<string name="cardboard_mode_hint">Imagini pentru ochiul stâng și cel drept, pentru un vizor VR pentru telefon.</string>
|
||||
|
||||
@@ -2553,6 +2553,7 @@
|
||||
<string name="glasses_xreal_network_missing">Ожидание подключения очков по USB Ethernet. Этот телефон может не предоставлять его приложениям.</string>
|
||||
<string name="glasses_xreal_connection_failed">Подключение к XREAL прервано или получен неподдерживаемый ответ. Повторная попытка…</string>
|
||||
<string name="glasses_xreal_experimental">Экспериментальная поддержка 1S. Включите режим Follow и отключите стабилизацию в меню очков. Направления отслеживания и режимы отображения ещё нужно проверить на устройстве.</string>
|
||||
<string name="glasses_pro2_experimental">Экспериментальное отслеживание движений головы для Pro 2. Настройка яркости и громкости и переключение режимов отображения пока не поддерживаются.</string>
|
||||
<string name="stores_fact_developer">Разработчик</string>
|
||||
<string name="stores_fact_publisher">Издатель</string>
|
||||
<string name="stores_fact_released">Дата выхода</string>
|
||||
|
||||
@@ -2507,6 +2507,7 @@
|
||||
<string name="glasses_xreal_network_missing">Väntar på glasögonens USB Ethernet-anslutning. Telefonen kanske inte gör den tillgänglig för appar.</string>
|
||||
<string name="glasses_xreal_connection_failed">XREAL-anslutningen avbröts eller gav ett svar som inte stöds. Försöker igen…</string>
|
||||
<string name="glasses_xreal_experimental">Experimentellt stöd för 1S. Använd Follow-läget och stäng av stabiliseringen i glasögonens meny. Spårningsriktningar och visningslägen behöver fortfarande testas på enheten.</string>
|
||||
<string name="glasses_pro2_experimental">Experimentell huvudspårning för Pro 2. Justering av ljusstyrka och volym samt byte av visningsläge stöds inte ännu.</string>
|
||||
<string name="cardboard_title">Cardboard VR</string>
|
||||
<string name="cardboard_mode">Cardboard-läge</string>
|
||||
<string name="cardboard_mode_hint">Bilder för vänster och höger öga till ett VR-headset för mobilen.</string>
|
||||
|
||||
@@ -2482,6 +2482,7 @@
|
||||
<string name="glasses_xreal_network_missing">กำลังรอการเชื่อมต่อ USB Ethernet ของแว่นตา โทรศัพท์นี้อาจไม่เปิดให้แอปเข้าถึงการเชื่อมต่อนี้</string>
|
||||
<string name="glasses_xreal_connection_failed">การเชื่อมต่อ XREAL ขาดหายหรือได้รับการตอบกลับที่ไม่รองรับ กำลังลองใหม่…</string>
|
||||
<string name="glasses_xreal_experimental">รองรับ 1S แบบทดลอง ใช้โหมด Follow และปิดการกันสั่นในเมนูของแว่นตา ทิศทางการติดตามและโหมดการแสดงผลยังต้องทดสอบกับอุปกรณ์จริง</string>
|
||||
<string name="glasses_pro2_experimental">การติดตามศีรษะแบบทดลองสำหรับ Pro 2 ยังไม่รองรับการปรับความสว่าง ระดับเสียง และการสลับโหมดการแสดงผล</string>
|
||||
<string name="cardboard_title">Cardboard VR</string>
|
||||
<string name="cardboard_mode">โหมด Cardboard</string>
|
||||
<string name="cardboard_mode_hint">ภาพสำหรับตาซ้ายและตาขวาสำหรับแว่น VR ของโทรศัพท์</string>
|
||||
|
||||
@@ -2493,6 +2493,7 @@
|
||||
<string name="glasses_xreal_network_missing">Gözlüğün USB Ethernet bağlantısı bekleniyor. Bu telefon bu bağlantıyı uygulamalara açmıyor olabilir.</string>
|
||||
<string name="glasses_xreal_connection_failed">XREAL bağlantısı kesildi veya desteklenmeyen bir yanıt döndü. Yeniden deneniyor…</string>
|
||||
<string name="glasses_xreal_experimental">Deneysel 1S desteği. Gözlük menüsünde Follow modunu kullanın ve görüntü sabitlemeyi kapatın. Takip yönlerinin ve ekran modlarının hâlâ cihazda test edilmesi gerekiyor.</string>
|
||||
<string name="glasses_pro2_experimental">Pro 2 için deneysel baş takibi. Parlaklık ve ses düzeyi ayarı ile ekran modu değiştirme henüz desteklenmiyor.</string>
|
||||
<string name="cardboard_title">Cardboard VR</string>
|
||||
<string name="cardboard_mode">Cardboard modu</string>
|
||||
<string name="cardboard_mode_hint">Telefon VR gözlüğü için sol ve sağ göz görüntüleri.</string>
|
||||
|
||||
@@ -2557,6 +2557,7 @@
|
||||
<string name="glasses_xreal_network_missing">Очікування з’єднання USB Ethernet від окулярів. Цей телефон може не надавати його додаткам.</string>
|
||||
<string name="glasses_xreal_connection_failed">З’єднання з XREAL перервалося або повернуло непідтримувану відповідь. Повторна спроба…</string>
|
||||
<string name="glasses_xreal_experimental">Експериментальна підтримка 1S. Увімкніть режим Follow і вимкніть стабілізацію в меню окулярів. Напрямки відстеження й режими відображення ще потрібно перевірити на пристрої.</string>
|
||||
<string name="glasses_pro2_experimental">Експериментальне відстеження рухів голови для Pro 2. Налаштування яскравості й гучності та перемикання режимів відображення ще не підтримуються.</string>
|
||||
<string name="cardboard_title">Cardboard VR</string>
|
||||
<string name="cardboard_mode">Режим Cardboard</string>
|
||||
<string name="cardboard_mode_hint">Зображення для лівого й правого ока для VR-окулярів під телефон.</string>
|
||||
|
||||
@@ -2482,6 +2482,7 @@
|
||||
<string name="glasses_xreal_network_missing">Đang chờ kết nối USB Ethernet của kính. Điện thoại này có thể không cho ứng dụng truy cập kết nối đó.</string>
|
||||
<string name="glasses_xreal_connection_failed">Kết nối XREAL bị gián đoạn hoặc trả về phản hồi không được hỗ trợ. Đang thử lại…</string>
|
||||
<string name="glasses_xreal_experimental">Hỗ trợ 1S thử nghiệm. Dùng chế độ Follow và tắt ổn định hình ảnh trong menu của kính. Hướng theo dõi và các chế độ hiển thị vẫn cần thử nghiệm trên thiết bị.</string>
|
||||
<string name="glasses_pro2_experimental">Theo dõi chuyển động đầu thử nghiệm cho Pro 2. Chưa hỗ trợ điều chỉnh độ sáng, âm lượng và chuyển chế độ hiển thị.</string>
|
||||
<string name="cardboard_title">Cardboard VR</string>
|
||||
<string name="cardboard_mode">Chế độ Cardboard</string>
|
||||
<string name="cardboard_mode_hint">Hình cho mắt trái và mắt phải dành cho kính VR điện thoại.</string>
|
||||
|
||||
@@ -2485,6 +2485,7 @@
|
||||
<string name="glasses_xreal_network_missing">正在等待眼镜的 USB Ethernet 连接。这部手机可能不向应用开放此连接。</string>
|
||||
<string name="glasses_xreal_connection_failed">XREAL 连接中断或返回了不受支持的响应。正在重试…</string>
|
||||
<string name="glasses_xreal_experimental">实验性 1S 支持。请在眼镜菜单中使用跟随模式并关闭防抖。追踪方向和显示模式仍需在设备上测试。</string>
|
||||
<string name="glasses_pro2_experimental">Pro 2 实验性头部追踪。暂不支持亮度、音量调节和显示模式切换。</string>
|
||||
<string name="stores_fact_developer">开发商</string>
|
||||
<string name="stores_fact_publisher">发行商</string>
|
||||
<string name="stores_fact_released">发行日期</string>
|
||||
|
||||
@@ -2485,6 +2485,7 @@
|
||||
<string name="glasses_xreal_network_missing">正在等候眼鏡的 USB Ethernet 連線。這部手機可能不會向應用程式開放此連線。</string>
|
||||
<string name="glasses_xreal_connection_failed">XREAL 連線中斷或傳回不支援的回應。正在重試…</string>
|
||||
<string name="glasses_xreal_experimental">實驗性 1S 支援。請在眼鏡選單中使用跟隨模式並關閉畫面穩定。追蹤方向和顯示模式仍需在裝置上測試。</string>
|
||||
<string name="glasses_pro2_experimental">Pro 2 實驗性頭部追蹤。暫不支援亮度、音量調整及顯示模式切換。</string>
|
||||
<string name="stores_fact_developer">開發商</string>
|
||||
<string name="stores_fact_publisher">發行商</string>
|
||||
<string name="stores_fact_released">發行日期</string>
|
||||
|
||||
@@ -2485,6 +2485,7 @@
|
||||
<string name="glasses_xreal_network_missing">正在等待眼鏡的 USB Ethernet 連線。這支手機可能不會向應用程式開放此連線。</string>
|
||||
<string name="glasses_xreal_connection_failed">XREAL 連線中斷或傳回不支援的回應。正在重試…</string>
|
||||
<string name="glasses_xreal_experimental">實驗性 1S 支援。請在眼鏡選單中使用跟隨模式並關閉畫面穩定。追蹤方向和顯示模式仍需在實機上測試。</string>
|
||||
<string name="glasses_pro2_experimental">Pro 2 實驗性頭部追蹤。尚不支援亮度、音量調整及顯示模式切換。</string>
|
||||
<string name="stores_fact_developer">開發商</string>
|
||||
<string name="stores_fact_publisher">發行商</string>
|
||||
<string name="stores_fact_released">發行日期</string>
|
||||
|
||||
@@ -2639,6 +2639,7 @@
|
||||
<string name="glasses_xreal_network_missing">Waiting for the glasses’ USB Ethernet connection. This phone may not expose it to apps.</string>
|
||||
<string name="glasses_xreal_connection_failed">The XREAL connection was interrupted or returned an unsupported response. Retrying…</string>
|
||||
<string name="glasses_xreal_experimental">Experimental 1S support. Use Follow mode and disable stabilization in the glasses menu. Tracking directions and display modes still need device testing.</string>
|
||||
<string name="glasses_pro2_experimental">Experimental Pro 2 head tracking. Brightness, volume, and display switching are not supported yet.</string>
|
||||
<string name="display_picture_position">Picture position</string>
|
||||
<string name="display_position_top">Top</string>
|
||||
<string name="display_position_bottom">Bottom</string>
|
||||
|
||||
@@ -13,6 +13,11 @@ import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.Shadows.shadowOf
|
||||
import org.robolectric.annotation.Config
|
||||
import org.robolectric.annotation.LooperMode
|
||||
import java.nio.ByteBuffer
|
||||
import java.nio.ByteOrder
|
||||
import java.util.concurrent.CountDownLatch
|
||||
import java.util.concurrent.LinkedBlockingQueue
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [28], manifest = Config.NONE)
|
||||
@@ -232,4 +237,95 @@ class GlassesCallbacksTest {
|
||||
field("sink").set(null, null)
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun pro2CallbacksUseSharedPoseAndRejectThePreviousConnection() {
|
||||
fun v2(gen: Long) = Glasses::class.java.getDeclaredMethod("v2Listener", Long::class.javaPrimitiveType)
|
||||
.apply { isAccessible = true }.invoke(Glasses, gen) as VitureV2Link.Listener
|
||||
var delivered: FloatArray? = null
|
||||
var timestamp = 0L
|
||||
field("sink").set(null, Glasses.PoseSink { x, y, z, w, time ->
|
||||
delivered = floatArrayOf(x, y, z, w)
|
||||
timestamp = time
|
||||
})
|
||||
try {
|
||||
val q = floatArrayOf(0f, 0f, 0.6f, 0.8f)
|
||||
v2(0).onPose(ByteArray(24), q, 100)
|
||||
assertEquals(null, delivered)
|
||||
v2(1).onPose(ByteArray(24), q, 101)
|
||||
org.junit.Assert.assertArrayEquals(q, delivered, 0f)
|
||||
assertEquals(101L, timestamp)
|
||||
assertEquals(1L, field("imuPackets").getLong(null))
|
||||
v2(1).onValue(VitureProtocol.MSG_GET_DISPLAY, 0x32)
|
||||
shadowOf(Looper.getMainLooper()).idle()
|
||||
assertFalse(Glasses.state.value.sbs)
|
||||
v2(1).onValue(VitureProtocol.MSG_GET_BRIGHTNESS, 8)
|
||||
v2(1).onReady()
|
||||
v2(1).onTracking(true)
|
||||
v2(1).onLost()
|
||||
generation(2)
|
||||
shadowOf(Looper.getMainLooper()).idle()
|
||||
assertEquals(2, Glasses.state.value.brightness)
|
||||
assertTrue(Glasses.state.value.connected)
|
||||
assertFalse(Glasses.state.value.supportsScreen3dof)
|
||||
assertFalse(Glasses.state.value.tracking)
|
||||
} finally { field("sink").set(null, null) }
|
||||
}
|
||||
|
||||
@Test fun pro2DemandEndingBeforeTheFirstRestartPoseStillStopsTheStream() {
|
||||
val writes = LinkedBlockingQueue<ByteArray>()
|
||||
val incoming = LinkedBlockingQueue<VitureV2Link.Received>()
|
||||
val firstPose = CountDownLatch(1)
|
||||
val firstRead = CountDownLatch(1)
|
||||
val delegate = Glasses::class.java.getDeclaredMethod("v2Listener", Long::class.javaPrimitiveType)
|
||||
.apply { isAccessible = true }.invoke(Glasses, 1L) as VitureV2Link.Listener
|
||||
val listener = object : VitureV2Link.Listener by delegate {
|
||||
override fun onPose(raw: ByteArray, q: FloatArray, timeNs: Long) {
|
||||
delegate.onPose(raw, q, timeNs)
|
||||
firstPose.countDown()
|
||||
}
|
||||
}
|
||||
val transport = object : VitureV2Link.Transport {
|
||||
override fun write(packet: ByteArray): Boolean { writes += packet; return true }
|
||||
override fun read(timeoutMs: Long): VitureV2Link.Received? {
|
||||
firstRead.countDown()
|
||||
return incoming.poll(timeoutMs, TimeUnit.MILLISECONDS)
|
||||
}
|
||||
override fun close() {}
|
||||
}
|
||||
fun expectStream(stream: Int) = org.junit.Assert.assertArrayEquals(
|
||||
VitureV2Protocol.imuControl(stream), writes.poll(2, TimeUnit.SECONDS))
|
||||
fun updateImu() = Glasses::class.java.getDeclaredMethod("updateImu")
|
||||
.apply { isAccessible = true }.invoke(Glasses)
|
||||
val link = VitureV2Link(transport, listener)
|
||||
field("link").set(null, link)
|
||||
field("sink").set(null, null)
|
||||
try {
|
||||
expectStream(VitureV2Protocol.STREAM_POSE)
|
||||
assertTrue("Bootstrap write did not complete", firstRead.await(2, TimeUnit.SECONDS))
|
||||
val payload = ByteBuffer.allocate(24).order(ByteOrder.LITTLE_ENDIAN)
|
||||
.putInt(0).putInt(1).putFloat(1f).putFloat(0f).putFloat(0f).putFloat(0f).array()
|
||||
incoming += VitureV2Link.Received(VitureV2Protocol.packet(VitureV2Protocol.EVENT_POSE, payload), System.nanoTime())
|
||||
assertTrue(firstPose.await(2, TimeUnit.SECONDS))
|
||||
shadowOf(Looper.getMainLooper()).idle()
|
||||
expectStream(VitureV2Protocol.STREAM_OFF)
|
||||
assertTrue(Glasses.state.value.supportsScreen3dof)
|
||||
assertFalse(Glasses.state.value.tracking)
|
||||
|
||||
field("sink").set(null, Glasses.PoseSink { _, _, _, _, _ -> })
|
||||
updateImu()
|
||||
assertFalse(Glasses.state.value.tracking)
|
||||
field("sink").set(null, null)
|
||||
updateImu()
|
||||
expectStream(VitureV2Protocol.STREAM_POSE)
|
||||
expectStream(VitureV2Protocol.STREAM_OFF)
|
||||
assertFalse(link.trackingActive)
|
||||
assertFalse(Glasses.state.value.tracking)
|
||||
} finally {
|
||||
generation(2)
|
||||
link.close()
|
||||
field("link").set(null, null)
|
||||
field("sink").set(null, null)
|
||||
shadowOf(Looper.getMainLooper()).idle()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -155,6 +155,58 @@ class GlassesUsbTest {
|
||||
assertEquals(listOf(gt), manager.requests)
|
||||
}
|
||||
|
||||
@Test fun pro2RequestsPermissionWithoutTheSdkAndDoesNotClaimCompanionProducts() {
|
||||
val pro2 = device(0x1301, name = "VITURE Luma Ultra")
|
||||
manager.devices[pro2.deviceName] = pro2
|
||||
refresh(ask = true)
|
||||
assertEquals("VITURE Pro 2", state.value.model)
|
||||
assertTrue(state.value.controllable)
|
||||
assertTrue(state.value.experimental)
|
||||
assertFalse(state.value.hardwareControls)
|
||||
assertFalse(state.value.supportsDisplayModeControl)
|
||||
assertFalse(state.value.supportsScreen3dof)
|
||||
assertFalse(state.value.supportsSpatial)
|
||||
assertEquals(listOf(pro2), manager.requests)
|
||||
assertEquals(null, Glasses.deviceModel(device(0x1301, 0x1234, "VITURE Pro 2")))
|
||||
assertEquals(null, Glasses.deviceModel(device(0x1102, name = "VITURE Pro 2")))
|
||||
assertEquals(null, Glasses.deviceModel(device(0x1302, name = "VITURE Pro 2")))
|
||||
val ultra = Glasses.deviceModel(device(0x1104)) as VitureProtocol.Model
|
||||
assertEquals(VitureProtocol.Family.ULTRA, ultra.family)
|
||||
assertTrue(ultra.needsSdk)
|
||||
}
|
||||
|
||||
@Test fun pro2PoseAvailabilityDoesNotEnableDisplayOrHardwareWrites() {
|
||||
val pro2 = device(0x1301)
|
||||
manager.devices[pro2.deviceName] = pro2
|
||||
manager.granted.add(pro2.deviceName)
|
||||
val sent = mutableListOf<Int>()
|
||||
field("linkDevice").set(null, pro2)
|
||||
field("link").set(null, object : GlassesLink {
|
||||
override val hasImu = true
|
||||
override fun send(msgId: Int, payload: ByteArray): Boolean { sent += msgId; return true }
|
||||
override fun close() {}
|
||||
})
|
||||
try {
|
||||
refresh()
|
||||
assertTrue(state.value.canControl)
|
||||
assertTrue(state.value.supportsScreen3dof)
|
||||
assertFalse(state.value.can3d)
|
||||
assertFalse(state.value.supportsDisplayModeControl)
|
||||
assertFalse(state.value.hardwareControls)
|
||||
assertEquals(0, state.value.brightnessMax)
|
||||
assertEquals(0, state.value.volumeMax)
|
||||
Glasses.sendMode(0x32)
|
||||
Glasses.setBrightness(5)
|
||||
Glasses.setVolume(5)
|
||||
shadowOf(Looper.getMainLooper()).idle()
|
||||
assertTrue(sent.isEmpty())
|
||||
} finally {
|
||||
field("link").set(null, null)
|
||||
field("linkDevice").set(null, null)
|
||||
(field("handler").get(null) as Handler).removeCallbacksAndMessages(null)
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun gtVendorRequestsPermissionAndRetainsMaxProductName() {
|
||||
val gt = device(0xaf50, 0x3941, "RayNeo GT MAX")
|
||||
manager.devices[gt.deviceName] = gt
|
||||
|
||||
@@ -130,6 +130,31 @@ class VitureProtocolTest {
|
||||
assertArrayEquals(floatArrayOf(0f, 0f, sin(half).toFloat(), cos(half).toFloat()), q, 1e-5f)
|
||||
}
|
||||
|
||||
@Test fun directPro2KeepsSdkOnlyFamiliesAndUnknownProductsIsolated() {
|
||||
val direct = VitureProtocol.model(0x1301, "VITURE Luma Ultra")!!
|
||||
assertEquals("VITURE Pro 2", direct.name)
|
||||
assertEquals(VitureProtocol.Family.PRO2, direct.family)
|
||||
assertFalse(direct.needsSdk)
|
||||
assertFalse(direct.hardwareControls)
|
||||
assertFalse(direct.supportsDisplayModeControl)
|
||||
assertFalse(direct.hasSunblock)
|
||||
assertEquals(0, direct.brightnessMax)
|
||||
assertEquals(0, direct.volumeMax)
|
||||
|
||||
for (pid in listOf(0x1101, 0x1104, 0x1201, 0x1211)) {
|
||||
val model = VitureProtocol.model(pid, null)!!
|
||||
assertTrue(model.needsSdk)
|
||||
assertTrue(model.hardwareControls)
|
||||
assertTrue(model.supportsDisplayModeControl)
|
||||
}
|
||||
assertNull(VitureProtocol.model(0x1102, "VITURE Pro 2"))
|
||||
assertNull(VitureProtocol.model(0x1302, "VITURE Pro 2"))
|
||||
val sdk = VitureProtocol.sdkModel("Pro 2")!!
|
||||
assertTrue(sdk.needsSdk)
|
||||
assertTrue(sdk.hardwareControls)
|
||||
assertTrue(sdk.supportsDisplayModeControl)
|
||||
}
|
||||
|
||||
@Test fun imuFallsBackToEuler() {
|
||||
val payload = ByteBuffer.allocate(12).putFloat(0f).putFloat(0f).putFloat(30f).array()
|
||||
val q = VitureProtocol.imuQuaternion(payload)!!
|
||||
|
||||
@@ -0,0 +1,404 @@
|
||||
package com.droiddeck.launcher.glasses
|
||||
|
||||
import com.droiddeck.launcher.gpu.HeadPose
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertArrayEquals
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
import java.io.IOException
|
||||
import java.nio.ByteBuffer
|
||||
import java.nio.ByteOrder
|
||||
import java.util.concurrent.CopyOnWriteArrayList
|
||||
import java.util.concurrent.CountDownLatch
|
||||
import java.util.concurrent.LinkedBlockingQueue
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
import kotlin.math.sqrt
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [28], manifest = Config.NONE)
|
||||
class VitureV2LinkTest {
|
||||
private val transport = FakeTransport()
|
||||
private val listener = RecordingListener()
|
||||
private var link: VitureV2Link? = null
|
||||
|
||||
@After fun close() { link?.close() }
|
||||
|
||||
@Test fun writeAndAckDoNotBecomeReadyWithoutAValidPose() {
|
||||
val link = start()
|
||||
transport.feed(ack())
|
||||
transport.feed(pose(1).also { it[8] = (it[8].toInt() xor 1).toByte() })
|
||||
transport.feed(pose(2, floatArrayOf(0f, 0f, 0f, 0f)))
|
||||
transport.feed(VitureV2Protocol.packet(VitureV2Protocol.EVENT_RAW, ByteArray(56)))
|
||||
transport.flush()
|
||||
assertFalse(link.ready)
|
||||
assertFalse(link.hasImu)
|
||||
assertFalse(link.trackingActive)
|
||||
assertEquals(0, listener.readyCount.get())
|
||||
assertTrue(listener.poses.isEmpty())
|
||||
assertEquals(2L, link.badFrames)
|
||||
|
||||
val receiptTime = System.nanoTime()
|
||||
val valid = pose(3)
|
||||
transport.feed(valid, receiptTime)
|
||||
transport.flush()
|
||||
assertTrue(link.ready)
|
||||
assertTrue(link.hasImu)
|
||||
assertTrue(link.trackingActive)
|
||||
assertEquals(1, listener.readyCount.get())
|
||||
assertEquals(listOf(true), listener.tracking)
|
||||
assertEquals(1, listener.poses.size)
|
||||
assertEquals(receiptTime, listener.poses.single().timeNs)
|
||||
assertArrayEquals(valid, listener.poses.single().raw)
|
||||
}
|
||||
|
||||
@Test fun duplicatesAndBackwardTicksAreDroppedWhileUnsignedWrapAdvances() {
|
||||
start()
|
||||
for (tick in listOf(0xFFFFFFFEL, 0xFFFFFFFEL, 0xFFFFFFFDL, 0L, 0L, 0xFFFFFFFFL, 1L)) {
|
||||
transport.feed(pose(tick))
|
||||
}
|
||||
transport.flush()
|
||||
assertEquals(3, listener.poses.size)
|
||||
assertEquals(1, listener.readyCount.get())
|
||||
assertEquals(listOf(true), listener.tracking)
|
||||
assertEquals(0L, link!!.badFrames)
|
||||
}
|
||||
|
||||
@Test fun poseCollectedDuringBootstrapWriteDoesNotEstablishReadiness() {
|
||||
transport.collectDuringNextWrite(pose(1))
|
||||
val link = start()
|
||||
assertFalse(link.ready)
|
||||
assertFalse(link.trackingActive)
|
||||
assertTrue(listener.poses.isEmpty())
|
||||
|
||||
transport.feed(pose(2))
|
||||
transport.flush()
|
||||
assertTrue(link.ready)
|
||||
assertTrue(link.trackingActive)
|
||||
assertEquals(1, listener.readyCount.get())
|
||||
assertEquals(1, listener.poses.size)
|
||||
}
|
||||
|
||||
@Test fun poseCollectedDuringResumeWriteDoesNotRestartTracking() {
|
||||
val link = startReady(100)
|
||||
assertTrue(link.send(VitureProtocol.MSG_IMU, byteArrayOf(0)))
|
||||
transport.expectWrite(VitureV2Protocol.imuControl(VitureV2Protocol.STREAM_OFF))
|
||||
transport.flush()
|
||||
|
||||
transport.collectDuringNextWrite(pose(101))
|
||||
assertTrue(link.send(VitureProtocol.MSG_IMU, byteArrayOf(1)))
|
||||
transport.expectWrite(VitureV2Protocol.imuControl(VitureV2Protocol.STREAM_POSE))
|
||||
transport.flush()
|
||||
assertFalse(link.trackingActive)
|
||||
assertEquals(1, listener.poses.size)
|
||||
|
||||
transport.feed(pose(102))
|
||||
transport.flush()
|
||||
assertTrue(link.trackingActive)
|
||||
assertEquals(2, listener.poses.size)
|
||||
assertEquals(listOf(true, false, true), listener.tracking)
|
||||
}
|
||||
|
||||
@Test fun stoppingAndRestartingRequiresANewPoseAndRejectsQueuedOldSamples() {
|
||||
val link = startReady(100)
|
||||
assertTrue(link.send(VitureProtocol.MSG_IMU, byteArrayOf(0)))
|
||||
assertFalse(link.trackingActive)
|
||||
transport.expectWrite(VitureV2Protocol.imuControl(VitureV2Protocol.STREAM_OFF))
|
||||
transport.feed(pose(101))
|
||||
transport.feed(ack())
|
||||
transport.flush()
|
||||
assertEquals(1, listener.poses.size)
|
||||
assertTrue(link.ready)
|
||||
assertFalse(link.trackingActive)
|
||||
|
||||
val beforeRestart = System.nanoTime()
|
||||
assertTrue(link.send(VitureProtocol.MSG_IMU, byteArrayOf(1)))
|
||||
transport.expectWrite(VitureV2Protocol.imuControl(VitureV2Protocol.STREAM_POSE))
|
||||
transport.feed(pose(102), beforeRestart)
|
||||
transport.feed(ack())
|
||||
transport.flush()
|
||||
assertFalse(link.trackingActive)
|
||||
assertEquals(1, listener.poses.size)
|
||||
|
||||
transport.feed(pose(0))
|
||||
transport.flush()
|
||||
assertTrue(link.trackingActive)
|
||||
assertEquals(2, listener.poses.size)
|
||||
assertEquals(1, listener.readyCount.get())
|
||||
assertEquals(listOf(true, false, true), listener.tracking)
|
||||
}
|
||||
|
||||
@Test fun onReadyCanStopBootstrapBeforeTheFirstPoseIsForwarded() {
|
||||
val link = start()
|
||||
listener.whenReady = { assertTrue(link.send(VitureProtocol.MSG_IMU, byteArrayOf(0))) }
|
||||
transport.feed(pose(1))
|
||||
transport.expectWrite(VitureV2Protocol.imuControl(VitureV2Protocol.STREAM_OFF))
|
||||
transport.flush()
|
||||
assertEquals(1, listener.readyCount.get())
|
||||
assertTrue(link.ready)
|
||||
assertFalse(link.trackingActive)
|
||||
assertTrue(listener.poses.isEmpty())
|
||||
assertEquals(listOf(true, false), listener.tracking)
|
||||
}
|
||||
|
||||
@Test fun rapidStopStartCannotAcceptThePreviousStreamsPendingRead() {
|
||||
val link = startReady()
|
||||
val held = transport.hold(pose(2))
|
||||
try {
|
||||
assertTrue(link.send(VitureProtocol.MSG_IMU, byteArrayOf(0)))
|
||||
assertTrue(link.send(VitureProtocol.MSG_IMU, byteArrayOf(1)))
|
||||
} finally {
|
||||
held.release.countDown()
|
||||
}
|
||||
transport.expectWrite(VitureV2Protocol.imuControl(VitureV2Protocol.STREAM_OFF))
|
||||
transport.expectWrite(VitureV2Protocol.imuControl(VitureV2Protocol.STREAM_POSE))
|
||||
transport.flush()
|
||||
assertFalse(link.trackingActive)
|
||||
assertEquals(1, listener.poses.size)
|
||||
assertEquals(listOf(true, false), listener.tracking)
|
||||
|
||||
transport.feed(pose(3))
|
||||
transport.flush()
|
||||
assertTrue(link.trackingActive)
|
||||
assertEquals(2, listener.poses.size)
|
||||
}
|
||||
|
||||
@Test fun onReadyCanCloseWithoutForwardingAPoseOrReportingLoss() {
|
||||
val link = start()
|
||||
listener.whenReady = link::close
|
||||
transport.feed(pose(1))
|
||||
transport.awaitClosed()
|
||||
assertFalse(link.ready)
|
||||
assertFalse(link.trackingActive)
|
||||
assertTrue(listener.poses.isEmpty())
|
||||
assertEquals(0, listener.lostCount.get())
|
||||
transport.expectWrite(VitureV2Protocol.imuControl(VitureV2Protocol.STREAM_OFF))
|
||||
}
|
||||
|
||||
@Test fun unsupportedSettersNeverProduceWritesAndQueriesKeepGenericIds() {
|
||||
val link = startReady()
|
||||
for ((id, payload) in listOf(
|
||||
VitureProtocol.MSG_BRIGHTNESS to byteArrayOf(3),
|
||||
VitureProtocol.MSG_VOLUME to byteArrayOf(3),
|
||||
VitureProtocol.MSG_DISPLAY to byteArrayOf(0x32),
|
||||
VitureProtocol.MSG_FILM to byteArrayOf(1),
|
||||
VitureProtocol.MSG_IMU_RATE to byteArrayOf(3),
|
||||
VitureProtocol.MSG_IMU to byteArrayOf(2),
|
||||
VitureProtocol.MSG_IMU to byteArrayOf(),
|
||||
VitureProtocol.MSG_GET_VOLUME to byteArrayOf(1),
|
||||
)) assertFalse("msgId=$id", link.send(id, payload))
|
||||
assertTrue(link.send(VitureProtocol.MSG_GET_IMU, byteArrayOf()))
|
||||
transport.flush()
|
||||
assertTrue(transport.writes.isEmpty())
|
||||
|
||||
val queries = listOf(
|
||||
Triple(VitureProtocol.MSG_GET_BRIGHTNESS, VitureV2Protocol.MSG_GET_BRIGHTNESS, 3),
|
||||
Triple(VitureProtocol.MSG_GET_VOLUME, VitureV2Protocol.MSG_GET_VOLUME, 5),
|
||||
Triple(VitureProtocol.MSG_GET_DISPLAY, VitureV2Protocol.MSG_GET_DISPLAY, 0x31),
|
||||
)
|
||||
for ((genericId, wireId, value) in queries) {
|
||||
assertTrue(link.send(genericId, byteArrayOf()))
|
||||
transport.expectWrite(VitureV2Protocol.packet(wireId))
|
||||
transport.feed(VitureV2Protocol.packet(wireId + VitureV2Protocol.RESPONSE_OFFSET,
|
||||
byteArrayOf(0, value.toByte())))
|
||||
}
|
||||
transport.feed(VitureV2Protocol.packet(VitureV2Protocol.MSG_GET_VOLUME + VitureV2Protocol.RESPONSE_OFFSET,
|
||||
byteArrayOf(1, 7)))
|
||||
transport.feed(VitureV2Protocol.packet(VitureV2Protocol.MSG_GET_VOLUME + VitureV2Protocol.RESPONSE_OFFSET,
|
||||
byteArrayOf(0, 7, 8)))
|
||||
transport.flush()
|
||||
assertEquals(queries.map { it.first to it.third }, listener.values)
|
||||
}
|
||||
|
||||
@Test fun failureToWriteBootstrapClosesTransportAndReportsLoss() {
|
||||
transport.failNextWrite.set(true)
|
||||
val link = VitureV2Link(transport, listener).also { this.link = it }
|
||||
transport.awaitClosed()
|
||||
assertFalse(link.ready)
|
||||
assertFalse(link.hasImu)
|
||||
assertFalse(link.trackingActive)
|
||||
assertEquals(0, listener.readyCount.get())
|
||||
assertEquals(1, listener.lostCount.get())
|
||||
transport.expectWrite(VitureV2Protocol.imuControl(VitureV2Protocol.STREAM_POSE))
|
||||
transport.expectWrite(VitureV2Protocol.imuControl(VitureV2Protocol.STREAM_OFF))
|
||||
}
|
||||
|
||||
@Test fun rejectedStreamAckClosesWithoutMarkingTrackingActive() {
|
||||
val link = start()
|
||||
transport.feed(ack(status = 7))
|
||||
transport.awaitClosed()
|
||||
assertFalse(link.ready)
|
||||
assertFalse(link.trackingActive)
|
||||
assertEquals(1, listener.lostCount.get())
|
||||
assertEquals(0, listener.readyCount.get())
|
||||
assertTrue(listener.tracking.isEmpty())
|
||||
transport.expectWrite(VitureV2Protocol.imuControl(VitureV2Protocol.STREAM_OFF))
|
||||
}
|
||||
|
||||
@Test fun readFailureClearsTrackingAndClosesTransport() {
|
||||
val link = startReady()
|
||||
transport.disconnect()
|
||||
transport.awaitClosed()
|
||||
assertFalse(link.ready)
|
||||
assertFalse(link.trackingActive)
|
||||
assertEquals(listOf(true, false), listener.tracking)
|
||||
assertEquals(1, listener.lostCount.get())
|
||||
assertFalse(link.send(VitureProtocol.MSG_IMU, byteArrayOf(1)))
|
||||
transport.expectWrite(VitureV2Protocol.imuControl(VitureV2Protocol.STREAM_OFF))
|
||||
}
|
||||
|
||||
@Test fun explicitCloseSendsOffOnceAndDoesNotReportLoss() {
|
||||
val link = startReady()
|
||||
link.close()
|
||||
transport.awaitClosed()
|
||||
assertFalse(link.ready)
|
||||
assertFalse(link.trackingActive)
|
||||
assertEquals(listOf(true, false), listener.tracking)
|
||||
assertEquals(0, listener.lostCount.get())
|
||||
assertEquals(1, transport.closeCount.get())
|
||||
transport.expectWrite(VitureV2Protocol.imuControl(VitureV2Protocol.STREAM_OFF))
|
||||
link.close()
|
||||
assertFalse(link.send(VitureProtocol.MSG_GET_BRIGHTNESS, byteArrayOf()))
|
||||
assertEquals(1, transport.closeCount.get())
|
||||
assertTrue(transport.writes.isEmpty())
|
||||
}
|
||||
|
||||
@Test fun sharedPoseProducesTheSourceRightUpBackRelativeRotation() {
|
||||
startReady()
|
||||
val baseline = listener.poses.single().q
|
||||
val reference = HeadPose.recenter(HeadPose.fromGlasses(baseline[0], baseline[1], baseline[2], baseline[3]),
|
||||
centerView = true)
|
||||
val half = sqrt(0.5f)
|
||||
val rotations = listOf(
|
||||
floatArrayOf(half, half, 0f, 0f),
|
||||
floatArrayOf(half, 0f, half, 0f),
|
||||
floatArrayOf(half, 0f, 0f, half),
|
||||
floatArrayOf(0.5f, -0.5f, 0.5f, -0.5f),
|
||||
)
|
||||
rotations.forEachIndexed { index, q -> transport.feed(pose(index + 2L, q)) }
|
||||
transport.flush()
|
||||
for ((source, event) in rotations.zip(listener.poses.drop(1))) {
|
||||
val q = event.q
|
||||
val relative = HeadPose.relative(reference, HeadPose.fromGlasses(q[0], q[1], q[2], q[3]))
|
||||
assertArrayEquals(HeadPose.fromQuaternion(source[1], source[2], source[3], source[0]), relative, 1e-5f)
|
||||
}
|
||||
assertEquals(rotations.size + 1, listener.poses.size)
|
||||
}
|
||||
|
||||
private fun start(): VitureV2Link = VitureV2Link(transport, listener).also {
|
||||
link = it
|
||||
transport.expectWrite(VitureV2Protocol.imuControl(VitureV2Protocol.STREAM_POSE))
|
||||
transport.flush()
|
||||
}
|
||||
|
||||
private fun startReady(tick: Long = 1): VitureV2Link = start().also {
|
||||
transport.feed(pose(tick))
|
||||
transport.flush()
|
||||
assertTrue(it.ready)
|
||||
}
|
||||
|
||||
private fun ack(status: Int = 0) = VitureV2Protocol.packet(
|
||||
VitureV2Protocol.MSG_IMU_CONTROL + VitureV2Protocol.RESPONSE_OFFSET, byteArrayOf(status.toByte()))
|
||||
|
||||
private fun pose(tick: Long, wxyz: FloatArray = floatArrayOf(1f, 0f, 0f, 0f)): ByteArray {
|
||||
val payload = ByteBuffer.allocate(24).order(ByteOrder.LITTLE_ENDIAN)
|
||||
.putInt(0x126).putInt(tick.toInt())
|
||||
wxyz.forEach(payload::putFloat)
|
||||
return VitureV2Protocol.packet(VitureV2Protocol.EVENT_POSE, payload.array())
|
||||
}
|
||||
|
||||
private data class PoseEvent(val raw: ByteArray, val q: FloatArray, val timeNs: Long)
|
||||
|
||||
private class RecordingListener : VitureV2Link.Listener {
|
||||
val readyCount = AtomicInteger()
|
||||
val lostCount = AtomicInteger()
|
||||
val tracking = CopyOnWriteArrayList<Boolean>()
|
||||
val values = CopyOnWriteArrayList<Pair<Int, Int>>()
|
||||
val poses = CopyOnWriteArrayList<PoseEvent>()
|
||||
@Volatile var whenReady: (() -> Unit)? = null
|
||||
override fun onReady() { readyCount.incrementAndGet(); whenReady?.invoke() }
|
||||
override fun onValue(msgId: Int, value: Int) { values += msgId to value }
|
||||
override fun onPose(raw: ByteArray, q: FloatArray, timeNs: Long) { poses += PoseEvent(raw.copyOf(), q.copyOf(), timeNs) }
|
||||
override fun onTracking(active: Boolean) { tracking += active }
|
||||
override fun onLost() { lostCount.incrementAndGet() }
|
||||
}
|
||||
|
||||
private sealed interface ReadStep {
|
||||
data class Packet(val received: VitureV2Link.Received) : ReadStep
|
||||
data class Barrier(val reached: CountDownLatch) : ReadStep
|
||||
data class HeldPacket(
|
||||
val received: VitureV2Link.Received,
|
||||
val entered: CountDownLatch = CountDownLatch(1),
|
||||
val release: CountDownLatch = CountDownLatch(1),
|
||||
) : ReadStep
|
||||
data object Disconnected : ReadStep
|
||||
}
|
||||
|
||||
private class FakeTransport : VitureV2Link.Transport {
|
||||
val writes = LinkedBlockingQueue<ByteArray>(64)
|
||||
val closeCount = AtomicInteger()
|
||||
val failNextWrite = AtomicBoolean()
|
||||
private val collectedDuringWrite = AtomicReference<ByteArray?>()
|
||||
private val incoming = LinkedBlockingQueue<ReadStep>(128)
|
||||
private val closed = CountDownLatch(1)
|
||||
|
||||
override fun write(packet: ByteArray): Boolean {
|
||||
check(writes.offer(packet.copyOf()))
|
||||
val success = !failNextWrite.getAndSet(false)
|
||||
if (success) collectedDuringWrite.getAndSet(null)?.let { feed(it, System.nanoTime()) }
|
||||
return success
|
||||
}
|
||||
|
||||
override fun read(timeoutMs: Long): VitureV2Link.Received? = when (
|
||||
val step = incoming.poll(timeoutMs, TimeUnit.MILLISECONDS)
|
||||
) {
|
||||
is ReadStep.Packet -> step.received
|
||||
is ReadStep.Barrier -> { step.reached.countDown(); null }
|
||||
is ReadStep.HeldPacket -> {
|
||||
step.entered.countDown()
|
||||
check(step.release.await(2, TimeUnit.SECONDS))
|
||||
step.received
|
||||
}
|
||||
ReadStep.Disconnected -> throw IOException("Device disconnected")
|
||||
null -> null
|
||||
}
|
||||
|
||||
override fun close() { closeCount.incrementAndGet(); closed.countDown() }
|
||||
|
||||
fun feed(packet: ByteArray, timeNs: Long = System.nanoTime()) {
|
||||
check(incoming.offer(ReadStep.Packet(VitureV2Link.Received(packet.copyOf(), timeNs))))
|
||||
}
|
||||
|
||||
fun collectDuringNextWrite(packet: ByteArray) {
|
||||
check(collectedDuringWrite.compareAndSet(null, packet.copyOf()))
|
||||
}
|
||||
|
||||
fun disconnect() { check(incoming.offer(ReadStep.Disconnected)) }
|
||||
|
||||
fun hold(packet: ByteArray): ReadStep.HeldPacket {
|
||||
val held = ReadStep.HeldPacket(VitureV2Link.Received(packet.copyOf(), System.nanoTime()))
|
||||
check(incoming.offer(held))
|
||||
assertTrue("Worker did not enter the held read", held.entered.await(2, TimeUnit.SECONDS))
|
||||
return held
|
||||
}
|
||||
|
||||
fun expectWrite(expected: ByteArray) {
|
||||
assertArrayEquals(expected, writes.poll(2, TimeUnit.SECONDS))
|
||||
}
|
||||
|
||||
fun flush() {
|
||||
val reached = CountDownLatch(1)
|
||||
check(incoming.offer(ReadStep.Barrier(reached)))
|
||||
assertTrue("Worker did not consume queued reports", reached.await(2, TimeUnit.SECONDS))
|
||||
}
|
||||
|
||||
fun awaitClosed() { assertTrue("Transport did not close", closed.await(2, TimeUnit.SECONDS)) }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
// Fixtures adapted from elasticjava/viture-v2, MIT, Copyright (c) 2026 Holger Bartnick.
|
||||
// Source: ece8c30485f7d357fefa362ae74f3eabac9b3899; see docs/third-party/viture-v2/.
|
||||
package com.droiddeck.launcher.glasses
|
||||
|
||||
import org.junit.Assert.assertArrayEquals
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertNotNull
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.assertThrows
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import java.nio.ByteBuffer
|
||||
import java.nio.ByteOrder
|
||||
import kotlin.math.sqrt
|
||||
|
||||
class VitureV2ProtocolTest {
|
||||
@Test fun requestsMatchUpstreamWireExamples() {
|
||||
assertArrayEquals(hex("10 00 01 03 02 00 03 00 01 02"),
|
||||
VitureV2Protocol.imuControl(VitureV2Protocol.STREAM_POSE))
|
||||
assertArrayEquals(hex("10 00 01 03 02 00 04 00 02 02"),
|
||||
VitureV2Protocol.imuControl(VitureV2Protocol.STREAM_RAW))
|
||||
assertArrayEquals(hex("10 00 01 03 02 00 00 00 00 00"),
|
||||
VitureV2Protocol.imuControl(VitureV2Protocol.STREAM_OFF))
|
||||
assertArrayEquals(hex("10 00 22 31 00 00 00 00"),
|
||||
VitureV2Protocol.packet(VitureV2Protocol.MSG_GET_BRIGHTNESS))
|
||||
}
|
||||
|
||||
@Test fun requestBoundsAndStreamLimitsAreEnforced() {
|
||||
assertThrows(IllegalArgumentException::class.java) { VitureV2Protocol.packet(-1) }
|
||||
assertThrows(IllegalArgumentException::class.java) { VitureV2Protocol.packet(0x10000) }
|
||||
assertThrows(IllegalArgumentException::class.java) { VitureV2Protocol.packet(0, ByteArray(57)) }
|
||||
assertThrows(IllegalArgumentException::class.java) { VitureV2Protocol.imuControl(3) }
|
||||
assertThrows(IllegalArgumentException::class.java) {
|
||||
VitureV2Protocol.imuControl(VitureV2Protocol.STREAM_POSE, VitureV2Protocol.Rate.HZ_500)
|
||||
}
|
||||
assertArrayEquals(hex("10 00 01 03 02 00 07 00 02 05"),
|
||||
VitureV2Protocol.imuControl(VitureV2Protocol.STREAM_RAW, VitureV2Protocol.Rate.HZ_1000))
|
||||
val maximum = VitureV2Protocol.packet(0xFFFF, ByteArray(56) { 0xFF.toByte() })
|
||||
assertEquals(64, maximum.size)
|
||||
assertEquals(0x37C8, (maximum[6].toInt() and 0xFF) or ((maximum[7].toInt() and 0xFF) shl 8))
|
||||
assertNotNull(VitureV2Protocol.parse(maximum))
|
||||
}
|
||||
|
||||
@Test fun brightnessReplyMatchesUpstreamAndKeepsFailureStatus() {
|
||||
val frame = VitureV2Protocol.parse(hex("10 00 22 51 02 00 03 00 00 03"))!!
|
||||
val reply = VitureV2Protocol.reply(frame, VitureV2Protocol.MSG_GET_BRIGHTNESS)!!
|
||||
assertTrue(reply.success)
|
||||
assertEquals(0, reply.status)
|
||||
assertArrayEquals(byteArrayOf(3), reply.body)
|
||||
assertNull(VitureV2Protocol.reply(frame, VitureV2Protocol.MSG_GET_VOLUME))
|
||||
assertNull(VitureV2Protocol.reply(frame, -1))
|
||||
val failure = VitureV2Protocol.parse(hex("10 00 01 23 01 00 07 00 07"))!!
|
||||
val failedReply = VitureV2Protocol.reply(failure, VitureV2Protocol.MSG_IMU_CONTROL)!!
|
||||
assertFalse(failedReply.success)
|
||||
assertEquals(7, failedReply.status)
|
||||
assertTrue(failedReply.body.isEmpty())
|
||||
val noStatus = VitureV2Protocol.parse(hex("10 00 01 23 00 00 00 00"))!!
|
||||
assertNull(VitureV2Protocol.reply(noStatus, VitureV2Protocol.MSG_IMU_CONTROL))
|
||||
}
|
||||
|
||||
@Test fun validatesReceiveBoundsBeforeReadingHeader() {
|
||||
val valid = hex("10 00 22 51 02 00 03 00 00 03")
|
||||
for (size in listOf(-1, 0, 7, 9, 11, 65, Int.MAX_VALUE)) {
|
||||
assertNull("size=$size", VitureV2Protocol.parse(valid, size))
|
||||
}
|
||||
assertNull(VitureV2Protocol.parse(ByteArray(0)))
|
||||
assertNull(VitureV2Protocol.parse(valid.copyOf(65)))
|
||||
assertNull(VitureV2Protocol.parse(valid.copyOf().also { it[0] = 0x11 }))
|
||||
assertNull(VitureV2Protocol.parse(valid.copyOf().also { it[1] = 1 }))
|
||||
assertNull(VitureV2Protocol.parse(valid.copyOf().also { it[6] = 0xFF.toByte() }))
|
||||
assertNull(VitureV2Protocol.parse(valid.copyOf().also { it[9] = 4 }))
|
||||
}
|
||||
|
||||
@Test fun rejectsOversizedAndTruncatedDeclaredPayloads() {
|
||||
val valid = hex("10 00 22 51 02 00 03 00 00 03")
|
||||
assertNull(VitureV2Protocol.parse(valid.copyOf(9)))
|
||||
val tooLong = valid.copyOf(64).also { it[4] = 57 }
|
||||
assertNull(VitureV2Protocol.parse(tooLong))
|
||||
tooLong[4] = 0xFF.toByte()
|
||||
tooLong[5] = 0xFF.toByte()
|
||||
assertNull(VitureV2Protocol.parse(tooLong))
|
||||
val padded = valid.copyOf(64)
|
||||
val parsed = VitureV2Protocol.parse(padded)!!
|
||||
assertArrayEquals(byteArrayOf(0, 3), parsed.payload)
|
||||
padded[9] = 8
|
||||
assertArrayEquals(byteArrayOf(0, 3), parsed.payload)
|
||||
}
|
||||
|
||||
@Test fun poseFixturePreservesDeviceCounterAndConvertsWxyzToNormalizedXyzw() {
|
||||
val frame = VitureV2Protocol.parse(hex(
|
||||
"10 00 08 73 18 00 9c 08 " +
|
||||
"26 01 00 00 59 d6 21 00 dd e3 2b 3e 52 5d 7c 3f dd 45 9a 3b e8 27 52 3a"
|
||||
))!!
|
||||
val pose = VitureV2Protocol.pose(frame)!!
|
||||
assertEquals(0x0021D659L, pose.deviceTick)
|
||||
assertEquals(0x126L, pose.unknown)
|
||||
val expected = floatArrayOf(Float.fromBits(0x3F7C5D52), Float.fromBits(0x3B9A45DD),
|
||||
Float.fromBits(0x3A5227E8), Float.fromBits(0x3E2BE3DD))
|
||||
val norm = sqrt(expected.sumOf { it.toDouble() * it }).toFloat()
|
||||
assertArrayEquals(expected.map { it / norm }.toFloatArray(), pose.quaternion, 1e-7f)
|
||||
assertEquals(1.0, pose.quaternion.sumOf { it.toDouble() * it }, 1e-6)
|
||||
}
|
||||
|
||||
@Test fun poseNormalizesSmallScaleErrorsWithoutChangingAxesOrCounter() {
|
||||
val payload = posePayload(0.5f, -0.5f, 0.5f, -0.5f)
|
||||
ByteBuffer.wrap(payload).order(ByteOrder.LITTLE_ENDIAN).putInt(4, -1)
|
||||
val pose = VitureV2Protocol.pose(event(VitureV2Protocol.EVENT_POSE, payload))!!
|
||||
assertEquals(0xFFFFFFFFL, pose.deviceTick)
|
||||
assertArrayEquals(floatArrayOf(-0.5f, 0.5f, -0.5f, 0.5f), pose.quaternion, 0f)
|
||||
val scaled = VitureV2Protocol.pose(event(VitureV2Protocol.EVENT_POSE, posePayload(1.01f, 0f, 0f, 0f)))!!
|
||||
assertArrayEquals(floatArrayOf(0f, 0f, 0f, 1f), scaled.quaternion, 1e-7f)
|
||||
}
|
||||
|
||||
@Test fun rejectsMalformedPoseAndInvalidQuaternions() {
|
||||
val valid = posePayload(1f, 0f, 0f, 0f)
|
||||
assertNull(VitureV2Protocol.pose(event(VitureV2Protocol.EVENT_RAW, valid)))
|
||||
for (size in listOf(0, 23, 25, 56)) {
|
||||
assertNull(VitureV2Protocol.pose(event(VitureV2Protocol.EVENT_POSE, valid.copyOf(size))))
|
||||
}
|
||||
for (bad in listOf(0f, 0.5f, 2f, Float.MAX_VALUE, Float.NaN, Float.POSITIVE_INFINITY, Float.NEGATIVE_INFINITY)) {
|
||||
assertNull("w=$bad", VitureV2Protocol.pose(event(VitureV2Protocol.EVENT_POSE, posePayload(bad, 0f, 0f, 0f))))
|
||||
}
|
||||
for (component in 1..3) {
|
||||
val payload = valid.copyOf()
|
||||
ByteBuffer.wrap(payload).order(ByteOrder.LITTLE_ENDIAN).putFloat(8 + component * 4, Float.NaN)
|
||||
assertNull(VitureV2Protocol.pose(event(VitureV2Protocol.EVENT_POSE, payload)))
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun rawReadsUnalignedFloatsAndPreservesUnknownBytes() {
|
||||
val payload = rawPayload()
|
||||
val frame = event(VitureV2Protocol.EVENT_RAW, payload)
|
||||
val sample = VitureV2Protocol.raw(frame)!!
|
||||
assertEquals(0xFFFFFFFEL, sample.deviceTick)
|
||||
assertArrayEquals(floatArrayOf(1.5f, -2f, 0.25f), sample.gyroRadPerSec, 0f)
|
||||
assertArrayEquals(floatArrayOf(0.0024f, -0.3221f, -0.9287f), sample.accelG, 0f)
|
||||
assertArrayEquals(payload, sample.payload)
|
||||
frame.payload.fill(0)
|
||||
assertArrayEquals(payload, sample.payload)
|
||||
}
|
||||
|
||||
@Test fun rejectsMalformedRawAndNonfiniteMeasurementsButKeepsOpaqueTail() {
|
||||
val payload = rawPayload()
|
||||
assertNull(VitureV2Protocol.raw(event(VitureV2Protocol.EVENT_POSE, payload)))
|
||||
for (size in listOf(0, 24, 33, 34, 55)) {
|
||||
assertNull(VitureV2Protocol.raw(event(VitureV2Protocol.EVENT_RAW, payload.copyOf(size))))
|
||||
}
|
||||
for (offset in listOf(10, 14, 18, 22, 26, 30)) {
|
||||
for (bad in listOf(Float.NaN, Float.POSITIVE_INFINITY, Float.NEGATIVE_INFINITY)) {
|
||||
val invalid = payload.copyOf()
|
||||
ByteBuffer.wrap(invalid).order(ByteOrder.LITTLE_ENDIAN).putFloat(offset, bad)
|
||||
assertNull("offset=$offset, value=$bad", VitureV2Protocol.raw(event(VitureV2Protocol.EVENT_RAW, invalid)))
|
||||
}
|
||||
}
|
||||
ByteBuffer.wrap(payload).order(ByteOrder.LITTLE_ENDIAN).putFloat(46, Float.NaN)
|
||||
assertNotNull(VitureV2Protocol.raw(event(VitureV2Protocol.EVENT_RAW, payload)))
|
||||
}
|
||||
|
||||
private fun event(msgId: Int, payload: ByteArray) =
|
||||
VitureV2Protocol.parse(VitureV2Protocol.packet(msgId, payload))!!
|
||||
|
||||
private fun posePayload(w: Float, x: Float, y: Float, z: Float) =
|
||||
ByteBuffer.allocate(24).order(ByteOrder.LITTLE_ENDIAN)
|
||||
.putInt(0x126).putInt(123).putFloat(w).putFloat(x).putFloat(y).putFloat(z).array()
|
||||
|
||||
private fun rawPayload() = ByteBuffer.allocate(56).order(ByteOrder.LITTLE_ENDIAN)
|
||||
.putInt(0x126).putInt(-2).putShort(187)
|
||||
.putFloat(1.5f).putFloat(-2f).putFloat(0.25f)
|
||||
.putFloat(0.0024f).putFloat(-0.3221f).putFloat(-0.9287f)
|
||||
.putFloat(117.30f).putFloat(60.75f).putFloat(254.85f)
|
||||
.put(byteArrayOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)).array()
|
||||
|
||||
private fun hex(value: String) = value.split(' ').map { it.toInt(16).toByte() }.toByteArray()
|
||||
}
|
||||
@@ -30,6 +30,21 @@ import org.robolectric.annotation.Config
|
||||
class GlassesPanelTest {
|
||||
@get:Rule val compose = createRobolectricComposeRule()
|
||||
|
||||
@Test fun trackingOnlyDeviceHidesDisplayWritesButKeepsHeadTracking() {
|
||||
show(supportsDisplayModeControl = false)
|
||||
compose.onNodeWithTag("setting-glasses-hz").assertDoesNotExist()
|
||||
compose.onNodeWithTag("setting-glasses-resolution-two_d").assertDoesNotExist()
|
||||
compose.onNodeWithTag("setting-glasses-3d").assertDoesNotExist()
|
||||
compose.onNodeWithTag("setting-glasses-3dof").assertExists()
|
||||
}
|
||||
|
||||
@Test fun trackingOnlyDeviceHidesVrDisplayWrites() {
|
||||
show(supportsDisplayModeControl = false, tab = GlassesTab.VR, steamVrRunning = true)
|
||||
compose.onNodeWithTag("setting-glasses-resolution-vr").assertDoesNotExist()
|
||||
compose.onNodeWithTag("setting-glasses-3d-hz").assertDoesNotExist()
|
||||
compose.onNodeWithTag("setting-glasses-auto3d").assertDoesNotExist()
|
||||
}
|
||||
|
||||
@Test fun flatResolutionMenuShowsPerEyeResolutionsBesideRefresh() {
|
||||
show()
|
||||
compose.onNodeWithTag("setting-glasses-hz").assertExists()
|
||||
@@ -397,6 +412,7 @@ class GlassesPanelTest {
|
||||
outputActive: Boolean = inSession,
|
||||
controlAvailable: Boolean = true,
|
||||
supportsScreen3dof: Boolean = true,
|
||||
supportsDisplayModeControl: Boolean = true,
|
||||
supportsSpatial: Boolean = false,
|
||||
supports30Hz: Boolean = false,
|
||||
sbs90: Boolean = true,
|
||||
@@ -406,6 +422,7 @@ class GlassesPanelTest {
|
||||
onRecenter: (() -> Unit)? = {},
|
||||
) {
|
||||
val state = GlassesState(present = true, connected = controlAvailable, controllable = true,
|
||||
supportsDisplayModeControl = supportsDisplayModeControl,
|
||||
displayId = Display.DEFAULT_DISPLAY + 1, width = if (stereo) 3840 else 1920, height = 1200,
|
||||
model = "VITURE Luma Ultra", sbs = stereo, sbs90 = sbs90, supportsScreen3dof = supportsScreen3dof,
|
||||
supports30Hz = supports30Hz, supportsSpatial = supportsSpatial, resolutions = listOf(
|
||||
|
||||
Reference in new issue
Block a user