forked from Blendman974/faceclaw
Add Glanceboard depth setting
This commit is contained in:
1 parent
71c1971992
commit
915f155819
29 files changed
+262
-50
No files matched your search
@@ -54,6 +54,8 @@ export type GlanceboardProvider = {
|
||||
showOnLongPress: () => boolean;
|
||||
/** Whether the head-tilt wake goes to the board rather than the regular UI. */
|
||||
showOnHeadTilt: () => boolean;
|
||||
/** Stereo depth (firmware units; positive is nearer) while the board covers the screen. */
|
||||
depth: () => number;
|
||||
/** A fresh board; requestRender asks the host to repaint it. */
|
||||
createBoard: (requestRender: () => void) => GlanceBoardInstance;
|
||||
};
|
||||
|
||||
@@ -13,6 +13,7 @@ import { GlanceBoard } from "./board";
|
||||
import {
|
||||
clearConflictingSlots,
|
||||
glanceboardEnabledSetting,
|
||||
glanceDepthSetting,
|
||||
glanceLayout,
|
||||
glanceLayoutSetting,
|
||||
glanceShowLinesSetting,
|
||||
@@ -297,7 +298,7 @@ function openSlotPicker(ctx: LayerContext, slotIndex: number): void {
|
||||
openModalMenu(ctx, setting.label, items, Math.max(0, setting.values.indexOf(current)));
|
||||
}
|
||||
|
||||
/** Settings: layout, sleep gestures, duration, and slot lines. */
|
||||
/** Settings: layout, sleep gestures, duration, slot lines, and stereo depth. */
|
||||
function openGlanceSettings(ctx: LayerContext): void {
|
||||
const items: MenuItem[] = [
|
||||
enumSettingMenuItem(glanceLayoutSetting),
|
||||
@@ -305,6 +306,7 @@ function openGlanceSettings(ctx: LayerContext): void {
|
||||
toggleSettingMenuItem(glanceShowOnLongPressSetting),
|
||||
toggleSettingMenuItem(glanceShowOnHeadTiltSetting),
|
||||
toggleSettingMenuItem(glanceShowLinesSetting),
|
||||
enumSettingMenuItem(glanceDepthSetting),
|
||||
];
|
||||
ctx.stack.push(new MenuLayer("Glanceboard settings", items, pageMenuLayout(ctx.stack.getBaseSize().width)));
|
||||
}
|
||||
|
||||
@@ -103,6 +103,31 @@ export const glanceShowOnHeadTiltSetting = new ConfigSettingBoolean({
|
||||
description: "Tilting your head up while asleep shows the Glanceboard instead of waking the regular UI.",
|
||||
});
|
||||
|
||||
const DEPTH_VALUES = ["-64", "-48", "-32", "-16", "0", "16", "32", "48", "64"] as const;
|
||||
export type GlanceDepth = (typeof DEPTH_VALUES)[number];
|
||||
|
||||
/**
|
||||
* Stereo depth of the board, in the firmware's depth units: the lenses shift
|
||||
* it by half this many pixels each, in opposite directions.
|
||||
*/
|
||||
export const glanceDepthSetting = new ConfigSettingEnum<GlanceDepth>({
|
||||
id: "glanceboard-depth",
|
||||
label: "Depth",
|
||||
storageKey: "glanceboard.depth",
|
||||
defaultValue: "0",
|
||||
values: DEPTH_VALUES,
|
||||
formatValue: (value) => {
|
||||
const depth = Number(value);
|
||||
return depth === 0 ? "0" : depth > 0 ? `+${depth} (nearer)` : `${depth} (farther)`;
|
||||
},
|
||||
description:
|
||||
"Moves the Glanceboard nearer (positive) or farther away (negative) by shifting it in opposite directions on the two lenses.",
|
||||
});
|
||||
|
||||
export function glanceDepth(): number {
|
||||
return Number(glanceDepthSetting.get());
|
||||
}
|
||||
|
||||
/** Hairlines between the board's slots. */
|
||||
export const glanceShowLinesSetting = new ConfigSettingBoolean({
|
||||
id: "glanceboard-show-lines",
|
||||
|
||||
@@ -3,6 +3,7 @@ import { GlanceBoard } from "./board";
|
||||
import { createGlanceboardAppWindow, GLANCEBOARD_SURFACE_ID, GLANCEBOARD_WINDOW_ID } from "./glanceboard-app";
|
||||
import {
|
||||
glanceboardEnabledSetting,
|
||||
glanceDepth,
|
||||
glanceLayout,
|
||||
glanceShowOnHeadTiltSetting,
|
||||
glanceShowOnLongPressSetting,
|
||||
@@ -25,6 +26,7 @@ const glanceboardApp: AppDefinition = {
|
||||
tapTimeoutMs: glanceTapTimeoutMs,
|
||||
showOnLongPress: () => glanceShowOnLongPressSetting.get(),
|
||||
showOnHeadTilt: () => glanceShowOnHeadTiltSetting.get(),
|
||||
depth: glanceDepth,
|
||||
createBoard: (requestRender) => new GlanceBoard(requestRender),
|
||||
},
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user