forked from Blendman974/faceclaw
Add touch-down event to simulated and watch inputs
This commit is contained in:
1 parent
45d2ece0d2
commit
2052e268b0
19 files changed
+191
-35
No files matched your search
@@ -1057,6 +1057,9 @@ export class MainViewModel extends RemoteControlsViewModel {
|
||||
// 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.
|
||||
//
|
||||
// Every finger-down (the second tap of a pair included) first sends a
|
||||
// ring-press, as the ring does before it knows what the touch will become.
|
||||
|
||||
private ringPadDoubleTapPending = false;
|
||||
private ringPadHeld = false;
|
||||
@@ -1077,6 +1080,10 @@ export class MainViewModel extends RemoteControlsViewModel {
|
||||
}
|
||||
|
||||
async onRingPadTouch(args: TouchGestureEventData): Promise<void> {
|
||||
if (args.action === "down" && args.getPointerCount() === 1) {
|
||||
await dashboardController.injectSyntheticRingInput("ring-press");
|
||||
return;
|
||||
}
|
||||
if (args.action !== "up" && args.action !== "cancel") return;
|
||||
const pending = this.ringPadDoubleTapPending;
|
||||
this.ringPadDoubleTapPending = false;
|
||||
@@ -1148,11 +1155,15 @@ export class MainViewModel extends RemoteControlsViewModel {
|
||||
this.refreshPadFocusLine();
|
||||
}
|
||||
|
||||
/** Two fingers down and up without moving: back (the watch's two-finger tap). */
|
||||
/**
|
||||
* The first finger down sends a ring-press, as the watch pad does. Two
|
||||
* fingers down and up without moving: back (the watch's two-finger tap).
|
||||
*/
|
||||
async onPadTouch(args: TouchGestureEventData): Promise<void> {
|
||||
const count = args.getPointerCount();
|
||||
if (args.action === "down" || args.action === "move") {
|
||||
if (count >= 2) this.padTwoFingerDown = true;
|
||||
else if (args.action === "down") await dashboardController.injectSyntheticRingInput("ring-press", "watch");
|
||||
return;
|
||||
}
|
||||
if (args.action === "up" || args.action === "cancel") {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
/** One touch recognizer for a phone pad or mirror. Coordinates are in DIP. */
|
||||
declare function setTimeout(callback: () => void, ms: number): number
|
||||
declare function clearTimeout(id: number): void
|
||||
export type PhoneGesture = 'tap' | 'double-tap' | 'long-press' | 'long-press-release'
|
||||
/** 'press' is every first-finger touch-down, ahead of whatever gesture it becomes (the ring's ring-press). */
|
||||
export type PhoneGesture = 'press' | 'tap' | 'double-tap' | 'long-press' | 'long-press-release'
|
||||
| 'short-then-long-press' | 'swipe-up' | 'swipe-down' | 'swipe-left' | 'swipe-right'
|
||||
export type PhoneTouch = { action: 'down' | 'move' | 'up' | 'cancel'; x: number; y: number; pointers: number }
|
||||
export type GestureClock = { set: (callback: () => void, ms: number) => unknown; clear: (id: unknown) => void }
|
||||
@@ -27,6 +28,7 @@ export class PhoneGestureRecognizer {
|
||||
this.secondTap = !!this.lastTap && Math.hypot(event.x - this.lastTap.x, event.y - this.lastTap.y) < 36
|
||||
if (this.secondTap) { this.clearTap() }
|
||||
else if (this.lastTap) { const tap = this.lastTap; this.clearTap(); this.emit('tap', tap.x, tap.y) }
|
||||
this.emit('press', event.x, event.y)
|
||||
this.hold = this.timer.set(() => {
|
||||
this.hold = null
|
||||
if (!this.start || this.moved || this.multi) return
|
||||
|
||||
Reference in new issue
Block a user