From 0fe6481aed6f4876bdc8caa4caa769f5f3ac120b Mon Sep 17 00:00:00 2001 From: anod <182859762@qq.com> Date: Mon, 24 Apr 2023 16:58:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E4=BF=AE=E6=AD=A3=E7=BA=A2?= =?UTF-8?q?=E5=B1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/arm11/filebrowser.c | 70 ++++++++++++++++++++++++-------------- 1 file changed, 44 insertions(+), 26 deletions(-) diff --git a/source/arm11/filebrowser.c b/source/arm11/filebrowser.c index 4ad2484..283e216 100644 --- a/source/arm11/filebrowser.c +++ b/source/arm11/filebrowser.c @@ -458,13 +458,8 @@ static atp_error_t select_keys( atp_callerdata_t data, atp_counter_t index, atp_ return ATP_SUCCESS; } -static atp_error_t select_krp( atp_callerdata_t, atp_counter_t index, atp_itemcfg_t *cfg ) +static inline void key_tips( key_remix_t *p, atp_itemcfg_t *cfg ) { - static char name[20]; - ee_snprintf(name, sizeof(name), "键位配置项%d", index+1); - cfg->text = name; - cfg->value = index; - key_remix_t *p = &g_keyremixConfig[index]; if( p->remix_type == REMIX_TYPE_NONE ) { cfg->extra_text = "未添加"; @@ -485,6 +480,16 @@ static atp_error_t select_krp( atp_callerdata_t, atp_counter_t index, atp_itemcf cfg->extra_text = "自动蓄力"; cfg->extra_text_color = ATP_COLOR_MAGENTA; } +} + +static atp_error_t select_krp( atp_callerdata_t, atp_counter_t index, atp_itemcfg_t *cfg ) +{ + static char name[20]; + ee_snprintf(name, sizeof(name), "键位配置项%d", index+1); + cfg->text = name; + cfg->value = index; + key_remix_t *p = &g_keyremixConfig[index]; + key_tips(p, cfg); return ATP_SUCCESS; } @@ -493,10 +498,36 @@ static atp_error_t select_krp( atp_callerdata_t, atp_counter_t index, atp_itemcf #define KRFIELD_DEVICE 1 #define KRFIELD_GAME 2 -static atp_error_t select_kcf( atp_callerdata_t, atp_counter_t index, atp_itemcfg_t *cfg ) +const char *key_name[] = { + "上", "下", "左", "右", "A", "B", "L", "R", "SELECT", "START", "X", "Y", "ZL", "ZR" +}; +const u16 key_val[] = { + KEY_DUP, KEY_DDOWN, KEY_DLEFT, KEY_DRIGHT, KEY_A, KEY_B, KEY_L, KEY_R, KEY_SELECT, KEY_START, KEY_X, KEY_Y, KEY_ZL, KEY_ZR +}; +#define key_val_len (sizeof(key_val)/sizeof(u16)) +static atp_error_t select_kcf( atp_callerdata_t p, atp_counter_t index, atp_itemcfg_t *cfg ) { - if( index == KRFIELD_REMIX ) cfg->text = "选择键位功能"; - else if( index == KRFIELD_DEVICE ) cfg->text = "选择实机键位"; + key_remix_t *kcfg = (key_remix_t*)p; + if( index == KRFIELD_REMIX ) + { + cfg->text = "选择键位功能"; + key_tips(kcfg, cfg);) + } + else if( index == KRFIELD_DEVICE ) + { + cfg->text = "选择实机键位"; + if( kcfg->device_keys ) + { + for( int i=0; i < key_val_len; ++i) + { + if( key_val[i] == kcfg->device_keys ) + { + cfg->extra_text = key_name[i]; + cfg->extra_text_color = ATP_COLOR_BLUE; + } + } + } + } else if( index == KRFIELD_GAME ) cfg->text = "游戏中对应键位"; cfg->value = index; return ATP_SUCCESS; @@ -512,17 +543,8 @@ static atp_error_t select_remixtype( atp_callerdata_t, atp_counter_t index, atp_ return ATP_SUCCESS; } -const char *key_name[] = { - "上", "下", "左", "右", "A", "B", "L", "R", "SELECT", "START", "X", "Y", "ZL", "ZR" -}; -const u16 key_val[] = { - KEY_DUP, KEY_DDOWN, KEY_DLEFT, KEY_DRIGHT, KEY_A, KEY_B, KEY_L, KEY_R, KEY_SELECT, KEY_START, KEY_X, KEY_Y, KEY_ZL, KEY_ZR -}; -static atp_error_t select_hostkey( atp_callerdata_t data, atp_counter_t index, atp_itemcfg_t *cfg ) +static atp_error_t select_hostkey( atp_callerdata_t len, atp_counter_t index, atp_itemcfg_t *cfg ) { - u32 mix = (u32)data; - u16 len = mix & 0xffff; - u16 key = mix >> 16; if( len == 1 ) // cheat { cfg->text = "HOME"; @@ -532,11 +554,6 @@ static atp_error_t select_hostkey( atp_callerdata_t data, atp_counter_t index, a { cfg->text = key_name[index]; cfg->value = key_val[index]; - if( index == key ) - { - cfg->extra_text = '选中'; - cfg->extra_text_color = ATP_COLOR_GREEN; - } } return ATP_SUCCESS; } @@ -763,7 +780,8 @@ static atp_pageopt_t serve_on_key( atp_callerdata_t data, atp_counter_t index, a else if( status == DISP_SETK ) { ee_snprintf(tips, sizeof(tips), "编辑配置项%d", position+1); - res = atp_select( tips, 3, select_kcf, NULL, NULL, 0, 0, &field ); + key_remix_t *cur = &g_keyremixConfig[position]; + res = atp_select( tips, 3, select_kcf, NULL, cur, 0, 0, &field ); if( res == ATP_SUCCESS ) { status = field == KRFIELD_REMIX ? DISP_KMAP : (field == KRFIELD_DEVICE ? DISP_3DSK : DISP_GBAK); @@ -806,7 +824,7 @@ static atp_pageopt_t serve_on_key( atp_callerdata_t data, atp_counter_t index, a break; } } - res = atp_select( "选择实机键位(单选)", keys_count, select_hostkey, NULL, (selected<<16)|(keys_count&0xffff), 0, 0, &value); + res = atp_select( "选择实机键位(单选)", keys_count, select_hostkey, NULL, keys_count, selected>keys_count?0:selected, 0, &value); if( res == ATP_SUCCESS ) { cur->device_keys = value;