Let microphone = 0 refuse the game's input streams, and give the microphone code a neutral device name.

The input-stream overrides open the default recording device whenever the game asks. The setting keeps the earlier
refusal available, the stream-purge crash fix holds either way, the device name and log lines no longer say Windows on
every platform, and the error result is named.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-09 08:19:55 -05:00
parent 45a8cc3d8b
commit acdf1711b9
3 changed files with 26 additions and 11 deletions

View File

@@ -47,7 +47,7 @@ static const char *const known[] = {
"HDR_EXPOSURE", "HDR_FLARE", "HDR_GAMMA", "HDR_GAME_NITS", "HDR_GRADE", "HDR_HIGHLIGHT_SAT", "HDR_HIGHLIGHTS", "HDR_HUE",
"HDR_PEAK_NITS", "HDR_SATURATION", "HDR_SHADOWS", "HDR_TONEMAP", "HDR_UI_NITS", "HIGHFPS_FIX", "INPUT", "INPUT_RECORD", "INPUT_SCRIPT", "LANG", "LIB_PREBUILD",
"BIG_BUILD_FREE_MB", "BIG_BUILD_MAX_MB", "LIB_PREBUILD_BIG", "LIB_PREBUILD_BIG_BG", "LIB_PREBUILD_KEEP", "LIB_PREBUILD_THREADS", "LOCALE", "LOD_GUARD", "LSTICK_DEADZONE", "MEMORY", "MENU_LANG", "MENU_SOUND_VOLUME", "MENU_TEST",
"MENU_CURSOR", "MENU_CURSOR_LOG", "MENU_TEST_DIR", "MENU_TEST_SET", "MINIMAL_LAYOUT", "MIRROR_GAP", "MODS_DIR", "MODS_DISABLED", "MODS_ORDER", "MODS_REBUILD", "MONITOR", "MOTION", "MOUSE_MODE", "MOUSE_DIRECT_PATCH", "MOUSE_SENS", "MOVIE_HOST", "MOVIE_PACE",
"MENU_CURSOR", "MENU_CURSOR_LOG", "MENU_TEST_DIR", "MENU_TEST_SET", "MINIMAL_LAYOUT", "MICROPHONE", "MIRROR_GAP", "MODS_DIR", "MODS_DISABLED", "MODS_ORDER", "MODS_REBUILD", "MONITOR", "MOTION", "MOUSE_MODE", "MOUSE_DIRECT_PATCH", "MOUSE_SENS", "MOVIE_HOST", "MOVIE_PACE",
"MVOBJ_ALL", "MVOBJ_BANKS", "MVOBJ_EQUAL", "MVOBJ_EXACT", "MVOBJ_EXEC", "MVOBJ_NOC4", "MVOBJ_ONLY", "MVOBJ_TIMES", "MVPREV_CHECK", "MVPREV_GROW", "MVPREV_SKIP", "MVPREV_TRUST", "MV_CHECK",
"MV_SURVEY",
"ONE_PER_CORE", "OPERATION_MODE", "OUTPUT_RES", "PAD_LAYOUT", "PACE_HZ", "PASS_CRUMBS", "PATCH_OUTPUT", "PATCH_RES_FIXED", "PATCH_SCENE", "PATCH_WIDE_ASPECT", "PATCH_WIDE_HUD", "PATCH_WIDE_MOVIE", "PATCH_WIDE_OUT", "PATCH_WIDE_SCENE", "PCSS", "PCSS_K", "PERF_OVERLAY", "PERF_SLOW_MS", "PIPELINE_CACHE", "PIPELINE_CACHE_MAX_MB", "PIPE_BINARIES", "PIPE_BINARIES_MAX_MB", "PIPE_FEEDBACK", "PIPE_MEMO", "PIPE_PREBUILD", "PIPE_SKIP", "PIPE_SYNC", "PIPE_WAIT", "POWER_FULL", "TEX_SAME", "PRESENT_HELD", "HELD_SYNC",
@@ -90,7 +90,7 @@ static const struct { const char *key, *section; } sections[] = {
{"PCSS", "display"},
{"MODS_DIR", "mods"}, {"MODS_ORDER", "mods"}, {"MODS_DISABLED", "mods"}, {"MODS_REBUILD", "mods"},
{"MENU_LANG", "language"}, {"LANG", "language"}, {"OPERATION_MODE", "language"},
{"VOLUME", "audio"}, {"AUDIO_CHANNELS", "audio"}, {"AUDIO_DEVICE", "audio"}, {"MENU_SOUND_VOLUME", "audio"},
{"VOLUME", "audio"}, {"AUDIO_CHANNELS", "audio"}, {"AUDIO_DEVICE", "audio"}, {"MICROPHONE", "audio"}, {"MENU_SOUND_VOLUME", "audio"},
{"MOTION", "input"}, {"RUMBLE_STRENGTH", "input"}, {"RUMBLE_CURVE", "input"}, {"RUMBLE_TRIGGERS", "input"},
{"PAD_LAYOUT", "input"}, {"PROMPTS", "input"}, {"STICK_DEADZONE", "input"}, {"LSTICK_DEADZONE", "input"}, {"RSTICK_DEADZONE", "input"},
{"STICK_SENS", "input"},
@@ -170,6 +170,7 @@ static const CfgMeta metas[] = {
// Sound, Controls, Menu
{"VOLUME", "100", "0..100", LIVE}, {"MENU_SOUND_VOLUME", "80", "0..100", LIVE}, {"AUDIO_CHANNELS", "stereo", "auto|stereo|5.1", RESTART},
{"AUDIO_DEVICE", "default", NULL, RESTART}, // default|<1-based index>|<part of a device name> (audio_mixer.c resolve_audio_device)
{"MICROPHONE", "1", "0|1", RESTART}, // ov_audio_input.c mic_on: 0 refuses the game's input streams
{"MOTION", "1", "0|1", LIVE}, {"RUMBLE_STRENGTH", "130", "0..300", LIVE}, {"RUMBLE_CURVE", "0.6", "0.2..1.5", LIVE},
{"RUMBLE_TRIGGERS", "0", "0|1", LIVE}, {"PAD_LAYOUT", "nintendo", "auto|nintendo|xbox|playstation", LIVE},
{"PROMPTS", "nintendo", "nintendo|xbox|playstation|pc", RESTART},

View File

@@ -1,5 +1,8 @@
/* Polling audio input for the public nn::audio calls Ocarina imports.
SDL converts the default recording device to the format the caller requests. */
// Audio input for the nn::audio input-stream calls the game imports (the Ocarina can be played into a microphone):
// each stream reads the default recording device through audio_capture.c, which SDL converts to the format the game
// asks for. The calls are overridden in the game (HOST_OVERRIDE) because the audio service refuses input streams. A
// stream that failed to open is unknown to every call here, so purging or closing it is safe; before, the game purged
// a stream that never opened and crashed. NX2NAVI_MICROPHONE=0 refuses every input stream, as the game saw before.
#include "audio_capture.h"
#include "host.h"
#include "ipc.h"
@@ -8,7 +11,7 @@
#include <stdio.h>
#include <string.h>
#define BAD_INPUT 0x70899u
#define BAD_INPUT 0x70899u // nn::audio's invalid-argument result (module 153, description 900), as audio_mixer.c
typedef struct {
uint64_t key;
MicCapture *mic;
@@ -16,7 +19,15 @@ typedef struct {
uint64_t frames_read, next_log;
} Input;
static Input inputs[8];
static const char input_name[] = "WindowsDefaultMicrophone";
static const char input_name[] = "DefaultMicrophone"; // the name the game is given for the default device
static int mic_on(void) { // NX2NAVI_MICROPHONE (default 1)
static int on = -1;
if (on < 0) {
on = rt_knob("MICROPHONE", "1") != 0;
if (!on) rt_log("mic: input streams refused (NX2NAVI_MICROPHONE=0)");
}
return on;
}
static Input *find(uint64_t key) {
for (int i = 0; i < 8; i++)
if (inputs[i].key == key && key)
@@ -29,10 +40,10 @@ static void name_out(uint64_t addr) {
memcpy(p, input_name, sizeof input_name);
}
static void list_devices(Cpu *c) {
int n = mic_device_count();
int n = mic_on() ? mic_device_count() : 0;
if ((int)c->x[1] > 0 && n > 0)
name_out(c->x[0]);
rt_log("mic: input enumeration: %d Windows recording devices", n);
rt_log("mic: input enumeration: %d recording devices", n);
ret_x(c, (int)c->x[1] > 0 && n > 0 ? 1 : 0);
}
static void default_device(Cpu *c) {
@@ -69,13 +80,13 @@ static void open_input(Cpu *c) {
s = &inputs[i];
uint64_t zero = 0;
memcpy(ipc_guest(key, 8), &zero, 8);
if (!s) {
if (!s || !mic_on()) {
ret_x(c, BAD_INPUT);
return;
}
MicCapture *m = mic_open(f[0], f[1], f[2], frames);
if (!m) {
rt_log("mic: cannot open Windows default input: %s", mic_error());
rt_log("mic: cannot open the default recording device: %s", mic_error());
ret_x(c, BAD_INPUT);
return;
}
@@ -86,7 +97,7 @@ static void open_input(Cpu *c) {
s->next_log = (uint64_t)f[2] * 5;
uint64_t impl = key + 8;
memcpy(ipc_guest(key, 8), &impl, 8);
rt_log("mic: Windows default input opened; bounded buffer %d frames", mic_capacity(m));
rt_log("mic: default recording device opened; bounded buffer %d frames", mic_capacity(m));
ret_x(c, 0);
}
static void start_input(Cpu *c) {