Add support for the new short-then-long-press gesture

This commit is contained in:
James Babcock committed 2026-08-31 20:31:08 -07:00
1 parent 596c767446
commit 6483d00647
4 files changed
+27 -4

No files matched your search

+3
View File
@@ -69,6 +69,8 @@ export const OsEventTypeList = {
IMU_DATA_REPORT: 8,
RING_LONG_PRESS_EVENT: 9,
RING_LONG_PRESS_RELEASE_EVENT: 10,
/** CFW extension: the 2.2.9 tap-then-hold Menu gesture. */
SHORT_THEN_LONG_PRESS_EVENT: 11,
} as const;
export const OsEventTypeName: Record<number, string> = {
@@ -83,4 +85,5 @@ export const OsEventTypeName: Record<number, string> = {
8: "IMU_DATA_REPORT",
9: "RING_LONG_PRESS_EVENT",
10: "RING_LONG_PRESS_RELEASE_EVENT",
11: "SHORT_THEN_LONG_PRESS_EVENT",
};
+2
View File
@@ -25,6 +25,8 @@ export type InputEventPayload =
| { type: "scroll-down"; source?: InputSource }
| { type: "long-press"; source: InputSource }
| { type: "long-press-release"; source: InputSource }
/** G2 2.2.9 tap-then-hold gesture, reserved for the shell system menu. */
| { type: "short-then-long-press"; source: InputSource }
/**
* Spatial (four-way) input, which only a watch can produce: the ring's
* scroll is a one-dimensional cursor, these are directions. Components with
+20 -4
View File
@@ -61,7 +61,8 @@ import {
* the sidebar it focuses the window first); by convention apps answer it with
* a window menu that ends in Voice input / Close window. Holding the press
* past the escape threshold opens the shell's own escape menu, so the shell
* keeps working when a window's handler hangs.
* keeps working when a window's handler hangs. The 2.2.9 tap-then-hold gesture
* opens that shell menu immediately.
*/
export type ShellWindow = {
@@ -631,6 +632,16 @@ class Shell {
return { shell: false, window: false };
}
// The 2.2.9 tap-then-hold gesture is a direct, shell-owned escape hatch.
// Unlike an ordinary long-press it never reaches the app or starts the
// fallback timer: it opens the same system menu that an extended hold
// would eventually open. Its later generic release is consumed while the
// shell overlay is active and therefore cannot leak into the app.
if (event.type === "short-then-long-press") {
this.openEscapeMenu();
return { shell: true, window: false };
}
// Long-press goes to the foreground window (from the sidebar it focuses
// the window first); apps conventionally answer it with their window
// menu. The escape timer runs regardless of what the app does with it:
@@ -1141,9 +1152,10 @@ class Shell {
}
/**
* The held-long-press safeguard menu. Shell-owned and shell-drawn (never
* the app's), so an unresponsive app can always be closed. It opens over
* whatever the app did with the long-press, including its own menu.
* The system/escape menu. Shell-owned and shell-drawn (never the app's), so
* an unresponsive app can always be closed. It opens after an extended hold
* or immediately for tap-then-hold, over whatever the app did with an earlier
* ordinary long-press, including opening its own menu.
*/
private openEscapeMenu(): void {
if (!this.screenOn || this.activeVoiceLayer || !this.stack.isAtBase()) return;
@@ -1254,6 +1266,8 @@ function rawInputEventToPayload(event: RawInputEvent): InputEventPayload {
return { type: "long-press", source: eventSourceToString(event.eventSource) };
} else if (event.eventType === OsEventTypeList.RING_LONG_PRESS_RELEASE_EVENT) {
return { type: "long-press-release", source: eventSourceToString(event.eventSource) };
} else if (event.eventType === OsEventTypeList.SHORT_THEN_LONG_PRESS_EVENT) {
return { type: "short-then-long-press", source: eventSourceToString(event.eventSource) };
}
} else if (event.kind === "watch-gesture") {
// Synthetic, from the Wear OS remote (app/g2/wear-remote.ts); the glasses
@@ -1325,6 +1339,8 @@ export function inputEventToString(event: InputEvent): string {
return `Long press from ${event.source}`;
case "long-press-release":
return `Long press release from ${event.source}`;
case "short-then-long-press":
return `Short then long press from ${event.source}`;
case "swipe-left":
return `Swipe left from ${event.source}`;
case "swipe-right":