forked from Blendman974/faceclaw
Add support for the new short-then-long-press gesture
This commit is contained in:
1 parent
596c767446
commit
6483d00647
4 files changed
+27
-4
No files matched your search
@@ -104,6 +104,8 @@ public class BleProtocol {
|
|||||||
public static final int EVENT_IMU_DATA_REPORT = 8;
|
public static final int EVENT_IMU_DATA_REPORT = 8;
|
||||||
public static final int EVENT_RING_LONG_PRESS = 9;
|
public static final int EVENT_RING_LONG_PRESS = 9;
|
||||||
public static final int EVENT_RING_LONG_PRESS_RELEASE = 10;
|
public static final int EVENT_RING_LONG_PRESS_RELEASE = 10;
|
||||||
|
// CFW extension: G2 2.2.9 tap-then-hold gesture forwarded to the phone.
|
||||||
|
public static final int EVENT_SHORT_THEN_LONG_PRESS = 11;
|
||||||
|
|
||||||
public static final int EVENT_SOURCE_GLASSES_R = 1;
|
public static final int EVENT_SOURCE_GLASSES_R = 1;
|
||||||
public static final int EVENT_SOURCE_RING = 2;
|
public static final int EVENT_SOURCE_RING = 2;
|
||||||
|
|||||||
@@ -69,6 +69,8 @@ export const OsEventTypeList = {
|
|||||||
IMU_DATA_REPORT: 8,
|
IMU_DATA_REPORT: 8,
|
||||||
RING_LONG_PRESS_EVENT: 9,
|
RING_LONG_PRESS_EVENT: 9,
|
||||||
RING_LONG_PRESS_RELEASE_EVENT: 10,
|
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;
|
} as const;
|
||||||
|
|
||||||
export const OsEventTypeName: Record<number, string> = {
|
export const OsEventTypeName: Record<number, string> = {
|
||||||
@@ -83,4 +85,5 @@ export const OsEventTypeName: Record<number, string> = {
|
|||||||
8: "IMU_DATA_REPORT",
|
8: "IMU_DATA_REPORT",
|
||||||
9: "RING_LONG_PRESS_EVENT",
|
9: "RING_LONG_PRESS_EVENT",
|
||||||
10: "RING_LONG_PRESS_RELEASE_EVENT",
|
10: "RING_LONG_PRESS_RELEASE_EVENT",
|
||||||
|
11: "SHORT_THEN_LONG_PRESS_EVENT",
|
||||||
};
|
};
|
||||||
@@ -25,6 +25,8 @@ export type InputEventPayload =
|
|||||||
| { type: "scroll-down"; source?: InputSource }
|
| { type: "scroll-down"; source?: InputSource }
|
||||||
| { type: "long-press"; source: InputSource }
|
| { type: "long-press"; source: InputSource }
|
||||||
| { type: "long-press-release"; 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
|
* Spatial (four-way) input, which only a watch can produce: the ring's
|
||||||
* scroll is a one-dimensional cursor, these are directions. Components with
|
* scroll is a one-dimensional cursor, these are directions. Components with
|
||||||
|
|||||||
+20
-4
@@ -61,7 +61,8 @@ import {
|
|||||||
* the sidebar it focuses the window first); by convention apps answer it with
|
* 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
|
* 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
|
* 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 = {
|
export type ShellWindow = {
|
||||||
@@ -631,6 +632,16 @@ class Shell {
|
|||||||
return { shell: false, window: false };
|
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
|
// Long-press goes to the foreground window (from the sidebar it focuses
|
||||||
// the window first); apps conventionally answer it with their window
|
// the window first); apps conventionally answer it with their window
|
||||||
// menu. The escape timer runs regardless of what the app does with it:
|
// 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 system/escape menu. Shell-owned and shell-drawn (never the app's), so
|
||||||
* the app's), so an unresponsive app can always be closed. It opens over
|
* an unresponsive app can always be closed. It opens after an extended hold
|
||||||
* whatever the app did with the long-press, including its own menu.
|
* 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 {
|
private openEscapeMenu(): void {
|
||||||
if (!this.screenOn || this.activeVoiceLayer || !this.stack.isAtBase()) return;
|
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) };
|
return { type: "long-press", source: eventSourceToString(event.eventSource) };
|
||||||
} else if (event.eventType === OsEventTypeList.RING_LONG_PRESS_RELEASE_EVENT) {
|
} else if (event.eventType === OsEventTypeList.RING_LONG_PRESS_RELEASE_EVENT) {
|
||||||
return { type: "long-press-release", source: eventSourceToString(event.eventSource) };
|
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") {
|
} else if (event.kind === "watch-gesture") {
|
||||||
// Synthetic, from the Wear OS remote (app/g2/wear-remote.ts); the glasses
|
// 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}`;
|
return `Long press from ${event.source}`;
|
||||||
case "long-press-release":
|
case "long-press-release":
|
||||||
return `Long press release from ${event.source}`;
|
return `Long press release from ${event.source}`;
|
||||||
|
case "short-then-long-press":
|
||||||
|
return `Short then long press from ${event.source}`;
|
||||||
case "swipe-left":
|
case "swipe-left":
|
||||||
return `Swipe left from ${event.source}`;
|
return `Swipe left from ${event.source}`;
|
||||||
case "swipe-right":
|
case "swipe-right":
|
||||||
|
|||||||
Reference in new issue
Block a user