반응형
아래 소스의 연사버턴의 구현에 대한 코드가 거의 전부이다.
적당한 시간 계산과 무조건 연사발동 그리고 연사 해제까지 있다.
연사 버턴이라고 해서 무조건 누르고 있는것은 아니라 적당한 시점에서 조금씩 버턴을 off 시켜야 한다.
void Gamepad::auto_button_function(int idx, GamepadButtonMapping *mapButtonB, uint32_t pinMask)
{
static int auto_cnt[8];
static uint32_t pre_BTN[8];
static uint32_t off_Time[8];
static uint32_t on_Time[8];
static int auto_delaytime[8] = { 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000,};
bool bauto;
if(g_BTN[idx] == 0 || g_BTN[idx] == 1)
{
if ( (pinMask) && pre_BTN[idx] == pinMask)
{
if ((g_BTN[idx] == 1) || (getMillis() - off_Time[idx]> auto_delaytime[idx]))
{
auto_cnt[idx]++;
if (auto_cnt[idx]== 3) auto_cnt[idx] = 0;
bauto = true;
}
else
{
bauto = false;
}
}
else
{
off_Time[idx] = getMillis();
pre_BTN[idx] = pinMask;
bauto = false;
if (getMillis() - on_Time[idx]> 10000) auto_delaytime[idx]= 2000;
}
}
else if(g_BTN[idx] == 2)
{
bauto = false;
}
if (bauto)
{
state.buttons |= ((auto_cnt[idx]%2!=0) ? 0 : mapButtonB->buttonMask );
auto_delaytime[idx] = 500;
on_Time[idx] = getMillis();
}
else state.buttons |= ((pinMask) ? mapButtonB->buttonMask : 0);
return ;
}
'오락실' 카테고리의 다른 글
레트로아크 설정 회전편 -#1 (0) | 2022.06.18 |
---|---|
ES, 레트로아크 그리고 코어 -#2 (0) | 2022.06.18 |
ES, 레트로아크 그리고 코어 -#1 (0) | 2022.06.18 |
소프트웨어로 구현하는 오락실 연사버턴- #1 (0) | 2022.04.03 |
오락실게임 세로 설정 (0) | 2022.02.10 |
댓글