//
// cocos2d::CCKeyboardDispatcher::dispatchKeyboardMSG from 0x1002035b0 to 0x100203855 (677 bytes)
//
// 2 xrefs:
// > -[EAGLView keyDownExec:] @ 0x100666d14
// > -[EAGLView keyUpExec:] @ 0x100666fa3
//
// 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::CCKeyboardDispatcher::dispatchKeyboardMSG(
cocos2d::CCKeyboardDispatcher *a1,
cocos2d::enumKeyCodes a2,
bool a3,
bool a4,
double a5)
{
cocos2d::enumKeyCodes v5; // r14d
cocos2d::CCKeyboardDispatcher *v6; // rbx
bool v7; // r15
bool v8; // r12
cocos2d::CCArray *m_pDelegates; // r15
int v10; // eax
cocos2d::CCKeyboardHandler *v11; // rax
cocos2d::CCKeyboardDelegate *v12; // rax
cocos2d::CCKeyboardDelegate *Delegate; // rax
cocos2d::CCArray *v14; // r14
int v15; // eax
cocos2d::ccCArray *m_pUnknown40; // rdi
cocos2d::CCArray *v17; // rax
unsigned __int64 v18; // r15
cocos2d::ccArray *data; // rax
cocos2d::CCKeyboardDelegate *v20; // r12
cocos2d::CCKeyboardHandler **arr; // r13
cocos2d::CCKeyboardHandler **v22; // rbx
cocos2d::CCKeyboardHandler *v23; // r14
cocos2d::ccCArray *m_pUnknown3c; // rdi
unsigned __int64 v25; // r14
cocos2d::CCKeyboardHandler *v26; // rax
double v28; // [rsp+0h] [rbp-30h]
cocos2d::CCKeyboardDispatcher *v29; // [rsp+0h] [rbp-30h]
v5 = a2;
v6 = a1;
if ( a4 && a1->m_bBlockRepeat )
return 0;
v28 = a5;
switch ( a2 )
{
case KEY_ArrowUp:
v8 = a3;
v5 = KEY_Up;
goto LABEL_13;
case KEY_ArrowDown:
v8 = a3;
v5 = KEY_Down;
goto LABEL_13;
case KEY_ArrowLeft:
v8 = a3;
v5 = KEY_Left;
goto LABEL_13;
case KEY_ArrowRight:
v8 = a3;
v5 = KEY_Right;
goto LABEL_13;
default:
v7 = 0;
if ( (unsigned int)(a2 - 16) < 3 || a2 == CONTROLLER_Back )
return v7;
v28 = a5;
v8 = a3;
LABEL_13:
a1->m_bUnknown38 = 1;
if ( !(unsigned int)sub_100720070(a1->m_pDelegates) || !(unsigned int)sub_100720070(a1->m_pDelegates) )
goto LABEL_22;
m_pDelegates = a1->m_pDelegates;
v10 = sub_100720070(m_pDelegates);
v11 = (cocos2d::CCKeyboardHandler *)sub_1007200C0(m_pDelegates, (unsigned int)(v10 - 1));
if ( !v8 )
{
if ( !v11 )
goto LABEL_22;
Delegate = cocos2d::CCKeyboardHandler::getDelegate(v11);
((void (__fastcall *)(cocos2d::CCKeyboardDelegate *, _QWORD, double))Delegate->keyUp)(
Delegate,
(unsigned int)v5,
v28);
if ( (unsigned int)sub_100720070(a1->m_pDelegates) <= 1 )
goto LABEL_22;
LABEL_21:
v14 = a1->m_pDelegates;
v15 = sub_100720070(v14);
sub_1007200C0(v14, (unsigned int)(v15 - 2));
goto LABEL_22;
}
if ( v11 )
{
v12 = cocos2d::CCKeyboardHandler::getDelegate(v11);
((void (__fastcall *)(cocos2d::CCKeyboardDelegate *, _QWORD, double))v12->keyDown)(v12, (unsigned int)v5, v28);
if ( (unsigned int)sub_100720070(a1->m_pDelegates) >= 2 )
goto LABEL_21;
}
LABEL_22:
a1->m_bUnknown38 = 0;
if ( a1->m_bUnknown3a )
{
a1->m_bUnknown3a = 0;
m_pUnknown40 = a1->m_pUnknown40;
if ( m_pUnknown40->num )
{
v17 = v6->m_pDelegates;
if ( v17 )
{
v29 = v6;
v18 = 0;
LABEL_26:
data = v17->data;
if ( !data->num )
goto LABEL_33;
v20 = (cocos2d::CCKeyboardDelegate *)m_pUnknown40->arr[v18];
arr = (cocos2d::CCKeyboardHandler **)data->arr;
v22 = &arr[data->num - 1];
do
{
v23 = *arr;
if ( !*arr )
break;
if ( cocos2d::CCKeyboardHandler::getDelegate(*arr) == v20 )
{
sub_100720220(v29->m_pDelegates, v23, 1);
break;
}
++arr;
}
while ( arr <= v22 );
LABEL_33:
while ( 1 )
{
++v18;
v6 = v29;
m_pUnknown40 = v29->m_pUnknown40;
if ( v18 >= m_pUnknown40->num )
break;
v17 = v29->m_pDelegates;
if ( v17 )
goto LABEL_26;
}
}
}
sub_1006682A0();
}
v7 = 1;
if ( v6->m_bUnknown39 )
{
v6->m_bUnknown39 = 0;
m_pUnknown3c = v6->m_pUnknown3c;
if ( m_pUnknown3c->num )
{
v25 = 0;
do
{
v26 = cocos2d::CCKeyboardHandler::handlerWithDelegate((cocos2d::CCKeyboardDelegate *)m_pUnknown3c->arr[v25]);
if ( v26 )
sub_10071FCD0(v6->m_pDelegates, v26);
++v25;
m_pUnknown3c = v6->m_pUnknown3c;
}
while ( v25 < m_pUnknown3c->num );
}
sub_1006682A0();
}
return v7;
}
}