新增测试耳机插入检测函数

This commit is contained in:
anod 2022-11-22 14:22:23 +08:00
parent 8a5baf2490
commit 15a8ab234b
3 changed files with 20 additions and 1 deletions

View File

@ -54,3 +54,10 @@ void CODEC_wakeup(void);
* @return Returns true if data was available and false otherwise.
*/
bool CODEC_getRawAdcData(CdcAdcData *data);
/**
* @brief Get the headphone connect state
*
* @return Returns true if headphone is connected
*/
u8 CODEC_isHeadsetUsing(void);

View File

@ -758,3 +758,8 @@ bool CODEC_getRawAdcData(CdcAdcData *data)
return false;
}
u8 CODEC_isHeadsetUsing(void)
{
return readReg(CDC_REG_100_44) & 3u;
}

View File

@ -40,6 +40,7 @@
#include "arm11/atp.h"
#include "kernel.h"
#include "kevent.h"
#include "arm11/drivers/codec.h"
#define OAF_WORK_DIR "sdmc:/3ds/open_agb_firm"
@ -167,6 +168,7 @@ 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 )
@ -192,6 +194,11 @@ 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;
}
@ -255,7 +262,7 @@ atp_error_t oaf_config_page()
title, sizeof(title),
"参数配置           当前电量:%3d%%"
"每次开机存档方案重置为“和卡带序列号一致”,这个方案会优先使用游戏最后一次启动时设置的存档类型", MCU_getBatteryLevel());
atp_error_t res = atp_select( title, 4, config_item, config_adjust, NULL, 0, 0, NULL );
atp_error_t res = atp_select( title, 5, config_item, config_adjust, NULL, 0, 0, NULL );
if( res == ATP_NO_ACTION )
{
memcpy( &g_oafConfig, prev, sizeof(g_oafConfig) );