//
// GJBaseGameLayer::handleButton from 0x9c264c to 0x9c28d8 (652 bytes)
//
// 3 xrefs:
// > GJBaseGameLayer::processQueuedButtons @ 0x9c2934
// > GJBaseGameLayer::updateReplay @ 0x9c2af8
// > ??> @ 0xd96a8
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// 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 12:58:30 +0000
//
__int64 __fastcall GJBaseGameLayer::handleButton(GJBaseGameLayer *this, unsigned __int8 a2, int a3, unsigned __int8 a4)
{
char *v4; // x22
unsigned int v5; // w21
int v7; // w20
__int64 result; // x0
unsigned int v10; // w24
GameManager *v11; // x0
GameManager *v12; // x0
unsigned __int8 hasActiveDualTouch; // w0
int v14; // w2
int v15; // w3
int v16; // w4
int v17; // w5
int v18; // w6
int v19; // w7
unsigned int v20; // w1
int v21; // w0
__int64 v22; // x0
PlayerObject *v23; // x0
int v24; // w0
PlayerObject *v25; // x0
char v26; // w0
unsigned int v27; // w2
__int64 v28; // x0
unsigned int v29; // w1
int v30; // w3
char v31; // w0
char vars0; // [xsp+0h] [xbp+0h]
v4 = (char *)this + 0x2000;
v5 = a4;
v7 = a2;
if ( *((_BYTE *)this + 12238) )
{
v22 = *((_QWORD *)this + 409);
if ( a2 )
*((_BYTE *)this + 1968) = 1;
v10 = *(unsigned __int8 *)(v22 + 340);
}
else
{
result = (unsigned int)(a3 - 2);
if ( (unsigned int)result <= 1 )
return result;
if ( a2 )
{
v28 = *((_QWORD *)this + 409);
*((_BYTE *)this + 1968) = 1;
v10 = *(unsigned __int8 *)(v28 + 340);
v11 = (GameManager *)*((unsigned __int8 *)this + 12448);
if ( !*((_BYTE *)this + 12448) )
{
LABEL_5:
v12 = (GameManager *)GameManager::sharedState(v11);
if ( (unsigned __int8)GameManager::getGameVariable(v12, "0010") )
v5 ^= 1u;
hasActiveDualTouch = GJEffectManager::hasActiveDualTouch(*((GJEffectManager **)this + 269));
v20 = hasActiveDualTouch;
if ( v7 )
goto LABEL_8;
LABEL_19:
if ( !v4[4012] )
goto LABEL_20;
goto LABEL_9;
}
}
else
{
v10 = *(unsigned __int8 *)(*((_QWORD *)this + 409) + 340LL);
v11 = (GameManager *)*((unsigned __int8 *)this + 12448);
if ( !*((_BYTE *)this + 12448) )
goto LABEL_5;
}
}
hasActiveDualTouch = GJEffectManager::hasActiveDualTouch(*((GJEffectManager **)this + 269));
v20 = hasActiveDualTouch;
if ( !v7 )
goto LABEL_19;
LABEL_8:
v4[4012] = hasActiveDualTouch;
LABEL_9:
if ( v5 < v20 )
goto LABEL_10;
LABEL_20:
if ( v5 >= v10 )
{
v23 = *((PlayerObject **)this + 407);
if ( v7 )
{
v24 = (unsigned __int8)PlayerObject::pushButton(v23, a3, v14, v15, v16, v17, v18, v19, vars0);
if ( v4[4012] )
goto LABEL_36;
}
else
{
v24 = (unsigned __int8)PlayerObject::releaseButton((__int64)v23, a3);
if ( v4[4012] )
goto LABEL_36;
}
if ( *((_BYTE *)this + 1010) && v5 <= (v10 ^ 1) )
goto LABEL_25;
LABEL_36:
if ( !v24 )
goto LABEL_10;
v27 = 0;
if ( v7 )
goto LABEL_38;
LABEL_46:
if ( (unsigned int)(a3 - 1) > 2 )
goto LABEL_10;
v29 = dword_116CFA0[a3 - 1];
goto LABEL_40;
}
if ( v4[4012] || !*((_BYTE *)this + 1010) || v5 > (v10 ^ 1) )
goto LABEL_10;
LABEL_25:
v25 = *((PlayerObject **)this + 408);
if ( !v7 )
{
v31 = PlayerObject::releaseButton((__int64)v25, a3);
v27 = v10;
if ( !v31 )
goto LABEL_10;
goto LABEL_46;
}
v26 = PlayerObject::pushButton(v25, a3, v14, v15, v16, v17, v18, v19, vars0);
v27 = v10;
if ( !v26 )
goto LABEL_10;
LABEL_38:
if ( (unsigned int)(a3 - 1) <= 2 )
{
v29 = dword_116CF90[a3 - 1];
LABEL_40:
if ( v29 )
{
if ( v27 )
v30 = 2;
else
v30 = 1;
GJBaseGameLayer::gameEventTriggered((__int64)this, v29, 0, v30);
}
LABEL_10:
if ( *(_BYTE *)(*((_QWORD *)this + 407) + 2424LL) )
goto LABEL_11;
goto LABEL_28;
}
if ( !*(_BYTE *)(*((_QWORD *)this + 407) + 2424LL) )
{
LABEL_28:
GJEffectManager::playerButton(*((GJEffectManager **)this + 269), v7, v5);
LABEL_11:
result = GJBaseGameLayer::recordAction(this, a3, v7, v10 & (v5 ^ 1));
if ( !v7 )
return result;
goto LABEL_12;
}
GJBaseGameLayer::recordAction(this, a3, v7, v10 & (v5 ^ 1));
LABEL_12:
v21 = *((_DWORD *)this + 3333);
++*((_DWORD *)this + 3052);
result = (unsigned int)(v21 + 1);
*((_DWORD *)this + 3333) = result;
if ( a3 == 1 )
{
result = 1;
v4[4024] = 1;
}
return result;
}