//
// cocos2d::CCKeyboardDispatcher::dispatchKeyboardMSG from 0xdb3a28 to 0xdb3f8c (1380 bytes)
//
// 2 xrefs:
// > Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeKeyboardEvent @ 0xd81b90
// > ??> @ 0xef980
//
// 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 13:08:40 +0000
//
__int64 __fastcall cocos2d::CCKeyboardDispatcher::dispatchKeyboardMSG(
__int64 a1,
unsigned int a2,
unsigned __int8 a3,
unsigned __int8 a4,
double a5)
{
unsigned int v6; // w22
int v7; // w19
__int64 result; // x0
int v10; // w0
unsigned int v11; // w24
__int64 *v12; // x0
__int64 v13; // x0
unsigned int *v14; // x1
__int64 v15; // x2
__int64 v16; // x19
int v17; // w25
char *v18; // x0
char *v19; // x0
char *v20; // x3
char *v21; // x4
cocos2d::CCDirector *v22; // x0
__int64 *v23; // x0
__int64 *v24; // x19
unsigned __int64 v25; // x2
__int64 v26; // x4
unsigned __int64 v27; // x6
unsigned __int64 v28; // x3
__int64 v29; // x7
__int64 v30; // x5
unsigned __int64 v31; // x3
__int64 v32; // x9
__int64 *i; // x1
unsigned __int64 v34; // x0
unsigned __int64 v35; // x0
unsigned __int64 v36; // x0
__int64 v37; // x0
unsigned __int64 v38; // x5
char *v39; // x0
char *v40; // x1
__int64 v41; // x0
__int64 *v42; // x0
char *v43; // x0
__int64 v44; // x0
unsigned int v45; // [xsp+68h] [xbp+68h]
void *v46; // [xsp+78h] [xbp+78h] BYREF
char *v47; // [xsp+80h] [xbp+80h]
char *v48; // [xsp+88h] [xbp+88h]
unsigned int *v49; // [xsp+90h] [xbp+90h] BYREF
char *v50; // [xsp+98h] [xbp+98h]
char *v51; // [xsp+A0h] [xbp+A0h]
v6 = a3;
v7 = a4;
if ( a3 )
{
v45 = a2;
v22 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(_stack_chk_guard);
cocos2d::CCDirector::noteInput(v22);
a2 = v45;
}
if ( v7 )
{
result = 0;
if ( *(_BYTE *)(a1 + 132) )
return result;
}
*(_BYTE *)(a1 + 133) = v7;
v10 = cocos2d::CCKeyboardDispatcher::convertKeyCode(a2);
v11 = v10;
if ( v10 >= 16 && (v10 <= 18 || v10 == 1011) )
return 0;
v46 = nullptr;
v47 = nullptr;
v48 = nullptr;
if ( v6 )
{
LODWORD(v49) = v10;
v12 = std::__hash_table>,std::__unordered_map_hasher>,std::hash,true>,std::__unordered_map_equal>,std::equal_to,true>,std::allocator>>>::find(
(_QWORD *)(a1 + 88),
(int *)&v49);
if ( v7 && v12 )
{
if ( &v46 != (void **)(v12 + 3) )
std::vector::assign((__int64 *)&v46, (char *)v12[3], v12[4]);
}
else
{
v41 = *(_QWORD *)(a1 + 136);
if ( v41 )
{
(*(void (__fastcall **)(unsigned int **__return_ptr, __int64, _QWORD, _QWORD, _QWORD, _QWORD))(*(_QWORD *)v41 + 80LL))(
&v49,
v41,
v11,
*(unsigned __int8 *)(a1 + 129),
*(unsigned __int8 *)(a1 + 130),
*(unsigned __int8 *)(a1 + 128));
v46 = v49;
v47 = v50;
v48 = v51;
}
LODWORD(v49) = v11;
v42 = (__int64 *)std::unordered_map>::operator[](a1 + 88, (int *)&v49);
if ( &v46 != (void **)v42 )
std::vector::assign(v42, (char *)v46, (__int64)v47);
}
goto LABEL_13;
}
LODWORD(v49) = v10;
v23 = std::__hash_table>,std::__unordered_map_hasher>,std::hash,true>,std::__unordered_map_equal>,std::equal_to,true>,std::allocator>>>::find(
(_QWORD *)(a1 + 88),
(int *)&v49);
v24 = v23;
if ( v23 )
{
if ( &v46 != (void **)(v23 + 3) )
std::vector::assign((__int64 *)&v46, (char *)v23[3], v23[4]);
v25 = *(_QWORD *)(a1 + 96);
v26 = *v24;
v27 = v25 - 1;
v28 = v24[1];
v29 = (v25 - 1) & v25;
v30 = *v24;
if ( v29 )
v31 = v28 % v25;
else
v31 = v27 & v28;
v32 = *(_QWORD *)(a1 + 88);
for ( i = *(__int64 **)(v32 + 8 * v31); v24 != (__int64 *)*i; i = (__int64 *)*i )
;
if ( i == (__int64 *)(a1 + 104) || ((v34 = i[1], v29) ? (v35 = v34 % v25) : (v35 = v27 & v34), v31 != v35) )
{
if ( v26 )
{
v36 = *(_QWORD *)(v26 + 8);
if ( v29 )
{
v38 = v36 / v25;
if ( v31 == v36 % v25 )
goto LABEL_57;
}
else
{
v37 = v27 & v36;
if ( v31 == v37 )
goto LABEL_58;
}
}
*(_QWORD *)(v32 + 8 * v31) = 0;
v26 = *v24;
v30 = *v24;
}
if ( !v26 )
{
LABEL_60:
*i = v30;
*v24 = 0;
--*(_QWORD *)(a1 + 112);
v39 = (char *)v24[3];
if ( v39 )
{
v40 = (char *)v24[4];
if ( v39 != v40 )
v24[4] = (__int64)&v40[4 * ~((unsigned __int64)(v40 - 4 - v39) >> 2)];
operator delete(v39);
}
operator delete(v24);
goto LABEL_13;
}
v36 = *(_QWORD *)(v26 + 8);
if ( !v29 )
{
v37 = v27 & v36;
LABEL_58:
v30 = v26;
if ( v31 != v37 )
{
*(_QWORD *)(*(_QWORD *)(a1 + 88) + 8 * v37) = i;
v30 = *v24;
}
goto LABEL_60;
}
v38 = v36 / v25;
LABEL_57:
v37 = v36 - v38 * v25;
goto LABEL_58;
}
v44 = *(_QWORD *)(a1 + 136);
if ( !v44 )
{
LABEL_74:
*(_BYTE *)(a1 + 64) = 1;
cocos2d::CCKeyboardDispatcher::dispatchToTopDelegate(a1, v11, v6, (__int64)&v46, a5);
*(_BYTE *)(a1 + 64) = 0;
cocos2d::CCKeyboardDispatcher::flushPendingDelegates((cocos2d::CCKeyboardDispatcher *)a1);
v19 = (char *)v46;
goto LABEL_31;
}
(*(void (__fastcall **)(__int64, _QWORD, _QWORD, _QWORD, _QWORD))(*(_QWORD *)v44 + 80LL))(
v44,
v11,
*(unsigned __int8 *)(a1 + 129),
*(unsigned __int8 *)(a1 + 130),
*(unsigned __int8 *)(a1 + 128));
v46 = v49;
v47 = v50;
v48 = v51;
LABEL_13:
v13 = *(_QWORD *)(a1 + 136);
if ( !v13 || *(_BYTE *)(a1 + 134) )
goto LABEL_74;
v14 = (unsigned int *)v46;
v15 = (__int64)v47;
v49 = nullptr;
v50 = nullptr;
v51 = nullptr;
if ( !((v47 - (_BYTE *)v46) >> 2) )
{
v43 = v48;
v46 = nullptr;
v49 = v14;
v47 = nullptr;
v50 = (char *)v15;
v48 = nullptr;
v51 = v43;
goto LABEL_70;
}
v16 = 0;
v17 = 0;
while ( 1 )
{
if ( (*(unsigned __int8 (__fastcall **)(__int64, _QWORD, _QWORD))(*(_QWORD *)v13 + 88LL))(v13, v14[v16], v6) )
{
v14 = (unsigned int *)v46;
v17 = 1;
goto LABEL_18;
}
v18 = v50;
v14 = (unsigned int *)v46;
if ( v50 != v51 )
break;
std::vector::__push_back_slow_path((__int64)&v49, (_DWORD *)v46 + v16);
v14 = (unsigned int *)v46;
LABEL_18:
v15 = (__int64)v47;
if ( ++v16 >= (unsigned __int64)((v47 - (char *)v14) >> 2) )
goto LABEL_25;
LABEL_19:
v13 = *(_QWORD *)(a1 + 136);
}
if ( v50 )
{
*(_DWORD *)v50 = *((_DWORD *)v46 + v16);
v18 = v50;
v14 = (unsigned int *)v46;
}
v15 = (__int64)v47;
v50 = v18 + 4;
if ( ++v16 < (unsigned __int64)((v47 - (char *)v14) >> 2) )
goto LABEL_19;
LABEL_25:
v19 = (char *)v49;
v20 = v50;
v21 = v48;
v46 = v49;
v49 = v14;
v47 = v50;
v50 = (char *)v15;
v48 = v51;
v51 = v21;
if ( !v17 || v20 != v19 )
{
LABEL_70:
if ( v14 )
{
if ( v14 != (unsigned int *)v15 )
v50 = (char *)(v15 + 4 * ~((unsigned __int64)(v15 - 4 - (_QWORD)v14) >> 2));
operator delete(v14);
}
goto LABEL_74;
}
if ( v14 )
{
if ( v14 != (unsigned int *)v15 )
v50 = (char *)(v15 + 4 * ~((unsigned __int64)(v15 - 4 - (_QWORD)v14) >> 2));
operator delete(v14);
v19 = (char *)v46;
}
LABEL_31:
if ( v19 )
{
if ( v47 != v19 )
v47 += 4 * ~((unsigned __int64)(v47 - 4 - v19) >> 2);
operator delete(v19);
}
return 1;
}