forked from Blendman974/faceclaw
Add support for buzzer sound effects on iOS
This commit is contained in:
1 parent
1412db8e82
commit
e50da605e0
19 files changed
+211
-48
No files matched your search
@@ -17,6 +17,7 @@ import { prepareFrameDraws } from "../../graphics/glyph-wire";
|
||||
import { getFont } from "../../graphics/bdffont";
|
||||
import { getDefaultSmallFont } from "../../graphics/ui-fonts";
|
||||
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";
|
||||
@@ -33,7 +34,6 @@ import {
|
||||
} from "../../ui/gestures";
|
||||
|
||||
declare const global: any;
|
||||
declare const com: any;
|
||||
|
||||
const largeFont = getFont("terminus32");
|
||||
const mediumFont = getFont("terminus24");
|
||||
@@ -295,16 +295,13 @@ function inferForeground(window: BlocksWindow, focused: boolean): void {
|
||||
|
||||
/**
|
||||
* 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
|
||||
* (same path as frame submission). Effects never exceed one message, so no
|
||||
* phrase pacing is needed.
|
||||
* steps on its own timer; the platform bridge routes it from the worker.
|
||||
* Effects never exceed one message, so no phrase pacing is needed.
|
||||
*/
|
||||
function playSfx(window: BlocksWindow, 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(`blocks sfx failed: ${error}`);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user