forked from Blendman974/faceclaw
Add support for using RayNeo iO together with an R1 ring
This commit is contained in:
1 parent
dee60bbcd2
commit
fde847a31a
10 files changed
+172
-47
No files matched your search
+6
-4
@@ -1792,14 +1792,15 @@ class GlassesSessionCore(
|
||||
return
|
||||
}
|
||||
val uuid = characteristicUuid.lowercase()
|
||||
if (isIo) {
|
||||
ioOnNotification(address, uuid, data)
|
||||
return
|
||||
}
|
||||
// The phone's own R1 link, beside either glasses (the iO's ring is always direct).
|
||||
if (isDirectRingNotification(address, uuid)) {
|
||||
handleDirectRingNotification(uuid, data)
|
||||
return
|
||||
}
|
||||
if (isIo) {
|
||||
ioOnNotification(address, uuid, data)
|
||||
return
|
||||
}
|
||||
if (BleProtocol.RENDER_NOTIFY_UUID == uuid) {
|
||||
handleRenderNotification(address, data)
|
||||
return
|
||||
@@ -2100,6 +2101,7 @@ class GlassesSessionCore(
|
||||
lastConnectionOrInputAtMs = arrivalMs
|
||||
lastDirectRingInputAtMs = arrivalMs
|
||||
lastDirectRingInputLabel = decoded.label + " " + decoded.detail
|
||||
if (isIo) ioReclaimPageOnInputLocked()
|
||||
}
|
||||
logLine("direct ring " + decoded.label + " " + decoded.detail + " raw=" + hex(data))
|
||||
val frameId = frameTimings.startFrame("input:ring:" + decoded.label)
|
||||
|
||||
+12
-6
@@ -519,6 +519,17 @@ private fun GlassesSessionCore.ioHandlePage(payload: ByteArray) {
|
||||
interruptibleSleep.interrupt()
|
||||
}
|
||||
|
||||
/**
|
||||
* The wearer gave input (a temple touch, or the R1's) after closing our page:
|
||||
* take it back. Caller holds `monitor`.
|
||||
*/
|
||||
internal fun GlassesSessionCore.ioReclaimPageOnInputLocked() {
|
||||
if (io.pageWanted || !sessionReady) return
|
||||
io.pageWanted = true
|
||||
shutdownRequested = false
|
||||
io.pageRequestSentAtMs = 0
|
||||
}
|
||||
|
||||
private fun GlassesSessionCore.ioHandleGesture(gesture: RayNeoIoProtocol.Gesture) {
|
||||
val event: G2Event? = when (gesture.eventType) {
|
||||
// Same numbering as the G2's OsEventTypeList; head up wakes like the G2 CFW's forward.
|
||||
@@ -529,12 +540,7 @@ private fun GlassesSessionCore.ioHandleGesture(gesture: RayNeoIoProtocol.Gesture
|
||||
monitor.withLock {
|
||||
lastIncomingAtMs = now()
|
||||
if (event != null) lastConnectionOrInputAtMs = lastIncomingAtMs
|
||||
if (event != null && "sys-event" == event.kind && !io.pageWanted && sessionReady) {
|
||||
// The wearer touched the glasses after closing our page: take it back.
|
||||
io.pageWanted = true
|
||||
shutdownRequested = false
|
||||
io.pageRequestSentAtMs = 0
|
||||
}
|
||||
if (event != null && "sys-event" == event.kind) ioReclaimPageOnInputLocked()
|
||||
}
|
||||
logLine("RayNeo iO gesture type=" + gesture.eventType + " source=" + gesture.source + (if (event == null) " (ignored)" else ""))
|
||||
if (event == null) return
|
||||
|
||||
+10
@@ -971,6 +971,13 @@ internal fun macWireBytes(address: String): ByteArray? {
|
||||
internal fun GlassesSessionCore.queueGlassesRingLinkCommandLocked(
|
||||
action: String, fallbackAddress: String, fallbackName: String,
|
||||
): Boolean {
|
||||
if (isIo) {
|
||||
// A RayNeo iO has no ring link of its own; the phone holds the ring directly.
|
||||
lastRingLinkCommand = "$action: not applicable (RayNeo iO)"
|
||||
lastRingLinkCommandAtMs = now()
|
||||
logLine("glasses ring $action skipped: RayNeo iO glasses have no ring link")
|
||||
return false
|
||||
}
|
||||
val reported = glassesRingMac
|
||||
val mac = reported ?: macWireBytes(fallbackAddress)
|
||||
if (mac == null) {
|
||||
@@ -1091,6 +1098,9 @@ internal fun GlassesSessionCore.queueRingConfigCommandLocked(
|
||||
frame = RingProtocol.buildPairAuth(seq)
|
||||
}
|
||||
"targets-glasses" -> {
|
||||
// The iO never connects to the ring: naming it would make the ring drop
|
||||
// the phone's glasses-role link (the advStart check, ~20 s later).
|
||||
if (isIo) return "not sent: RayNeo iO glasses don't hold the ring"
|
||||
val right = macWireBytes(rightAddress)
|
||||
val left = macWireBytes(leftAddress)
|
||||
if (right == null || left == null) return "not sent: glasses addresses unparseable"
|
||||
|
||||
Reference in new issue
Block a user