mirror of
https://gitee.com/anod/open_agb_firm.git
synced 2025-05-06 13:54:09 +08:00
重构按键映射的代码
This commit is contained in:
parent
c3a9952f89
commit
6525b85698
@ -3,10 +3,13 @@
|
||||
|
||||
#include "arm11/atp.h"
|
||||
#include "arm11/cheat.h"
|
||||
#include "arm11/keyremix.h"
|
||||
#include "arm11/open_agb_firm.h"
|
||||
|
||||
extern atp_error_t disp_str( atp_callerdata_t , atp_counter_t, atp_linecfg_t * );
|
||||
extern atp_error_t use_config_page( struct global_oaf_config* );
|
||||
extern atp_error_t use_cheat_page( const char* );
|
||||
extern atp_error_t use_keyremix_page( char *file );
|
||||
|
||||
extern atp_error_t help_page( atp_text_t *wording, atp_counter_t length );
|
||||
|
||||
|
@ -210,13 +210,6 @@ DECLARE_ERROR_PAGE( display_empty, "没有合适的文件" )
|
||||
DECLARE_ERROR_PAGE( display_toolong, "路径过长,改名或移动文件后再试" )
|
||||
DECLARE_ERROR_PAGE( display_pathfull, "游戏或目录过量,最多显示999个" )
|
||||
DECLARE_ERROR_PAGE( display_longname, "文件名总计过长,只显示前面的文件" )
|
||||
DECLARE_ERROR_PAGE( display_conflictkey, "和已有键位产生冲突" )
|
||||
|
||||
static atp_error_t disp_str( atp_callerdata_t data, atp_counter_t, atp_linecfg_t *cfg )
|
||||
{
|
||||
cfg->text = (atp_text_t)data;
|
||||
return ATP_SUCCESS;
|
||||
}
|
||||
|
||||
/*void log( const char *fmt, ... ) {
|
||||
char buf[512];
|
||||
@ -236,194 +229,6 @@ static atp_error_t disp_str( atp_callerdata_t data, atp_counter_t, atp_linecfg_t
|
||||
}while ( down == 0 );
|
||||
}*/
|
||||
|
||||
static inline void key_tips( key_remix_t *p, atp_boolean_t checking, atp_itemcfg_t *cfg )
|
||||
{
|
||||
if( p->remix_type == REMIX_TYPE_NONE )
|
||||
{
|
||||
cfg->extra_text = "未添加";
|
||||
cfg->extra_text_color = ATP_COLOR_LIGHT;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( p->remix_type == REMIX_TYPE_CHEAT )
|
||||
{
|
||||
if( checking && p->game_keys == 0)
|
||||
{
|
||||
cfg->extra_text = "配置不齐";
|
||||
cfg->extra_text_color = ATP_COLOR_RED;
|
||||
}
|
||||
else
|
||||
{
|
||||
cfg->extra_text = "金手指键";
|
||||
cfg->extra_text_color = ATP_COLOR_GREEN;
|
||||
}
|
||||
}
|
||||
else if( p->remix_type == REMIX_TYPE_REMAP )
|
||||
{
|
||||
if( checking && (p->game_keys==0 || p->device_keys==0) )
|
||||
{
|
||||
cfg->extra_text = "配置不齐";
|
||||
cfg->extra_text_color = ATP_COLOR_RED;
|
||||
}
|
||||
else
|
||||
{
|
||||
cfg->extra_text = "键位映射";
|
||||
cfg->extra_text_color = ATP_COLOR_GREEN;
|
||||
}
|
||||
}
|
||||
else if( p->remix_type == REMIX_TYPE_HOLD )
|
||||
{
|
||||
if( checking && (p->game_keys==0 || p->device_keys==0) )
|
||||
{
|
||||
cfg->extra_text = "配置不齐";
|
||||
cfg->extra_text_color = ATP_COLOR_RED;
|
||||
}
|
||||
else
|
||||
{
|
||||
cfg->extra_text = "模拟长按";
|
||||
cfg->extra_text_color = ATP_COLOR_GREEN;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define KCP_OPTION_BASE 1000
|
||||
static atp_error_t select_krp( atp_callerdata_t, atp_counter_t index, atp_itemcfg_t *cfg )
|
||||
{
|
||||
static char name[20];
|
||||
if( index < KEY_REMIX_LIMIT )
|
||||
{
|
||||
ee_snprintf(name, sizeof(name), "键位配置项%ld", index+1);
|
||||
cfg->text = name;
|
||||
cfg->value = index;
|
||||
key_remix_t *p = &g_keyremixConfig[index];
|
||||
key_tips(p, 1, cfg);
|
||||
}
|
||||
else
|
||||
{
|
||||
cfg->text = index == KEY_REMIX_LIMIT ? "保存当前配置到SD卡" : "从SD卡加载已保存的配置";
|
||||
cfg->value = KCP_OPTION_BASE + index-KEY_REMIX_LIMIT;
|
||||
}
|
||||
return ATP_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
#define KRFIELD_REMIX 0
|
||||
#define KRFIELD_DEVICE 1
|
||||
#define KRFIELD_GAME 2
|
||||
|
||||
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 )
|
||||
{
|
||||
key_remix_t *kcfg = (key_remix_t*)p;
|
||||
if( index == KRFIELD_REMIX )
|
||||
{
|
||||
cfg->text = "选择键位功能";
|
||||
key_tips(kcfg, 0, cfg);
|
||||
}
|
||||
else if( index == KRFIELD_DEVICE )
|
||||
{
|
||||
cfg->text = "选择实机键位";
|
||||
if( kcfg->device_keys )
|
||||
{
|
||||
for( u8 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_GREEN;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( kcfg->remix_type == REMIX_TYPE_CHEAT )
|
||||
{
|
||||
cfg->extra_text = "HOME";
|
||||
cfg->extra_text_color = ATP_COLOR_GREEN;
|
||||
}
|
||||
else
|
||||
{
|
||||
cfg->extra_text = "未设置";
|
||||
cfg->extra_text_color = ATP_COLOR_LIGHT;
|
||||
}
|
||||
}
|
||||
else if( index == KRFIELD_GAME )
|
||||
{
|
||||
cfg->text = "游戏中对应键位";
|
||||
if( kcfg->game_keys == 0 )
|
||||
{
|
||||
cfg->extra_text = "未设置";
|
||||
cfg->extra_text_color = ATP_COLOR_LIGHT;
|
||||
}
|
||||
else
|
||||
{
|
||||
cfg->extra_text = "已设置";
|
||||
cfg->extra_text_color = ATP_COLOR_GREEN;
|
||||
}
|
||||
}
|
||||
cfg->value = index;
|
||||
return ATP_SUCCESS;
|
||||
}
|
||||
|
||||
static atp_error_t select_remixtype( atp_callerdata_t, atp_counter_t index, atp_itemcfg_t *cfg )
|
||||
{
|
||||
if( index == REMIX_TYPE_NONE ) cfg->text = "停用设置";
|
||||
else if( index == REMIX_TYPE_REMAP ) cfg->text = "键位映射";
|
||||
else if( index == REMIX_TYPE_CHEAT ) cfg->text = "金手指键";
|
||||
else if( index == REMIX_TYPE_HOLD ) cfg->text = "模拟长按";
|
||||
cfg->value = index;
|
||||
return ATP_SUCCESS;
|
||||
}
|
||||
static atp_error_t select_unikey( atp_callerdata_t str, atp_counter_t, atp_itemcfg_t *cfg )
|
||||
{
|
||||
cfg->text = (atp_text_t)str;
|
||||
cfg->value = 0;
|
||||
return ATP_SUCCESS;
|
||||
}
|
||||
static atp_error_t select_hostkey( atp_callerdata_t dat, atp_counter_t index, atp_itemcfg_t *cfg )
|
||||
{
|
||||
phykey_t k = (phykey_t)dat;
|
||||
cfg->text = key_name[index];
|
||||
cfg->value = key_val[index];
|
||||
if( k == key_val[index] )
|
||||
{
|
||||
cfg->extra_text = "选中";
|
||||
cfg->extra_text_color = ATP_COLOR_GREEN;
|
||||
}
|
||||
return ATP_SUCCESS;
|
||||
}
|
||||
|
||||
static atp_error_t select_gbakey( atp_callerdata_t p_curkey, atp_counter_t index, atp_itemcfg_t *cfg )
|
||||
{
|
||||
conkey_t key = *(conkey_t*)p_curkey;
|
||||
cfg->text = key_name[index];
|
||||
cfg->value = key_val[index];
|
||||
if( key & key_val[index] )
|
||||
{
|
||||
cfg->extra_text = "选中";
|
||||
cfg->extra_text_color = ATP_COLOR_GREEN;
|
||||
}
|
||||
return ATP_SUCCESS;
|
||||
}
|
||||
|
||||
static atp_error_t active_gbakey( atp_callerdata_t p_curkey, atp_counter_t index, atp_boolean_t x, atp_boolean_t y, atp_boolean_t l, atp_boolean_t r, atp_boolean_t start, atp_boolean_t select )
|
||||
{
|
||||
conkey_t *pkey = (conkey_t*)p_curkey;
|
||||
if( x )
|
||||
{
|
||||
conkey_t res = *pkey & key_val[index];
|
||||
if( res ) *pkey &= ~key_val[index];
|
||||
else *pkey |= key_val[index];
|
||||
return ATP_PAGE_UPDATE;
|
||||
}
|
||||
else return ATP_PAGE_NOOPTION;
|
||||
}
|
||||
|
||||
extern atp_error_t oaf_config_page();
|
||||
|
||||
#define DIRBUFFSIZE 512
|
||||
@ -481,161 +286,12 @@ static atp_pageopt_t serve_on_key( atp_callerdata_t data, atp_counter_t index, a
|
||||
extern u8 dump_patched_rom;
|
||||
dump_patched_rom = 0;
|
||||
#endif
|
||||
atp_itemval_t position=0, field=0, value;
|
||||
atp_error_t res;
|
||||
atp_text_t oldtips;
|
||||
atp_tips( "确定A/返回B", &oldtips );
|
||||
|
||||
#define DISP_DONE 0
|
||||
#define DISP_KPOS 1
|
||||
#define DISP_SETK 2 // SET KEY
|
||||
#define DISP_KMAP 3 // REMUX TYPE
|
||||
#define DISP_3DSK 4 // 3DS KEY
|
||||
#define DISP_GBAK 5 // GBA KEY
|
||||
|
||||
uint8_t status = DISP_KPOS;
|
||||
char tips[32];
|
||||
while ( status != DISP_DONE )
|
||||
{
|
||||
if ( status == DISP_KPOS)
|
||||
{
|
||||
res = atp_select( "选择配置项后,按A进行键位配置", KEY_REMIX_LIMIT+2, select_krp, NULL, NULL, position, 0, &position );
|
||||
if( res == ATP_SUCCESS )
|
||||
{
|
||||
void* *dat = (void **)data;
|
||||
DirList const *dList = (DirList*)dat[0];
|
||||
char *file = &dList->ptrs[index][1];
|
||||
|
||||
if( position < KEY_REMIX_LIMIT )
|
||||
{
|
||||
status = DISP_SETK;
|
||||
field = 0;
|
||||
}
|
||||
else if( position == KCP_OPTION_BASE )
|
||||
{
|
||||
const char *err = keyremix_dump( file );
|
||||
if( !err ) status = DISP_DONE;
|
||||
else atp_show( 1, disp_str, err );
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *err = keyremix_load( file );
|
||||
if( !err ) position = 0;
|
||||
else atp_show( 1, disp_str, err );
|
||||
}
|
||||
}
|
||||
else break;
|
||||
}
|
||||
else if( status == DISP_SETK )
|
||||
{
|
||||
ee_snprintf(tips, sizeof(tips), "编辑配置项%ld", position+1);
|
||||
key_remix_t *cur = &g_keyremixConfig[position];
|
||||
res = atp_select( tips, 3, select_kcf, NULL, cur, field, 0, &field );
|
||||
if( res == ATP_SUCCESS )
|
||||
{
|
||||
status = field == KRFIELD_REMIX ? DISP_KMAP : (field == KRFIELD_DEVICE ? DISP_3DSK : DISP_GBAK);
|
||||
}
|
||||
else if( res == ATP_NO_ACTION )
|
||||
{
|
||||
int fault = 0;
|
||||
for( int i=0; i < KEY_REMIX_LIMIT; ++i )
|
||||
{
|
||||
if( i!=position )
|
||||
{
|
||||
if( g_keyremixConfig[i].remix_type == cur->remix_type
|
||||
&& g_keyremixConfig[i].device_keys == cur->device_keys )
|
||||
{
|
||||
fault = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( fault && cur->remix_type != REMIX_TYPE_NONE )
|
||||
atp_show(1, display_conflictkey, NULL);
|
||||
else status = DISP_KPOS;
|
||||
}
|
||||
else break;
|
||||
}
|
||||
else if( status == DISP_KMAP )
|
||||
{
|
||||
key_remix_t *cur = &g_keyremixConfig[position];
|
||||
res = atp_select( "配置键位功能", REMIX_TYPE_COUNT, select_remixtype, NULL, cur->remix_type, 0, 0, &value );
|
||||
if( res == ATP_SUCCESS )
|
||||
{
|
||||
if( cur->remix_type != value )
|
||||
{
|
||||
cur->remix_type = value;
|
||||
cur->device_keys = 0;
|
||||
cur->game_keys = value == REMIX_TYPE_CHEAT ? DEFAULT_CHEATKEY : 0;
|
||||
}
|
||||
status = DISP_SETK;
|
||||
}
|
||||
else if( res == ATP_NO_ACTION )
|
||||
{
|
||||
status = DISP_SETK;
|
||||
}
|
||||
else break;
|
||||
}
|
||||
else if( status == DISP_3DSK )
|
||||
{
|
||||
key_remix_t *cur = &g_keyremixConfig[position];
|
||||
atp_counter_t keys_count = 12; // old 3ds, old 3dsLL, 2ds
|
||||
u8 host = MCU_getSystemModel();// 0=3ds 1=3dsll 2=n3ds 3=2ds 4=n3dsll 5=n2dsll
|
||||
atp_text_t text;
|
||||
if( cur->remix_type == REMIX_TYPE_CHEAT )
|
||||
{
|
||||
keys_count = 1;
|
||||
text = "HOME";
|
||||
}
|
||||
else if( host > 1 && host != 3 ) // N3DS/N3DSLL/N2DSLL
|
||||
{
|
||||
keys_count = 14;
|
||||
}
|
||||
u8 selected = 31;
|
||||
for( u8 i=0; i < key_val_len; ++i )
|
||||
{
|
||||
if( key_val[i] == cur->device_keys )
|
||||
{
|
||||
selected = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( keys_count == 1 ) res = atp_select("选择实机键位(单选)", 1, select_unikey, NULL, text, 0, 0, &value);
|
||||
else res = atp_select( "选择实机键位(单选)", keys_count, select_hostkey, NULL, cur->device_keys, selected>keys_count?0:selected, 0, &value);
|
||||
if( res == ATP_SUCCESS )
|
||||
{
|
||||
cur->device_keys = value;
|
||||
status = DISP_SETK;
|
||||
}
|
||||
else if( res == ATP_NO_ACTION )
|
||||
{
|
||||
status = DISP_SETK;
|
||||
}
|
||||
else break;
|
||||
}
|
||||
else if( status == DISP_GBAK )
|
||||
{
|
||||
key_remix_t *cur = &g_keyremixConfig[position];
|
||||
conkey_t key_editing = cur->game_keys;
|
||||
atp_text_t current;
|
||||
atp_tips("选择X/确定A/返回B", ¤t);
|
||||
res = atp_select( "选择游戏中对应键位[多选,按X键设置选中]", 10, select_gbakey, active_gbakey, &key_editing, 0, 0, &value);
|
||||
atp_tips( current, NULL );
|
||||
if( res == ATP_SUCCESS )
|
||||
{
|
||||
cur->game_keys = key_editing;
|
||||
status = DISP_SETK;
|
||||
}
|
||||
else if( res == ATP_NO_ACTION )
|
||||
{
|
||||
status = DISP_SETK;
|
||||
}
|
||||
else break;
|
||||
}
|
||||
}
|
||||
atp_tips( oldtips, NULL );
|
||||
void* *dat = (void **)data;
|
||||
DirList const *dList = (DirList*)dat[0];
|
||||
char *file = &dList->ptrs[index][1];
|
||||
|
||||
return WAIT_ON_ACT(res);
|
||||
return WAIT_ON_ACT( use_keyremix_page(file) );
|
||||
}
|
||||
|
||||
return ATP_PAGE_NOOPTION;
|
||||
|
@ -1,6 +1,14 @@
|
||||
#include "types.h"
|
||||
#include "arm11/pages.h"
|
||||
#include "arm11/drivers/mcu.h"
|
||||
|
||||
atp_error_t disp_str( atp_callerdata_t data, atp_counter_t, atp_linecfg_t *cfg )
|
||||
{
|
||||
cfg->text = (atp_text_t)data;
|
||||
cfg->text_color = ATP_COLOR_RED;
|
||||
return ATP_SUCCESS;
|
||||
}
|
||||
|
||||
/// @brief base process for helping page
|
||||
/// @param table
|
||||
/// @param index
|
||||
@ -209,8 +217,6 @@ DECLARE_ERROR_PAGE( display_nocheat, "找不到对应的金手指配置" )
|
||||
|
||||
static atp_error_t select_region( atp_callerdata_t, atp_counter_t index, atp_itemcfg_t *config )
|
||||
{
|
||||
static char text[16];
|
||||
|
||||
acl_region_t sreg;
|
||||
acl_chtid_t sid, id;
|
||||
if( ACHTLIB_SUCCESS != acl_query_cheat_set(index, &sid, &sreg) )
|
||||
@ -233,7 +239,7 @@ static atp_error_t select_region( atp_callerdata_t, atp_counter_t index, atp_ite
|
||||
case 'X': case 'P': t = "欧洲语种"; break;
|
||||
default: t = "其他语种"; break;
|
||||
}
|
||||
ee_sprintf(text, "%c-%s", 'A'+(char)index, t);
|
||||
ee_sprintf(page_strbuf, "%c-%s", 'A'+(char)index, t);
|
||||
|
||||
if( CCHT_NOT_INIT == info_current_cheat( &id, NULL ) )
|
||||
id = 0;
|
||||
@ -295,7 +301,6 @@ static atp_error_t select_keys( atp_callerdata_t data, atp_counter_t index, atp_
|
||||
return ATP_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static atp_error_t select_onoff( atp_callerdata_t data, atp_counter_t index, atp_itemcfg_t *cfg )
|
||||
{
|
||||
acl_entryid_t eid = (acl_entryid_t)data;
|
||||
@ -344,13 +349,12 @@ ALWAYS_INLINE u16 calc_step( u16 value )
|
||||
|
||||
static atp_error_t step_provider( atp_callerdata_t mixid, atp_counter_t index, atp_itemcfg_t *cfg )
|
||||
{
|
||||
static char number[8];
|
||||
u32 mix = (u32)mixid;
|
||||
u16 max = mix & 0xffff;
|
||||
u16 step = mix >> 16;
|
||||
u16 res = step * (index+1);
|
||||
ee_snprintf( number, 8, "%d", res < max ? res : max );
|
||||
cfg->text = number;
|
||||
ee_snprintf( page_strbuf, 8, "%d", res < max ? res : max );
|
||||
cfg->text = page_strbuf;
|
||||
cfg->value = res < max ? res : max;
|
||||
return ATP_SUCCESS;
|
||||
}
|
||||
@ -392,11 +396,10 @@ static atp_error_t handle_onoff_entry( acl_entryid_t id, acl_elemlen_t codelen,
|
||||
atp_error_t res = atp_select( "选择此项目对应的设置", 3, select_onoff, NULL, targetval << 16 | id, 0, 0, item );
|
||||
if( res == ATP_SUCCESS && *item == 0 )
|
||||
{
|
||||
char title[24];
|
||||
ee_snprintf( title, sizeof(title), "默认值:%d", targetval );
|
||||
ee_snprintf( page_strbuf, sizeof(page_strbuf), "默认值:%d", targetval );
|
||||
u16 step = calc_step( targetval );
|
||||
atp_counter_t n = (targetval-1+step)/step;
|
||||
res = atp_select(title, n, step_provider, NULL, (atp_callerdata_t)(step<<16|targetval), n, 0, item );
|
||||
res = atp_select(page_strbuf, n, step_provider, NULL, (atp_callerdata_t)(step<<16|targetval), n, 0, item );
|
||||
if( res == ATP_SUCCESS && *item != targetval )
|
||||
overwrite_current_cheat( 1<<16|id, *item );
|
||||
|
||||
@ -508,6 +511,353 @@ atp_error_t use_cheat_page( const char *serial )
|
||||
}
|
||||
|
||||
acl_close_lib();
|
||||
atp_tips( oldtips, NULL );
|
||||
return res;
|
||||
}
|
||||
|
||||
// --------------------------
|
||||
// code for oaf cheat page
|
||||
// --------------------------
|
||||
|
||||
#define DISP_KPOS 1
|
||||
#define DISP_SETK 2 // SET KEY
|
||||
#define DISP_KMAP 3 // REMUX TYPE
|
||||
#define DISP_3DSK 4 // 3DS KEY
|
||||
#define DISP_GBAK 5 // GBA KEY
|
||||
|
||||
#define KCP_OPTION_BASE 1000
|
||||
|
||||
#define KRFIELD_REMIX 0
|
||||
#define KRFIELD_DEVICE 1
|
||||
#define KRFIELD_GAME 2
|
||||
|
||||
DECLARE_ERROR_PAGE( display_conflictkey, "和已有键位产生冲突" )
|
||||
|
||||
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_krp( atp_callerdata_t, atp_counter_t index, atp_itemcfg_t *cfg )
|
||||
{
|
||||
if( index < KEY_REMIX_LIMIT )
|
||||
{
|
||||
ee_snprintf(page_strbuf, sizeof(page_strbuf), "键位配置项%ld", index+1);
|
||||
cfg->text = page_strbuf;
|
||||
cfg->value = index;
|
||||
key_remix_t *p = &g_keyremixConfig[index];
|
||||
key_tips(p, 1, cfg);
|
||||
}
|
||||
else
|
||||
{
|
||||
cfg->text = index == KEY_REMIX_LIMIT ? "保存当前配置到SD卡" : "从SD卡加载已保存的配置";
|
||||
cfg->value = KCP_OPTION_BASE + index-KEY_REMIX_LIMIT;
|
||||
}
|
||||
return ATP_SUCCESS;
|
||||
}
|
||||
|
||||
static inline void key_tips( key_remix_t *p, atp_boolean_t checking, atp_itemcfg_t *cfg )
|
||||
{
|
||||
if( p->remix_type == REMIX_TYPE_NONE )
|
||||
{
|
||||
cfg->extra_text = "未添加";
|
||||
cfg->extra_text_color = ATP_COLOR_LIGHT;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( p->remix_type == REMIX_TYPE_CHEAT )
|
||||
{
|
||||
if( checking && p->game_keys == 0)
|
||||
{
|
||||
cfg->extra_text = "配置不齐";
|
||||
cfg->extra_text_color = ATP_COLOR_RED;
|
||||
}
|
||||
else
|
||||
{
|
||||
cfg->extra_text = "金手指键";
|
||||
cfg->extra_text_color = ATP_COLOR_GREEN;
|
||||
}
|
||||
}
|
||||
else if( p->remix_type == REMIX_TYPE_REMAP )
|
||||
{
|
||||
if( checking && (p->game_keys==0 || p->device_keys==0) )
|
||||
{
|
||||
cfg->extra_text = "配置不齐";
|
||||
cfg->extra_text_color = ATP_COLOR_RED;
|
||||
}
|
||||
else
|
||||
{
|
||||
cfg->extra_text = "键位映射";
|
||||
cfg->extra_text_color = ATP_COLOR_GREEN;
|
||||
}
|
||||
}
|
||||
else if( p->remix_type == REMIX_TYPE_HOLD )
|
||||
{
|
||||
if( checking && (p->game_keys==0 || p->device_keys==0) )
|
||||
{
|
||||
cfg->extra_text = "配置不齐";
|
||||
cfg->extra_text_color = ATP_COLOR_RED;
|
||||
}
|
||||
else
|
||||
{
|
||||
cfg->extra_text = "模拟长按";
|
||||
cfg->extra_text_color = ATP_COLOR_GREEN;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static atp_error_t select_kcf( atp_callerdata_t p, atp_counter_t index, atp_itemcfg_t *cfg )
|
||||
{
|
||||
key_remix_t *kcfg = (key_remix_t*)p;
|
||||
if( index == KRFIELD_REMIX )
|
||||
{
|
||||
cfg->text = "选择键位功能";
|
||||
key_tips(kcfg, 0, cfg);
|
||||
}
|
||||
else if( index == KRFIELD_DEVICE )
|
||||
{
|
||||
cfg->text = "选择实机键位";
|
||||
if( kcfg->device_keys )
|
||||
{
|
||||
for( u8 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_GREEN;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( kcfg->remix_type == REMIX_TYPE_CHEAT )
|
||||
{
|
||||
cfg->extra_text = "HOME";
|
||||
cfg->extra_text_color = ATP_COLOR_GREEN;
|
||||
}
|
||||
else
|
||||
{
|
||||
cfg->extra_text = "未设置";
|
||||
cfg->extra_text_color = ATP_COLOR_LIGHT;
|
||||
}
|
||||
}
|
||||
else if( index == KRFIELD_GAME )
|
||||
{
|
||||
cfg->text = "游戏中对应键位";
|
||||
if( kcfg->game_keys == 0 )
|
||||
{
|
||||
cfg->extra_text = "未设置";
|
||||
cfg->extra_text_color = ATP_COLOR_LIGHT;
|
||||
}
|
||||
else
|
||||
{
|
||||
cfg->extra_text = "已设置";
|
||||
cfg->extra_text_color = ATP_COLOR_GREEN;
|
||||
}
|
||||
}
|
||||
cfg->value = index;
|
||||
return ATP_SUCCESS;
|
||||
}
|
||||
static atp_error_t select_remixtype( atp_callerdata_t, atp_counter_t index, atp_itemcfg_t *cfg )
|
||||
{
|
||||
if( index == REMIX_TYPE_NONE ) cfg->text = "停用设置";
|
||||
else if( index == REMIX_TYPE_REMAP ) cfg->text = "键位映射";
|
||||
else if( index == REMIX_TYPE_CHEAT ) cfg->text = "金手指键";
|
||||
else if( index == REMIX_TYPE_HOLD ) cfg->text = "模拟长按";
|
||||
cfg->value = index;
|
||||
return ATP_SUCCESS;
|
||||
}
|
||||
static atp_error_t select_unikey( atp_callerdata_t str, atp_counter_t, atp_itemcfg_t *cfg )
|
||||
{
|
||||
cfg->text = (atp_text_t)str;
|
||||
cfg->value = 0;
|
||||
return ATP_SUCCESS;
|
||||
}
|
||||
static atp_error_t select_hostkey( atp_callerdata_t dat, atp_counter_t index, atp_itemcfg_t *cfg )
|
||||
{
|
||||
phykey_t k = (phykey_t)dat;
|
||||
cfg->text = key_name[index];
|
||||
cfg->value = key_val[index];
|
||||
if( k == key_val[index] )
|
||||
{
|
||||
cfg->extra_text = "选中";
|
||||
cfg->extra_text_color = ATP_COLOR_GREEN;
|
||||
}
|
||||
return ATP_SUCCESS;
|
||||
}
|
||||
|
||||
static atp_error_t select_gbakey( atp_callerdata_t p_curkey, atp_counter_t index, atp_itemcfg_t *cfg )
|
||||
{
|
||||
conkey_t key = *(conkey_t*)p_curkey;
|
||||
cfg->text = key_name[index];
|
||||
cfg->value = key_val[index];
|
||||
if( key & key_val[index] )
|
||||
{
|
||||
cfg->extra_text = "选中";
|
||||
cfg->extra_text_color = ATP_COLOR_GREEN;
|
||||
}
|
||||
return ATP_SUCCESS;
|
||||
}
|
||||
|
||||
static atp_error_t active_gbakey( atp_callerdata_t p_curkey, atp_counter_t index, atp_boolean_t x, atp_boolean_t y, atp_boolean_t l, atp_boolean_t r, atp_boolean_t start, atp_boolean_t select )
|
||||
{
|
||||
conkey_t *pkey = (conkey_t*)p_curkey;
|
||||
if( x )
|
||||
{
|
||||
conkey_t res = *pkey & key_val[index];
|
||||
if( res ) *pkey &= ~key_val[index];
|
||||
else *pkey |= key_val[index];
|
||||
return ATP_PAGE_UPDATE;
|
||||
}
|
||||
else return ATP_PAGE_NOOPTION;
|
||||
}
|
||||
|
||||
atp_error_t use_keyremix_page( char *file )
|
||||
{
|
||||
atp_itemval_t position=0, field=0, value;
|
||||
atp_error_t res;
|
||||
atp_text_t oldtips;
|
||||
atp_tips( "确定A/返回B", &oldtips );
|
||||
|
||||
uint8_t status = DISP_KPOS;
|
||||
while ( status != DISP_DONE )
|
||||
{
|
||||
if ( status == DISP_KPOS)
|
||||
{
|
||||
res = atp_select( "选择配置项后,按A进行键位配置", KEY_REMIX_LIMIT+2, select_krp, NULL, NULL, position, 0, &position );
|
||||
if( res == ATP_SUCCESS )
|
||||
{
|
||||
|
||||
if( position < KEY_REMIX_LIMIT )
|
||||
{
|
||||
status = DISP_SETK;
|
||||
field = 0;
|
||||
}
|
||||
else if( position == KCP_OPTION_BASE )
|
||||
{
|
||||
const char *err = keyremix_dump( file );
|
||||
if( !err ) status = DISP_DONE;
|
||||
else atp_show( 1, disp_str, err );
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *err = keyremix_load( file );
|
||||
if( !err ) position = 0;
|
||||
else atp_show( 1, disp_str, err );
|
||||
}
|
||||
}
|
||||
else break;
|
||||
}
|
||||
else if( status == DISP_SETK )
|
||||
{
|
||||
ee_snprintf(page_strbuf, sizeof(page_strbuf), "编辑配置项%ld", position+1);
|
||||
key_remix_t *cur = &g_keyremixConfig[position];
|
||||
res = atp_select( page_strbuf, 3, select_kcf, NULL, cur, field, 0, &field );
|
||||
if( res == ATP_SUCCESS )
|
||||
{
|
||||
status = field == KRFIELD_REMIX ? DISP_KMAP : (field == KRFIELD_DEVICE ? DISP_3DSK : DISP_GBAK);
|
||||
}
|
||||
else if( res == ATP_NO_ACTION )
|
||||
{
|
||||
int fault = 0;
|
||||
for( int i=0; i < KEY_REMIX_LIMIT; ++i )
|
||||
{
|
||||
if( i!=position )
|
||||
{
|
||||
if( g_keyremixConfig[i].remix_type == cur->remix_type
|
||||
&& g_keyremixConfig[i].device_keys == cur->device_keys )
|
||||
{
|
||||
fault = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( fault && cur->remix_type != REMIX_TYPE_NONE )
|
||||
atp_show(1, display_conflictkey, NULL);
|
||||
else status = DISP_KPOS;
|
||||
}
|
||||
else break;
|
||||
}
|
||||
else if( status == DISP_KMAP )
|
||||
{
|
||||
key_remix_t *cur = &g_keyremixConfig[position];
|
||||
res = atp_select( "配置键位功能", REMIX_TYPE_COUNT, select_remixtype, NULL, cur->remix_type, 0, 0, &value );
|
||||
if( res == ATP_SUCCESS )
|
||||
{
|
||||
if( cur->remix_type != value )
|
||||
{
|
||||
cur->remix_type = value;
|
||||
cur->device_keys = 0;
|
||||
cur->game_keys = value == REMIX_TYPE_CHEAT ? DEFAULT_CHEATKEY : 0;
|
||||
}
|
||||
status = DISP_SETK;
|
||||
}
|
||||
else if( res == ATP_NO_ACTION )
|
||||
{
|
||||
status = DISP_SETK;
|
||||
}
|
||||
else break;
|
||||
}
|
||||
else if( status == DISP_3DSK )
|
||||
{
|
||||
key_remix_t *cur = &g_keyremixConfig[position];
|
||||
atp_counter_t keys_count = 12; // old 3ds, old 3dsLL, 2ds
|
||||
u8 host = MCU_getSystemModel();// 0=3ds 1=3dsll 2=n3ds 3=2ds 4=n3dsll 5=n2dsll
|
||||
atp_text_t text;
|
||||
if( cur->remix_type == REMIX_TYPE_CHEAT )
|
||||
{
|
||||
keys_count = 1;
|
||||
text = "HOME";
|
||||
}
|
||||
else if( host > 1 && host != 3 ) // N3DS/N3DSLL/N2DSLL
|
||||
{
|
||||
keys_count = 14;
|
||||
}
|
||||
u8 selected = 31;
|
||||
for( u8 i=0; i < key_val_len; ++i )
|
||||
{
|
||||
if( key_val[i] == cur->device_keys )
|
||||
{
|
||||
selected = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( keys_count == 1 ) res = atp_select("选择实机键位(单选)", 1, select_unikey, NULL, text, 0, 0, &value);
|
||||
else res = atp_select( "选择实机键位(单选)", keys_count, select_hostkey, NULL, cur->device_keys, selected>keys_count?0:selected, 0, &value);
|
||||
if( res == ATP_SUCCESS )
|
||||
{
|
||||
cur->device_keys = value;
|
||||
status = DISP_SETK;
|
||||
}
|
||||
else if( res == ATP_NO_ACTION )
|
||||
{
|
||||
status = DISP_SETK;
|
||||
}
|
||||
else break;
|
||||
}
|
||||
else if( status == DISP_GBAK )
|
||||
{
|
||||
key_remix_t *cur = &g_keyremixConfig[position];
|
||||
conkey_t key_editing = cur->game_keys;
|
||||
atp_text_t current;
|
||||
atp_tips("选择X/确定A/返回B", ¤t);
|
||||
res = atp_select( "选择游戏中对应键位[多选,按X键设置选中]", 10, select_gbakey, active_gbakey, &key_editing, 0, 0, &value);
|
||||
atp_tips( current, NULL );
|
||||
if( res == ATP_SUCCESS )
|
||||
{
|
||||
cur->game_keys = key_editing;
|
||||
status = DISP_SETK;
|
||||
}
|
||||
else if( res == ATP_NO_ACTION )
|
||||
{
|
||||
status = DISP_SETK;
|
||||
}
|
||||
else break;
|
||||
}
|
||||
}
|
||||
|
||||
atp_tips( oldtips, NULL );
|
||||
return res;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user