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
@@ -25,6 +25,7 @@ import { getFont } from "../../graphics/bdffont";
|
||||
import { getDefaultSmallFont } from "../../graphics/ui-fonts";
|
||||
import { getStringSetting, setStringSetting } from "../../native/settings-store";
|
||||
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";
|
||||
@@ -43,7 +44,6 @@ import {
|
||||
import { clamp } from "../../util/numeric-util";
|
||||
|
||||
declare const global: any;
|
||||
declare const com: any;
|
||||
|
||||
const largeFont = getFont("terminus32");
|
||||
const mediumFont = getFont("terminus24");
|
||||
@@ -278,14 +278,12 @@ function saveDifficultyIndex(window: MinesweeperWindow): 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.
|
||||
* steps on its own timer; the platform bridge routes it from the worker.
|
||||
*/
|
||||
function playSfx(window: MinesweeperWindow, 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(`minesweeper sfx failed: ${error}`);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user