//
// cocos2d::CCTouchDispatcher::touches from 0xdb1de8 to 0xdb226c (1156 bytes)
//
// 5 xrefs:
// > cocos2d::CCTouchDispatcher::touchesBegan @ 0xdb2310
// > cocos2d::CCTouchDispatcher::touchesMoved @ 0xdb2384
// > cocos2d::CCTouchDispatcher::touchesEnded @ 0xdb23a0
// > cocos2d::CCTouchDispatcher::touchesCancelled @ 0xdb23bc
// > ??> @ 0xca9a8
//
// 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:39 +0000
//
__int64 __fastcall cocos2d::CCTouchDispatcher::touches(__int64 a1, cocos2d::CCSet *a2, __int64 a3, unsigned int a4)
{
cocos2d::CCDirector *v8; // x0
cocos2d::CCArray *v9; // x0
int v10; // w20
int v11; // w24
int v12; // w0
__int64 v13; // x0
unsigned int v14; // w20
cocos2d::CCTouchDelegate *v15; // x1
cocos2d::CCArray *v16; // x0
unsigned int *v17; // x2
cocos2d::CCTouchHandler **v18; // x20
__int64 v19; // x1
char *v20; // x22
cocos2d::CCTouchHandler *v21; // x21
__int64 result; // x0
__int64 v23; // x0
unsigned int *v24; // x1
cocos2d::CCTouchHandler **v25; // x20
__int64 v26; // x0
char *v27; // x21
cocos2d::CCTouchHandler *i; // x0
_QWORD *v29; // x28
__int64 v30; // x0
cocos2d::CCObject *v31; // x21
unsigned int *v32; // x0
cocos2d::CCTargetedTouchHandler **v33; // x26
cocos2d::CCTargetedTouchHandler **v34; // x20
_QWORD *v35; // x0
__int64 v36; // x0
cocos2d::CCTouchHandler *v37; // x27
cocos2d::CCSet *ClaimedTouches; // x0
__int64 Delegate; // x0
_QWORD *v40; // x1
_QWORD *v41; // x1
cocos2d::CCSet *v42; // x0
void (*v43)(void); // x6
cocos2d::CCSet *v44; // x0
__int64 v45; // x0
__int64 v46; // x0
__int64 v47; // x0
__int64 v48; // x0
cocos2d::CCSet *v49; // [xsp+60h] [xbp+60h]
_BOOL4 v50; // [xsp+68h] [xbp+68h]
int v51; // [xsp+6Ch] [xbp+6Ch]
v8 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector((cocos2d::CCDirector *)a1);
cocos2d::CCDirector::noteInput(v8);
v9 = *(cocos2d::CCArray **)(a1 + 64);
*(_BYTE *)(a1 + 80) = 1;
v10 = cocos2d::CCArray::count(v9);
v50 = cocos2d::CCArray::count(*(cocos2d::CCArray **)(a1 + 72)) != 0;
v51 = v50 && v10 != 0;
if ( v50 && v10 != 0 )
{
v49 = cocos2d::CCSet::mutableCopy(a2);
v11 = *(_DWORD *)(a1 + 4LL * a4 + 108);
LABEL_31:
v29 = (_QWORD *)cocos2d::CCSet::begin(a2);
while ( 1 )
{
if ( v29 == (_QWORD *)cocos2d::CCSet::end(a2) )
{
LABEL_39:
a2 = v49;
goto LABEL_3;
}
while ( 1 )
{
v30 = *(_QWORD *)(a1 + 64);
v31 = (cocos2d::CCObject *)v29[4];
if ( v30 )
{
v32 = *(unsigned int **)(v30 + 56);
if ( *v32 )
{
v33 = *((cocos2d::CCTargetedTouchHandler ***)v32 + 2);
v34 = &v33[*v32 - 1];
while ( v34 >= v33 )
{
v37 = *v33;
if ( !*v33 )
break;
if ( a4 )
{
ClaimedTouches = (cocos2d::CCSet *)cocos2d::CCTargetedTouchHandler::getClaimedTouches(*v33);
if ( !cocos2d::CCSet::containsObject(ClaimedTouches, v31) )
goto LABEL_41;
switch ( v11 )
{
case 2:
v43 = *(void (**)(void))(*(_QWORD *)cocos2d::CCTouchHandler::getDelegate(v37) + 32LL);
goto LABEL_57;
case 3:
v43 = *(void (**)(void))(*(_QWORD *)cocos2d::CCTouchHandler::getDelegate(v37) + 40LL);
LABEL_57:
v43();
v44 = (cocos2d::CCSet *)cocos2d::CCTargetedTouchHandler::getClaimedTouches(v37);
cocos2d::CCSet::removeObject(v44, v31);
break;
case 1:
Delegate = cocos2d::CCTouchHandler::getDelegate(v37);
(*(void (__fastcall **)(__int64, cocos2d::CCObject *, __int64))(*(_QWORD *)Delegate + 24LL))(
Delegate,
v31,
a3);
break;
}
}
else
{
v36 = cocos2d::CCTouchHandler::getDelegate(*v33);
if ( !(*(unsigned __int8 (__fastcall **)(__int64, cocos2d::CCObject *, __int64))(*(_QWORD *)v36 + 16LL))(
v36,
v31,
a3) )
goto LABEL_41;
v42 = (cocos2d::CCSet *)cocos2d::CCTargetedTouchHandler::getClaimedTouches(v37);
cocos2d::CCSet::addObject(v42, v31);
}
if ( (unsigned __int8)cocos2d::CCTargetedTouchHandler::isSwallowsTouches(v37) )
{
if ( !v51 )
break;
cocos2d::CCSet::removeObject(v49, v31);
v35 = (_QWORD *)v29[1];
if ( v35 )
goto LABEL_37;
goto LABEL_52;
}
LABEL_41:
++v33;
}
}
}
v35 = (_QWORD *)v29[1];
if ( !v35 )
break;
do
{
LABEL_37:
v29 = v35;
v35 = (_QWORD *)*v35;
}
while ( v35 );
if ( v29 == (_QWORD *)cocos2d::CCSet::end(a2) )
goto LABEL_39;
}
do
{
LABEL_52:
v40 = v29;
v29 = (_QWORD *)v29[2];
if ( v40 == (_QWORD *)*v29 )
break;
v41 = v29;
v29 = (_QWORD *)v29[2];
}
while ( v41 != (_QWORD *)*v29 );
}
}
v11 = *(_DWORD *)(a1 + 4LL * a4 + 108);
if ( v10 )
{
v49 = a2;
goto LABEL_31;
}
LABEL_3:
if ( v50 && (int)cocos2d::CCSet::count(a2) > 0 )
{
v23 = *(_QWORD *)(a1 + 72);
if ( v23 )
{
v24 = *(unsigned int **)(v23 + 56);
if ( *v24 )
{
v25 = *((cocos2d::CCTouchHandler ***)v24 + 2);
v26 = 8LL * *v24 - 8;
v27 = (char *)v25 + v26;
if ( v25 <= (cocos2d::CCTouchHandler **)((char *)v25 + v26) )
{
for ( i = *v25; *v25; i = *v25 )
{
switch ( v11 )
{
case 0:
v48 = cocos2d::CCTouchHandler::getDelegate(i);
(*(void (__fastcall **)(__int64, cocos2d::CCSet *, __int64))(*(_QWORD *)v48 + 48LL))(v48, a2, a3);
break;
case 1:
v47 = cocos2d::CCTouchHandler::getDelegate(i);
(*(void (__fastcall **)(__int64, cocos2d::CCSet *, __int64))(*(_QWORD *)v47 + 56LL))(v47, a2, a3);
break;
case 2:
v45 = cocos2d::CCTouchHandler::getDelegate(i);
(*(void (__fastcall **)(__int64, cocos2d::CCSet *, __int64))(*(_QWORD *)v45 + 64LL))(v45, a2, a3);
break;
case 3:
v46 = cocos2d::CCTouchHandler::getDelegate(i);
(*(void (__fastcall **)(__int64, cocos2d::CCSet *, __int64))(*(_QWORD *)v46 + 72LL))(v46, a2, a3);
break;
default:
break;
}
if ( v27 < (char *)++v25 )
break;
}
}
}
}
}
if ( v51 )
cocos2d::CCObject::release(a2);
v12 = *(unsigned __int8 *)(a1 + 82);
*(_BYTE *)(a1 + 80) = 0;
if ( v12 )
{
v13 = *(_QWORD *)(a1 + 96);
*(_BYTE *)(a1 + 82) = 0;
if ( *(_DWORD *)v13 )
{
v14 = 0;
do
{
v15 = *(cocos2d::CCTouchDelegate **)(*(_QWORD *)(v13 + 16) + 8LL * v14++);
cocos2d::CCTouchDispatcher::forceRemoveDelegate((cocos2d::CCTouchDispatcher *)a1, v15);
v13 = *(_QWORD *)(a1 + 96);
}
while ( *(_DWORD *)v13 > v14 );
}
cocos2d::ccCArrayRemoveAllValues((_DWORD *)v13);
}
if ( *(_BYTE *)(a1 + 81) )
{
v16 = *(cocos2d::CCArray **)(a1 + 88);
*(_BYTE *)(a1 + 81) = 0;
if ( v16 )
{
v17 = *((unsigned int **)v16 + 7);
if ( *v17 )
{
v18 = *((cocos2d::CCTouchHandler ***)v17 + 2);
v19 = 8LL * *v17 - 8;
v20 = (char *)v18 + v19;
if ( v18 <= (cocos2d::CCTouchHandler **)((char *)v18 + v19) )
{
v21 = *v18;
if ( *v18 )
{
do
{
if ( _dynamic_cast(
v21,
(const struct __class_type_info *)&`typeinfo for'cocos2d::CCTouchHandler,
(const struct __class_type_info *)&`typeinfo for'cocos2d::CCTargetedTouchHandler,
0) )
{
cocos2d::CCTouchDispatcher::forceAddHandler(
(cocos2d::CCTouchDispatcher *)a1,
v21,
*(cocos2d::CCArray **)(a1 + 64));
}
else
{
cocos2d::CCTouchDispatcher::forceAddHandler(
(cocos2d::CCTouchDispatcher *)a1,
v21,
*(cocos2d::CCArray **)(a1 + 72));
}
if ( v20 < (char *)++v18 )
break;
v21 = *v18;
}
while ( *v18 );
v16 = *(cocos2d::CCArray **)(a1 + 88);
}
}
}
}
cocos2d::CCArray::removeAllObjects(v16);
}
result = *(unsigned __int8 *)(a1 + 104);
if ( *(_BYTE *)(a1 + 104) )
{
*(_BYTE *)(a1 + 104) = 0;
return cocos2d::CCTouchDispatcher::forceRemoveAllDelegates((cocos2d::CCArray **)a1);
}
return result;
}