mirror of
https://git.undefined-dev.fr/Blendman974/faceclaw.git
synced 2026-11-19 21:03:09 +00:00
Partial support for Rayneo iO
This commit is contained in:
1 parent
742a5a3f81
commit
4d101eefe1
23 files changed
+1954
-69
No files matched your search
@@ -56,7 +56,7 @@ import { claimGlassesOnboardingAutoLaunch, ONBOARDING_APP_ID } from "../apps/onb
|
||||
import { beginRenderPass, endRenderPass } from "../util/render-freshness";
|
||||
import { voiceControlBridge } from "../native/voice-control";
|
||||
import { voiceActivity } from "../ui/shell/voice-activity";
|
||||
import { G2_LENS_HEIGHT, G2_LENS_WIDTH, GrayImage } from "../graphics/image";
|
||||
import { G2_LENS_HEIGHT, G2_LENS_WIDTH, GrayImage, RAYNEO_IO_HEIGHT, RAYNEO_IO_WIDTH } from "../graphics/image";
|
||||
import { flattenPlanesWithDraws, planesFingerprint, type Plane } from "../graphics/plane";
|
||||
import { prepareFrameDraws } from "../graphics/glyph-wire";
|
||||
import { createLockScreenImage, LOCK_SCREEN_SURFACE_ID } from "./lock-screen";
|
||||
@@ -78,7 +78,7 @@ import { loadPersistedOpenApps, savePersistedOpenApps } from "../ui/shell/open-a
|
||||
import { appViewportRect, isOnSwitcherEdge, sidebarStripVisible, type ScreenRect, type WindowHeightMode } from "../ui/shell/geometry";
|
||||
import { type ContinuousCaptureOptions, type LayerActions, type TextSettingsEditToggle, type TranscriptionChoice } from "../ui/layers";
|
||||
import { type KeyboardInputSession } from "../ui/shell/keyboard-input";
|
||||
import { appSwitcherPositionSetting, statusBarPositionSetting, statusBarVisibilitySetting, windowBorderSetting, assistantAllowProactiveSetting, assistantBackendSetting, assistantBridgeHostSetting, assistantBridgePortSetting, assistantBridgeTokenSetting, getBrightnessPreferences, displayLayoutSetting, navigateDisplayLayoutSetting, terminalDisplayLayoutSetting, elevenLabsApiKeySetting, getStringSettingById, openAiApiKeySetting, nightscoutApiTokenSetting, firmwareDebugFlagsSetting, whisperServerApiKeySetting, whisperServerLanguageSetting, whisperServerModelSetting, whisperServerUrlSetting, lockScreenEnabledSetting, nightscoutSiteUrlSetting, onAnySettingChanged, previewColorSetting, ringConnectionModeSetting, type RingConnectionMode, saveVoiceRecordingsSetting, sonioxApiKeySetting, screenTimeoutSetting, screenTimeoutSettingToMs, suspendEvenHubWhenScreenOffSetting, voiceProviderSetting, wakeWordActionSetting, type ConfigSettingString } from "../ui/dashboard-settings";
|
||||
import { appSwitcherPositionSetting, glassesTypeSetting, statusBarPositionSetting, statusBarVisibilitySetting, windowBorderSetting, assistantAllowProactiveSetting, assistantBackendSetting, assistantBridgeHostSetting, assistantBridgePortSetting, assistantBridgeTokenSetting, getBrightnessPreferences, displayLayoutSetting, navigateDisplayLayoutSetting, terminalDisplayLayoutSetting, elevenLabsApiKeySetting, getStringSettingById, openAiApiKeySetting, nightscoutApiTokenSetting, firmwareDebugFlagsSetting, whisperServerApiKeySetting, whisperServerLanguageSetting, whisperServerModelSetting, whisperServerUrlSetting, lockScreenEnabledSetting, nightscoutSiteUrlSetting, onAnySettingChanged, previewColorSetting, ringConnectionModeSetting, type RingConnectionMode, saveVoiceRecordingsSetting, sonioxApiKeySetting, screenTimeoutSetting, screenTimeoutSettingToMs, suspendEvenHubWhenScreenOffSetting, voiceProviderSetting, wakeWordActionSetting, type ConfigSettingString } from "../ui/dashboard-settings";
|
||||
import { isIgnoringBatteryOptimizations, requestIgnoreBatteryOptimizations } from "../native/battery-optimization";
|
||||
import {
|
||||
getInstalledEvenHubAppById,
|
||||
@@ -1479,12 +1479,15 @@ class DashboardController {
|
||||
// address disables every direct-ring code path in the communicator.
|
||||
const ringMode = ringConnectionModeSetting.get();
|
||||
this.ringModeAtConnect = ringMode;
|
||||
const ringAddress = ringMode !== "glasses" ? addresses.ring : "";
|
||||
// A RayNeo iO is one link (its address in both arm slots) and has no ring.
|
||||
const glassesType = glassesTypeSetting.get();
|
||||
const ringAddress = ringMode !== "glasses" && glassesType === "g2" ? addresses.ring : "";
|
||||
// Direct mode may unpair the ring from the glasses; remember to hand it
|
||||
// back once a later session runs in another mode.
|
||||
if (ringMode === "direct" && ringAddress) setBooleanSetting(RING_TAKEN_FROM_GLASSES_KEY, true);
|
||||
this.appendLog(
|
||||
`Using configured arms: R=${addresses.right} L=${addresses.left}${ringAddress ? ` ring=${ringAddress}` : ""}`,
|
||||
this.appendLog(glassesType === "rayneo-io"
|
||||
? `Using configured RayNeo iO: ${addresses.right}`
|
||||
: `Using configured arms: R=${addresses.right} L=${addresses.left}${ringAddress ? ` ring=${ringAddress}` : ""}`,
|
||||
);
|
||||
|
||||
let communicator: FaceclawCommunicatorBridge | null = null;
|
||||
@@ -1506,6 +1509,7 @@ class DashboardController {
|
||||
// sync needs the phone role, which the session borrows briefly for
|
||||
// each pull (GlassesSessionRing.beginRingHealthWindowLocked).
|
||||
ringRole: ringMode === "direct" ? "glasses" : "phone",
|
||||
glassesType,
|
||||
});
|
||||
this.communicator = communicator;
|
||||
// Size the compositor before anything else is awaited: windows opened
|
||||
@@ -1513,7 +1517,10 @@ class DashboardController {
|
||||
// configure their surfaces through this.communicator, and the Java call
|
||||
// queue is FIFO, so enqueuing the screen size first guarantees it lands
|
||||
// ahead of them. Mirrors ensurePreviewDisplay.
|
||||
await communicator.configureCompositorScreen(G2_LENS_WIDTH, G2_LENS_HEIGHT);
|
||||
// The iO shows 540x220: the layout stays the G2's and is cropped at the right and
|
||||
// bottom (geometry.ts pins the band to the top-left while an iO is configured).
|
||||
if (glassesType === "rayneo-io") await communicator.configureCompositorScreen(RAYNEO_IO_WIDTH, RAYNEO_IO_HEIGHT);
|
||||
else await communicator.configureCompositorScreen(G2_LENS_WIDTH, G2_LENS_HEIGHT);
|
||||
await communicator.configureBrightness(getBrightnessPreferences());
|
||||
this.offState = communicator.onStateChange((state) => {
|
||||
if (state.phase !== "connected") resetRingInputFilter();
|
||||
|
||||
@@ -30,7 +30,7 @@ export { bytesToHex, hexToBytes };
|
||||
/** Even Realities' manufacturer-data company identifier (`"ER"` read little-endian). */
|
||||
export const EVEN_COMPANY_IDENTIFIER = 0x5245;
|
||||
|
||||
export type EvenDeviceRole = "left" | "right" | "ring";
|
||||
export type EvenDeviceRole = "left" | "right" | "ring" | "rayneo-io";
|
||||
|
||||
/** True when the manufacturer data opens with Even's `"ER"` marker. */
|
||||
export function hasEvenManufacturerSignature(mfg: Uint8Array): boolean {
|
||||
@@ -71,6 +71,14 @@ export function extractG2AdvertisementFlag(mfg: Uint8Array): number | null {
|
||||
return mfg[22]!;
|
||||
}
|
||||
|
||||
/** RayNeo iO manufacturer data (company 0x5716, little-endian first): `[07][MAC x6]...`, outside pairing mode. */
|
||||
export const RAYNEO_COMPANY_IDENTIFIER = 0x5716;
|
||||
|
||||
export function extractRayNeoMac(mfg: Uint8Array): string | null {
|
||||
if (mfg.length < 9 || mfg[0] !== 0x16 || mfg[1] !== 0x57 || mfg[2] !== 0x07) return null;
|
||||
return Array.from(mfg.subarray(3, 9), (byte) => byte.toString(16).padStart(2, "0").toUpperCase()).join(":");
|
||||
}
|
||||
|
||||
/**
|
||||
* Which side a G2 temple advertisement belongs to, from the local name.
|
||||
* Null when the name carries neither or both markers.
|
||||
@@ -230,8 +238,32 @@ export function classifyAdvertisement(raw: RawAdvertisement): EvenAdvertisement
|
||||
const hasSignature = hasEvenManufacturerSignature(mfg);
|
||||
const looksLikeRing = /^EVEN R1([_ ]|$)/.test(upper);
|
||||
const looksLikeG2 = upper.includes("G2");
|
||||
const rayneoMac = extractRayNeoMac(mfg);
|
||||
const looksLikeRayNeo = upper.startsWith("RAYNEO") || rayneoMac !== null;
|
||||
|
||||
if (!looksLikeRing && !looksLikeG2 && !hasSignature) return null;
|
||||
if (!looksLikeRing && !looksLikeG2 && !hasSignature && !looksLikeRayNeo) return null;
|
||||
|
||||
if (looksLikeRayNeo && !hasSignature) {
|
||||
const address = normalizeMacAddress(raw.address);
|
||||
return {
|
||||
address,
|
||||
name,
|
||||
role: "rayneo-io",
|
||||
serial: null,
|
||||
embeddedMac: rayneoMac,
|
||||
embeddedMacMismatch: !!rayneoMac && rayneoMac !== address,
|
||||
flag: null,
|
||||
ringSerialSuffix: null,
|
||||
rssi: raw.rssi,
|
||||
txPower: raw.txPower,
|
||||
connectable: raw.connectable,
|
||||
bonded: raw.bonded,
|
||||
source: raw.source,
|
||||
seenAtMs: raw.seenAtMs,
|
||||
manufacturerData: raw.manufacturerData ?? "",
|
||||
note: null,
|
||||
};
|
||||
}
|
||||
|
||||
const base = {
|
||||
address: normalizeMacAddress(raw.address),
|
||||
|
||||
@@ -21,7 +21,7 @@ import {
|
||||
type ProximityZone,
|
||||
} from "./ble-proximity";
|
||||
import { classifyAdvertisement, normalizeMacAddress, type EvenAdvertisement, type RawAdvertisement } from "./even-advertisement";
|
||||
import { glassesImagePath, R1_IMAGE_PATH } from "./glasses-artwork";
|
||||
import { GENERIC_G2_IMAGE_PATH, glassesImagePath, R1_IMAGE_PATH } from "./glasses-artwork";
|
||||
import {
|
||||
colorwayDisplayName,
|
||||
colorwaySwatchHex,
|
||||
@@ -56,6 +56,15 @@ export type GlassesPairCandidate = {
|
||||
mismatchWarning: string | null;
|
||||
};
|
||||
|
||||
/** A RayNeo iO: one device, one address (no arms to join). */
|
||||
export type RayNeoCandidate = {
|
||||
id: string;
|
||||
advertisement: EvenAdvertisement;
|
||||
rssi: number | null;
|
||||
proximity: ProximityEstimate | null;
|
||||
lastSeenMs: number;
|
||||
};
|
||||
|
||||
export type RingCandidate = {
|
||||
id: string;
|
||||
advertisement: EvenAdvertisement;
|
||||
@@ -176,7 +185,7 @@ export class DiscoveryAggregator {
|
||||
pairs(): GlassesPairCandidate[] {
|
||||
const groups = new Map<string, { left: (EvenAdvertisement & { smoothedRssi: number | null }) | null; right: (EvenAdvertisement & { smoothedRssi: number | null }) | null }>();
|
||||
for (const record of this.byAddress.values()) {
|
||||
if (record.role === "ring") continue;
|
||||
if (record.role === "ring" || record.role === "rayneo-io") continue;
|
||||
const canonical = serialKey(record.serial);
|
||||
const key = canonical ? `serial:${canonical}` : `arm:${record.address}`;
|
||||
const group = groups.get(key) ?? { left: null, right: null };
|
||||
@@ -225,6 +234,22 @@ export class DiscoveryAggregator {
|
||||
}
|
||||
|
||||
/** Every R1 ring seen, closest first. */
|
||||
rayneos(): RayNeoCandidate[] {
|
||||
const found: RayNeoCandidate[] = [];
|
||||
for (const record of this.byAddress.values()) {
|
||||
if (record.role !== "rayneo-io") continue;
|
||||
const rssi = record.smoothedRssi != null ? Math.round(record.smoothedRssi) : null;
|
||||
found.push({
|
||||
id: `rayneo:${record.address}`,
|
||||
advertisement: stripSmoothing(record),
|
||||
rssi,
|
||||
proximity: estimateProximity(rssi, GLASSES_CALIBRATION),
|
||||
lastSeenMs: record.seenAtMs,
|
||||
});
|
||||
}
|
||||
return sortedByProximity(found, (candidate) => candidate.proximity, (candidate) => candidate.id);
|
||||
}
|
||||
|
||||
rings(): RingCandidate[] {
|
||||
const rings: RingCandidate[] = [];
|
||||
for (const record of this.byAddress.values()) {
|
||||
@@ -281,7 +306,7 @@ export function isPreviouslyPaired(name: string | null | undefined, pairedSerial
|
||||
|
||||
export type PairingRowPresentation = {
|
||||
id: string;
|
||||
kind: "glasses" | "ring";
|
||||
kind: "glasses" | "ring" | "rayneo-io";
|
||||
/** "Even G2 B" / "Even R1" / fallback product name. */
|
||||
modelTitle: string;
|
||||
/** The serial (glasses) or local name (ring). */
|
||||
@@ -416,6 +441,28 @@ export function ringRow(ring: RingCandidate, context: RowContext = {}): PairingR
|
||||
};
|
||||
}
|
||||
|
||||
export function rayneoRow(candidate: RayNeoCandidate, context: { pairedAddress?: string; nearestId?: string | null } = {}): PairingRowPresentation {
|
||||
const ad = candidate.advertisement;
|
||||
const isPaired = !!context.pairedAddress && normalizeMacAddress(context.pairedAddress) === ad.address;
|
||||
const isNearest = !!context.nearestId && context.nearestId === candidate.id;
|
||||
const warnings: string[] = [];
|
||||
if (ad.embeddedMacMismatch) warnings.push(`It advertises ${ad.embeddedMac} but was heard as ${ad.address}.`);
|
||||
return {
|
||||
id: candidate.id,
|
||||
kind: "rayneo-io",
|
||||
modelTitle: "RayNeo iO",
|
||||
deviceName: ad.name || ad.address,
|
||||
variantSummary: null,
|
||||
colorway: null,
|
||||
swatchHex: null,
|
||||
imagePath: GENERIC_G2_IMAGE_PATH,
|
||||
hasVariantImage: false,
|
||||
...presentationBase(candidate.proximity, isNearest, isPaired, warnings),
|
||||
armsSummary: "Needs the Faceclaw custom firmware. First time: put it in pairing mode (on the charger, hold the button ~5 s until the light blinks blue).",
|
||||
canSelect: true,
|
||||
};
|
||||
}
|
||||
|
||||
/** Convenience: a colourway's display text, for rows that show the swatch alone. */
|
||||
export function colorwayLabel(colorway: GlassesColorway | null): string {
|
||||
return colorway ? colorwayDisplayName(colorway) : "";
|
||||
|
||||
@@ -6,6 +6,9 @@ import { wrapText } from "./textwrap";
|
||||
|
||||
export const G2_LENS_WIDTH = 640;
|
||||
export const G2_LENS_HEIGHT = 480;
|
||||
/** RayNeo iO screen (per eye) with the Faceclaw firmware: 540x220. */
|
||||
export const RAYNEO_IO_WIDTH = 540;
|
||||
export const RAYNEO_IO_HEIGHT = 220;
|
||||
const DEFAULT_CORNER_RADIUS = 8;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { GlassesType } from "../ui/dashboard-settings";
|
||||
import type { RingInput } from "../g2/ring-input";
|
||||
import { File, knownFolders, path, type ImageSource } from "@nativescript/core";
|
||||
import { REQUIRED_FACECLAW_FIRMWARE_VERSION, type FirmwareInfo } from "../g2/firmware-compat";
|
||||
@@ -241,7 +242,10 @@ export class FaceclawCommunicatorBridge {
|
||||
return FaceclawCommunicatorBridge.active;
|
||||
}
|
||||
|
||||
constructor(addresses: { right: string; left: string; ring?: string; ringRole?: string }) {
|
||||
constructor(addresses: { right: string; left: string; ring?: string; ringRole?: string; glassesType?: GlassesType }) {
|
||||
if (addresses.glassesType === "rayneo-io") {
|
||||
throw new Error("RayNeo iO glasses are not supported on iOS yet.");
|
||||
}
|
||||
this.communicator = FaceclawKitIosGlassesSession.alloc().initWithRightAddressLeftAddressRingAddress(
|
||||
String(addresses.right ?? "").toUpperCase(),
|
||||
String(addresses.left ?? "").toUpperCase(),
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { GlassesType } from "../ui/dashboard-settings";
|
||||
import type { RingInput } from "../g2/ring-input";
|
||||
import { ImageSource, Utils } from "@nativescript/core";
|
||||
import * as frameTimings from "./frame-timings";
|
||||
@@ -161,7 +162,7 @@ export class FaceclawCommunicatorBridge {
|
||||
private readonly firmwareInfoListeners = new Set<(info: FirmwareInfo) => void>();
|
||||
private readonly previewAnimationListeners = new Set<() => void>();
|
||||
|
||||
constructor(addresses: { right: string; left: string; ring?: string; ringRole?: string }) {
|
||||
constructor(addresses: { right: string; left: string; ring?: string; ringRole?: string; glassesType?: GlassesType }) {
|
||||
const context = Utils.android.getApplicationContext();
|
||||
if (!context) throw new Error("Android application context unavailable");
|
||||
|
||||
@@ -173,6 +174,8 @@ export class FaceclawCommunicatorBridge {
|
||||
);
|
||||
// The shared session halts on any other firmware ("incompatible-firmware").
|
||||
this.communicator.setRequiredFirmwareRevision(REQUIRED_FACECLAW_FIRMWARE_VERSION);
|
||||
// RayNeo iO: one link (its address in both arm slots), its own handshake and page lease.
|
||||
if (addresses.glassesType === "rayneo-io") this.communicator.useRayNeoIo();
|
||||
// Which R1 role the direct ring link claims; only matters with a ring address.
|
||||
if (addresses.ringRole) this.communicator.setDirectRingRole(addresses.ringRole);
|
||||
this.listenerProxy = new com.faceclaw.app.FaceclawBleCommunicatorListener({
|
||||
|
||||
@@ -10,11 +10,14 @@ import {
|
||||
DiscoveryAggregator,
|
||||
glassesRow,
|
||||
nearestCandidateId,
|
||||
rayneoRow,
|
||||
ringRow,
|
||||
type GlassesPairCandidate,
|
||||
type PairingRowPresentation,
|
||||
type RayNeoCandidate,
|
||||
type RingCandidate,
|
||||
} from "../g2/pairing-candidates";
|
||||
import { glassesTypeSetting } from "../ui/dashboard-settings";
|
||||
import { DeviceDiscoveryBridge } from "../native/device-discovery";
|
||||
import { setPreviewOnlyMode } from "./onboarding-state";
|
||||
|
||||
@@ -65,6 +68,8 @@ export class PairingViewModel extends Observable {
|
||||
private _ringRows: PairingRowItem[] = [];
|
||||
private selectedPair: GlassesPairCandidate | null = null;
|
||||
private selectedRing: RingCandidate | null = null;
|
||||
/** A RayNeo iO instead of a G2 pair (the two are exclusive). */
|
||||
private selectedIo: RayNeoCandidate | null = null;
|
||||
private readonly previouslyPairedSerial: string | null;
|
||||
private readonly previouslyPairedRing: string;
|
||||
|
||||
@@ -181,7 +186,7 @@ export class PairingViewModel extends Observable {
|
||||
|
||||
get instructions(): string {
|
||||
return (
|
||||
"Select your G2 glasses and R1 ring below. Wear the glasses or take them out of the case, " +
|
||||
"Select your G2 glasses and R1 ring, or your RayNeo iO, below. Wear the glasses or take them out of the case, " +
|
||||
"and keep the glasses and phone nearby. If your glasses are not detected, make sure no other " +
|
||||
"apps are connected."
|
||||
);
|
||||
@@ -249,11 +254,14 @@ export class PairingViewModel extends Observable {
|
||||
}
|
||||
|
||||
get selectionVisibility(): "visible" | "collapse" {
|
||||
return this.selectedPair || this.selectedRing ? "visible" : "collapse";
|
||||
return this.selectedPair || this.selectedRing || this.selectedIo ? "visible" : "collapse";
|
||||
}
|
||||
|
||||
get selectionSummary(): string {
|
||||
const parts: string[] = [];
|
||||
if (this.selectedIo) {
|
||||
parts.push(`RayNeo iO · ${this.selectedIo.advertisement.name} · ${this.selectedIo.advertisement.address}`);
|
||||
}
|
||||
if (this.selectedPair) {
|
||||
const identity = this.selectedPair.identity;
|
||||
const label = identity ? identity.displayName : "Even Realities G2";
|
||||
@@ -273,7 +281,7 @@ export class PairingViewModel extends Observable {
|
||||
}
|
||||
|
||||
get primaryEnabled(): boolean {
|
||||
return !!this.selectedPair || (!this.onboarding && !!this.selectedRing);
|
||||
return !!this.selectedPair || !!this.selectedIo || (!this.onboarding && !!this.selectedRing);
|
||||
}
|
||||
|
||||
get secondaryLabel(): string {
|
||||
@@ -287,7 +295,14 @@ export class PairingViewModel extends Observable {
|
||||
readonly onRowTap = (args: EventData): void => {
|
||||
const row = (args.object as View).bindingContext as PairingRowItem | undefined;
|
||||
if (!row) return;
|
||||
if (row.kind === "glasses") {
|
||||
if (row.kind === "rayneo-io") {
|
||||
const io = this.aggregator.rayneos().find((candidate) => candidate.id === row.id) ?? null;
|
||||
this.selectedIo = this.selectedIo?.id === io?.id ? null : io;
|
||||
if (this.selectedIo) {
|
||||
this.selectedPair = null;
|
||||
this.selectedRing = null;
|
||||
}
|
||||
} else if (row.kind === "glasses") {
|
||||
const pair = this.aggregator.pairs().find((candidate) => candidate.id === row.id) ?? null;
|
||||
if (!pair) return;
|
||||
if (!row.canSelect) {
|
||||
@@ -295,14 +310,39 @@ export class PairingViewModel extends Observable {
|
||||
return;
|
||||
}
|
||||
this.selectedPair = this.selectedPair?.id === pair.id ? null : pair;
|
||||
if (this.selectedPair) this.selectedIo = null;
|
||||
} else {
|
||||
const ring = this.aggregator.rings().find((candidate) => candidate.id === row.id) ?? null;
|
||||
this.selectedRing = this.selectedRing?.id === ring?.id ? null : ring;
|
||||
if (this.selectedRing) this.selectedIo = null;
|
||||
}
|
||||
this.refresh();
|
||||
};
|
||||
|
||||
onPrimaryTap(): void {
|
||||
const io = this.selectedIo;
|
||||
if (io) {
|
||||
// One link: the same address stands for both arms; no ring.
|
||||
const address = io.advertisement.address;
|
||||
saveDeviceAddresses({ right: address, left: address, ring: "" });
|
||||
glassesTypeSetting.set("rayneo-io");
|
||||
savePairedGlassesIdentity({
|
||||
serial: io.advertisement.embeddedMac ?? address,
|
||||
leftName: io.advertisement.name,
|
||||
rightName: io.advertisement.name,
|
||||
leftAddress: address,
|
||||
rightAddress: address,
|
||||
ringName: "",
|
||||
ringAddress: "",
|
||||
pairedAtMs: Date.now(),
|
||||
});
|
||||
this.dispose();
|
||||
if (this.onboarding) setPreviewOnlyMode(false);
|
||||
// The G2 firmware check/flash pages don't apply; the session reports
|
||||
// incompatible firmware if the iO lacks the Faceclaw build.
|
||||
finishOnboardingNavigation();
|
||||
return;
|
||||
}
|
||||
const pair = this.selectedPair;
|
||||
const ring = this.selectedRing;
|
||||
if (!pair && !ring) return;
|
||||
@@ -317,6 +357,7 @@ export class PairingViewModel extends Observable {
|
||||
ring: ring?.advertisement.address ?? existing.ring,
|
||||
};
|
||||
saveDeviceAddresses(addresses);
|
||||
if (pair) glassesTypeSetting.set("g2");
|
||||
if (pair) {
|
||||
savePairedGlassesIdentity({
|
||||
serial: pair.serial ?? "",
|
||||
@@ -387,6 +428,10 @@ export class PairingViewModel extends Observable {
|
||||
this.aggregator.prune(Date.now(), DEFAULT_STALE_AFTER_MS);
|
||||
const pairs = this.aggregator.pairs();
|
||||
const rings = this.aggregator.rings();
|
||||
const rayneos = this.aggregator.rayneos();
|
||||
if (this.selectedIo) {
|
||||
this.selectedIo = rayneos.find((candidate) => candidate.id === this.selectedIo!.id) ?? null;
|
||||
}
|
||||
|
||||
// Keep the selection pointing at live data (addresses can only change if a
|
||||
// side was replaced); drop it if the pair disappeared — or if it degraded
|
||||
@@ -402,13 +447,24 @@ export class PairingViewModel extends Observable {
|
||||
|
||||
const nearestPair = nearestCandidateId(pairs);
|
||||
const nearestRing = nearestCandidateId(rings);
|
||||
this._glassesRows = pairs.map((pair) =>
|
||||
toRowItem(
|
||||
glassesRow(pair, { pairedSerial: this.previouslyPairedSerial, nearestId: nearestPair }),
|
||||
this.selectedPair?.id === pair.id,
|
||||
this.onRowTap,
|
||||
const pairedAddress = glassesTypeSetting.get() === "rayneo-io" ? loadDeviceAddresses().right : "";
|
||||
const nearestIo = nearestCandidateId(rayneos);
|
||||
this._glassesRows = [
|
||||
...rayneos.map((candidate) =>
|
||||
toRowItem(
|
||||
rayneoRow(candidate, { pairedAddress, nearestId: nearestIo }),
|
||||
this.selectedIo?.id === candidate.id,
|
||||
this.onRowTap,
|
||||
),
|
||||
),
|
||||
);
|
||||
...pairs.map((pair) =>
|
||||
toRowItem(
|
||||
glassesRow(pair, { pairedSerial: this.previouslyPairedSerial, nearestId: nearestPair }),
|
||||
this.selectedPair?.id === pair.id,
|
||||
this.onRowTap,
|
||||
),
|
||||
),
|
||||
];
|
||||
this._ringRows = rings.map((ring) =>
|
||||
toRowItem(
|
||||
ringRow(ring, { pairedRingAddress: this.previouslyPairedRing, nearestId: nearestRing }),
|
||||
@@ -423,13 +479,14 @@ export class PairingViewModel extends Observable {
|
||||
this.status = `Scan failed: ${this.scanFailure}`;
|
||||
} else if (!this._scanning) {
|
||||
this.status = "Scan paused.";
|
||||
} else if (!pairs.length && !rings.length) {
|
||||
} else if (!pairs.length && !rings.length && !rayneos.length) {
|
||||
this.status = "Scanning…";
|
||||
} else {
|
||||
const bits = [
|
||||
complete ? `${complete} ${complete === 1 ? "pair" : "pairs"} ready` : null,
|
||||
partial ? `${partial} with one arm heard` : null,
|
||||
rings.length ? `${rings.length} ${rings.length === 1 ? "ring" : "rings"}` : null,
|
||||
rayneos.length ? `${rayneos.length} RayNeo iO` : null,
|
||||
].filter(Boolean);
|
||||
this.status = `Scanning… ${bits.join(" · ")}. Tap a pair to select it.`;
|
||||
}
|
||||
|
||||
@@ -153,15 +153,19 @@ type ConfigSettingEnumOptions<TValue extends string, TId extends string> = Confi
|
||||
normalize?: (value: string | null | undefined) => TValue;
|
||||
/** Dynamic availability check used by enum picker rows. */
|
||||
isDisabled?: (value: TValue) => boolean;
|
||||
/** A value forced regardless of storage while it returns one (stored choice untouched). */
|
||||
pinned?: () => TValue | undefined;
|
||||
};
|
||||
|
||||
export class ConfigSettingEnum<TValue extends string, TId extends string = string> extends ConfigSetting<TValue, TId> {
|
||||
readonly values: readonly TValue[];
|
||||
private readonly normalizer: (value: string | null | undefined) => TValue;
|
||||
private readonly disabledPredicate: (value: TValue) => boolean;
|
||||
protected readonly pinned: (() => TValue | undefined) | undefined;
|
||||
|
||||
constructor(options: ConfigSettingEnumOptions<TValue, TId>) {
|
||||
super(options);
|
||||
this.pinned = options.pinned;
|
||||
if (options.reportInAnalytics !== false) fixedChoiceSettings.set(options.storageKey, this);
|
||||
this.values = options.values;
|
||||
this.disabledPredicate = options.isDisabled ?? (() => false);
|
||||
@@ -177,6 +181,8 @@ export class ConfigSettingEnum<TValue extends string, TId extends string = strin
|
||||
}
|
||||
|
||||
get(): TValue {
|
||||
const pinned = this.pinned?.();
|
||||
if (pinned !== undefined) return pinned;
|
||||
return this.normalizer(getStringSetting(this.storageKey, this.defaultValue));
|
||||
}
|
||||
|
||||
@@ -367,6 +373,18 @@ export const distanceUnitSetting = new ConfigSettingEnum<DistanceUnit>({
|
||||
*/
|
||||
export type AppSwitcherPosition = "left" | "right" | "bottom" | "popup";
|
||||
|
||||
/** Which glasses the saved addresses belong to (set by pairing; see g2/device-addresses.ts). */
|
||||
export type GlassesType = "g2" | "rayneo-io";
|
||||
|
||||
export const glassesTypeSetting = new ConfigSettingEnum<GlassesType>({
|
||||
id: "glasses-type",
|
||||
label: "Glasses",
|
||||
storageKey: "deviceType",
|
||||
defaultValue: "g2",
|
||||
values: ["g2", "rayneo-io"],
|
||||
reportInAnalytics: false,
|
||||
});
|
||||
|
||||
const APP_SWITCHER_POSITION_LABELS: Record<AppSwitcherPosition, string> = {
|
||||
left: "Left",
|
||||
right: "Right",
|
||||
@@ -380,6 +398,8 @@ export const appSwitcherPositionSetting = new ConfigSettingEnum<AppSwitcherPosit
|
||||
storageKey: "display.appSwitcherPosition",
|
||||
defaultValue: "bottom",
|
||||
values: ["left", "right", "bottom", "popup"],
|
||||
// RayNeo iO, until its own layout: windows at x=0, the strip past the 540 px it shows.
|
||||
pinned: () => (glassesTypeSetting.get() === "rayneo-io" ? "right" : undefined),
|
||||
formatValue: (value) => APP_SWITCHER_POSITION_LABELS[value] ?? value,
|
||||
description:
|
||||
"Where the open-app icons go. Left and right take a column beside windows; bottom puts a row beneath the window, which makes full-height windows a little shorter; popup shows them only while you're in the app switcher, in a box over the dimmed window. Bottom and popup leave room at the sides to set the display's depth. Open apps reopen at their new size when a change resizes windows.",
|
||||
@@ -395,6 +415,8 @@ class ConfigSettingEnumWithLegacy<TValue extends string> extends ConfigSettingEn
|
||||
}
|
||||
|
||||
get(): TValue {
|
||||
const pinned = this.pinned?.();
|
||||
if (pinned !== undefined) return pinned;
|
||||
return getStringSetting(this.storageKey, "") === "" ? this.legacyValue() : super.get();
|
||||
}
|
||||
}
|
||||
@@ -456,6 +478,8 @@ export const displayLayoutSetting = new ConfigSettingEnumWithLegacy<DisplayLayou
|
||||
storageKey: "display.layout",
|
||||
defaultValue: "band-middle",
|
||||
values: DISPLAY_LAYOUT_VALUES,
|
||||
// RayNeo iO, until its own layout: the band at the top, where its 220 rows look.
|
||||
pinned: () => (glassesTypeSetting.get() === "rayneo-io" ? "band-top" : undefined),
|
||||
formatValue: displayLayoutLabel,
|
||||
isDisabled: (value) => value === "fullscreen" && !fullScreenAvailable(),
|
||||
description:
|
||||
|
||||
Reference in new issue
Block a user