Implemented proper headphone detection.

Added a config option to override the audio output.
This commit is contained in:
profi200 2023-08-05 02:07:13 +02:00
parent 30351188a4
commit 726a4f3355
No known key found for this signature in database
GPG Key ID: FD2BAB7782919B0A
2 changed files with 27 additions and 3 deletions

View File

@ -76,6 +76,12 @@ Video-related settings.
`float brightness` - Screen lift
* Default: `0.0`
### Audio
Audio settings.
`u8 audioOut` - Audio output. 0 = auto, 1 = speakers, 2 = headphones.
* Default: `0`
### Game
Game-specific settings. Only intended to be used in the per-game settings (romName.ini in `/3ds/open_agb_firm/saves`).
@ -201,4 +207,4 @@ You may use this under the terms of the GNU General Public License GPL v3 or the
* **Oleh Prypin (oprypin) for nightly.link**
* ...everyone who contributed to **3dbrew.org**
Copyright (C) 2021 derrek, profi200, d0k3
Copyright (C) 2021 derrek, profi200, d0k3

View File

@ -36,6 +36,7 @@
#include "arm11/filebrowser.h"
#include "arm11/drivers/lcd.h"
#include "arm11/gpu_cmd_lists.h"
#include "arm11/drivers/codec.h"
#include "arm11/drivers/mcu.h"
#include "arm11/patch.h"
#include "kernel.h"
@ -56,6 +57,8 @@
"lcdGamma=1.54\n" \
"contrast=1.0\n" \
"brightness=0.0\n\n" \
"[audio]\n" \
"audioOut=0\n\n" \
"[advanced]\n" \
"saveOverride=false\n" \
"defaultSave=14"
@ -69,12 +72,15 @@ typedef struct
bool useGbaDb;
// [video]
u8 scaler; // 0 = 1:1, 1 = bilinear (GPU) x1.5, 2 = matrix (hardware) x1.5.
u8 scaler; // 0 = 1:1, 1 = bilinear (GPU) x1.5, 2 = matrix (hardware) x1.5.
float gbaGamma;
float lcdGamma;
float contrast;
float brightness;
// [audio]
u8 audioOut; // 0 = auto, 1 = speakers, 2 = headphones.
// [game]
u8 saveSlot;
u8 saveType;
@ -109,9 +115,12 @@ static OafConfig g_oafConfig =
1.f, // contrast
0.f, // brightness
// [audio]
0, // Automatic audio output.
// [game]
0, // saveSlot
0xFF, // saveType
0xFF, // saveType
// [advanced]
false, // saveOverride
@ -507,6 +516,7 @@ static void gbaGfxHandler(void *args)
GFX_waitForP3D();
GX_displayTransfer((u32*)(0x18180000 + (16 * 240 * 3)), 368u<<16 | 240u,
GFX_getFramebuffer(SCREEN_TOP) + (16 * 240 * 3), 368u<<16 | 240u, 1u<<12 | 1u<<8);
CODEC_runHeadphoneDetection(); // Run headphone detection while PPF is busy.
GFX_waitForPPF();
GFX_swapFramebufs();
@ -546,6 +556,11 @@ static int cfgIniCallback(void* user, const char* section, const char* name, con
else if(strcmp(name, "brightness") == 0)
config->brightness = str2float(value);
}
else if(strcmp(section, "audio") == 0)
{
if(strcmp(name, "audioOut") == 0)
config->audioOut = (u8)strtoul(value, NULL, 10);
}
else if(strcmp(section, "game") == 0)
{
if(strcmp(name, "saveSlot") == 0)
@ -745,6 +760,9 @@ Result oafInitAndRun(void)
{
do
{
// Set audio output.
CODEC_setAudioOutput(g_oafConfig.audioOut);
// Try to load the ROM path from autoboot.txt.
// If this file doesn't exist show the file browser.
if((res = fsLoadPathFromFile("autoboot.txt", filePath)) == RES_FR_NO_FILE)