forked from Blendman974/faceclaw
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
@@ -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" />
|
||||
|
||||
Reference in new issue
Block a user