forked from Blendman974/faceclaw
Implement press-and-hold for glanceboard in watch and simulated inputs
This commit is contained in:
1 parent
cd1e815174
commit
4681f14dae
4 files changed
+43
-16
No files matched your search
@@ -1001,8 +1001,15 @@ export class MainViewModel extends Observable {
|
|||||||
// Each pad therefore defers its double-click until the finger-up (the touch
|
// 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
|
// handler) and converts the deferred pair into the G2 tap-then-hold gesture
|
||||||
// when a longPress lands first.
|
// when a longPress lands first.
|
||||||
|
//
|
||||||
|
// A hold is two events, like the hardware's: longPress sends the press
|
||||||
|
// (long-press-start, which the controller delivers as a plain long-press)
|
||||||
|
// and the finger-up sends the release, so a hold really holds (the
|
||||||
|
// Glanceboard stays up until the finger lifts). The firmware sends the
|
||||||
|
// same release after a tap-then-hold, so that pair gets one too.
|
||||||
|
|
||||||
private ringPadDoubleTapPending = false;
|
private ringPadDoubleTapPending = false;
|
||||||
|
private ringPadHeld = false;
|
||||||
|
|
||||||
async onRingPadTap(): Promise<void> {
|
async onRingPadTap(): Promise<void> {
|
||||||
await dashboardController.injectSyntheticRingInput("click");
|
await dashboardController.injectSyntheticRingInput("click");
|
||||||
@@ -1013,8 +1020,9 @@ export class MainViewModel extends Observable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async onRingPadLongPress(): Promise<void> {
|
async onRingPadLongPress(): Promise<void> {
|
||||||
const kind = this.ringPadDoubleTapPending ? "short-then-long-press" : "long-press";
|
const kind = this.ringPadDoubleTapPending ? "short-then-long-press" : "long-press-start";
|
||||||
this.ringPadDoubleTapPending = false;
|
this.ringPadDoubleTapPending = false;
|
||||||
|
this.ringPadHeld = true;
|
||||||
await dashboardController.injectSyntheticRingInput(kind);
|
await dashboardController.injectSyntheticRingInput(kind);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1022,6 +1030,11 @@ export class MainViewModel extends Observable {
|
|||||||
if (args.action !== "up" && args.action !== "cancel") return;
|
if (args.action !== "up" && args.action !== "cancel") return;
|
||||||
const pending = this.ringPadDoubleTapPending;
|
const pending = this.ringPadDoubleTapPending;
|
||||||
this.ringPadDoubleTapPending = false;
|
this.ringPadDoubleTapPending = false;
|
||||||
|
if (this.ringPadHeld) {
|
||||||
|
this.ringPadHeld = false;
|
||||||
|
await dashboardController.injectSyntheticRingInput("long-press-release");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (args.action === "up" && pending) {
|
if (args.action === "up" && pending) {
|
||||||
await dashboardController.injectSyntheticRingInput("double-click");
|
await dashboardController.injectSyntheticRingInput("double-click");
|
||||||
}
|
}
|
||||||
@@ -1048,8 +1061,9 @@ export class MainViewModel extends Observable {
|
|||||||
|
|
||||||
private padTwoFingerDown = false;
|
private padTwoFingerDown = false;
|
||||||
// See the ring pad above: defers the double-click so a longPress can turn
|
// See the ring pad above: defers the double-click so a longPress can turn
|
||||||
// the pair into tap-then-hold.
|
// the pair into tap-then-hold, and pairs every hold with a release.
|
||||||
private padDoubleTapPending = false;
|
private padDoubleTapPending = false;
|
||||||
|
private padHeld = false;
|
||||||
|
|
||||||
/** What the next gesture lands on, as the watch pad shows it. */
|
/** What the next gesture lands on, as the watch pad shows it. */
|
||||||
get padFocusLine(): string {
|
get padFocusLine(): string {
|
||||||
@@ -1071,8 +1085,10 @@ export class MainViewModel extends Observable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async onPadLongPress(): Promise<void> {
|
async onPadLongPress(): Promise<void> {
|
||||||
const kind = this.padDoubleTapPending ? "short-then-long-press" : "long-press";
|
if (this.padTwoFingerDown) return;
|
||||||
|
const kind = this.padDoubleTapPending ? "short-then-long-press" : "long-press-start";
|
||||||
this.padDoubleTapPending = false;
|
this.padDoubleTapPending = false;
|
||||||
|
this.padHeld = true;
|
||||||
await dashboardController.injectSyntheticRingInput(kind, "watch");
|
await dashboardController.injectSyntheticRingInput(kind, "watch");
|
||||||
this.refreshPadFocusLine();
|
this.refreshPadFocusLine();
|
||||||
}
|
}
|
||||||
@@ -1092,6 +1108,12 @@ export class MainViewModel extends Observable {
|
|||||||
if (args.action === "up" || args.action === "cancel") {
|
if (args.action === "up" || args.action === "cancel") {
|
||||||
const pendingDouble = this.padDoubleTapPending;
|
const pendingDouble = this.padDoubleTapPending;
|
||||||
this.padDoubleTapPending = false;
|
this.padDoubleTapPending = false;
|
||||||
|
if (this.padHeld) {
|
||||||
|
this.padHeld = false;
|
||||||
|
await dashboardController.injectSyntheticRingInput("long-press-release", "watch");
|
||||||
|
this.refreshPadFocusLine();
|
||||||
|
return;
|
||||||
|
}
|
||||||
const twoFinger = this.padTwoFingerDown;
|
const twoFinger = this.padTwoFingerDown;
|
||||||
if (twoFinger) {
|
if (twoFinger) {
|
||||||
// Let the single-tap recognizer's delayed tap see the flag first.
|
// Let the single-tap recognizer's delayed tap see the flag first.
|
||||||
|
|||||||
+1
-1
@@ -18,7 +18,7 @@ answered on `/faceclaw/ack`.
|
|||||||
|
|
||||||
| Path | Payload | Effect |
|
| 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`, `short-then-long-press` (tap then hold: the app's context menu; a plain `long-press` is 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/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 app's context menu; a plain `long-press` is 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, a double-click wakes the display, a `click` shows the phone's Glanceboard for a few seconds, and `long-press-start`/`long-press-release` hold it up; everything else is ignored. |
|
||||||
| `/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/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/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. |
|
| `/faceclaw/text` | `{text}` | Type text into the foreground window (`receiveTextInput`, e.g. the terminal). Refused when the window doesn't take text. |
|
||||||
|
|||||||
@@ -139,16 +139,13 @@ class MainActivity : ComponentActivity() {
|
|||||||
if (event.repeatCount == 0) {
|
if (event.repeatCount == 0) {
|
||||||
cancelStemHold()
|
cancelStemHold()
|
||||||
stemHoldSent = false
|
stemHoldSent = false
|
||||||
stemOneIgnored = glassesScreenIsOff()
|
// A dark display takes the stem too: a press shows the
|
||||||
if (stemOneIgnored) return true
|
// phone's Glanceboard, a hold keeps it up until release.
|
||||||
|
stemOneIgnored = false
|
||||||
val runnable = Runnable {
|
val runnable = Runnable {
|
||||||
if (glassesScreenIsOff()) {
|
stemHoldSent = true
|
||||||
stemOneIgnored = true
|
haptics.heavy()
|
||||||
} else {
|
link.sendGesture(Gesture.LONG_PRESS_START)
|
||||||
stemHoldSent = true
|
|
||||||
haptics.heavy()
|
|
||||||
link.sendGesture(Gesture.LONG_PRESS_START)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
stemHoldRunnable = runnable
|
stemHoldRunnable = runnable
|
||||||
stemHandler.postDelayed(runnable, STEM_HOLD_MS)
|
stemHandler.postDelayed(runnable, STEM_HOLD_MS)
|
||||||
@@ -184,7 +181,7 @@ class MainActivity : ComponentActivity() {
|
|||||||
stemHoldSent = false
|
stemHoldSent = false
|
||||||
haptics.click()
|
haptics.click()
|
||||||
link.sendGesture(Gesture.LONG_PRESS_RELEASE)
|
link.sendGesture(Gesture.LONG_PRESS_RELEASE)
|
||||||
} else if (!glassesScreenIsOff()) {
|
} else {
|
||||||
haptics.click()
|
haptics.click()
|
||||||
link.sendGesture(Gesture.CLICK)
|
link.sendGesture(Gesture.CLICK)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,8 +143,16 @@ fun RemoteScreen(
|
|||||||
|
|
||||||
fun glassesScreenIsOff(): Boolean = currentState?.connected == true && currentState?.screenOn == false
|
fun glassesScreenIsOff(): Boolean = currentState?.connected == true && currentState?.screenOn == false
|
||||||
|
|
||||||
|
// A dark display still takes a double-click (wake), and a tap or a hold
|
||||||
|
// (the phone's Glanceboard: a tap shows it for a few seconds, a hold
|
||||||
|
// until released). Scrolls, swipes and the menu gesture mean nothing
|
||||||
|
// there, so they are dropped here without a buzz.
|
||||||
fun gestureAllowed(gesture: Gesture): Boolean =
|
fun gestureAllowed(gesture: Gesture): Boolean =
|
||||||
!glassesScreenIsOff() || gesture == Gesture.DOUBLE_CLICK
|
!glassesScreenIsOff() ||
|
||||||
|
gesture == Gesture.DOUBLE_CLICK ||
|
||||||
|
gesture == Gesture.CLICK ||
|
||||||
|
gesture == Gesture.LONG_PRESS_START ||
|
||||||
|
gesture == Gesture.LONG_PRESS_RELEASE
|
||||||
|
|
||||||
fun scroll(gesture: Gesture, steps: Int) {
|
fun scroll(gesture: Gesture, steps: Int) {
|
||||||
if (!gestureAllowed(gesture)) return
|
if (!gestureAllowed(gesture)) return
|
||||||
@@ -186,7 +194,7 @@ fun RemoteScreen(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLongPressStart = {
|
onLongPressStart = {
|
||||||
longPressSent = !glassesScreenIsOff()
|
longPressSent = gestureAllowed(Gesture.LONG_PRESS_START)
|
||||||
if (longPressSent) {
|
if (longPressSent) {
|
||||||
haptics.heavy()
|
haptics.heavy()
|
||||||
link.sendGesture(Gesture.LONG_PRESS_START)
|
link.sendGesture(Gesture.LONG_PRESS_START)
|
||||||
|
|||||||
Reference in new issue
Block a user