mirror of
https://gitee.com/anod/open_agb_firm.git
synced 2025-05-06 13:54:09 +08:00
尝试修复一个模拟长按的问题:
条件:互换L/R的映射 + 模拟长按绑定游戏内L,启用后,按L会激发而不是R,但是L和R互换了,应该是R激发
This commit is contained in:
parent
29d74ba72c
commit
72fdff8858
@ -7,7 +7,8 @@
|
||||
key_remix_t g_keyremixConfig[KEY_REMIX_LIMIT];
|
||||
|
||||
static key_remix_t *frozen_start, *frozen_end;
|
||||
static phykey_t prev_status = 0;
|
||||
static phykey_t prev_phykey = 0;
|
||||
static conkey_t prev_conkey = 0;
|
||||
static conkey_t blind_conkey;
|
||||
static u16 flags_holding = 0;
|
||||
|
||||
@ -29,9 +30,11 @@ uint16_t keyremix_cheatkey()
|
||||
|
||||
void keyremix_freeze()
|
||||
{
|
||||
// 空白选项忽略,填充blind_conkey,金手指放首位
|
||||
// 空白选项忽略,填充blind_conkey,金手指放首位,REMAP紧跟金手指,HOLD在后面
|
||||
key_remix_t temp[KEY_REMIX_LIMIT+1];
|
||||
int j=1, has_cheat=0;
|
||||
|
||||
// 第一次循环:扫描得到各remix_type数量,用于定位在数组的位置
|
||||
int has_cheat=0, rem_count=0, valid_count=0;
|
||||
blind_conkey = 0;
|
||||
for( int i=0; i < KEY_REMIX_LIMIT; ++i )
|
||||
{
|
||||
@ -46,40 +49,60 @@ void keyremix_freeze()
|
||||
else if( p->remix_type != REMIX_TYPE_NONE
|
||||
&& p->device_keys != 0
|
||||
&& p->game_keys != 0 )
|
||||
{
|
||||
valid_count++;
|
||||
if( p->remix_type == REMIX_TYPE_REMAP ) rem_count++;
|
||||
if( p->device_keys & CON_KEY_MASK )
|
||||
blind_conkey |= p->device_keys;
|
||||
}
|
||||
}
|
||||
|
||||
// 第二次循环:根据remix_type放置到数组特定位置
|
||||
int j=has_cheat;
|
||||
int k=j+rem_count;
|
||||
for( int i=0; i < KEY_REMIX_LIMIT; ++i )
|
||||
{
|
||||
key_remix_t *p = &g_keyremixConfig[i];
|
||||
if( p->remix_type == REMIX_TYPE_CHEAT )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if( p->remix_type == REMIX_TYPE_REMAP
|
||||
&& p->device_keys != 0
|
||||
&& p->game_keys != 0 )
|
||||
{
|
||||
temp[j].remix_type = p->remix_type;
|
||||
temp[j].device_keys = p->device_keys;
|
||||
temp[j].game_keys = p->game_keys;
|
||||
if( p->device_keys & CON_KEY_MASK )
|
||||
blind_conkey |= p->device_keys;
|
||||
++j;
|
||||
}
|
||||
}
|
||||
memset( g_keyremixConfig, 0, sizeof(g_keyremixConfig) );
|
||||
if( has_cheat )
|
||||
else if( p->remix_type == REMIX_TYPE_HOLD
|
||||
&& p->device_keys != 0
|
||||
&& p->game_keys != 0 )
|
||||
{
|
||||
memcpy( g_keyremixConfig, temp, sizeof(key_remix_t)*j );
|
||||
frozen_start = &g_keyremixConfig[1];
|
||||
frozen_end = &g_keyremixConfig[j];
|
||||
temp[k].remix_type = p->remix_type;
|
||||
temp[k].device_keys = p->device_keys;
|
||||
temp[k].game_keys = p->game_keys;
|
||||
++k;
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy( g_keyremixConfig, &temp[1], sizeof(key_remix_t)*(j-1) );
|
||||
frozen_start = &g_keyremixConfig[0];
|
||||
frozen_end = &g_keyremixConfig[j-1];
|
||||
}
|
||||
memcpy( g_keyremixConfig, temp, sizeof(g_keyremixConfig) );
|
||||
frozen_start = &g_keyremixConfig[has_cheat];
|
||||
frozen_end = &g_keyremixConfig[has_cheat+valid_count];
|
||||
}
|
||||
|
||||
void keyremix_update( uint16_t active_cheatkey )
|
||||
{
|
||||
phykey_t now = hidKeysHeld();
|
||||
conkey_t cur = 0;
|
||||
u8 init_cur = 0;
|
||||
vu16 *hid_set = (vu16*)0x10141112;
|
||||
vu16 *hid_mode = (vu16*)0x10141110;
|
||||
|
||||
if( hidGetExtraKeys(0) & KEY_HOME )
|
||||
now |= VKEY_HOME;
|
||||
|
||||
if( active_cheatkey && now_release(now, prev_status, VKEY_HOME) )
|
||||
if( active_cheatkey && now_release(now, prev_phykey, VKEY_HOME) )
|
||||
{
|
||||
*hid_mode = active_cheatkey;
|
||||
*hid_set = ~active_cheatkey;
|
||||
@ -111,15 +134,20 @@ void keyremix_update( uint16_t active_cheatkey )
|
||||
}
|
||||
else if( p->remix_type == REMIX_TYPE_HOLD )
|
||||
{
|
||||
if( init_cur == 0 )
|
||||
{
|
||||
init_cur = 1;
|
||||
cur = res;
|
||||
}
|
||||
uint16_t flag = 1<<holding_pos++;
|
||||
uint16_t oldf = flags_holding;
|
||||
if( now_release(now, prev_status, p->device_keys) )
|
||||
if( now_release(now, prev_phykey, p->device_keys) )
|
||||
flags_holding ^= flag;
|
||||
|
||||
if( flags_holding & flag )
|
||||
{
|
||||
// exclude console keys is up
|
||||
res |= now_release(now, prev_status, p->game_keys) ^ p->game_keys;
|
||||
res |= now_release(cur, prev_conkey, p->game_keys) ^ p->game_keys;
|
||||
}
|
||||
else if( oldf != flags_holding )// release
|
||||
{
|
||||
@ -130,7 +158,8 @@ void keyremix_update( uint16_t active_cheatkey )
|
||||
*hid_mode = CON_KEY_MASK;
|
||||
*hid_set = ~res;
|
||||
}
|
||||
prev_status = now;
|
||||
prev_phykey = now;
|
||||
prev_conkey = cur;
|
||||
}
|
||||
|
||||
const char* keyremix_load( const char *file )
|
||||
|
Loading…
x
Reference in New Issue
Block a user