forked from Blendman974/faceclaw
Add mic support for EvenHub apps
This commit is contained in:
1 parent
add8763028
commit
b86f395866
11 files changed
+593
-17
No files matched your search
@@ -5,6 +5,7 @@ import type { RawInputEvent } from "../../native/faceclaw-communicator";
|
||||
import { DashboardInputEvent, Layer, LayerActions, LayerContext, LayerStack, noopLayerActions } from "../layers";
|
||||
import { MenuLayer, type MenuItem } from "../menu";
|
||||
import { VoiceInputLayer, type VoiceSendTarget } from "./voice-input";
|
||||
import { voiceActivity } from "./voice-activity";
|
||||
import { AssistantLayer } from "./assistant";
|
||||
import { AssistantSession, type AssistantBackendConfig } from "../../assistant/session";
|
||||
import { resolveAssistantModel } from "../../assistant/models";
|
||||
@@ -675,6 +676,7 @@ class Shell {
|
||||
onClosed: () => {
|
||||
if (this.activeVoiceLayer === layer) {
|
||||
this.activeVoiceLayer = null;
|
||||
voiceActivity.setActive(false);
|
||||
// The idle countdown restarts in full once voice input ends.
|
||||
this.noteUserActivity();
|
||||
}
|
||||
@@ -689,6 +691,7 @@ class Shell {
|
||||
autoSend,
|
||||
});
|
||||
this.activeVoiceLayer = layer;
|
||||
voiceActivity.setActive(true);
|
||||
this.stack.push(layer);
|
||||
layer.startCapture();
|
||||
}
|
||||
@@ -850,6 +853,7 @@ class Shell {
|
||||
onClosed: () => {
|
||||
if (this.activeVoiceLayer === voice) {
|
||||
this.activeVoiceLayer = null;
|
||||
voiceActivity.setActive(false);
|
||||
this.noteUserActivity();
|
||||
}
|
||||
},
|
||||
@@ -864,6 +868,7 @@ class Shell {
|
||||
autoSend: handsFree && assistantSkipConfirmationSetting.get(),
|
||||
});
|
||||
this.activeVoiceLayer = voice;
|
||||
voiceActivity.setActive(true);
|
||||
this.stack.push(voice);
|
||||
voice.startCapture();
|
||||
this.config.requestShellRender();
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* A tiny global signal for whether a voice-input modal (the assistant dialog)
|
||||
* is currently open. The shell sets it; the EvenHub mic router reads it to
|
||||
* decide whether an app may hold the glasses microphone — an app receives no
|
||||
* audio while the assistant is active, since both share the one G2 mic.
|
||||
*
|
||||
* Kept as a dependency-free leaf so both the shell and the EvenHub layer can
|
||||
* import it without a cycle.
|
||||
*/
|
||||
|
||||
type Listener = (active: boolean) => void;
|
||||
|
||||
let active = false;
|
||||
const listeners = new Set<Listener>();
|
||||
|
||||
export const voiceActivity = {
|
||||
isActive(): boolean {
|
||||
return active;
|
||||
},
|
||||
setActive(next: boolean): void {
|
||||
if (active === next) return;
|
||||
active = next;
|
||||
listeners.forEach((listener) => listener(active));
|
||||
},
|
||||
subscribe(listener: Listener): () => void {
|
||||
listeners.add(listener);
|
||||
return () => listeners.delete(listener);
|
||||
},
|
||||
};
|
||||
Reference in new issue
Block a user