forked from Blendman974/faceclaw
Configurable custom keybindings for bluetooth keyboards paired with the glasses
This commit is contained in:
1 parent
fd3c26333f
commit
344e140e92
17 files changed
+1203
-100
No files matched your search
@@ -196,9 +196,10 @@ export type ShellWindow = {
|
||||
/**
|
||||
* 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).
|
||||
* implement it. They get the keys no keybinding claimed while they have
|
||||
* input focus, presses and releases alike; the rest of the time, and for
|
||||
* every other window, the navigation keys act as gestures (see
|
||||
* app/g2/keyboard/bindings.ts).
|
||||
*/
|
||||
handleKeyEvent?: (event: KeyEvent) => void;
|
||||
/** Foreground state changed: this window's surface is (not) the visible one. */
|
||||
|
||||
@@ -58,6 +58,16 @@ export type WorkerAppReply =
|
||||
type: "worker-ready";
|
||||
}
|
||||
| { type: "yield-focus"; windowId: string }
|
||||
| {
|
||||
/**
|
||||
* A "key" message the window had no use for as a key (a terminal
|
||||
* showing its session list rather than a session). The host gives it
|
||||
* the keyboard's navigation meaning instead.
|
||||
*/
|
||||
type: "key-unhandled";
|
||||
windowId: string;
|
||||
event: unknown;
|
||||
}
|
||||
| {
|
||||
/** Foreground and focus one of the app's existing windows. */
|
||||
type: "focus-window";
|
||||
@@ -202,9 +212,9 @@ export type WorkerWindowSpec = {
|
||||
acceptsDirectional?: boolean;
|
||||
/**
|
||||
* Deliver hardware-keyboard keys to the worker as "key" messages while the
|
||||
* window has input focus, instead of the navigation-gesture fallback. The
|
||||
* worker then owns what every key means in every window state, navigation
|
||||
* included (see ShellWindow.handleKeyEvent).
|
||||
* window has input focus (see ShellWindow.handleKeyEvent). The worker
|
||||
* answers "key-unhandled" for a key it doesn't want as a key just then,
|
||||
* which gets the keyboard's navigation meaning instead.
|
||||
*/
|
||||
acceptsKeys?: boolean;
|
||||
};
|
||||
@@ -234,6 +244,8 @@ export type WorkerAppHostOptions = {
|
||||
startTextSettingEdit: (settingId: string) => void;
|
||||
/** Close the phone text editor opened by startTextSettingEdit. */
|
||||
endTextSettingEdit: () => void;
|
||||
/** A key a window was sent and handed back (the "key-unhandled" reply); a KeyEvent. */
|
||||
unhandledKey?: (event: unknown) => void;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -323,6 +335,10 @@ export class WorkerAppHost {
|
||||
shell.yieldFocusToSidebar();
|
||||
}
|
||||
break;
|
||||
case "key-unhandled":
|
||||
// Stale once focus has moved on: the key was meant for that window.
|
||||
if (shell.isWindowFocused(message.windowId)) this.options.unhandledKey?.(message.event);
|
||||
break;
|
||||
case "focus-window":
|
||||
if (this.openWindows.has(message.windowId)) {
|
||||
shell.focusWindow(message.windowId);
|
||||
|
||||
Reference in new issue
Block a user