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

+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" };