Forward ring input events before filtering, and include swipe info

This commit is contained in:
James Babcock committed 2026-09-19 19:02:11 -07:00
1 parent b972cd7682
commit 7b19c00443
20 files changed
+368 -75

No files matched your search

+25 -8
View File
@@ -11,14 +11,15 @@ export class InputEventsLayer implements Layer {
readonly acceptsDirectional = true;
readonly log = new InputEventLog();
private scrollRow = 0;
private phoneTime = false;
private visibleRows = 1;
private readonly unsubscribe: () => void;
constructor(requestRender: () => void, isVisible: () => boolean,
private readonly removed: () => void = () => {}) {
this.unsubscribe = addInputListener((event) => {
this.unsubscribe = addInputListener((event, filtered) => {
if (!isVisible() || this.log.paused) return;
this.log.add(event);
this.log.add(event, filtered);
this.scrollRow = 0;
requestRender();
});
@@ -38,6 +39,10 @@ export class InputEventsLayer implements Layer {
this.scrollRow = 0;
ctx.stack.pop();
} },
{ label: this.phoneTime ? "Show ring timestamps" : "Show phone receive time", onSelect: (ctx) => {
this.phoneTime = !this.phoneTime;
ctx.stack.pop();
} },
{ label: "Back to Debug tests", onSelect: (ctx) => { ctx.stack.popThrough(this); } },
];
}
@@ -49,8 +54,9 @@ export class InputEventsLayer implements Layer {
image.drawText(font, 12, 8, "Input events", 230);
const status = `${this.log.paused ? "Paused" : "Live"} ${this.log.count} events`;
image.drawText(font, width - 12 - font.measureText(status), 8, status, 180);
image.drawText(font, 12, 28, "Phone receive time | gap ms | source | event", 140);
const rowHeight = Math.max(18, font.lineHeight + 2);
image.drawText(font, 12, 28, this.phoneTime ? "Phone receive time | gap ms | source | event" : "Time (R=ring tick) | gap | source | event", 140);
const lineHeight = Math.max(18, font.lineHeight + 2);
const rowHeight = lineHeight * 2 + 4;
this.visibleRows = Math.max(1, Math.floor((height - 76) / rowHeight));
this.scrollRow = Math.min(this.scrollRow, Math.max(0, this.log.entries.length - this.visibleRows));
const timeX = 12;
@@ -62,20 +68,31 @@ export class InputEventsLayer implements Layer {
image.drawText(font, 12, 82, "Press arrives before an interpreted gesture.", 150);
}
for (const [index, entry] of this.log.entries.slice(this.scrollRow, this.scrollRow + this.visibleRows).entries()) {
const { event, gapMs } = entry;
const { event } = entry;
const ringTime = !this.phoneTime && event.ringInput;
const gapMs = ringTime ? entry.ringGapTicks : entry.gapMs;
const y = 50 + index * rowHeight;
const gap = gapMs === null ? "-" : `${gapMs >= 0 ? "+" : ""}${gapMs}`;
const source = "source" in event ? event.source ?? "-" : "-";
const label = event.type === "unknown" ? `${event.kind} ${event.eventSource}/${event.eventType}` : event.type;
image.drawText(font, timeX, y, inputTimestamp(event.timestampMs), 170);
const label = (entry.filtered ? "*" : "") + (event.type === "unknown"
? event.ringInput ? `ring type ${event.ringInput.type}` : `${event.kind} ${event.eventSource}/${event.eventType}`
: event.type);
image.drawText(font, timeX, y, ringTime ? `R${ringTime.tick}` : inputTimestamp(event.timestampMs), 170);
image.drawText(font, gapX, y, truncateText(font, gap, sourceX - gapX - 4), 160);
image.drawText(font, sourceX, y, source, 180);
image.drawText(font, eventX, y, truncateText(font, label, width - eventX - 12), event.type === "ring-press" ? 255 : 200);
if (event.ringInput) {
const { type, aux, speed } = event.ringInput;
// These are the original report bytes, not physical distance/speed units.
const details = `Raw ring: type ${type} AUX ${aux} speed ${speed}`;
image.drawText(font, timeX + 12, y + lineHeight,
truncateText(font, details, width - timeX - 36), 170);
}
}
if (this.log.paused) drawListScrollbar(image, width - 5, 50, height - 78,
this.scrollRow, this.visibleRows, this.log.entries.length);
image.drawText(font, 12, height - 20,
this.log.paused ? "Scroll: history Tap-hold: controls" : "Newest first Tap-hold: pause / clear / back", 140);
this.log.paused ? "Scroll: history Tap-hold: controls" : "Unfiltered (*=dedup) Tap-hold: controls", 140);
return image;
}
+4 -1
View File
@@ -1,3 +1,4 @@
import { type RingInput } from "./ring-input";
import { type CompassEvent } from '../native/compass-types'
/** iOS binary bridge to the same Kotlin protocol used by Android. */
import { fromData, toData, nativeArray } from '../native/kotlin-data'
@@ -52,10 +53,12 @@ export const readString = (data: Uint8Array, field: number): string => protocol.
export function authenticationSucceeded(message: ProtocolMessage, magic: number): boolean {
return message.sid === SID.auth && message.command === 4 && message.magic === magic && readBytes(message.payload, 3)?.length === 0
}
export type GlassesInput = { kind: 'sys-event' | 'list-click' | 'text-click' | 'display-wake' | 'even-ai'; eventType: number; eventSource: number; systemExitReasonCode: number; containerName: string; frameId: number }
export type GlassesInput = { ringInput?: RingInput; kind: 'sys-event' | 'list-click' | 'text-click' | 'display-wake' | 'even-ai'; eventType: number; eventSource: number; systemExitReasonCode: number; containerName: string; frameId: number }
function input(event: any): GlassesInput | null {
return event ? { kind: event.kind === 'sys-event' && event.eventType === OsEventTypeList.HEAD_UP_EVENT ? 'display-wake' : event.kind,
eventType: event.eventType, eventSource: event.eventSource, systemExitReasonCode: event.systemExitReasonCode,
ringInput: Number(event.ringTick) >= 0 ? { tick: Number(event.ringTick), type: Number(event.ringType),
aux: Number(event.ringAux), speed: Number(event.ringSpeed) } : undefined,
containerName: event.containerName, frameId: 0 } : null
}
export const decodeGlassesInput = (message: ProtocolMessage): GlassesInput | null => input(protocol.glassesInputDataSidFlag(toData(message.payload), message.sid, message.flag))
+3 -1
View File
@@ -1,3 +1,4 @@
import { type RingInput, decodeRingMetadata } from "./ring-input";
import { type CompassEvent } from '../native/compass-types'
/** G2 wire protocol, ported from g2protocol/BleProtocol.java. No platform APIs. */
import { OsEventTypeList } from './events'
@@ -127,7 +128,7 @@ export function readString(data: Uint8Array, number: number): string { return Ar
export function authenticationSucceeded(message: ProtocolMessage, magic: number): boolean {
return message.sid === SID.auth && message.command === 4 && message.magic === magic && readBytes(message.payload, 3)?.length === 0
}
export type GlassesInput = { kind: 'sys-event' | 'list-click' | 'text-click' | 'display-wake' | 'even-ai'; eventType: number; eventSource: number; systemExitReasonCode: number; containerName: string; frameId: number }
export type GlassesInput = { ringInput?: RingInput; kind: 'sys-event' | 'list-click' | 'text-click' | 'display-wake' | 'even-ai'; eventType: number; eventSource: number; systemExitReasonCode: number; containerName: string; frameId: number }
export function decodeGlassesInput(message: ProtocolMessage): GlassesInput | null {
if (message.sid !== SID.hub || ![1, 6].includes(message.flag)) return null
const events = readBytes(message.payload, 13); if (!events) return null
@@ -135,6 +136,7 @@ export function decodeGlassesInput(message: ProtocolMessage): GlassesInput | nul
const event = readBytes(events, field)
if (event) return { kind: kind === 'sys-event' && readInteger(event, typeField) === OsEventTypeList.HEAD_UP_EVENT ? 'display-wake' : kind,
eventType: readInteger(event, typeField), eventSource: field === 3 ? readInteger(event, 2) : 0,
ringInput: field === 3 && readInteger(event, 2) === 2 ? decodeRingMetadata(readBytes(event, 100)) : undefined,
systemExitReasonCode: field === 3 ? readInteger(event, 4) : 0, containerName: field === 3 ? '' : readString(event, 2), frameId: 0 }
}
return null
+3
View File
@@ -1,3 +1,4 @@
import { acceptInput, resetRingInputFilter } from "../ui/input-monitor";
import { Application, ImageSource } from "@nativescript/core";
import { EvenAIStatus, EvenAIStatusName, EventSourceType, EventSourceTypeName, OsEventTypeList, OsEventTypeName, WatchGestureType, WatchGestureTypeName } from "./events";
import { isValidMacAddress, loadDeviceAddresses } from "./device-addresses";
@@ -1320,6 +1321,7 @@ class DashboardController {
this.appendLog(line);
});
this.offState = communicator.onStateChange((state) => {
if (state.phase !== "connected") resetRingInputFilter();
if (state.phase === "unpaired") {
// Java parked its retry loop: an arm's Android bond is gone, so
// every redial would fail the same way until the user re-pairs.
@@ -2047,6 +2049,7 @@ class DashboardController {
let frameOwned = false;
try {
const inputEvent = rawInputEventToInputEvent(event);
if (!acceptInput(inputEvent)) return;
// The gesture, plus which app is on screen and whether input goes to it,
// the sidebar, or a shell overlay. Java only knows the raw event codes,
// and without the target the export says what was pressed but not who
+1 -1
View File
@@ -26,7 +26,7 @@ export type FirmwareInfo = {
};
/** The Faceclaw firmware revision this build of the app needs. */
export const REQUIRED_FACECLAW_FIRMWARE_VERSION = 18;
export const REQUIRED_FACECLAW_FIRMWARE_VERSION = 22;
const FACECLAW_PREFIX = "Faceclaw/";
const LEGACY_PREFIX = "EVENCFW";
+42 -36
View File
@@ -19,8 +19,14 @@ export type FirmwarePatchSet = {
export const CFW_PATCH_SET: FirmwarePatchSet = {
"base": "g2_2.3.0.24.bin",
"baseSha256": "187ccf2bcc5c17a212106e8a376745511e8289c4232b634a7ea94b9bf25a0979",
"outputSha256": "71e02f9f184951080efe1b4baea3f3d23bde4b7132025535e9cd14c7d74b15fc",
"outputSha256": "059ff37a5455b9b272b715ab62c2910ee4dc4966fbfb2e117159bda746bd7315",
"patches": [
{
"offset": 1045797,
"old": "38b584b0",
"new": "5af317bf",
"desc": "ring receiver entry: timestamped unfiltered reports under framebuffer lease"
},
{
"offset": 1437929,
"old": "15e0",
@@ -30,49 +36,49 @@ export const CFW_PATCH_SET: FirmwarePatchSet = {
{
"offset": 1437923,
"old": "fef788ff",
"new": "fbf23afc",
"new": "fbf226fc",
"desc": "cfw_ancs_event"
},
{
"offset": 1437951,
"old": "fef7e8fb",
"new": "fbf274f9",
"new": "fbf260f9",
"desc": "cfw_ancs_open"
},
{
"offset": 1437969,
"old": "fef7e7fb",
"new": "fbf28bf9",
"new": "fbf277f9",
"desc": "cfw_ancs_close"
},
{
"offset": 1388387,
"old": "39694d00",
"new": "5d407d00",
"new": "35407d00",
"desc": "connection-bound ANCS EUS write callback"
},
{
"offset": 971497,
"old": "fff717f8",
"new": "6af3bdfe",
"desc": "bl cfw_message_bridge_received (ordered private bridge delivery before worker pool)"
"new": "6df347f8",
"desc": "bl faceclaw_input_bridge_received (ring relay and ordered private transport before worker pool)"
},
{
"offset": 971845,
"old": "fef769ff",
"new": "6af30ffe",
"desc": "bl cfw_message_bridge_received (ordered private bridge delivery before worker pool)"
"new": "6cf399ff",
"desc": "bl faceclaw_input_bridge_received (ring relay and ordered private transport before worker pool)"
},
{
"offset": 979579,
"old": "fdf74ef8",
"new": "68f3f4fe",
"desc": "bl cfw_message_bridge_received (ordered private bridge delivery before worker pool)"
"new": "6bf37ef8",
"desc": "bl faceclaw_input_bridge_received (ring relay and ordered private transport before worker pool)"
},
{
"offset": 1428895,
"old": "f8f76cfd",
"new": "faf2b0f9",
"new": "faf224f9",
"desc": "bl cfw_receive_packet (private SID-f0 probe before TPL reassembly)"
},
{
@@ -102,145 +108,145 @@ export const CFW_PATCH_SET: FirmwarePatchSet = {
{
"offset": 1248487,
"old": "d4f712fb",
"new": "28f368fa",
"new": "28f378f9",
"desc": "bl settings_send_wrapper (append caps field 100)"
},
{
"offset": 1246183,
"old": "f5f7e2f8",
"new": "28f3ecfb",
"new": "28f310fb",
"desc": "bl settings_decode_wrapper (Faceclaw lease field 101)"
},
{
"offset": 975219,
"old": "02f083fc",
"new": "6af34efc",
"new": "6af372fb",
"desc": "bl faceclaw_display_start @ 0x467d68 (fail-open wake takeover)"
},
{
"offset": 975411,
"old": "02f023fc",
"new": "6af3bcfc",
"new": "6af3e0fb",
"desc": "bl faceclaw_display_start_headup @ 0x467e28 (fail-open wake takeover)"
},
{
"offset": 975103,
"old": "07f085fb",
"new": "6cf368f9",
"new": "6cf350f8",
"desc": "bl headup_gate (head-up sensor event -> EvenHub sys event 12 under lease)"
},
{
"offset": 830549,
"old": "19f03efb",
"new": "8ff317fb",
"new": "8ff3fff9",
"desc": "bl gesture_ring_press_mode (observe ring touch-down, preserve stock dispatch)"
},
{
"offset": 830795,
"old": "1ff071ff",
"new": "8ff3d0fa",
"new": "8ff3b8f9",
"desc": "bl gesture_press (owned event 9 before stock menu gate)"
},
{
"offset": 830887,
"old": "1ff043ff",
"new": "8ff3cafa",
"new": "8ff3b2f9",
"desc": "bl gesture_short_long (Faceclaw lease gates event 11 vs stock Menu path)"
},
{
"offset": 831763,
"old": "1ff08dfd",
"new": "8ff300f9",
"new": "8ef3e8ff",
"desc": "bl gesture_release (owned event 10 before stock menu gate)"
},
{
"offset": 1570209,
"old": "7fb50600",
"new": "d9f2f9bd",
"new": "d9f209bd",
"desc": "even_ai_display_ctrl entry -> conditional Faceclaw lease trampoline"
},
{
"offset": 1051545,
"old": "f6f787f9",
"new": "53f327ff",
"new": "53f3d7fe",
"desc": "bl display_copy_hook @ 0x47a78e (640x480 direct framebuffer)"
},
{
"offset": 1051861,
"old": "f6f7e9f8",
"new": "53f389fe",
"new": "53f339fe",
"desc": "bl display_copy_hook @ 0x47a8ca (640x480 direct framebuffer)"
},
{
"offset": 1262237,
"old": "d9f7d0fd",
"new": "24f397fa",
"new": "24f3cff9",
"desc": "bl faceclaw_send_wear_event @ 0x4ade92 (outside onboarding)"
},
{
"offset": 1262337,
"old": "d9f79efd",
"new": "24f365fa",
"new": "24f39df9",
"desc": "bl faceclaw_send_wear_event @ 0x4adef6 (outside onboarding)"
},
{
"offset": 1309405,
"old": "67f02dff",
"new": "18f37ffb",
"new": "18f3b7fa",
"desc": "bl compass_decode_capture (sample-matched GAF diagnostics)"
},
{
"offset": 1307865,
"old": "fff7c9fb",
"new": "18f3fdfe",
"new": "18f335fe",
"desc": "bl compass_report_event (stock UI + heading with diagnostics over BLE)"
},
{
"offset": 1300937,
"old": "00210170",
"new": "1af3e3fb",
"new": "1af31bfb",
"desc": "bl compass_preserve_accuracy (retain magnetic calibration under Faceclaw framebuffer lease)"
},
{
"offset": 4537963,
"old": "",
"new": "b0b581ea00039b0701d0034637e0c2b110f0030315d000f1010ca2f1010e0023cc5c9e45c45403f1010404d0634413f003032346f4d121440319121b102a14d302e00346102a10d3d1f800c0d1f804e0cc688d68103adc609d60c3f804e043f810cb0f2a01f11001eed8042a07d300bf51f8045b043a032a43f8045bf8d8002a08bfb0bd0139013b11f8015f013a03f8015ff9d1b0bd00bf884218bf002a00d1704710b50b1a38bf431a934207d288420ad281ea00039b0726d0034669e0fff79fffbde81040704781ea000300eb020c9b0701eb020e42d15fea8c732bd0a0f1010c00bf8b1813f801ec8418531e04f801ec04d0624412f003021a46f2d101eb030e00eb030c17e0830736d0a2f1010c00f1010e002300bfcc5c9c45c45403f1010404d0734413f003032346f4d1121b2144031922e01346042b0ed3aef10402acf1040152f80449043b032b41f80449f8d802f1040e01f1040c1a4653b1aef10101acf1010300bf11f80149013a03f80149f9d1bde8104070470346042a06d351f8044b043a032a43f8044bf8d8002af0d00139013b00bf11f8014f013a03f8014ff9d1e6e700bf2de9f04fa5b04ef66c6b4ff29c5416460d46ccf2ff0bc2f229044ff6ff7900274ff00108019006e048f2a351c0f24501bff32f8f8847d4f800a0bff35f8f20680321cff680710140b1f1005fbff35f8f03d10168594500f0d7804ff4397005f063fa002800f0f3824ff61c51cff6ff7142184a3182f8e47282f8e57282f8e67282f8e77282f8e87282f8e97282f8ea7282f8eb7282f8ec7282f8ed7282f8ee7282f8ef7282f8f07282f8f17282f8f27282f8f37282f8f47282f8f57282f8f67282f8f77282f8f87282f8f97282f8fa7282f8fb7282f8fc7282f8fd7282f8fe7282f8ff7282f8007382f8017382f8027382f8037382f8047382f8057382f8067382f8077382f8087382f8097382f80a7382f80b7382f80c7382f80d7382f80e7382f80f7382f8107382f8117382f8127382f8137382f8147382f8157382f8167382f8177382f8187382f8197382f81a7382f81b7382f81c7382f81d7382f81e7382f81f7382f8207382f8217382f8227382f8237382f8247382f8257382f8267382f8277382f8287382f8297382f82a7382f82b7382f82c7382f82d737ff468afc0f800b080f80a80a0f81c90a0f81e90a0f82090a0f82290a0f82490a0f82690a0f82890a0f82a90a0f82c90a0f82e90a0f83090a0f83290a0f83490a0f83690a0f83890a0f83a9054e8001f51457ff41bafbff35f8f00bf44e8000121b154e8001f5145f8d00fe7aa4645ea064100260127c0f8701206e048f2a351c0f24501bff32f8f88472568bff35f8f20680321cff680710140b1f1005fbff35f8f03d10168594500f0d6804ff4397005f06cf9002800f0fc814ff61c51cff6ff7100bf42184a3182f8e46282f8e56282f8e66282f8e76282f8e86282f8e96282f8ea6282f8eb6282f8ec6282f8ed6282f8ee6282f8ef6282f8f06282f8f16282f8f26282f8f36282f8f46282f8f56282f8f66282f8f76282f8f86282f8f96282f8fa6282f8fb6282f8fc6282f8fd6282f8fe6282f8ff6282f8006382f8016382f8026382f8036382f8046382f8056382f8066382f8076382f8086382f8096382f80a6382f80b6382f80c6382f80d6382f80e6382f80f6382f8106382f8116382f8126382f8136382f8146382f8156382f8166382f8176382f8186382f8196382f81a6382f81b6382f81c6382f81d6382f81e6382f81f6382f8206382f8216382f8226382f8236382f8246382f8256382f8266382f8276382f8286382f8296382f82a6382f82b6382f82c6382f82d637ff468afc0f800b08772a0f81c90a0f81e90a0f82090a0f82290a0f82490a0f82690a0f82890a0f82a90a0f82c90a0f82e90a0f83090a0f83290a0f83490a0f83690a0f83890a0f83a9054e8001fa9427ff41cafbff35f8f44e8000121b154e8001fa942f8d011e7d0f8746242f6f767c0f24407002ebff35f8f00f0078107f19a0230464ff0ff314ff0ff379047002840f05d8147f6df40c0f24f00804700274ff001080397adf8107006e048f2a351c0f24501bff32f8f88472568bff35f8f20680321cff680710140b1f1005fbff35f8f03d10168594500f0fd804ff4397005f05cf8002800f0f5804ff61c51cff6ff7100bf42184a3182f8e47282f8e57282f8e67282f8e77282f8e87282f8e97282f8ea7282f8eb7282f8ec7282f8ed7282f8ee7282f8ef7282f8f07282f8f17282f8f27282f8f37282f8f47282f8f57282f8f67282f8f77282f8f87282f8f97282f8fa7282f8fb7282f8fc7282f8fd7282f8fe7282f8ff7282f8007382f8017382f8027382f8037382f8047382f8057382f8067382f8077382f8087382f8097382f80a7382f80b7382f80c7382f80d7382f80e7382f80f7382f8107382f8117382f8127382f8137382f8147382f8157382f8167382f8177382f8187382f8197382f81a7382f81b7382f81c7382f81d7382f81e7382f81f7382f8207382f8217382f8227382f8237382f8247382f8257382f8267382f8277382f8287382f8297382f82a7382f82b7382f82c7382f82d737ff468afc0f800b080f80a80a0f81c90a0f81e90a0f82090a0f82290a0f82490a0f82690a0f82890a0f82a90a0f82c90a0f82e90a0f83090a0f83290a0f83490a0f83690a0f83890a0f83a9054e8001fa9427ff41bafbff35f8f00bf44e8000149b354e8001fa942f8d00fe705460020b847b0b105f51d7151e8006f4eb9bff35f8f00bf41e8000292b151e8006f002ef8d00021bff32f8fbff35f8f21b10646dde64ff0ff3742e007f5a9718847d6e60121f1e70020019d42f6f764002d4ff0010bc0f2440418bfbaf1000f33d10df108098046484602f089fa03ab28465146012206f06bfa9df8111007464846002918bf4ff0ff3702f0c9fbbbf1000f044608d19df8100028b94af21f30c0f247004c308047b8f1000f18bfc8f80c4042f6f764c0f2440404f5807130468847384625b0bde8f08f2a7802f07f01a1f1150313f1030f0bd802f07b030b2b07d002f07e02082a03d0032901d00629b7d140b14af21f31c0f247010746884797f8641111b14ff0ff37d6e738464ff0000ba6e72de9f04f81b04ef66c6b4ff29c554ff61c5848f2a35accf2ff0bc2f229054ff6ff76cff6ff7800274ff00109c0f2450a03e000bfbff32f8fd0472c68bff35f8f2868bff35f8f01466ff39601b1f1005f03d10168594500f0c6804ff4397004f0cdfe002800f0be80414600bf42184a3182f8e47282f8e57282f8e67282f8e77282f8e87282f8e97282f8ea7282f8eb7282f8ec7282f8ed7282f8ee7282f8ef7282f8f07282f8f17282f8f27282f8f37282f8f47282f8f57282f8f67282f8f77282f8f87282f8f97282f8fa7282f8fb7282f8fc7282f8fd7282f8fe7282f8ff7282f8007382f801738Line truncated
"new": "b0b581ea00039b0701d0034637e0c2b110f0030315d000f1010ca2f1010e0023cc5c9e45c45403f1010404d0634413f003032346f4d121440319121b102a14d302e00346102a10d3d1f800c0d1f804e0cc688d68103adc609d60c3f804e043f810cb0f2a01f11001eed8042a07d300bf51f8045b043a032a43f8045bf8d8002a08bfb0bd0139013b11f8015f013a03f8015ff9d1b0bd00bf884218bf002a00d1704710b50b1a38bf431a934207d288420ad281ea00039b0726d0034669e0fff79fffbde81040704781ea000300eb020c9b0701eb020e42d15fea8c732bd0a0f1010c00bf8b1813f801ec8418531e04f801ec04d0624412f003021a46f2d101eb030e00eb030c17e0830736d0a2f1010c00f1010e002300bfcc5c9c45c45403f1010404d0734413f003032346f4d1121b2144031922e01346042b0ed3aef10402acf1040152f80449043b032b41f80449f8d802f1040e01f1040c1a4653b1aef10101acf1010300bf11f80149013a03f80149f9d1bde8104070470346042a06d351f8044b043a032a43f8044bf8d8002af0d00139013b00bf11f8014f013a03f8014ff9d1e6e700bf2de9f04fa5b04ef66c6b4ff29c5416460d46ccf2ff0bc2f229044ff6ff7900274ff00108019006e048f2a351c0f24501bff32f8f8847d4f800a0bff35f8f20680321cff680710140b1f1005fbff35f8f03d10168594500f0c3804ff4407005f073f9002800f0b7824ff60051cff6ff714218403182f8007382f8017382f8027382f8037382f8047382f8057382f8067382f8077382f8087382f8097382f80a7382f80b7382f80c7382f80d7382f80e7382f80f7382f8107382f8117382f8127382f8137382f8147382f8157382f8167382f8177382f8187382f8197382f81a7382f81b7382f81c7382f81d7382f81e7382f81f7382f8207382f8217382f8227382f8237382f8247382f8257382f8267382f8277382f8287382f8297382f82a7382f82b7382f82c7382f82d7382f82e7382f82f7382f8307382f8317382f8327382f8337382f8347382f8357382f8367382f8377382f8387382f8397382f83a7382f83b7382f83c7382f83d7382f83e7382f83f737ff47cafc0f800b080f80a80a0f81c90a0f81e90a0f82090a0f82290a0f82490a0f82690a0f82890a0f82a90a0f82c90a0f82e90a0f83090a0f83290a0f83490a0f83690a0f83890a0f83a9054e8001f51457ff42fafbff35f8f00bf44e8000121b154e8001f5145f8d023e7aa4645ea064100260127c0f8701206e048f2a351c0f24501bff32f8f88472568bff35f8f20680321cff680710140b1f1005fbff35f8f03d10168594500f0c2804ff4407005f090f8002800f0d4814ff60051cff6ff7100bf4218403182f8006382f8016382f8026382f8036382f8046382f8056382f8066382f8076382f8086382f8096382f80a6382f80b6382f80c6382f80d6382f80e6382f80f6382f8106382f8116382f8126382f8136382f8146382f8156382f8166382f8176382f8186382f8196382f81a6382f81b6382f81c6382f81d6382f81e6382f81f6382f8206382f8216382f8226382f8236382f8246382f8256382f8266382f8276382f8286382f8296382f82a6382f82b6382f82c6382f82d6382f82e6382f82f6382f8306382f8316382f8326382f8336382f8346382f8356382f8366382f8376382f8386382f8396382f83a6382f83b6382f83c6382f83d6382f83e6382f83f637ff47cafc0f800b08772a0f81c90a0f81e90a0f82090a0f82290a0f82490a0f82690a0f82890a0f82a90a0f82c90a0f82e90a0f83090a0f83290a0f83490a0f83690a0f83890a0f83a9054e8001fa9427ff430afbff35f8f44e8000121b154e8001fa942f8d025e7d0f8746242f6f767c0f24407002ebff35f8f00f0f38007f19a0230464ff0ff314ff0ff379047002840f0498147f6df40c0f24f00804700274ff001080397adf8107006e048f2a351c0f24501bff32f8f88472568bff35f8f20680321cff680710140b1f1005fbff35f8f03d10168594500f0e9804ff4407004f094ff002800f0e1804ff60051cff6ff7100bf4218403182f8007382f8017382f8027382f8037382f8047382f8057382f8067382f8077382f8087382f8097382f80a7382f80b7382f80c7382f80d7382f80e7382f80f7382f8107382f8117382f8127382f8137382f8147382f8157382f8167382f8177382f8187382f8197382f81a7382f81b7382f81c7382f81d7382f81e7382f81f7382f8207382f8217382f8227382f8237382f8247382f8257382f8267382f8277382f8287382f8297382f82a7382f82b7382f82c7382f82d7382f82e7382f82f7382f8307382f8317382f8327382f8337382f8347382f8357382f8367382f8377382f8387382f8397382f83a7382f83b7382f83c7382f83d7382f83e7382f83f737ff47cafc0f800b080f80a80a0f81c90a0f81e90a0f82090a0f82290a0f82490a0f82690a0f82890a0f82a90a0f82c90a0f82e90a0f83090a0f83290a0f83490a0f83690a0f83890a0f83a9054e8001fa9427ff42fafbff35f8f00bf44e8000149b354e8001fa942f8d023e705460020b847b0b105f51d7151e8006f4eb9bff35f8f00bf41e8000292b151e8006f002ef8d00021bff32f8fbff35f8f21b10646f1e64ff0ff3742e007f5a9718847eae60121f1e70020019d42f6f764002d4ff0010bc0f2440418bfbaf1000f33d10df108098046484602f061fa03ab28465146012206f093fa9df8111007464846002918bf4ff0ff3702f08dfbbbf1000f044608d19df8100028b94af21f30c0f247004c308047b8f1000f18bfc8f80c4042f6f764c0f2440404f5807130468847384625b0bde8f08f2a7802f07f01a1f1150313f1030f0bd802f07b030b2b07d002f07e02082a03d0032901d00629b7d140b14af21f31c0f247010746884797f8641111b14ff0ff37d6e738464ff0000ba6e72de9f04f81b04ef66c6b4ff29c554ff6005848f2a35accf2ff0bc2f229054ff6ff76cff6ff7800274ff00109c0f2450a03e000bfbff32f8fd0472c68bff35f8f2868bff35f8f01466ff39601b1f1005f03d10168594500f0b2804ff4407004f019fe002800f0aa80414600bf4218403182f8007382f8017382f8027382f8037382f8047382f8057382f8067382f8077382f8087382f8097382f80a7382f80b7382f80c7382f80d7382f80e7382f80f7382f8107382f8117382f8127382f8137382f8147382f8157382f8167382f8177382f8187382f8197382f81a7382f81b7382f81c7382f81d7382f81e7382f81f7382f8207382f8217382f8227382f8237382f8247382f8257382f8267382f8277382f8287382f8297382f82a7382f82b7382f82c7382f82d7382f82e7382f82f7382f8307382f8317382f8327382f8337382f8347382f8357382f8367382f8377382f8387382f8397382f83a7382f83b738Line truncated
"desc": "append injected blobs to main-app payload"
},
{
"offset": 779123,
"old": "805a3900",
"new": "80193a00",
"new": "f0173a00",
"desc": "main-app subheader payload size (ps)"
},
{
"offset": 152,
"old": "005b3900",
"new": "001a3a00",
"new": "70183a00",
"desc": "main-app TOC entry size (ps + 128)"
},
{
"offset": 779243,
"old": "805a3904",
"new": "80193a04",
"new": "f0173a04",
"desc": "main-app preamble length (low 24 bits)"
},
{
"offset": 779247,
"old": "effdbcea",
"new": "30750afb",
"new": "ed6be905",
"desc": "[5] ota/s200_firmware_ota.bin preamble crc32"
},
{
"offset": 156,
"old": "c0c6322a",
"new": "067916a3",
"new": "18540264",
"desc": "[5] ota/s200_firmware_ota.bin component crc32c (TOC)"
},
{
"offset": 779127,
"old": "c0c6322a",
"new": "067916a3",
"new": "18540264",
"desc": "[5] ota/s200_firmware_ota.bin component crc32c (subheader)"
}
]
+3
View File
@@ -1,3 +1,4 @@
import { acceptInput, resetRingInputFilter } from "../ui/input-monitor";
import { bindIosNotifications, iosNotificationsChanged, onIosNotificationPopup } from '../native/notification-icons.ios'
import { shouldShowNotificationOnGlasses } from '../native/notification-sources'
import { readActiveNotifications } from '../native/notification-icons.ios'
@@ -347,6 +348,7 @@ export class IosPreviewController {
}).catch(error => this.fail(error))
}
private async receiveInput(event: InputEvent, headTilt = false): Promise<void> {
if (!acceptInput(event)) return
if (this.glassesLocked) {
// Preserve the locked display's sleep/wake controls without dispatching
// gestures to apps, shell menus, voice input or the Glanceboard.
@@ -497,6 +499,7 @@ export class IosPreviewController {
if (error) { this.onError(error); return }
if (!this.session) {
this.session = new GlassesSession(iosBluetooth(), state => {
if (state.phase !== "connected") resetRingInputFilter()
this.maybePlayWelcomeSound(state)
if (state.phase !== 'connected' && state.phase !== 'connecting') this.glassesWorn = null
if (state.phase !== 'connected') iosVoiceInput.handleSessionEnded()
+11
View File
@@ -0,0 +1,11 @@
/** Original R1 report metadata. Tick is unsigned ring uptime, not phone time.
* Keep the native clock units: G2's deduplication threshold is 100 ticks. */
export type RingInput = Readonly<{ tick: number; type: number; aux: number; speed: number }>;
/** Faceclaw/19 EvenHub SysEvent field 100, version 1. */
export function decodeRingMetadata(raw: Uint8Array | null | undefined): RingInput | undefined {
if (!raw || raw.length !== 12 || raw[0] !== 0x52 || raw[1] !== 0x49 ||
raw[2] !== 1 || raw[3] !== 1 || raw[7] !== 0) return undefined;
return { tick: (raw[8] | raw[9] << 8 | raw[10] << 16 | raw[11] << 24) >>> 0,
type: raw[4], aux: raw[5], speed: raw[6] };
}
+6 -2
View File
@@ -1,3 +1,4 @@
import type { RingInput } from "../g2/ring-input";
import { ImageSource, Utils } from "@nativescript/core";
import * as frameTimings from "./frame-timings";
@@ -52,7 +53,7 @@ export type SurfaceOptions = {
transparency: "opaque" | "color-key";
};
export type RawInputEvent =
export type RawInputEvent = { ringInput?: RingInput } & (
| {
kind: "list-click";
containerName: string;
@@ -113,7 +114,7 @@ export type RawInputEvent =
eventSource: number;
systemExitReasonCode: number;
frameId: number;
};
});
function nonNegativeNumber(value: number): number {
const numeric = Number(value);
@@ -177,6 +178,7 @@ export class FaceclawCommunicatorBridge {
eventSource: number,
systemExitReasonCode: number,
frameId: number,
ringTick: number, ringType: number, ringAux: number, ringSpeed: number,
) => {
const event = {
kind: String(kind) as RawInputEvent["kind"],
@@ -185,6 +187,8 @@ export class FaceclawCommunicatorBridge {
eventSource: Number(eventSource),
systemExitReasonCode: Number(systemExitReasonCode),
frameId: Number(frameId),
ringInput: Number(ringTick) >= 0 ? { tick: Number(ringTick), type: Number(ringType),
aux: Number(ringAux), speed: Number(ringSpeed) } : undefined,
};
frameTimings.logFrame(event.frameId, "input event received on JS side");
this.emitAsync(this.ringListeners, event);
+6 -2
View File
@@ -1,3 +1,5 @@
import type { RingInput } from "../g2/ring-input";
/**
* Where an input came from. The ring and the glasses' arms are the stock
* sources; "watch" is the Wear OS remote, which components may treat with a
@@ -10,10 +12,12 @@ export type InputSource = "ring" | "left-arm" | "right-arm" | "watch";
export type BaseInputEvent = {
/**
* When the event was received from the device (or synthesized), as a
* Date.now() epoch-ms value. The G2 wire formats carry no device-side
* clock, so this is phone receive time.
* Date.now() epoch-ms value. This remains separate from the original
* ring clock so app timers can continue comparing against Date.now().
*/
timestampMs: number;
/** Present for unfiltered ring reports forwarded by Faceclaw/19. */
ringInput?: RingInput;
};
/** The per-type part of InputEvent; makeInputEvent adds the BaseInputEvent fields. */
+52 -7
View File
@@ -1,26 +1,65 @@
import type { InputEvent } from "./gestures";
type InputListener = (event: Readonly<InputEvent>) => void;
type InputListener = (event: Readonly<InputEvent>, filtered: boolean) => void;
const listeners = new Set<InputListener>();
/** Observe input before shell routing consumes menu, hold, or back gestures. */
/** Observe every input before deduplication or wake/menu/app routing. */
export function addInputListener(listener: InputListener): () => void {
listeners.add(listener);
return () => { listeners.delete(listener); };
}
export function notifyInputListeners(event: InputEvent): void {
export function notifyInputListeners(event: InputEvent, filtered = false): void {
if (!listeners.size) return;
const snapshot = Object.freeze({ ...event });
const snapshot = Object.freeze({ ...event,
...(event.ringInput ? { ringInput: Object.freeze({ ...event.ringInput }) } : {}) });
for (const listener of listeners) {
try { listener(snapshot); }
try { listener(snapshot, filtered); }
catch (error) { console.warn("Input observer failed", error); }
}
}
/** Reproduce G2 2.3.0's receiver filter in the original unsigned ring clock.
* Press (wire 10) neither filters nor advances the clock; hold-release (8)
* always passes and advances it. Rejected reports do not extend the window.
* Backward ticks (including ring restart) use the same uint32 subtraction as
* stock. Legacy, temple, and watch events have no raw metadata and pass through.
*/
export class RingInputFilter {
private lastTick = 0;
reset(): void { this.lastTick = 0; }
accept(event: InputEvent): boolean {
const raw = event.ringInput;
if (!raw) return true;
if (raw.type !== 8 && raw.type !== 10 && this.lastTick !== 0 &&
((raw.tick - this.lastTick) >>> 0) < 100) return false;
if (raw.type !== 10) this.lastTick = raw.tick;
return true;
}
}
const ringFilter = new RingInputFilter();
const decisions = new WeakMap<InputEvent, boolean>();
export function resetRingInputFilter(): void { ringFilter.reset(); }
/** Controllers call before lock/glance handling; Shell also accepts direct
* synthetic input. Cache by event identity so both stages observe/filter once.
* Debug capture sees even rejected events, without sending them to other apps.
*/
export function acceptInput(event: InputEvent): boolean {
const previous = decisions.get(event);
if (previous !== undefined) return previous;
const timingAccepted = ringFilter.accept(event);
const accepted = timingAccepted && !(event.ringInput && event.type === "unknown");
decisions.set(event, accepted);
notifyInputListeners(event, !timingAccepted);
return accepted;
}
export type InputLogEntry = {
event: Readonly<InputEvent>;
gapMs: number | null;
ringGapTicks: number | null;
filtered: boolean;
};
/** A bounded arrival-ordered history; equal timestamps must keep both events. */
@@ -29,14 +68,19 @@ export class InputEventLog {
paused = false;
count = 0;
private previousMs: number | null = null;
private previousRingTick: number | null = null;
add(event: Readonly<InputEvent>): void {
add(event: Readonly<InputEvent>, filtered = false): void {
if (this.paused) return;
this.entries.unshift({
event: { ...event },
event: { ...event, ...(event.ringInput ? { ringInput: { ...event.ringInput } } : {}) },
filtered,
ringGapTicks: !event.ringInput || this.previousRingTick === null ? null :
(event.ringInput.tick - this.previousRingTick) >>> 0,
gapMs: this.previousMs === null ? null : event.timestampMs - this.previousMs,
});
this.previousMs = event.timestampMs;
if (event.ringInput) this.previousRingTick = event.ringInput.tick;
this.count++;
if (this.entries.length > 200) this.entries.length = 200;
}
@@ -44,6 +88,7 @@ export class InputEventLog {
clear(): void {
this.entries.length = 0;
this.previousMs = null;
this.previousRingTick = null;
this.count = 0;
}
}
+10 -5
View File
@@ -2,7 +2,7 @@ import { G2_LENS_HEIGHT, G2_LENS_WIDTH, GrayImage } from "../../graphics/image";
import { singlePlane, type Plane } from "../../graphics/plane";
import { getDefaultSmallFont } from "../../graphics/ui-fonts";
import { EvenAIStatus, EventSourceType, OsEventTypeList, WatchGestureType } from "../../g2/events";
import { notifyInputListeners } from "../input-monitor";
import { acceptInput } from "../input-monitor";
import type { RawInputEvent } from "../../native/faceclaw-communicator";
import {
directionalFallback,
@@ -709,7 +709,7 @@ class Shell {
}
async receiveInput(event: InputEvent, frameId = 0): Promise<ShellInputOutcome> {
notifyInputListeners(event);
if (!acceptInput(event)) return { shell: false, window: false };
try {
return await this.routeInput(event, frameId);
} finally {
@@ -1552,7 +1552,8 @@ function formatAssistantTime(date: Date): string {
}
export function rawInputEventToInputEvent(event: RawInputEvent): InputEvent {
return makeInputEvent(rawInputEventToPayload(event));
return { ...makeInputEvent(rawInputEventToPayload(event)),
...(event.ringInput ? { ringInput: { ...event.ringInput } } : {}) };
}
function rawInputEventToPayload(event: RawInputEvent): InputEventPayload {
@@ -1625,9 +1626,13 @@ function rawInputEventToPayload(event: RawInputEvent): InputEventPayload {
};
}
/** Scroll events only carry a source when it is the watch (the stock ones never needed one). */
/** Preserve explicit sources; stock scroll notifications usually omit them. */
function scrollEvent(type: "scroll-up" | "scroll-down", eventSource: number): InputEventPayload {
return eventSource === EventSourceType.TOUCH_EVENT_FROM_WATCH ? { type, source: "watch" } : { type };
return eventSource === EventSourceType.TOUCH_EVENT_FROM_WATCH ||
eventSource === EventSourceType.TOUCH_EVENT_FROM_RING ||
eventSource === EventSourceType.TOUCH_EVENT_FROM_GLASSES_L ||
eventSource === EventSourceType.TOUCH_EVENT_FROM_GLASSES_R
? { type, source: eventSourceToString(eventSource) } : { type };
}
function eventSourceToString(eventSource: number): InputSource {