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
@@ -40,6 +40,9 @@ test('new SysEvent decodes independently of click, double-tap, hold and release'
|
||||
const decoded = d.rawInputEventToPayload({ kind: 'sys-event', eventType: 14, eventSource: source });
|
||||
assert.equal(decoded.type, 'ring-press'); assert.equal(decoded.source, 'ring');
|
||||
}
|
||||
// Synthetic watch touch-down (TOUCH_EVENT_FROM_WATCH, never sent by firmware).
|
||||
const watch = d.rawInputEventToPayload({ kind: 'sys-event', eventType: 14, eventSource: 4 });
|
||||
assert.equal(watch.type, 'ring-press'); assert.equal(watch.source, 'watch');
|
||||
for (const source of [1, 3, 99, undefined]) {
|
||||
assert.equal(d.rawInputEventToPayload({ kind: 'sys-event', eventType: 14, eventSource: source }).type, 'unknown');
|
||||
}
|
||||
@@ -192,3 +195,20 @@ test('debug history retains both clocks and uses unsigned gaps across counter wr
|
||||
assert.equal(log.entries[0].filtered,true);
|
||||
log.clear(); log.add(ring(1,500)); assert.equal(log.entries[0].ringGapTicks,null);
|
||||
});
|
||||
|
||||
test('PressTracker pairs each gesture with the touch-down that began it', () => {
|
||||
const { PressTracker } = load('app/ui/gestures.ts');
|
||||
const t = new PressTracker();
|
||||
const ev = (type, source) => ({ type, source, timestampMs: 0 });
|
||||
assert.equal(t.followsPress(ev('ring-press', 'watch')), false);
|
||||
assert.equal(t.followsPress(ev('click', 'watch')), true);
|
||||
// Input with no touch-down of its own (finger-pinch tap, crown, older watch app) still acts.
|
||||
assert.equal(t.followsPress(ev('click', 'watch')), false);
|
||||
// A press pairs only with the next event, and only from its own source.
|
||||
t.followsPress(ev('ring-press', 'watch'));
|
||||
assert.equal(t.followsPress(ev('click', 'left-arm')), false);
|
||||
assert.equal(t.followsPress(ev('click', 'watch')), false);
|
||||
// Stock ring scroll notifications omit their source.
|
||||
t.followsPress(ev('ring-press', 'ring'));
|
||||
assert.equal(t.followsPress({ type: 'scroll-up', timestampMs: 0 }), true);
|
||||
});
|
||||
@@ -20,37 +20,42 @@ function setup() {
|
||||
}
|
||||
test('single tap retains mirror coordinates and waits to disambiguate double tap', () => {
|
||||
const s = setup(); s.touch('down'); s.touch('up');
|
||||
assert.deepEqual(s.types(), []); s.advance(280);
|
||||
assert.deepEqual(s.events, [{ type: 'tap', x: 20, y: 30 }]);
|
||||
assert.deepEqual(s.types(), ['press']); s.advance(280);
|
||||
assert.deepEqual(s.events, [{ type: 'press', x: 20, y: 30 }, { type: 'tap', x: 20, y: 30 }]);
|
||||
});
|
||||
test('every first-finger touch-down presses; a far second touch flushes the pending tap first', () => {
|
||||
const s = setup(); s.touch('down'); s.touch('up'); s.advance(100);
|
||||
s.touch('down', 200, 30); s.touch('down', 201, 30, 2); s.touch('up', 201, 30, 2); s.touch('up', 200, 30); s.advance(1000);
|
||||
assert.deepEqual(s.types(), ['press', 'tap', 'press', 'double-tap']);
|
||||
});
|
||||
test('double tap emits back without accidental selection', () => {
|
||||
const s = setup(); s.touch('down'); s.touch('up'); s.advance(150);
|
||||
s.touch('down'); s.touch('up'); s.advance(1000);
|
||||
assert.deepEqual(s.types(), ['double-tap']);
|
||||
assert.deepEqual(s.types(), ['press', 'press', 'double-tap']);
|
||||
});
|
||||
test('a hold emits a press and release, never a tap', () => {
|
||||
const s = setup(); s.touch('down'); s.advance(500); s.touch('up'); s.advance(1000);
|
||||
assert.deepEqual(s.types(), ['long-press', 'long-press-release']);
|
||||
assert.deepEqual(s.types(), ['press', 'long-press', 'long-press-release']);
|
||||
});
|
||||
test('tap then hold emits the app-menu gesture without an earlier selection', () => {
|
||||
const s = setup(); s.touch('down'); s.touch('up'); s.advance(100);
|
||||
s.touch('down'); s.advance(500); s.touch('up'); s.advance(1000);
|
||||
assert.deepEqual(s.types(), ['short-then-long-press', 'long-press-release']);
|
||||
assert.deepEqual(s.types(), ['press', 'press', 'short-then-long-press', 'long-press-release']);
|
||||
});
|
||||
test('four directional swipes cancel pending holds and taps', () => {
|
||||
for (const [x, y, expected] of [[80, 30, 'swipe-right'], [-40, 30, 'swipe-left'], [20, 90, 'swipe-down'], [20, -30, 'swipe-up']]) {
|
||||
const s = setup(); s.touch('down'); s.touch('move', x, y); s.advance(500); s.touch('up', x, y); s.advance(500);
|
||||
assert.deepEqual(s.types(), [expected]);
|
||||
assert.deepEqual(s.types(), ['press', expected]);
|
||||
}
|
||||
});
|
||||
test('two fingers send back exactly once and cancel the long-press timer', () => {
|
||||
const s = setup(); s.touch('down'); s.touch('down', 21, 30, 2); s.advance(500);
|
||||
s.touch('up', 21, 30, 2); s.touch('up'); s.advance(1000);
|
||||
assert.deepEqual(s.types(), ['double-tap']);
|
||||
assert.deepEqual(s.types(), ['press', 'double-tap']);
|
||||
});
|
||||
test('cancellation prevents delayed selections and releases active holds', () => {
|
||||
const s = setup(); s.touch('down'); s.touch('up'); s.r.cancel(); s.advance(1000);
|
||||
assert.deepEqual(s.types(), []);
|
||||
assert.deepEqual(s.types(), ['press']);
|
||||
s.touch('down'); s.advance(500); s.touch('cancel'); s.advance(1000);
|
||||
assert.deepEqual(s.types(), ['long-press', 'long-press-release']);
|
||||
assert.deepEqual(s.types(), ['press', 'press', 'long-press', 'long-press-release']);
|
||||
});
|
||||
Reference in new issue
Block a user