//
// GJBaseGameLayer::handleButton from 0x5a4c18 to 0x5a4da0 (392 bytes)
//
// 2 xrefs:
// > GJBaseGameLayer::processQueuedButtons @ 0x5a4dfe
// > GJBaseGameLayer::updateReplay @ 0x5a4f10
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:53:19 +0000
//
void __fastcall GJBaseGameLayer::handleButton(GJBaseGameLayer *this, _BOOL4 a2, int a3, int a4)
{
int v6; // r3
int v9; // r5
GameManager *v10; // r0
int hasActiveDualTouch; // r0
int v12; // r2
int v13; // r0
int v14; // r2
PlayerObject *v15; // r0
unsigned int v16; // r3
int v17; // r1
int v18; // r3
char v19; // r3
v6 = *((unsigned __int8 *)this + 10614);
if ( *((_BYTE *)this + 10614) )
{
if ( !a2 )
{
v9 = *(unsigned __int8 *)(*((_DWORD *)this + 521) + 280);
goto LABEL_8;
}
goto LABEL_4;
}
if ( (unsigned int)(a3 - 2) <= 1 )
return;
if ( a2 )
{
LABEL_4:
*((_BYTE *)this + 1424) = 1;
v9 = *(unsigned __int8 *)(*((_DWORD *)this + 521) + 280);
if ( v6 )
goto LABEL_8;
goto LABEL_5;
}
v9 = *(unsigned __int8 *)(*((_DWORD *)this + 521) + 280);
LABEL_5:
if ( !*((_BYTE *)this + 10728) )
{
v10 = (GameManager *)GameManager::sharedState(this);
if ( GameManager::getGameVariable(v10, "0010") )
a4 ^= 1u;
}
LABEL_8:
hasActiveDualTouch = GJEffectManager::hasActiveDualTouch(*((GJEffectManager **)this + 381));
if ( a2 )
{
*((_BYTE *)this + 10580) = hasActiveDualTouch;
if ( a4 )
{
LABEL_15:
v13 = PlayerObject::pushButton(*((PlayerObject **)this + 519), a3, v12);
goto LABEL_19;
}
}
else
{
if ( !*((_BYTE *)this + 10580) )
{
if ( !a4 )
goto LABEL_13;
LABEL_17:
v13 = PlayerObject::releaseButton(*((_DWORD *)this + 519), a3, v12);
goto LABEL_19;
}
if ( a4 )
goto LABEL_17;
}
if ( hasActiveDualTouch )
goto LABEL_42;
LABEL_13:
if ( !v9 )
{
if ( a2 )
goto LABEL_15;
goto LABEL_17;
}
v13 = 0;
LABEL_19:
v14 = *((unsigned __int8 *)this + 10580);
if ( *((_BYTE *)this + 10580) )
{
v14 = 0;
LABEL_29:
if ( !v13 )
goto LABEL_42;
if ( !v9 )
v14 = 0;
goto LABEL_32;
}
if ( !*((_BYTE *)this + 866) )
{
v14 = *((unsigned __int8 *)this + 866);
goto LABEL_29;
}
if ( !a4 || !v9 )
{
v15 = *((PlayerObject **)this + 520);
if ( a2 )
v13 = PlayerObject::pushButton(v15, a3, v14);
else
v13 = PlayerObject::releaseButton((int)v15, a3, v14);
v14 = 1;
goto LABEL_29;
}
if ( !v13 )
goto LABEL_42;
LABEL_32:
v16 = a3 - 1;
if ( a2 )
{
if ( v16 <= 2 )
{
v17 = *((unsigned __int8 *)&unk_BEE010 + v16 + 108);
goto LABEL_37;
}
}
else if ( v16 <= 2 )
{
v17 = *((unsigned __int8 *)&unk_BEE010 + v16 + 112);
LABEL_37:
if ( v17 )
{
if ( v14 )
v18 = 2;
else
v18 = 1;
GJBaseGameLayer::gameEventTriggered((int **)this, v17, 0, v18);
}
}
LABEL_42:
if ( !*(_BYTE *)(*((_DWORD *)this + 519) + 1960) )
GJEffectManager::playerButton(*((GJEffectManager **)this + 381), a2, a4);
if ( v9 )
v19 = a4 ^ 1;
else
v19 = 0;
GJBaseGameLayer::recordAction(this, a3, a2, v19);
if ( a2 )
{
++*((_DWORD *)this + 2646);
++*((_DWORD *)this + 2817);
if ( a3 == 1 )
*((_BYTE *)this + 10592) = 1;
}
}