mirror of
https://gitee.com/anod/open_agb_firm.git
synced 2025-05-06 22:04:10 +08:00
commit
8520b83131
@ -9,6 +9,8 @@
|
|||||||
#define REMIX_TYPE_HOLD 3
|
#define REMIX_TYPE_HOLD 3
|
||||||
#define REMIX_TYPE_COUNT 4
|
#define REMIX_TYPE_COUNT 4
|
||||||
|
|
||||||
|
#define KEYREMIX_OUTPUT_DIR "keymaps"
|
||||||
|
|
||||||
#include "arm11/drivers/hid.h"
|
#include "arm11/drivers/hid.h"
|
||||||
#define DEFAULT_CHEATKEY (KEY_DDOWN|KEY_L|KEY_R|KEY_SELECT)
|
#define DEFAULT_CHEATKEY (KEY_DDOWN|KEY_L|KEY_R|KEY_SELECT)
|
||||||
|
|
||||||
@ -29,5 +31,7 @@ extern key_remix_t g_keyremixConfig[KEY_REMIX_LIMIT];
|
|||||||
uint16_t keyremix_cheatkey();
|
uint16_t keyremix_cheatkey();
|
||||||
void keyremix_freeze();
|
void keyremix_freeze();
|
||||||
void keyremix_update( uint16_t active_cheatkey );
|
void keyremix_update( uint16_t active_cheatkey );
|
||||||
|
const char* keyremix_dump( const char* gbafile );
|
||||||
|
const char* keyremix_load( const char* gbafile );
|
||||||
|
|
||||||
#endif//_KEY_REMIX_H_
|
#endif//_KEY_REMIX_H_
|
||||||
|
@ -504,21 +504,30 @@ static inline void key_tips( key_remix_t *p, atp_boolean_t checking, atp_itemcfg
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cfg->extra_text = "自动蓄力";
|
cfg->extra_text = "模拟长按";
|
||||||
cfg->extra_text_color = ATP_COLOR_GREEN;
|
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 atp_error_t select_krp( atp_callerdata_t, atp_counter_t index, atp_itemcfg_t *cfg )
|
||||||
{
|
{
|
||||||
static char name[20];
|
static char name[20];
|
||||||
ee_snprintf(name, sizeof(name), "键位配置项%ld", index+1);
|
if( index < KEY_REMIX_LIMIT )
|
||||||
cfg->text = name;
|
{
|
||||||
cfg->value = index;
|
ee_snprintf(name, sizeof(name), "键位配置项%ld", index+1);
|
||||||
key_remix_t *p = &g_keyremixConfig[index];
|
cfg->text = name;
|
||||||
key_tips(p, 1, cfg);
|
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;
|
return ATP_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -590,7 +599,7 @@ static atp_error_t select_remixtype( atp_callerdata_t, atp_counter_t index, atp_
|
|||||||
if( index == REMIX_TYPE_NONE ) cfg->text = "停用设置";
|
if( index == REMIX_TYPE_NONE ) cfg->text = "停用设置";
|
||||||
else if( index == REMIX_TYPE_REMAP ) cfg->text = "键位映射";
|
else if( index == REMIX_TYPE_REMAP ) cfg->text = "键位映射";
|
||||||
else if( index == REMIX_TYPE_CHEAT ) cfg->text = "金手指键";
|
else if( index == REMIX_TYPE_CHEAT ) cfg->text = "金手指键";
|
||||||
else if( index == REMIX_TYPE_HOLD ) cfg->text = "自动蓄力";
|
else if( index == REMIX_TYPE_HOLD ) cfg->text = "模拟长按";
|
||||||
cfg->value = index;
|
cfg->value = index;
|
||||||
return ATP_SUCCESS;
|
return ATP_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -827,11 +836,30 @@ static atp_pageopt_t serve_on_key( atp_callerdata_t data, atp_counter_t index, a
|
|||||||
{
|
{
|
||||||
if ( status == DISP_KPOS)
|
if ( status == DISP_KPOS)
|
||||||
{
|
{
|
||||||
res = atp_select( "选择配置项后,按A进行键位配置", KEY_REMIX_LIMIT, select_krp, NULL, NULL, position, 0, &position );
|
res = atp_select( "选择配置项后,按A进行键位配置", KEY_REMIX_LIMIT+2, select_krp, NULL, NULL, position, 0, &position );
|
||||||
if( res == ATP_SUCCESS )
|
if( res == ATP_SUCCESS )
|
||||||
{
|
{
|
||||||
status = DISP_SETK;
|
void* *dat = (void **)data;
|
||||||
field = 0;
|
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 break;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include "fs.h"
|
||||||
|
#include "fsutil.h"
|
||||||
|
#include "drivers/lgy.h"
|
||||||
#include "arm11/keyremix.h"
|
#include "arm11/keyremix.h"
|
||||||
|
|
||||||
key_remix_t g_keyremixConfig[KEY_REMIX_LIMIT];
|
key_remix_t g_keyremixConfig[KEY_REMIX_LIMIT];
|
||||||
@ -8,6 +11,8 @@ static phykey_t prev_status = 0;
|
|||||||
static conkey_t blind_conkey;
|
static conkey_t blind_conkey;
|
||||||
static u16 flags_holding = 0;
|
static u16 flags_holding = 0;
|
||||||
|
|
||||||
|
#define DIR_SEPARATOR "/"
|
||||||
|
#define OUTPUT_DIR (KEYREMIX_OUTPUT_DIR##DIR_SEPARATOR)
|
||||||
#define VKEY_HOME (1u<<21)
|
#define VKEY_HOME (1u<<21)
|
||||||
#define now_release( now, prev, key ) ((~(now))&(prev)&(key))
|
#define now_release( now, prev, key ) ((~(now))&(prev)&(key))
|
||||||
#define CON_KEY_MASK (KEY_A|KEY_B|KEY_L|KEY_R|KEY_SELECT|KEY_START|KEY_DUP|KEY_DDOWN|KEY_DLEFT|KEY_DRIGHT)
|
#define CON_KEY_MASK (KEY_A|KEY_B|KEY_L|KEY_R|KEY_SELECT|KEY_START|KEY_DUP|KEY_DDOWN|KEY_DLEFT|KEY_DRIGHT)
|
||||||
@ -77,6 +82,10 @@ void keyremix_update( uint16_t active_cheatkey )
|
|||||||
*hid_mode = active_cheatkey;
|
*hid_mode = active_cheatkey;
|
||||||
*hid_set = ~active_cheatkey;
|
*hid_set = ~active_cheatkey;
|
||||||
}
|
}
|
||||||
|
else if( frozen_end == frozen_start )// 空白键位设置,走原来流程就好
|
||||||
|
{
|
||||||
|
LGY_handleOverrides();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
conkey_t res = now & CON_KEY_MASK;
|
conkey_t res = now & CON_KEY_MASK;
|
||||||
@ -121,3 +130,46 @@ void keyremix_update( uint16_t active_cheatkey )
|
|||||||
}
|
}
|
||||||
prev_status = now;
|
prev_status = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* keyremix_load( const char *file )
|
||||||
|
{
|
||||||
|
char output[512];
|
||||||
|
int len = strlen( file ) + strlen(OUTPUT_DIR);
|
||||||
|
if( len+1 > 512 ) return "文件名太长,无法保存";
|
||||||
|
strcpy( output, OUTPUT_DIR );
|
||||||
|
strcpy( &output[strlen(OUTPUT_DIR)], file );
|
||||||
|
output[len] = '\0';
|
||||||
|
output[len-1] = 'm';
|
||||||
|
output[len-2] = 'r';
|
||||||
|
output[len-3] = 'k';
|
||||||
|
|
||||||
|
FILINFO fi;
|
||||||
|
const char *retval = NULL;
|
||||||
|
if( fStat(output, &fi) == RES_OK )
|
||||||
|
{
|
||||||
|
u8 dat[sizeof(g_keyremixConfig)];
|
||||||
|
if( RES_OK == fsQuickRead(output, dat, sizeof(dat) ) )
|
||||||
|
memcpy( g_keyremixConfig, dat, sizeof(g_keyremixConfig) );
|
||||||
|
else retval = "读文件失败";
|
||||||
|
}
|
||||||
|
else retval = "文件不存在";
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* keyremix_dump( const char *file )
|
||||||
|
{
|
||||||
|
char output[512];
|
||||||
|
int len = strlen( file ) + strlen(OUTPUT_DIR);
|
||||||
|
if( len+1 > 512 ) return "文件名太长,无法保存";
|
||||||
|
strcpy( output, OUTPUT_DIR );
|
||||||
|
strcpy( &output[strlen(OUTPUT_DIR)], file );
|
||||||
|
output[len] = '\0';
|
||||||
|
output[len-1] = 'm';
|
||||||
|
output[len-2] = 'r';
|
||||||
|
output[len-3] = 'k';
|
||||||
|
|
||||||
|
const char *retval = NULL;
|
||||||
|
if( RES_OK != fsQuickWrite(output, g_keyremixConfig, sizeof(g_keyremixConfig)) )
|
||||||
|
retval = "保存失败";
|
||||||
|
return retval;
|
||||||
|
}
|
@ -1041,6 +1041,7 @@ Result oafParseConfigEarly(void)
|
|||||||
// Create the saves folder.
|
// Create the saves folder.
|
||||||
if((res = fMkdir(OAF_SAVE_DIR)) != RES_OK && res != RES_FR_EXIST) break;
|
if((res = fMkdir(OAF_SAVE_DIR)) != RES_OK && res != RES_FR_EXIST) break;
|
||||||
|
|
||||||
|
if((res = fMkdir(KEYREMIX_OUTPUT_DIR)) != RES_OK && res != RES_FR_EXIST) break;
|
||||||
if((res = acf_initialize("wqy11.fnt")) != RES_OK ) break;
|
if((res = acf_initialize("wqy11.fnt")) != RES_OK ) break;
|
||||||
|
|
||||||
// Parse the config.
|
// Parse the config.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user