//
// GJBaseGameLayer::handleButton from 0x10014aba0 to 0x10014ad97 (503 bytes)
//
// 2 xrefs:
// > GJBaseGameLayer::processQueuedButtons @ 0x10014aae3
// > GJBaseGameLayer::processQueuedButtons @ 0x10014ab53
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
void __fastcall GJBaseGameLayer::handleButton(GJBaseGameLayer *a1, bool a2, int a3, bool a4)
{
bool m_twoPlayerMode; // r14
GameManager *v9; // rax
bool hasActiveDualTouch; // al
PlayerObject *m_player1; // rdi
bool v12; // al
PlayerObject *m_player2; // rdi
bool v14; // al
bool v15; // cl
GJGameEvent v16; // esi
bool v17; // al
m_twoPlayerMode = a1->m_levelSettings->m_twoPlayerMode;
if ( !a1->m_isPlatformer && !a1->m_useReplay )
{
v9 = GameManager::sharedState();
a4 ^= GameManager::getGameVariable(v9, "0010");
}
hasActiveDualTouch = GJEffectManager::hasActiveDualTouch(a1->m_effectManager);
if ( a2 )
{
a1->m_dualTouchTrigger = hasActiveDualTouch;
if ( !a4 && hasActiveDualTouch )
goto LABEL_36;
}
else if ( !a4 && a1->m_dualTouchTrigger && hasActiveDualTouch )
{
goto LABEL_36;
}
if ( a4 || !m_twoPlayerMode )
{
m_player1 = a1->m_player1;
if ( a2 )
v12 = PlayerObject::pushButton(m_player1, (PlayerButton)a3);
else
v12 = PlayerObject::releaseButton(m_player1, (PlayerButton)a3);
if ( a1->m_dualTouchTrigger )
{
LABEL_20:
if ( !v12 )
goto LABEL_36;
v15 = 0;
if ( a2 )
{
LABEL_22:
switch ( a3 )
{
case 1:
v16 = JumpPush;
break;
case 3:
v16 = RightPush;
break;
case 2:
v16 = LeftPush;
break;
default:
goto LABEL_36;
}
LABEL_35:
GJBaseGameLayer::gameEventTriggered(a1, v16, 0, v15 + 1);
goto LABEL_36;
}
LABEL_27:
switch ( a3 )
{
case 1:
v16 = JumpRelease;
break;
case 3:
v16 = RightRelease;
break;
case 2:
v16 = LeftRelease;
break;
default:
goto LABEL_36;
}
goto LABEL_35;
}
}
else
{
v12 = 0;
if ( a1->m_dualTouchTrigger )
goto LABEL_20;
}
if ( !a1->m_gameState.m_isDualMode || m_twoPlayerMode && a4 )
goto LABEL_20;
m_player2 = a1->m_player2;
if ( !a2 )
{
v17 = PlayerObject::releaseButton(m_player2, (PlayerButton)a3);
v15 = m_twoPlayerMode;
if ( !v17 )
goto LABEL_36;
goto LABEL_27;
}
v14 = PlayerObject::pushButton(m_player2, (PlayerButton)a3);
v15 = m_twoPlayerMode;
if ( v14 )
goto LABEL_22;
LABEL_36:
if ( a1->m_player1->m_isDead )
{
if ( a1->m_useReplay )
goto LABEL_38;
}
else
{
GJEffectManager::playerButton(a1->m_effectManager, a2, a4);
if ( a1->m_useReplay )
{
LABEL_38:
if ( !a2 )
return;
goto LABEL_42;
}
}
GJBaseGameLayer::recordAction(a1, a3, a2, !a4 && m_twoPlayerMode);
if ( !a2 )
return;
LABEL_42:
++a1->m_clicks;
++a1->m_clickIndex;
if ( a3 == 1 )
a1->m_jumping = 1;
}