//
// TouchControlEditLayer::ccTouchBegan from 0x140454180 to 0x14045463c (1212 bytes)
//
// 5 xrefs:
// > ??> @ 0x140795b10
// > ??> @ 0x1408cccdc
// > ??> @ 0x1408cccec
// > ??> @ 0x1408ccd1c
// > ??> @ 0x14092795c
//
// This function is hookable on this platform (idp: pc, 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 11:32:28 +0000
//
char __fastcall TouchControlEditLayer::ccTouchBegan(__int64 a1, __int64 a2)
{
__int64 v3; // rdx
__int64 v4; // rcx
__int64 v5; // r8
__int64 v6; // r9
cocos2d::CCEGLViewProtocol *v7; // rax
__int64 v8; // rdx
__int64 v9; // rcx
__int64 v10; // r8
__int64 v11; // r9
cocos2d::CCEGLViewProtocol *v12; // rax
__int64 v13; // rdx
__int64 v14; // rcx
__int64 v15; // r8
__int64 v16; // r9
cocos2d::CCEGLViewProtocol *v17; // rax
float *v18; // r15
float **v19; // r15
float v20; // xmm7_4
float v21; // xmm6_4
const struct cocos2d::CCPoint *v22; // rax
const struct cocos2d::CCPoint *v23; // r8
__int64 v24; // rdi
__int64 v25; // rcx
__int64 v26; // rsi
__int64 v27; // rdi
const struct cocos2d::CCPoint *v28; // rdx
char *v30; // r8
char *v31; // rcx
float v32; // xmm2_4
float v33; // xmm0_4
__int32 v34; // xmm7_4
float v35; // xmm2_4
__int64 v36; // rcx
double v37; // xmm0_8
int v38; // xmm1_4
float *v39; // rcx
float v40; // xmm6_4
float v41; // xmm0_4
float v42; // xmm0_4
float v43; // [rsp+28h] [rbp-49h] BYREF
float v44; // [rsp+2Ch] [rbp-45h]
char v45[8]; // [rsp+30h] [rbp-41h] BYREF
char v46[8]; // [rsp+38h] [rbp-39h] BYREF
__m128i si128; // [rsp+40h] [rbp-31h] BYREF
_BYTE v48[8]; // [rsp+50h] [rbp-21h] BYREF
char v49[8]; // [rsp+58h] [rbp-19h] BYREF
char v50[8]; // [rsp+60h] [rbp-11h] BYREF
char v51[8]; // [rsp+68h] [rbp-9h] BYREF
if ( *(_QWORD *)(a1 + 896) != *(_QWORD *)(a1 + 904) )
{
cocos2d::CCTouch::getLocation(a2, v46);
cocos2d::CCNode::convertToNodeSpace(a1 - 320, v45, v46);
v7 = (cocos2d::CCEGLViewProtocol *)cocos2d::CCEGLView::sharedOpenGLView(v4, v3, v5, v6);
cocos2d::CCEGLViewProtocol::getScaleY(v7);
v12 = (cocos2d::CCEGLViewProtocol *)cocos2d::CCEGLView::sharedOpenGLView(v9, v8, v10, v11);
cocos2d::CCEGLViewProtocol::getScaleY(v12);
v17 = (cocos2d::CCEGLViewProtocol *)cocos2d::CCEGLView::sharedOpenGLView(v14, v13, v15, v16);
cocos2d::CCEGLViewProtocol::getScaleY(v17);
v18 = *(float **)(a1 + 920);
if ( v18 || (v19 = *(float ***)(a1 + 896), v19 != *(float ***)(a1 + 904)) && (v18 = *v19) != nullptr )
{
v20 = v18[86] * 0.5;
v21 = v18[87] * 0.5;
v22 = (const struct cocos2d::CCPoint *)(*(__int64 (__fastcall **)(float *))(*(_QWORD *)v18 + 200LL))(v18);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v43, v22);
si128 = _mm_load_si128((const __m128i *)&xmmword_1408367C0);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v48, v43 - v20, v21 + v44);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v49, v20 + v43, v21 + v44);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v50, v43 - v20, v44 - v21);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v51, v20 + v43, v44 - v21);
v24 = 0;
while ( cocos2d::ccpDistance((cocos2d *)v45, (const struct cocos2d::CCPoint *)&v48[8 * v24], v23) >= 22.050001 )
{
v24 = (unsigned int)(v24 + 1);
if ( (int)v24 >= 4 )
goto LABEL_8;
}
v30 = v45;
*(_DWORD *)(a1 + 960) = si128.m128i_i32[v24];
v31 = &v48[8 * v24];
*(_QWORD *)(a1 + 968) = v18;
goto LABEL_14;
}
LABEL_8:
v25 = *(_QWORD *)(a1 + 896);
v26 = 0;
if ( (*(_QWORD *)(a1 + 904) - v25) >> 3 )
{
while ( 1 )
{
v27 = *(_QWORD *)(v25 + 8 * v26);
cocos2d::CCNode::convertToNodeSpace(v27, &v43, v46);
if ( cocos2d::CCRect::containsPoint((cocos2d::CCRect *)(v27 + 336), (const struct cocos2d::CCPoint *)&v43) )
break;
v25 = *(_QWORD *)(a1 + 896);
if ( ++v26 >= (unsigned __int64)((*(_QWORD *)(a1 + 904) - v25) >> 3) )
goto LABEL_11;
}
if ( v27 != *(_QWORD *)(a1 + 920) )
{
*(_QWORD *)(a1 + 920) = v27;
TouchControlEditLayer::refreshHud((__int64 *)(a1 - 320));
TouchControlEditLayer::updateHandles((_QWORD *)(a1 - 320));
TouchControlEditLayer::updateHudVisibility(a1 - 320);
}
if ( !*(_QWORD *)(v27 + 328) )
goto LABEL_22;
if ( *(_BYTE *)(v27 + 381) )
{
v32 = cocos2d::ccpLength((cocos2d *)&v43, v28);
v33 = *(float *)(v27 + 372);
if ( fabs(v32 - v33) < 22.050001 )
{
*(_DWORD *)(a1 + 960) = 7;
*(_QWORD *)(a1 + 968) = v27;
*(float *)(a1 + 984) = *(float *)(v27 + 372) - v32;
return 1;
}
if ( v33 <= v32 )
goto LABEL_22;
LABEL_24:
*(_DWORD *)(a1 + 960) = 6;
*(_QWORD *)(a1 + 968) = v27;
TouchControlEditLayer::beginDeadzoneDrag(a1 - 320, v27, (cocos2d *)&v43);
return 1;
}
v34 = _mm_load_si128((const __m128i *)&xmmword_140836C90).m128i_i32[0];
v35 = v43;
if ( COERCE_FLOAT(COERCE_UNSIGNED_INT(COERCE_FLOAT(LODWORD(v43) & v34) - *(float *)(v27 + 376)) & v34) < 14.700001 )
goto LABEL_24;
v36 = *(_QWORD *)(v27 + 320);
if ( v36 )
{
v37 = (*(double (__fastcall **)(__int64))(*(_QWORD *)v36 + 216LL))(v36);
v35 = v43;
v38 = LODWORD(v37) & v34;
}
else
{
v38 = *(int *)(v27 + 372);
}
if ( COERCE_FLOAT(COERCE_UNSIGNED_INT(COERCE_FLOAT(LODWORD(v35) & v34) - *(float *)&v38) & v34) >= 22.050001
|| COERCE_FLOAT(LODWORD(v44) & v34) >= 29.400002 )
{
LABEL_22:
*(_DWORD *)(a1 + 960) = 1;
*(_QWORD *)(a1 + 968) = v27;
v30 = (char *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v27 + 200LL))(v27);
v31 = v45;
LABEL_14:
cocos2d::CCPoint::operator-(v31, &si128, v30);
cocos2d::CCPoint::operator=(a1 + 976, &si128);
return 1;
}
*(_DWORD *)(a1 + 960) = 7;
*(_QWORD *)(a1 + 968) = v27;
v39 = *(float **)(v27 + 320);
if ( v39 )
{
v40 = v39[108];
v41 = (*(float (**)(void))(*(_QWORD *)v39 + 168LL))();
v35 = v43;
v42 = v41 * v40;
}
else
{
v42 = 0.0;
}
*(float *)(a1 + 984) = *(float *)(v27 + 372) - (float)(COERCE_FLOAT(LODWORD(v35) & v34) - (float)(v42 * 0.5));
}
else
{
LABEL_11:
*(_DWORD *)(a1 + 960) = 0;
*(_QWORD *)(a1 + 968) = 0;
}
}
return 1;
}