Revert "feat: add shared tilt-down hide and current-angle measurement"

This reverts commit f029e3ce91.
This commit is contained in:
Blendman974 committed 2026-11-06 22:20:24 +01:00
1 parent f029e3ce91
commit fe87e75fc2
21 files changed
+24 -356

No files matched your search

+1 -8
View File
@@ -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, getHeadUpPreferences, headDownHideSetting, 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, statusBarPositionSetting, statusBarVisibilitySetting, windowBorderSetting, assistantAllowProactiveSetting, assistantBackendSetting, assistantBridgeHostSetting, assistantBridgePortSetting, assistantBridgeTokenSetting, getBrightnessPreferences, getHeadUpPreferences, 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,
@@ -2403,13 +2403,6 @@ class DashboardController {
frameTimings.logFrame(frameId, `TS input handler start: ${event.kind} ${eventLabel(event.kind, event.eventType)}`);
let frameOwned = false;
try {
if (event.kind === "sys-event" && event.eventType === OsEventTypeList.HEAD_DOWN_EVENT) {
if (headDownHideSetting.get()) {
this.glance.dismiss();
if (shell.isScreenOn()) shell.sleep();
}
return;
}
const inputEvent = rawInputEventToInputEvent(event);
if (!acceptInput(inputEvent)) return;
// The gesture, plus which app is on screen and whether input goes to it,
-2
View File
@@ -77,7 +77,6 @@ export const OsEventTypeList = {
* this eventType; the glance host treats it as a press.
*/
HEAD_UP_EVENT: 12,
HEAD_DOWN_EVENT: 15,
/** Faceclaw/18: R1 touch-down, before click/hold/slide recognition. */
RING_PRESS_EVENT: 14,
} as const;
@@ -96,6 +95,5 @@ export const OsEventTypeName: Record<number, string> = {
10: "RING_LONG_PRESS_RELEASE_EVENT",
11: "SHORT_THEN_LONG_PRESS_EVENT",
12: "HEAD_UP_EVENT",
15: "HEAD_DOWN_EVENT",
14: "RING_PRESS_EVENT",
};
+1 -2
View File
@@ -1,4 +1,3 @@
import { headDownHideSetting } from "../ui/dashboard-settings";
/**
* Shows the Glanceboard while the shell sleeps. The board is not a window:
* it lives on its own full-screen opaque compositor surface above the shell
@@ -93,7 +92,7 @@ export class GlanceHost {
if (gesture === "click" && !provider.showOnTap()) return null;
if ((gesture === "long-press" || gesture === "short-then-long-press") && !provider.showOnLongPress()) return null;
if (gesture === "head-tilt" && !provider.showOnHeadTilt()) return null;
return glanceEventForGesture(gesture, this.isVisible(), headDownHideSetting.get());
return glanceEventForGesture(gesture, this.isVisible());
}
/**
+3 -11
View File
@@ -12,13 +12,11 @@
/** Fallback press timeout when the host supplies none; each further press restarts it. */
export const GLANCE_TIMEOUT_MS = 3000;
export const GLANCE_TILT_MAX_MS = 60_000;
export type GlanceState = {
visible: boolean;
/** A long-press is holding the board up; the timer does not run meanwhile. */
holding: boolean;
tilted?: boolean;
/** When the board hides on its own (epoch ms), or null while held / hidden. */
hideAtMs: number | null;
};
@@ -26,7 +24,6 @@ export type GlanceState = {
export type GlanceEvent =
/** Single tap or head-tilt wake: show, and (re)start the auto-hide timer. */
| { type: "press" }
| { type: "tilt" }
/** Long-press: show and keep showing until the release. */
| { type: "hold" }
/** The long-press ended. */
@@ -47,15 +44,12 @@ export function reduceGlance(
switch (event.type) {
case "press":
// A tap during a hold changes nothing: the hold decides when it ends.
if (state.holding || state.tilted) return state;
if (state.holding) return state;
return { visible: true, holding: false, hideAtMs: nowMs + timeoutMs };
case "tilt":
return { visible: true, holding: state.holding, tilted: true, hideAtMs: state.holding ? null : nowMs + GLANCE_TILT_MAX_MS };
case "hold":
return { visible: true, holding: true, ...(state.tilted ? { tilted: true } : {}), hideAtMs: null };
return { visible: true, holding: true, hideAtMs: null };
case "release":
// Releases delivered late or after a disabled hold gesture mean nothing here.
if (state.holding && state.tilted) return { visible: true, holding: false, tilted: true, hideAtMs: nowMs + GLANCE_TILT_MAX_MS };
return state.holding ? GLANCE_HIDDEN : state;
case "timeout":
if (!state.visible || state.holding || state.hideAtMs === null || nowMs < state.hideAtMs) return state;
@@ -74,13 +68,11 @@ export function reduceGlance(
export function glanceEventForGesture(
gesture: "click" | "double-click" | "long-press" | "short-then-long-press" | "long-press-release" | "head-tilt" | (string & {}),
boardVisible: boolean,
tiltDownToHide = false,
): GlanceEvent | null {
switch (gesture) {
case "click":
return { type: "press" };
case "head-tilt":
return { type: tiltDownToHide ? "tilt" : "press" };
return { type: "press" };
case "long-press":
case "short-then-long-press":
return { type: "hold" };
-86
View File
@@ -1,86 +0,0 @@
import { headUpAngleSetting } from "../ui/dashboard-settings";
import type { ImuReading } from "../native/imu-types";
declare const com: any;
/** Experimental inclination estimate inspired by https://github.com/jimrandomh/faceclaw/pull/64; not a calibrated sensor-axis pitch. */
export function estimateHeadInclination(samples: ImuReading[]): number | null {
if (samples.length < 3) return null;
const mean = samples.reduce((v, s) => [v[0]! + s.x, v[1]! + s.y, v[2]! + s.z], [0, 0, 0]).map(v => v / samples.length);
const magnitude = Math.hypot(...mean);
if (!Number.isFinite(magnitude) || magnitude < 1e-6) return null;
// Reject motion instead of persisting a passing acceleration as an angle.
for (const s of samples) {
const length = Math.hypot(s.x, s.y, s.z);
const dot = (s.x * mean[0]! + s.y * mean[1]! + s.z * mean[2]!) / (length * magnitude);
if (!Number.isFinite(dot) || Math.acos(Math.max(-1, Math.min(1, dot))) * 180 / Math.PI > 5) return null;
}
return Math.acos(Math.min(1, Math.max(...mean.map(Math.abs)) / magnitude)) * 180 / Math.PI;
}
export type HeadAngleDevice = {
beginHeadAngleMeasurement(): boolean;
endHeadAngleMeasurement(): void;
getHeadUpCalibration(): number;
subscribe(listener: (reading: ImuReading) => void): () => void;
};
let measuring = false;
export async function setAngleFromCurrentHead(device: HeadAngleDevice | null = androidDevice()): Promise<string> {
if (measuring) return "Measurement already running";
if (!device) return "Connect the glasses first";
measuring = true;
let release = () => {};
let lease = false;
try {
if (!device.beginHeadAngleMeasurement()) return "Glasses unavailable or measurement busy";
lease = true;
const samples: ImuReading[] = [];
await new Promise<void>((resolve, reject) => {
let source: number | null = null;
let sampleTimer: ReturnType<typeof setTimeout> | null = null;
const timeout = setTimeout(resolve, 4200);
const finish = () => { clearTimeout(timeout); if (sampleTimer !== null) clearTimeout(sampleTimer); resolve(); };
try {
const unsubscribe = device.subscribe(reading => {
if (![0, 1, 3].includes(reading.source) || ![reading.x, reading.y, reading.z].every(Number.isFinite)) return;
if (source === null) { source = reading.source; sampleTimer = setTimeout(finish, 1200); }
if (source === reading.source && samples.length < 200) samples.push(reading);
});
release = () => { clearTimeout(timeout); if (sampleTimer !== null) clearTimeout(sampleTimer); unsubscribe(); };
} catch (error) { clearTimeout(timeout); if (sampleTimer !== null) clearTimeout(sampleTimer); reject(error); }
});
const degrees = estimateHeadInclination(samples);
if (degrees === null) return "No stable sensor data; keep still and retry";
const calibration = device.getHeadUpCalibration();
if (!Number.isFinite(calibration)) return "Glasses calibration not received; retry";
// Preserve the existing raw-angle preference and firmware calibration, rather
// than changing the meaning of saved angles for existing installations.
const offset = Math.round((degrees - calibration) / 5) * 5;
if (offset < 0 || offset > 60) return "Measured angle is outside the supported range";
headUpAngleSetting.set(String(offset));
return `Saved estimated head-up angle: ${offset}°`;
} catch { return "Measurement failed; try again"; }
finally {
try { release(); } catch { /* Disconnected communicator. */ }
try { if (lease) device.endHeadAngleMeasurement(); } catch { /* Disconnected communicator. */ }
measuring = false;
}
}
function androidDevice(): HeadAngleDevice | null {
if (!global.isAndroid) return null;
let active: any;
try { active = com.faceclaw.app.FaceclawBleCommunicator.getActive(); } catch { return null; }
if (!active) return null;
return {
beginHeadAngleMeasurement: () => Boolean(active.beginHeadAngleMeasurement()),
endHeadAngleMeasurement: () => active.endHeadAngleMeasurement(),
getHeadUpCalibration: () => Number(active.getHeadUpCalibration()),
subscribe(listener) {
const proxy = new com.faceclaw.app.FaceclawImuListener({ onImuData: (x: number, y: number, z: number, source: number) =>
listener({ x: Number(x), y: Number(y), z: Number(z), source: Number(source) }) });
active.addImuListener(proxy);
return () => active.removeImuListener(proxy);
},
};
}
+1 -8
View File
@@ -53,7 +53,7 @@ import { onAnySettingChanged,
previewColorSetting, lockScreenEnabledSetting, getBrightnessPreferences, getStringSettingById,
nightscoutSiteUrlSetting, nightscoutApiTokenSetting, voiceProviderSetting, elevenLabsApiKeySetting,
openAiApiKeySetting, sonioxApiKeySetting, whisperServerApiKeySetting, whisperServerLanguageSetting,
headDownHideSetting, whisperServerModelSetting, whisperServerUrlSetting, ringConnectionModeSetting, saveTranscribeAudioSetting } from '../ui/dashboard-settings'
whisperServerModelSetting, whisperServerUrlSetting, ringConnectionModeSetting, saveTranscribeAudioSetting } from '../ui/dashboard-settings'
import { transcriptionKey, type VoiceProviderSelection } from '../native/cloud-stt-provider'
import type { PhoneGesture } from '../phone-ui/phone-gestures'
import { claimGlassesOnboardingAutoLaunch, ONBOARDING_APP_ID } from '../apps/onboarding/onboarding-progress'
@@ -1007,13 +1007,6 @@ export class IosPreviewController {
private handleRingEvent(input: RawInputEvent): void {
this.inputQueue = this.inputQueue.then(async () => {
if (this.state.phase !== 'connected') return
if (input.kind === 'sys-event' && input.eventType === OsEventTypeList.HEAD_DOWN_EVENT) {
if (headDownHideSetting.get()) {
this.glance.dismiss()
if (shell.isScreenOn()) shell.sleep()
}
return
}
this.onActivity()
if (input.ringInput) this.state = { ...this.state, ring: true }
await this.receiveInput(rawInputEventToInputEvent(input),
+1 -6
View File
@@ -566,11 +566,6 @@ export const headUpWakeSetting = new HeadUpWakeSetting({
description: "Enable waking the glasses when you look up. Until changed, the glasses keep their current setting. Glanceboard's Show on head tilt chooses what appears after waking.",
});
export const headDownHideSetting = new ConfigSettingBoolean({
id: "head-down-hide", label: "Tilt down to hide", storageKey: "display.headDownHide", defaultValue: false,
description: "Lowering your head hides the display, including Glanceboard. A board shown by head tilt stays until you lower your head, with a 60-second safety timeout. Requires firmware forwarding HEAD_DOWN (Faceclaw/38).",
});
export function normalizeHeadUpAngle(value: string | null | undefined): string {
if (value == null || value.trim() === "" || !Number.isFinite(Number(value))) return "30";
return String(Math.max(0, Math.min(60, Math.round(Number(value)))));
@@ -581,7 +576,7 @@ export const headUpAngleSetting = new ConfigSettingEnum({
values: Array.from({ length: 61 }, (_, angle) => String(angle)),
normalize: normalizeHeadUpAngle,
formatValue: angle => `${angle}°`,
description: "Firmware head-up angle, 0–60 degrees, added to the glasses’ stored calibration. Until changed, the glasses keep their current angle. Requires validation on your Faceclaw firmware.",
description: "Look-up trigger angle, 0–60 degrees. Until changed, the glasses keep their current angle. Requires validation on your Faceclaw firmware.",
});
/** -1 means leave that firmware field unchanged; no writes on an untouched installation. */
+1 -12
View File
@@ -1,4 +1,3 @@
import { setAngleFromCurrentHead } from "../../g2/head-angle";
import { remoteInputMenuItem } from "./remote-input-menu";
import { knownFolders } from "@nativescript/core";
import { getDefaultSmallFont } from "../../graphics/ui-fonts";
@@ -52,7 +51,6 @@ import {
brightnessSetting,
headUpWakeSetting,
headUpAngleSetting,
headDownHideSetting,
autoBrightnessMinSetting,
autoBrightnessMaxSetting,
autoBrightnessCurveSetting,
@@ -122,16 +120,7 @@ function settingsSections(): SettingsSection[] {
// the dashboard controller when changed and on each connect.
enumSettingMenuItem(brightnessSetting),
autoBrightnessMenuItem(),
...(!global.isIOS ? [toggleSettingMenuItem(headUpWakeSetting), enumSettingMenuItem(headUpAngleSetting), {
label: "Set to current head angle",
description: "Experimental estimate inspired by PR #64. Keep still, without tilting sideways, at a moderate head-up angle (under 45°). Adjust manually if needed.",
onSelect: async (ctx: LayerContext) => {
shell.showAlert("Measuring head angle — keep still");
const result = await setAngleFromCurrentHead();
shell.showAlert(result);
ctx.actions.requestRender();
},
}, toggleSettingMenuItem(headDownHideSetting)] : []),
...(!global.isIOS ? [toggleSettingMenuItem(headUpWakeSetting), enumSettingMenuItem(headUpAngleSetting)] : []),
enumSettingMenuItem(screenTimeoutSetting, {
onChange: () => {
shell.noteUserActivity();