feat(controller): route status messages through notifications

- Send controller connected and disabled messages over a new IPC channel so they follow ankiConnect.behavior.notificationType
- Remove the separate controller status toast from the overlay
- Only announce connected controllers when controller.enabled is on
- Announce a controller again after it reconnects, and update usage docs
This commit is contained in:
sudacode committed 2026-11-03 21:55:55 -08:00
1 parent 1c50d249e0
commit 8976d78390
15 files changed
+84 -167

No files matched your search

+8
View File
@@ -92,6 +92,7 @@ export interface IpcServiceDeps {
/** The overlay reports the controller it is reading (null when none). */
reportActiveController: (gamepadId: string | null) => void;
getActiveControllerId: () => string | null;
notifyControllerStatus: (message: string) => void;
getSecondarySubMode: () => unknown;
getCurrentSecondarySub: () => string;
focusMainWindow: () => void;
@@ -362,6 +363,7 @@ export interface IpcDepsRuntimeOptions {
/** The overlay reports the controller it is reading (null when none). */
reportActiveController: (gamepadId: string | null) => void;
getActiveControllerId: () => string | null;
notifyControllerStatus: (message: string) => void;
getSecondarySubMode: () => unknown;
getMpvClient: () => MpvClientLike | null;
focusMainWindow: () => void;
@@ -440,6 +442,7 @@ export function createIpcDepsRuntime(options: IpcDepsRuntimeOptions): IpcService
saveControllerConfig: options.saveControllerConfig,
reportActiveController: options.reportActiveController,
getActiveControllerId: options.getActiveControllerId,
notifyControllerStatus: options.notifyControllerStatus,
getSecondarySubMode: options.getSecondarySubMode,
getCurrentSecondarySub: () => options.getMpvClient()?.currentSecondarySubText || '',
focusMainWindow: () => {
@@ -777,6 +780,11 @@ export function registerIpcHandlers(deps: IpcServiceDeps, ipc: IpcMainRegistrar
return deps.getActiveControllerId();
});
ipc.on(IPC_CHANNELS.command.notifyControllerStatus, (_event: unknown, message: unknown) => {
if (typeof message !== 'string' || message.trim().length === 0) return;
deps.notifyControllerStatus(message);
});
ipc.handle(IPC_CHANNELS.request.getSecondarySubMode, () => {
return deps.getSecondarySubMode();
});