forked from Blendman974/faceclaw
Forward ring input events before filtering, and include swipe info
This commit is contained in:
1 parent
b972cd7682
commit
7b19c00443
20 files changed
+368
-75
No files matched your search
@@ -11,14 +11,15 @@ export class InputEventsLayer implements Layer {
|
||||
readonly acceptsDirectional = true;
|
||||
readonly log = new InputEventLog();
|
||||
private scrollRow = 0;
|
||||
private phoneTime = false;
|
||||
private visibleRows = 1;
|
||||
private readonly unsubscribe: () => void;
|
||||
|
||||
constructor(requestRender: () => void, isVisible: () => boolean,
|
||||
private readonly removed: () => void = () => {}) {
|
||||
this.unsubscribe = addInputListener((event) => {
|
||||
this.unsubscribe = addInputListener((event, filtered) => {
|
||||
if (!isVisible() || this.log.paused) return;
|
||||
this.log.add(event);
|
||||
this.log.add(event, filtered);
|
||||
this.scrollRow = 0;
|
||||
requestRender();
|
||||
});
|
||||
@@ -38,6 +39,10 @@ export class InputEventsLayer implements Layer {
|
||||
this.scrollRow = 0;
|
||||
ctx.stack.pop();
|
||||
} },
|
||||
{ label: this.phoneTime ? "Show ring timestamps" : "Show phone receive time", onSelect: (ctx) => {
|
||||
this.phoneTime = !this.phoneTime;
|
||||
ctx.stack.pop();
|
||||
} },
|
||||
{ label: "Back to Debug tests", onSelect: (ctx) => { ctx.stack.popThrough(this); } },
|
||||
];
|
||||
}
|
||||
@@ -49,8 +54,9 @@ export class InputEventsLayer implements Layer {
|
||||
image.drawText(font, 12, 8, "Input events", 230);
|
||||
const status = `${this.log.paused ? "Paused" : "Live"} ${this.log.count} events`;
|
||||
image.drawText(font, width - 12 - font.measureText(status), 8, status, 180);
|
||||
image.drawText(font, 12, 28, "Phone receive time | gap ms | source | event", 140);
|
||||
const rowHeight = Math.max(18, font.lineHeight + 2);
|
||||
image.drawText(font, 12, 28, this.phoneTime ? "Phone receive time | gap ms | source | event" : "Time (R=ring tick) | gap | source | event", 140);
|
||||
const lineHeight = Math.max(18, font.lineHeight + 2);
|
||||
const rowHeight = lineHeight * 2 + 4;
|
||||
this.visibleRows = Math.max(1, Math.floor((height - 76) / rowHeight));
|
||||
this.scrollRow = Math.min(this.scrollRow, Math.max(0, this.log.entries.length - this.visibleRows));
|
||||
const timeX = 12;
|
||||
@@ -62,20 +68,31 @@ export class InputEventsLayer implements Layer {
|
||||
image.drawText(font, 12, 82, "Press arrives before an interpreted gesture.", 150);
|
||||
}
|
||||
for (const [index, entry] of this.log.entries.slice(this.scrollRow, this.scrollRow + this.visibleRows).entries()) {
|
||||
const { event, gapMs } = entry;
|
||||
const { event } = entry;
|
||||
const ringTime = !this.phoneTime && event.ringInput;
|
||||
const gapMs = ringTime ? entry.ringGapTicks : entry.gapMs;
|
||||
const y = 50 + index * rowHeight;
|
||||
const gap = gapMs === null ? "-" : `${gapMs >= 0 ? "+" : ""}${gapMs}`;
|
||||
const source = "source" in event ? event.source ?? "-" : "-";
|
||||
const label = event.type === "unknown" ? `${event.kind} ${event.eventSource}/${event.eventType}` : event.type;
|
||||
image.drawText(font, timeX, y, inputTimestamp(event.timestampMs), 170);
|
||||
const label = (entry.filtered ? "*" : "") + (event.type === "unknown"
|
||||
? event.ringInput ? `ring type ${event.ringInput.type}` : `${event.kind} ${event.eventSource}/${event.eventType}`
|
||||
: event.type);
|
||||
image.drawText(font, timeX, y, ringTime ? `R${ringTime.tick}` : inputTimestamp(event.timestampMs), 170);
|
||||
image.drawText(font, gapX, y, truncateText(font, gap, sourceX - gapX - 4), 160);
|
||||
image.drawText(font, sourceX, y, source, 180);
|
||||
image.drawText(font, eventX, y, truncateText(font, label, width - eventX - 12), event.type === "ring-press" ? 255 : 200);
|
||||
if (event.ringInput) {
|
||||
const { type, aux, speed } = event.ringInput;
|
||||
// These are the original report bytes, not physical distance/speed units.
|
||||
const details = `Raw ring: type ${type} AUX ${aux} speed ${speed}`;
|
||||
image.drawText(font, timeX + 12, y + lineHeight,
|
||||
truncateText(font, details, width - timeX - 36), 170);
|
||||
}
|
||||
}
|
||||
if (this.log.paused) drawListScrollbar(image, width - 5, 50, height - 78,
|
||||
this.scrollRow, this.visibleRows, this.log.entries.length);
|
||||
image.drawText(font, 12, height - 20,
|
||||
this.log.paused ? "Scroll: history Tap-hold: controls" : "Newest first Tap-hold: pause / clear / back", 140);
|
||||
this.log.paused ? "Scroll: history Tap-hold: controls" : "Unfiltered (*=dedup) Tap-hold: controls", 140);
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user