diff --git a/arm9/data/config_template.ini b/arm9/data/config_template.ini index 1dd2da768..1d3cd2548 100644 Binary files a/arm9/data/config_template.ini and b/arm9/data/config_template.ini differ diff --git a/arm9/source/config.c b/arm9/source/config.c index ec5e03996..b82e8d5e3 100644 --- a/arm9/source/config.c +++ b/arm9/source/config.c @@ -65,7 +65,6 @@ static const char *singleOptionIniNamesBoot[] = { "app_syscore_threads_on_core_2", "show_system_settings_string", "show_gba_boot_screen", - "force_headphone_output", }; static const char *singleOptionIniNamesMisc[] = { @@ -409,10 +408,31 @@ static int configIniHandler(void* user, const char* section, const char* name, c CHECK_PARSE_OPTION(-1); } } else if (strcmp(name, "autoboot_mode") == 0) { - s64 opt; - CHECK_PARSE_OPTION(parseDecIntOption(&opt, value, 0, 2)); - cfg->multiConfig |= (u32)opt << (2 * (u32)AUTOBOOTMODE); - return 1; + if (strcasecmp(value, "off") == 0) { + cfg->multiConfig |= 0 << (2 * (u32)AUTOBOOTMODE); + return 1; + } else if (strcasecmp(value, "3ds") == 0) { + cfg->multiConfig |= 1 << (2 * (u32)AUTOBOOTMODE); + return 1; + } else if (strcasecmp(value, "dsi") == 0) { + cfg->multiConfig |= 2 << (2 * (u32)AUTOBOOTMODE); + return 1; + } else { + CHECK_PARSE_OPTION(-1); + } + } else if (strcmp(name, "force_audio_output") == 0) { + if (strcasecmp(value, "off") == 0) { + cfg->multiConfig |= 0 << (2 * (u32)FORCEAUDIOOUTPUT); + return 1; + } else if (strcasecmp(value, "headphones") == 0) { + cfg->multiConfig |= 1 << (2 * (u32)FORCEAUDIOOUTPUT); + return 1; + } else if (strcasecmp(value, "speakers") == 0) { + cfg->multiConfig |= 2 << (2 * (u32)FORCEAUDIOOUTPUT); + return 1; + } else { + CHECK_PARSE_OPTION(-1); + } } else { CHECK_PARSE_OPTION(-1); } @@ -529,6 +549,8 @@ static size_t saveLumaIniConfigToStr(char *out) const char *splashPosStr; const char *n3dsCpuStr; + const char *autobootModeStr; + const char *forceAudioOutputStr; switch (MULTICONFIG(SPLASH)) { default: case 0: splashPosStr = "off"; break; @@ -543,6 +565,18 @@ static size_t saveLumaIniConfigToStr(char *out) case 3: n3dsCpuStr = "clock+l2"; break; } + switch (MULTICONFIG(AUTOBOOTMODE)) { + default: case 0: autobootModeStr = "off"; break; + case 1: autobootModeStr = "3ds"; break; + case 2: autobootModeStr = "dsi"; break; + } + + switch (MULTICONFIG(FORCEAUDIOOUTPUT)) { + default: case 0: forceAudioOutputStr = "off"; break; + case 1: forceAudioOutputStr = "headphones"; break; + case 2: forceAudioOutputStr = "speakers"; break; + } + if (VERSION_BUILD != 0) { sprintf(lumaVerStr, "Luma3DS v%d.%d.%d", (int)VERSION_MAJOR, (int)VERSION_MINOR, (int)VERSION_BUILD); } else { @@ -582,11 +616,12 @@ static size_t saveLumaIniConfigToStr(char *out) (int)CONFIG(AUTOBOOTEMU), (int)CONFIG(USEEMUFIRM), (int)CONFIG(LOADEXTFIRMSANDMODULES), (int)CONFIG(PATCHGAMES), (int)CONFIG(REDIRECTAPPTHREADS), (int)CONFIG(PATCHVERSTRING), - (int)CONFIG(SHOWGBABOOT), (int)CONFIG(FORCEHEADPHONEOUTPUT), + (int)CONFIG(SHOWGBABOOT), 1 + (int)MULTICONFIG(DEFAULTEMU), 4 - (int)MULTICONFIG(BRIGHTNESS), splashPosStr, (unsigned int)cfg->splashDurationMsec, - pinNumDigits, n3dsCpuStr, (int)MULTICONFIG(AUTOBOOTMODE), + pinNumDigits, n3dsCpuStr, + autobootModeStr, forceAudioOutputStr, cfg->hbldr3dsxTitleId, rosalinaMenuComboStr, (int)cfg->ntpTzOffetMinutes, @@ -751,6 +786,7 @@ void configMenu(bool oldPinStatus, u32 oldPinMode) "PIN lock: Off( ) 4( ) 6( ) 8( ) digits", "New 3DS CPU: Off( ) Clock( ) L2( ) Clock+L2( )", "Homebrew autoboot: Off( ) 3DS( ) DSi( )", + "Force audio: Off( ) Headphones( ) Speakers( )" }; static const char *singleOptionsText[] = { "( ) Autoboot EmuNAND", @@ -802,6 +838,15 @@ void configMenu(bool oldPinStatus, u32 oldPinMode) "configuration file to configure\n" "this feature.", + "Force audio output to HPs or speakers.\n\n" + "Currently only for NATIVE_FIRM.\n\n" + "Due to software limitations, this gets\n" + "undone if you actually insert then\n" + "remove HPs (just enter then exit sleep\n" + "mode if this happens).\n\n" + "Also gets bypassed for camera shutter\n" + "sound.", + "If enabled, an EmuNAND\n" "will be launched on boot.\n\n" "Otherwise, SysNAND will.\n\n" @@ -859,15 +904,6 @@ void configMenu(bool oldPinStatus, u32 oldPinMode) "Enable showing the GBA boot screen\n" "when booting GBA games.", - - "Force audio output to headphones.\n\n" - "Currently only for NATIVE_FIRM.\n\n" - "Due to software limitations, this gets\n" - "undone if you actually insert then\n" - "remove HPs (just enter then exit sleep\n" - "mode if this happens).\n\n" - "Also gets bypassed for camera shutter\n" - "sound.", }; FirmwareSource nandType = FIRMWARE_SYSNAND; @@ -889,6 +925,7 @@ void configMenu(bool oldPinStatus, u32 oldPinMode) { .visible = true }, { .visible = ISN3DS }, { .visible = true }, + { .visible = true }, }; struct singleOption { @@ -903,7 +940,6 @@ void configMenu(bool oldPinStatus, u32 oldPinMode) { .visible = ISN3DS }, { .visible = true }, { .visible = true }, - { .visible = true }, }; //Calculate the amount of the various kinds of options and pre-select the first single one diff --git a/arm9/source/config.h b/arm9/source/config.h index 00de4c1e6..611509133 100644 --- a/arm9/source/config.h +++ b/arm9/source/config.h @@ -34,9 +34,9 @@ #define MULTICONFIG(a) ((configData.multiConfig >> (2 * (a))) & 3) #define BOOTCONFIG(a, b) ((configData.bootConfig >> (a)) & (b)) -#define CONFIG_FILE "config.bin" +#define CONFIG_FILE "config.ini" #define CONFIG_VERSIONMAJOR 3 -#define CONFIG_VERSIONMINOR 5 +#define CONFIG_VERSIONMINOR 6 #define BOOTCFG_NAND BOOTCONFIG(0, 7) #define BOOTCFG_FIRM BOOTCONFIG(3, 7) @@ -51,6 +51,7 @@ enum multiOptions PIN, NEWCPU, AUTOBOOTMODE, + FORCEAUDIOOUTPUT, }; enum singleOptions @@ -62,7 +63,6 @@ enum singleOptions REDIRECTAPPTHREADS, PATCHVERSTRING, SHOWGBABOOT, - FORCEHEADPHONEOUTPUT, PATCHUNITINFO, DISABLEARM11EXCHANDLERS, ENABLESAFEFIRMROSALINA, diff --git a/k11_extension/include/config.h b/k11_extension/include/config.h index b367b3865..205e7c4fc 100644 --- a/k11_extension/include/config.h +++ b/k11_extension/include/config.h @@ -22,6 +22,7 @@ enum multiOptions PIN, NEWCPU, AUTOBOOTMODE, + FORCEAUDIOOUTPUT, }; enum singleOptions @@ -33,7 +34,6 @@ enum singleOptions REDIRECTAPPTHREADS, PATCHVERSTRING, SHOWGBABOOT, - FORCEHEADPHONEOUTPUT, PATCHUNITINFO, DISABLEARM11EXCHANDLERS, ENABLESAFEFIRMROSALINA, diff --git a/sysmodules/loader/source/patcher.h b/sysmodules/loader/source/patcher.h index 94724310f..97d1375bd 100644 --- a/sysmodules/loader/source/patcher.h +++ b/sysmodules/loader/source/patcher.h @@ -25,6 +25,7 @@ enum multiOptions PIN, NEWCPU, AUTOBOOTMODE, + FORCEAUDIOOUTPUT, }; enum singleOptions @@ -36,7 +37,6 @@ enum singleOptions REDIRECTAPPTHREADS, PATCHVERSTRING, SHOWGBABOOT, - FORCEHEADPHONEOUTPUT, PATCHUNITINFO, DISABLEARM11EXCHANDLERS, ENABLESAFEFIRMROSALINA, diff --git a/sysmodules/pm/source/luma.h b/sysmodules/pm/source/luma.h index d73a610ff..d999a68d5 100644 --- a/sysmodules/pm/source/luma.h +++ b/sysmodules/pm/source/luma.h @@ -19,6 +19,7 @@ enum multiOptions PIN, NEWCPU, AUTOBOOTMODE, + FORCEAUDIOOUTPUT, }; enum singleOptions @@ -30,7 +31,6 @@ enum singleOptions REDIRECTAPPTHREADS, PATCHVERSTRING, SHOWGBABOOT, - FORCEHEADPHONEOUTPUT, PATCHUNITINFO, DISABLEARM11EXCHANDLERS, ENABLESAFEFIRMROSALINA, diff --git a/sysmodules/rosalina/data/config_template.ini b/sysmodules/rosalina/data/config_template.ini index 1dd2da768..1d3cd2548 100644 Binary files a/sysmodules/rosalina/data/config_template.ini and b/sysmodules/rosalina/data/config_template.ini differ diff --git a/sysmodules/rosalina/include/luma_config.h b/sysmodules/rosalina/include/luma_config.h index 2a5a44e86..4c9d285a8 100644 --- a/sysmodules/rosalina/include/luma_config.h +++ b/sysmodules/rosalina/include/luma_config.h @@ -39,7 +39,6 @@ enum singleOptions REDIRECTAPPTHREADS, PATCHVERSTRING, SHOWGBABOOT, - FORCEHEADPHONEOUTPUT, PATCHUNITINFO, DISABLEARM11EXCHANDLERS, ENABLESAFEFIRMROSALINA, @@ -53,6 +52,7 @@ enum multiOptions PIN, NEWCPU, AUTOBOOTMODE, + FORCEAUDIOOUTPUT, }; void LumaConfig_ConvertComboToString(char *out, u32 combo); diff --git a/sysmodules/rosalina/source/luma_config.c b/sysmodules/rosalina/source/luma_config.c index 5f1bb494b..5029a41e3 100644 --- a/sysmodules/rosalina/source/luma_config.c +++ b/sysmodules/rosalina/source/luma_config.c @@ -87,6 +87,8 @@ static size_t LumaConfig_SaveLumaIniConfigToStr(char *out, const CfgData *cfg) const char *splashPosStr; const char *n3dsCpuStr; + const char *autobootModeStr; + const char *forceAudioOutputStr; s64 outInfo; svcGetSystemInfo(&outInfo, 0x10000, 0); @@ -111,6 +113,18 @@ static size_t LumaConfig_SaveLumaIniConfigToStr(char *out, const CfgData *cfg) case 3: n3dsCpuStr = "clock+l2"; break; } + switch (MULTICONFIG(AUTOBOOTMODE)) { + default: case 0: autobootModeStr = "off"; break; + case 1: autobootModeStr = "3ds"; break; + case 2: autobootModeStr = "dsi"; break; + } + + switch (MULTICONFIG(FORCEAUDIOOUTPUT)) { + default: case 0: forceAudioOutputStr = "off"; break; + case 1: forceAudioOutputStr = "headphones"; break; + case 2: forceAudioOutputStr = "speakers"; break; + } + if (GET_VERSION_REVISION(version) != 0) { sprintf(lumaVerStr, "Luma3DS v%d.%d.%d", (int)GET_VERSION_MAJOR(version), (int)GET_VERSION_MINOR(version), (int)GET_VERSION_REVISION(version)); } else { @@ -150,11 +164,12 @@ static size_t LumaConfig_SaveLumaIniConfigToStr(char *out, const CfgData *cfg) (int)CONFIG(AUTOBOOTEMU), (int)CONFIG(USEEMUFIRM), (int)CONFIG(LOADEXTFIRMSANDMODULES), (int)CONFIG(PATCHGAMES), (int)CONFIG(REDIRECTAPPTHREADS), (int)CONFIG(PATCHVERSTRING), - (int)CONFIG(SHOWGBABOOT), (int)CONFIG(FORCEHEADPHONEOUTPUT), + (int)CONFIG(SHOWGBABOOT), 1 + (int)MULTICONFIG(DEFAULTEMU), 4 - (int)MULTICONFIG(BRIGHTNESS), splashPosStr, (unsigned int)cfg->splashDurationMsec, - pinNumDigits, n3dsCpuStr, (int)MULTICONFIG(AUTOBOOTMODE), + pinNumDigits, n3dsCpuStr, + autobootModeStr, forceAudioOutputStr, cfg->hbldr3dsxTitleId, rosalinaMenuComboStr, (int)cfg->ntpTzOffetMinutes, diff --git a/sysmodules/rosalina/source/shell.c b/sysmodules/rosalina/source/shell.c index b04d702e9..c867046d1 100644 --- a/sysmodules/rosalina/source/shell.c +++ b/sysmodules/rosalina/source/shell.c @@ -30,7 +30,7 @@ #include "screen_filters.h" #include "luma_config.h" -static void forceHeadphoneOutput(void) +static void forceAudioOutput(u32 forceOp) { // DSP/Codec sysmodule already have a way to force headphone output, // but it's only for when the shell is closed (applied on shell close, @@ -58,7 +58,19 @@ static void forceHeadphoneOutput(void) if (R_FAILED(res)) return; - u8 reg = 0x30; // Enable override selection (always set), then select HP. + u8 reg; + switch (forceOp) { + case 0: + default: + __builtin_trap(); + break; + case 1: + reg = 0x30; + break; + case 2: + reg = 0x20; + break; + } res = CDCCHK_WriteRegisters2(100, 69, ®, 1); svcCloseHandle(*cdcChkHandlePtr); @@ -67,8 +79,9 @@ static void forceHeadphoneOutput(void) void handleShellOpened(void) { s64 out = 0; - svcGetSystemInfo(&out, 0x10000, 3); - u32 config = (u32)out; + svcGetSystemInfo(&out, 0x10000, 4); + u32 multiConfig = (u32)out; + u32 forceOp = (multiConfig >> (2 * (u32)FORCEAUDIOOUTPUT)) & 3; // We need to check here if GSP has done its init stuff, in particular // clock and reset, otherwise we'll cause core1 to be in a waitstate @@ -77,6 +90,6 @@ void handleShellOpened(void) if (isServiceUsable("gsp::Gpu")) ScreenFiltersMenu_RestoreSettings(); - if ((config & BIT(FORCEHEADPHONEOUTPUT)) != 0 && isServiceUsable("cdc:CHK")) - forceHeadphoneOutput(); + if (forceOp != 0 && isServiceUsable("cdc:CHK")) + forceAudioOutput(forceOp); }