//
// cocos2d::CCKeypadDispatcher::dispatchKeypadMSG from 0x1005f9770 to 0x1005f99f4 (644 bytes)
//
// 2 xrefs:
// > cocos2d::CCLayer::keyDown @ 0x1004b0e7b
// > sub_1004B0E90 @ 0x1004b0ebb
//
// 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
//
bool __fastcall cocos2d::CCKeypadDispatcher::dispatchKeypadMSG(
cocos2d::CCKeypadDispatcher *a1,
cocos2d::ccKeypadMSGType a2)
{
cocos2d::CCKeypadDispatcher *v2; // rbx
cocos2d::CCArray *v3; // r14
int v4; // eax
cocos2d::CCKeypadHandler *v5; // rax
cocos2d::CCKeypadDelegate *v6; // rax
cocos2d::CCArray *m_pDelegates; // r14
int v8; // eax
cocos2d::CCKeypadHandler *v9; // rax
cocos2d::CCKeypadDelegate *Delegate; // rax
cocos2d::CCArray *v11; // r14
int v12; // eax
unsigned int v13; // r15d
int v14; // r12d
cocos2d::CCArray *v15; // r14
int v16; // eax
cocos2d::CCKeypadHandler *v17; // rax
cocos2d::_ccCArray *m_pHandlersToRemove; // rdi
cocos2d::CCArray *v19; // rax
unsigned __int64 v20; // r15
cocos2d::ccArray *data; // rax
cocos2d::CCKeypadDelegate *v22; // r12
cocos2d::CCKeypadHandler **arr; // r13
cocos2d::CCKeypadHandler **v24; // rbx
cocos2d::CCKeypadHandler *v25; // r14
cocos2d::_ccCArray *m_pHandlersToAdd; // rdi
unsigned __int64 v27; // r14
cocos2d::CCKeypadHandler *v28; // rax
cocos2d::CCKeypadDispatcher *v30; // [rsp+0h] [rbp-30h]
v2 = a1;
if ( cocos2d::CCDirector::sharedDirector()->m_bIsTransitioning )
return 1;
a1->m_bLocked = 1;
if ( !(unsigned int)sub_100720070(a1->m_pDelegates) || !(unsigned int)sub_100720070(a1->m_pDelegates) )
goto LABEL_15;
if ( a2 == kTypeBackClicked )
{
m_pDelegates = a1->m_pDelegates;
v8 = sub_100720070(m_pDelegates);
v9 = (cocos2d::CCKeypadHandler *)sub_1007200C0(m_pDelegates, (unsigned int)(v8 - 1));
if ( !v9 )
goto LABEL_15;
Delegate = cocos2d::CCKeypadHandler::getDelegate(v9);
((void (__fastcall *)(cocos2d::CCKeypadDelegate *))Delegate->keyBackClicked)(Delegate);
if ( (unsigned int)sub_100720070(a1->m_pDelegates) <= 1 )
goto LABEL_15;
goto LABEL_11;
}
if ( a2 != kTypeMenuClicked )
{
v13 = 0;
v14 = -1;
do
{
v15 = a1->m_pDelegates;
v16 = sub_100720070(v15);
v17 = (cocos2d::CCKeypadHandler *)sub_1007200C0(v15, (unsigned int)(v16 + v14));
if ( !v17 )
break;
cocos2d::CCKeypadHandler::getDelegate(v17);
++v13;
--v14;
}
while ( v13 < (unsigned int)sub_100720070(a1->m_pDelegates) );
goto LABEL_15;
}
v3 = a1->m_pDelegates;
v4 = sub_100720070(v3);
v5 = (cocos2d::CCKeypadHandler *)sub_1007200C0(v3, (unsigned int)(v4 - 1));
if ( v5 )
{
v6 = cocos2d::CCKeypadHandler::getDelegate(v5);
((void (__fastcall *)(cocos2d::CCKeypadDelegate *))v6->keyMenuClicked)(v6);
if ( (unsigned int)sub_100720070(a1->m_pDelegates) > 1 )
{
LABEL_11:
v11 = a1->m_pDelegates;
v12 = sub_100720070(v11);
sub_1007200C0(v11, (unsigned int)(v12 - 2));
}
}
LABEL_15:
a1->m_bLocked = 0;
if ( a1->m_bToRemove )
{
a1->m_bToRemove = 0;
m_pHandlersToRemove = a1->m_pHandlersToRemove;
if ( m_pHandlersToRemove->num )
{
v19 = v2->m_pDelegates;
if ( v19 )
{
v30 = v2;
v20 = 0;
LABEL_19:
data = v19->data;
if ( !data->num )
goto LABEL_26;
v22 = (cocos2d::CCKeypadDelegate *)m_pHandlersToRemove->arr[v20];
arr = (cocos2d::CCKeypadHandler **)data->arr;
v24 = &arr[data->num - 1];
do
{
v25 = *arr;
if ( !*arr )
break;
if ( cocos2d::CCKeypadHandler::getDelegate(*arr) == v22 )
{
sub_100720220(v30->m_pDelegates, v25, 1);
break;
}
++arr;
}
while ( arr <= v24 );
LABEL_26:
while ( 1 )
{
++v20;
v2 = v30;
m_pHandlersToRemove = v30->m_pHandlersToRemove;
if ( v20 >= m_pHandlersToRemove->num )
break;
v19 = v30->m_pDelegates;
if ( v19 )
goto LABEL_19;
}
}
}
sub_1006682A0();
}
if ( v2->m_bToAdd )
{
v2->m_bToAdd = 0;
m_pHandlersToAdd = v2->m_pHandlersToAdd;
if ( m_pHandlersToAdd->num )
{
v27 = 0;
do
{
v28 = cocos2d::CCKeypadHandler::handlerWithDelegate((cocos2d::CCKeypadDelegate *)m_pHandlersToAdd->arr[v27]);
if ( v28 )
sub_10071FCD0(v2->m_pDelegates, v28);
++v27;
m_pHandlersToAdd = v2->m_pHandlersToAdd;
}
while ( v27 < m_pHandlersToAdd->num );
}
sub_1006682A0();
}
return 1;
}