Add bluetooth keyboard support

G2 only: You can pair the glasses with a bluetooth keyboard. It will
relay key events, and you can use it to type in some apps and to
navigate the UI.
This commit is contained in:
James Babcock committed 2026-11-15 01:54:54 -08:00
1 parent 9372b2742c
commit fd3c26333f
46 files changed
+3867 -41

No files matched your search

+24
View File
@@ -17,6 +17,7 @@ import {
isWatchInput,
makeInputEvent,
} from "../gestures";
import type { KeyEvent } from "../../g2/keyboard/keys";
import { Layer, LayerActions, LayerContext, LayerStack, noopLayerActions } from "../layers";
import { CONTEXT_MENU_DIM, MenuLayer, type MenuItem } from "../menu";
import { VoiceInputLayer, type VoiceSendTarget } from "./voice-input";
@@ -192,6 +193,14 @@ export type ShellWindow = {
* only windows that consume typed text (the terminal) implement it.
*/
receiveTextInput?: (text: string, options?: { submit?: boolean }) => void;
/**
* Take a key from a hardware keyboard (app/g2/keyboard) as a key. Optional:
* only windows that give keys a meaning of their own (the terminal)
* implement it, and they get every key while they have input focus,
* presses and releases alike. For the rest the controller turns the few
* navigation keys into ring gestures (navigationGestureForKey).
*/
handleKeyEvent?: (event: KeyEvent) => void;
/** Foreground state changed: this window's surface is (not) the visible one. */
setForeground?: (foreground: boolean) => void;
/**
@@ -1606,6 +1615,21 @@ class Shell {
this.foregroundWindow()?.receiveTextInput?.(text, options);
}
/**
* Offer a hardware-keyboard key to the window that has input focus. True
* when that window takes keys (ShellWindow.handleKeyEvent) and got this
* one; false when the key is the caller's to interpret: the screen is off,
* the sidebar or a shell overlay has focus, or the window has no use for
* keys. Typing counts as activity for the screen timeout.
*/
receiveKeyEvent(event: KeyEvent): boolean {
const window = this.inputTargetWindow();
if (!window?.handleKeyEvent) return false;
if (event.phase === "down") this.lastInputAtMs = Date.now();
window.handleKeyEvent(event);
return true;
}
/**
* Open the voice dialog aimed at the foreground window. Called when the
* user picks Voice input from the system menu (or an app asks via a