Implement press-and-hold for glanceboard in watch and simulated inputs

This commit is contained in:
James Babcock committed 2026-09-11 19:34:50 -07:00
1 parent cd1e815174
commit 4681f14dae
4 files changed
+43 -16

No files matched your search

+1 -1
View File
@@ -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`, `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/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. |
@@ -139,16 +139,13 @@ class MainActivity : ComponentActivity() {
if (event.repeatCount == 0) {
cancelStemHold()
stemHoldSent = false
stemOneIgnored = glassesScreenIsOff()
if (stemOneIgnored) return true
// A dark display takes the stem too: a press shows the
// phone's Glanceboard, a hold keeps it up until release.
stemOneIgnored = false
val runnable = Runnable {
if (glassesScreenIsOff()) {
stemOneIgnored = true
} else {
stemHoldSent = true
haptics.heavy()
link.sendGesture(Gesture.LONG_PRESS_START)
}
stemHoldSent = true
haptics.heavy()
link.sendGesture(Gesture.LONG_PRESS_START)
}
stemHoldRunnable = runnable
stemHandler.postDelayed(runnable, STEM_HOLD_MS)
@@ -184,7 +181,7 @@ class MainActivity : ComponentActivity() {
stemHoldSent = false
haptics.click()
link.sendGesture(Gesture.LONG_PRESS_RELEASE)
} else if (!glassesScreenIsOff()) {
} else {
haptics.click()
link.sendGesture(Gesture.CLICK)
}
@@ -143,8 +143,16 @@ fun RemoteScreen(
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 =
!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) {
if (!gestureAllowed(gesture)) return
@@ -186,7 +194,7 @@ fun RemoteScreen(
}
},
onLongPressStart = {
longPressSent = !glassesScreenIsOff()
longPressSent = gestureAllowed(Gesture.LONG_PRESS_START)
if (longPressSent) {
haptics.heavy()
link.sendGesture(Gesture.LONG_PRESS_START)