Add support for buzzer sound effects on iOS

This commit is contained in:
James Babcock committed 2026-09-19 12:03:57 -07:00
1 parent 1412db8e82
commit e50da605e0
19 files changed
+211 -48

No files matched your search

+2 -1
View File
@@ -103,7 +103,8 @@ async function startApp(
cleanup?: () => void,
): Promise<void> {
const windowId = `evenhub:app:${nextSerial++}`;
const session = new EvenHubSession(manifest, distDir, ctx.appendLog, remoteUrl);
const session = new EvenHubSession(manifest, distDir, ctx.appendLog, remoteUrl,
payload => ctx.actions.playBuzzerSequence(payload));
const webView = createEvenHubWebView(session);
session.attachWebView({
evaluateJs: webView.evaluateJs,
+2 -14
View File
@@ -65,8 +65,6 @@ import { ensureFineLocationPermission } from "../../native/location-permissions"
const UPNG = require("upng-js");
declare const com: any;
/** OsEventTypeList values (PB ordinals). */
const CLICK_EVENT = 0;
const SCROLL_TOP_EVENT = 1;
@@ -371,6 +369,7 @@ export class EvenHubSession implements EvenHubMicClient, EvenHubImuClient, EvenH
distDir: string,
log: (message: string) => void,
remoteUrl = "",
private readonly sendBuzzerSequence: (payload: Uint8Array) => Promise<void> | void = () => {},
) {
this.manifest = manifest;
this.distDir = distDir;
@@ -1164,13 +1163,11 @@ export class EvenHubSession implements EvenHubMicClient, EvenHubImuClient, EvenH
private async playBuzzer(rawSteps: unknown[]): Promise<void> {
const steps = normalizeBuzzerSteps(rawSteps);
if (steps.length === 0) return;
const communicator = activeCommunicator();
if (!communicator) return;
for (let i = 0; i < steps.length; i += CFW_SEQ_MAX) {
const chunk = steps.slice(i, i + CFW_SEQ_MAX);
const payload = buildSoundSequencePayload(chunk);
try {
communicator.playBuzzerSequence(payload.buffer);
await this.sendBuzzerSequence(payload);
} catch (error) {
this.log(`evenhub: playBuzzer failed: ${error}`);
return;
@@ -1274,15 +1271,6 @@ function clampImuFreq(freq: number): number {
return Math.min(1000, Math.max(100, snapped));
}
function activeCommunicator(): any {
if (!global.isAndroid) return null;
try {
return com.faceclaw.app.FaceclawBleCommunicator.getActive();
} catch {
return null;
}
}
/**
* Copy content into a `preserve` container from the same-named, same-kind
* container in the previous page (if any), so a replaceLayout keeps its pixels /