mirror of
https://git.undefined-dev.fr/Blendman974/faceclaw.git
synced 2026-11-19 21:03:09 +00:00
Add support for short-then-long gesture to watch input and simulated inputs
This commit is contained in:
1 parent
6483d00647
commit
216dc59255
9 files changed
+93
-14
No files matched your search
@@ -1,5 +1,9 @@
|
||||
# Changelog
|
||||
|
||||
## 0.6.3 - Future
|
||||
* Update custom firmware base version from 2.2.6 to 2.2.9
|
||||
* Add support for the short-then-long-press gesture
|
||||
|
||||
## 0.6.2 - 2026-08-30
|
||||
* Preview Only mode works
|
||||
* Voice input uses phone mic in preview mode
|
||||
|
||||
@@ -2494,6 +2494,7 @@ class DashboardController {
|
||||
| "scroll-down"
|
||||
| "long-press"
|
||||
| "long-press-release"
|
||||
| "short-then-long-press"
|
||||
| "wakeword"
|
||||
| "swipe-left"
|
||||
| "swipe-right"
|
||||
@@ -2553,6 +2554,17 @@ class DashboardController {
|
||||
systemExitReasonCode: 0,
|
||||
frameId,
|
||||
};
|
||||
case "short-then-long-press":
|
||||
// Discrete, unlike a hold: the firmware's later generic release is a
|
||||
// hardware artifact the shell ignores, so synthetic sources send none.
|
||||
return {
|
||||
kind: "sys-event",
|
||||
containerName: "",
|
||||
eventType: OsEventTypeList.SHORT_THEN_LONG_PRESS_EVENT,
|
||||
eventSource,
|
||||
systemExitReasonCode: 0,
|
||||
frameId,
|
||||
};
|
||||
case "click":
|
||||
return {
|
||||
kind: "sys-event",
|
||||
|
||||
@@ -44,6 +44,7 @@ export type WearRemoteInputKind =
|
||||
| "long-press"
|
||||
| "long-press-start"
|
||||
| "long-press-release"
|
||||
| "short-then-long-press"
|
||||
| "wakeword"
|
||||
| "swipe-left"
|
||||
| "swipe-right"
|
||||
@@ -58,6 +59,7 @@ const INPUT_KINDS: readonly WearRemoteInputKind[] = [
|
||||
"long-press",
|
||||
"long-press-start",
|
||||
"long-press-release",
|
||||
"short-then-long-press",
|
||||
"wakeword",
|
||||
"swipe-left",
|
||||
"swipe-right",
|
||||
|
||||
@@ -846,16 +846,36 @@ export class MainViewModel extends Observable {
|
||||
dashboardController.openEvenAppSettings();
|
||||
}
|
||||
|
||||
// Tap-then-hold on the simulated pads: NativeScript reports doubleTap on
|
||||
// the second finger-down and still runs the long-press recognizer on that
|
||||
// same press, so the sequence arrives as doubleTap followed by longPress.
|
||||
// Each pad therefore defers its double-click until the finger-up (the touch
|
||||
// handler) and converts the deferred pair into the G2 tap-then-hold gesture
|
||||
// when a longPress lands first.
|
||||
|
||||
private ringPadDoubleTapPending = false;
|
||||
|
||||
async onRingPadTap(): Promise<void> {
|
||||
await dashboardController.injectSyntheticRingInput("click");
|
||||
}
|
||||
|
||||
async onRingPadDoubleTap(): Promise<void> {
|
||||
await dashboardController.injectSyntheticRingInput("double-click");
|
||||
this.ringPadDoubleTapPending = true;
|
||||
}
|
||||
|
||||
async onRingPadLongPress(): Promise<void> {
|
||||
await dashboardController.injectSyntheticRingInput("long-press");
|
||||
const kind = this.ringPadDoubleTapPending ? "short-then-long-press" : "long-press";
|
||||
this.ringPadDoubleTapPending = false;
|
||||
await dashboardController.injectSyntheticRingInput(kind);
|
||||
}
|
||||
|
||||
async onRingPadTouch(args: TouchGestureEventData): Promise<void> {
|
||||
if (args.action !== "up" && args.action !== "cancel") return;
|
||||
const pending = this.ringPadDoubleTapPending;
|
||||
this.ringPadDoubleTapPending = false;
|
||||
if (args.action === "up" && pending) {
|
||||
await dashboardController.injectSyntheticRingInput("double-click");
|
||||
}
|
||||
}
|
||||
|
||||
/** The ring pad only has a vertical axis, so left/right swipes are ignored. */
|
||||
@@ -878,6 +898,9 @@ export class MainViewModel extends Observable {
|
||||
// above stays on the ring's own scheme.
|
||||
|
||||
private padTwoFingerDown = false;
|
||||
// See the ring pad above: defers the double-click so a longPress can turn
|
||||
// the pair into tap-then-hold.
|
||||
private padDoubleTapPending = false;
|
||||
|
||||
/** What the next gesture lands on, as the watch pad shows it. */
|
||||
get padFocusLine(): string {
|
||||
@@ -895,12 +918,13 @@ export class MainViewModel extends Observable {
|
||||
}
|
||||
|
||||
async onPadDoubleTap(): Promise<void> {
|
||||
await dashboardController.injectSyntheticRingInput("double-click", "watch");
|
||||
this.refreshPadFocusLine();
|
||||
this.padDoubleTapPending = true;
|
||||
}
|
||||
|
||||
async onPadLongPress(): Promise<void> {
|
||||
await dashboardController.injectSyntheticRingInput("long-press", "watch");
|
||||
const kind = this.padDoubleTapPending ? "short-then-long-press" : "long-press";
|
||||
this.padDoubleTapPending = false;
|
||||
await dashboardController.injectSyntheticRingInput(kind, "watch");
|
||||
this.refreshPadFocusLine();
|
||||
}
|
||||
|
||||
@@ -917,6 +941,8 @@ export class MainViewModel extends Observable {
|
||||
return;
|
||||
}
|
||||
if (args.action === "up" || args.action === "cancel") {
|
||||
const pendingDouble = this.padDoubleTapPending;
|
||||
this.padDoubleTapPending = false;
|
||||
const twoFinger = this.padTwoFingerDown;
|
||||
if (twoFinger) {
|
||||
// Let the single-tap recognizer's delayed tap see the flag first.
|
||||
@@ -927,6 +953,9 @@ export class MainViewModel extends Observable {
|
||||
await dashboardController.injectSyntheticRingInput("double-click", "watch");
|
||||
this.refreshPadFocusLine();
|
||||
}
|
||||
} else if (args.action === "up" && pendingDouble) {
|
||||
await dashboardController.injectSyntheticRingInput("double-click", "watch");
|
||||
this.refreshPadFocusLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
scheme as the watch pad - tap = select, double-tap or two fingers = back,
|
||||
hold = menu, swipes navigate), and Ring (a touchpad on the ring's own
|
||||
scheme: vertical swipes scroll, tap/double-tap/hold = click/double-click/
|
||||
long-press). The narrow mic button at the tab bar's right edge fires the
|
||||
long-press). Tap-then-hold on either pad is the G2 system-menu gesture. The narrow mic button at the tab bar's right edge fires the
|
||||
wakeword without changing the selected tab. Used by main-page.xml in both
|
||||
orientations; binds to the page's MainViewModel, which collapses the whole
|
||||
area while a text setting is being edited (keyboard-input mode).
|
||||
@@ -63,7 +63,8 @@
|
||||
rows="*,auto,*,auto,*,auto,*,auto,*,auto,*,auto,*"
|
||||
horizontalAlignment="center" verticalAlignment="center"
|
||||
tap="{{ onRingPadTap }}" doubleTap="{{ onRingPadDoubleTap }}"
|
||||
longPress="{{ onRingPadLongPress }}" swipe="{{ onRingPadSwipe }}">
|
||||
longPress="{{ onRingPadLongPress }}" swipe="{{ onRingPadSwipe }}"
|
||||
touch="{{ onRingPadTouch }}">
|
||||
<Label row="1" class="ring-pad-marking" isUserInteractionEnabled="false" />
|
||||
<Label row="3" class="ring-pad-marking" isUserInteractionEnabled="false" />
|
||||
<Label row="5" class="ring-pad-marking" isUserInteractionEnabled="false" />
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ answered on `/faceclaw/ack`.
|
||||
|
||||
| Path | Payload | Effect |
|
||||
| --- | --- | --- |
|
||||
| `/faceclaw/input` | `{gesture, steps?}` | A ring gesture through the same path as the phone UI's test buttons. `gesture` ∈ `click`, `double-click`, `scroll-up`, `scroll-down`, `long-press` (complete short hold), `long-press-start`, `long-press-release`, `wakeword` ("Hey Even"), `swipe-up`, `swipe-down`, `swipe-left`, `swipe-right` (spatial input only a watch can produce: delivered to the glasses UI as `swipe-*` events for components that navigate spatially — launcher grid, settings columns, sidebar, Music — with a scroll / click / double-click fallback elsewhere). `steps` (1–12) repeats a scroll. Refused while the glasses are disconnected. The lock screen is honoured exactly as for the ring. While the display is off, only a double-click is accepted and it wakes the display. |
|
||||
| `/faceclaw/input` | `{gesture, steps?}` | A ring gesture through the same path as the phone UI's test buttons. `gesture` ∈ `click`, `double-click`, `scroll-up`, `scroll-down`, `long-press` (complete short hold), `long-press-start`, `long-press-release`, `short-then-long-press` (tap then hold: the glasses' system menu), `wakeword` ("Hey Even"), `swipe-up`, `swipe-down`, `swipe-left`, `swipe-right` (spatial input only a watch can produce: delivered to the glasses UI as `swipe-*` events for components that navigate spatially — launcher grid, settings columns, sidebar, Music — with a scroll / click / double-click fallback elsewhere). `steps` (1–12) repeats a scroll. Refused while the glasses are disconnected. The lock screen is honoured exactly as for the ring. While the display is off, only a double-click is accepted and it wakes the display. |
|
||||
| `/faceclaw/command` | `{command, …}` | `launch-app {appId}`, `focus-window {windowId}`, `close-window {windowId}`, `sidebar`, `wake`, `sleep`, `lock`, `unlock`, `connect`, `disconnect`, `close-assistant`, `display-mode {value}` (`value` ∈ `576x288`, `576x480`, `640x480`; sets the phone's Display > Display mode). Everything but connect/disconnect needs a connection; everything but lock/unlock is refused while locked; `unlock` also needs the phone's "Watch can unlock glasses" setting. |
|
||||
| `/faceclaw/assistant` | `{text}` | Send a query to the assistant (`shell.sendToAssistant`) — the reply shows on the glasses and streams back to the watch as events. |
|
||||
| `/faceclaw/text` | `{text}` | Type text into the foreground window (`receiveTextInput`, e.g. the terminal). Refused when the window doesn't take text. |
|
||||
|
||||
@@ -34,6 +34,8 @@ enum class Gesture(val wire: String) {
|
||||
/** Finger down: the hold lasts until LONG_PRESS_RELEASE. */
|
||||
LONG_PRESS_START("long-press-start"),
|
||||
LONG_PRESS_RELEASE("long-press-release"),
|
||||
/** Tap then hold: opens the glasses' system menu (G2 2.2.9 gesture). */
|
||||
SHORT_THEN_LONG_PRESS("short-then-long-press"),
|
||||
/** The spoken "Hey Even": opens the glasses' own voice dialog. */
|
||||
WAKEWORD("wakeword"),
|
||||
/**
|
||||
|
||||
@@ -190,6 +190,9 @@ fun RemoteScreen(
|
||||
}
|
||||
},
|
||||
onDoubleTap = { _ -> doubleClick() },
|
||||
onShortThenLongPress = {
|
||||
if (!glassesScreenIsOff()) { haptics.heavy(); link.sendGesture(Gesture.SHORT_THEN_LONG_PRESS) }
|
||||
},
|
||||
// Two fingers = back as well: easier than timing a double-tap.
|
||||
onTwoFingerTap = { doubleClick() },
|
||||
onTwoFingerSwipe = { dx, dy ->
|
||||
|
||||
@@ -13,6 +13,8 @@ import kotlin.math.abs
|
||||
class TouchpadCallbacks(
|
||||
val onTap: (position: Offset) -> Unit,
|
||||
val onDoubleTap: (position: Offset) -> Unit,
|
||||
/** A tap whose immediate second press was held: the G2 tap-then-hold gesture. */
|
||||
val onShortThenLongPress: () -> Unit,
|
||||
val onTwoFingerTap: () -> Unit,
|
||||
/** Two fingers travelled past touch slop; dx/dy are the primary finger's displacement. */
|
||||
val onTwoFingerSwipe: (dx: Float, dy: Float) -> Unit,
|
||||
@@ -25,9 +27,10 @@ class TouchpadCallbacks(
|
||||
/**
|
||||
* One detector for everything the pad does, so a gesture is reported exactly
|
||||
* once: tap, double-tap (a second tap inside the double-tap timeout), a hold
|
||||
* (reported at the long-press timeout and again on release), a swipe, and a
|
||||
* two-finger tap or swipe. Written as a single awaitEachGesture loop because the
|
||||
* stock detectors would each claim the same finger.
|
||||
* (reported at the long-press timeout and again on release), tap-then-hold (a
|
||||
* second tap held past the long-press timeout), a swipe, and a two-finger tap
|
||||
* or swipe. Written as a single awaitEachGesture loop because the stock
|
||||
* detectors would each claim the same finger.
|
||||
*/
|
||||
suspend fun PointerInputScope.detectTouchpadGestures(callbacks: TouchpadCallbacks) {
|
||||
val longPressTimeout = viewConfiguration.longPressTimeoutMillis
|
||||
@@ -96,9 +99,32 @@ suspend fun PointerInputScope.detectTouchpadGestures(callbacks: TouchpadCallback
|
||||
callbacks.onTap(down.position)
|
||||
} else {
|
||||
second.consume()
|
||||
val up = waitForUpOrCancellation()
|
||||
if (up != null) up.consume()
|
||||
callbacks.onDoubleTap(down.position)
|
||||
// Released within the long-press timeout it's a
|
||||
// double-tap; held past it, the G2 tap-then-hold
|
||||
// gesture (reported once at the timeout, movement
|
||||
// tolerated, the rest of the hold swallowed).
|
||||
var held = false
|
||||
while (true) {
|
||||
val remaining2 = if (held) {
|
||||
HOLD_POLL_MS
|
||||
} else {
|
||||
longPressTimeout - (System.currentTimeMillis() - wallClockAt(second.uptimeMillis))
|
||||
}
|
||||
val event2 = withTimeoutOrNull(remaining2.coerceAtLeast(1L)) { awaitPointerEvent() }
|
||||
if (event2 == null) {
|
||||
if (!held) {
|
||||
held = true
|
||||
callbacks.onShortThenLongPress()
|
||||
}
|
||||
continue
|
||||
}
|
||||
if (event2.changes.any { it.isConsumed }) break
|
||||
for (change in event2.changes) change.consume()
|
||||
if (event2.changes.none { it.pressed }) {
|
||||
if (!held) callbacks.onDoubleTap(down.position)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user