From ef72e9772a469ab9c22bb57ad32f32c059ea972c Mon Sep 17 00:00:00 2001 From: anod <182859762@qq.com> Date: Wed, 23 Nov 2022 12:25:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E5=9C=A8=E5=8F=91=E7=8E=B0?= =?UTF-8?q?=E8=80=B3=E6=9C=BA=E6=8F=92=E5=85=A5=E5=90=8E=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E9=9F=B3=E9=A2=91=E8=BE=93=E5=87=BA=E8=AE=BE=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libn3ds/include/arm11/drivers/codec.h | 7 +------ libn3ds/source/arm11/drivers/codec.c | 11 +++++++++-- source/arm11/open_agb_firm.c | 9 ++------- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/libn3ds/include/arm11/drivers/codec.h b/libn3ds/include/arm11/drivers/codec.h index 172a0e8..b10b57e 100644 --- a/libn3ds/include/arm11/drivers/codec.h +++ b/libn3ds/include/arm11/drivers/codec.h @@ -55,9 +55,4 @@ void CODEC_wakeup(void); */ bool CODEC_getRawAdcData(CdcAdcData *data); -/** - * @brief Get the headphone connect state - * - * @return Returns true if headphone is connected - */ -u8 CODEC_isHeadsetUsing(void); \ No newline at end of file +void CODEC_soundSwitchOutput(void); \ No newline at end of file diff --git a/libn3ds/source/arm11/drivers/codec.c b/libn3ds/source/arm11/drivers/codec.c index da3911e..14266f1 100644 --- a/libn3ds/source/arm11/drivers/codec.c +++ b/libn3ds/source/arm11/drivers/codec.c @@ -759,7 +759,14 @@ bool CODEC_getRawAdcData(CdcAdcData *data) return false; } -u8 CODEC_isHeadsetUsing(void) +void CODEC_soundSwitchOutput(void) { - return readReg(CDC_REG_100_44) & 3u; + static u8 headset = 0; + u8 state = readReg(CDC_REG_100_44) & 3u; + if( state != headset ) + { + headset = state; + if( headset ) maskReg( CDC_REG_HEADSET_SEL, HEADSET_SEL_HP, 0xff); + else maskReg( CDC_REG_HEADSET_SEL, HEADSET_SEL_SP, 0xff); + } } \ No newline at end of file diff --git a/source/arm11/open_agb_firm.c b/source/arm11/open_agb_firm.c index 74ea5ae..7132367 100644 --- a/source/arm11/open_agb_firm.c +++ b/source/arm11/open_agb_firm.c @@ -168,7 +168,6 @@ static atp_error_t config_item( atp_callerdata_t, atp_counter_t index, atp_itemc { const char *scaler_val[] = {"上屏无缩放", "上屏GPU放大", "上屏DMA放大", "下屏无缩放"}; const char *savetype_name[] = {"和卡带序列号一致", "读取ROM的特定标记", "汉化带SRAM补丁", "自行决定"}; - const char *headphone_name[] = {"零", "壹", "贰", "叁"}; static char buf[16]; cfg->extra_text_color = ATP_COLOR_GREEN; if( index == 0 ) @@ -194,11 +193,6 @@ static atp_error_t config_item( atp_callerdata_t, atp_counter_t index, atp_itemc cfg->text = "存档方案"; cfg->extra_text = savetype_name[g_oafConfig.savePolicy]; } - else - { - cfg->text = "耳机状态"; - cfg->extra_text = headphone_name[CODEC_isHeadsetUsing()]; - } cfg->value = index; return ATP_SUCCESS; } @@ -262,7 +256,7 @@ atp_error_t oaf_config_page() title, sizeof(title), "参数配置           当前电量:%3d%%" "每次开机存档方案重置为“和卡带序列号一致”,这个方案会优先使用游戏最后一次启动时设置的存档类型", MCU_getBatteryLevel()); - atp_error_t res = atp_select( title, 5, config_item, config_adjust, NULL, 0, 0, NULL ); + atp_error_t res = atp_select( title, 4, config_item, config_adjust, NULL, 0, 0, NULL ); if( res == ATP_NO_ACTION ) { memcpy( &g_oafConfig, prev, sizeof(g_oafConfig) ); @@ -785,6 +779,7 @@ static void gbaGfxHandler(void *args) GFX_swapFramebufs(); //if(hidKeysDown() == (KEY_Y | KEY_SELECT)) dumpFrameTex(); + CODEC_soundSwitchOutput(); } taskExit();