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

+3 -5
View File
@@ -25,6 +25,7 @@ import { getFont } from "../../graphics/bdffont";
import { ensurePreinstalledFonts, installedFontPath } from "../../graphics/installed-fonts";
import { TtfFont } from "../../graphics/ttf-font";
import * as frameTimings from "../../native/frame-timings";
import { playWorkerBuzzerSequence } from "../../native/worker-buzzer";
import { getActiveDisplay } from "../../native/active-display";
import { buildSoundSequencePayload, type Step } from "../../ui/sound-effects";
import { loadSoundEnabled, saveSoundEnabled } from "../../ui/sound-setting";
@@ -34,7 +35,6 @@ import type { WorkerAppMessage, WorkerAppReply } from "../../ui/shell/worker-win
import { directionalFallback, GESTURE_CLICK, GESTURE_DOUBLE_CLICK, GESTURE_LONG_PRESS, type InputEvent } from "../../ui/gestures";
declare const global: any;
declare const com: any;
ensurePreinstalledFonts();
const fontPath = installedFontPath("Roboto-Regular.ttf");
@@ -206,14 +206,12 @@ global.onmessage = (event: { data: WorkerAppMessage }) => {
/**
* Fire a buzzer effect. Non-blocking: the firmware's sequencer plays the
* steps on its own timer, and the Java call is safe from the worker thread.
* steps on its own timer; the platform bridge routes it from the worker.
*/
function playSfx(window: FreecellWindow, steps: Step[]): void {
if (!window.soundOn || steps.length === 0) return;
try {
const communicator = com.faceclaw.app.FaceclawBleCommunicator.getActive();
if (!communicator) return;
communicator.playBuzzerSequence(buildSoundSequencePayload(steps).buffer);
playWorkerBuzzerSequence(buildSoundSequencePayload(steps));
} catch (error) {
console.warn(`freecell sfx failed: ${error}`);
}