//
// CCTextInputNode::updateCursorPosition from 0x6c1688 to 0x6c1c60 (1496 bytes)
//
// 6 xrefs:
// > CCTextInputNode::moveCursorVertical @ 0x6c1e5c
// > CCTextInputNode::ccTouchBegan @ 0x6c2074
// > CCTextInputNode::ccTouchEnded @ 0x6c2160
// > CCTextInputNode::holdTimerFired @ 0x6c223c
// > CCTextInputNode::rightClick @ 0x6c2434
// > ??> @ 0xa0b28
//
// 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 12:51:19 +0000
//
__int64 __fastcall CCTextInputNode::updateCursorPosition(__int64 a1, float *a2)
{
__int64 v3; // x1
const char *v5; // x0
size_t v6; // x0
_BOOL4 v7; // w19
cocos2d::CCLabelBMFont *v8; // x21
__int64 v9; // x1
cocos2d::CCLabelBMFont *v10; // x0
int v11; // w26
int v12; // w25
__int64 v13; // x0
long double v14; // q0
float v15; // s11
cocos2d::CCNode *v16; // x19
const cocos2d::CCPoint *v17; // x0
float v18; // s10
__int64 v19; // x19
float i; // s8
unsigned int v21; // w24
signed int v22; // w20
cocos2d::CCArray *v23; // x19
unsigned int v24; // w1
__int64 v25; // x0
signed int v26; // w24
cocos2d::CCSprite *v27; // x0
float v28; // s0
float v29; // s10
const char *v30; // x0
size_t v31; // x0
int v32; // w1
int v33; // w0
signed int v34; // w28
cocos2d::CCSprite *v35; // x27
float v36; // s0
float v37; // s9
__int64 v38; // x27
int v39; // w0
__int64 v41; // x0
cocos2d::CCArray *v42; // x24
unsigned int v43; // w27
float v44; // s8
__int64 v45; // x25
float v46; // s0
float v47; // s0
float v48; // s0
signed int v49; // w2
int v50; // w1
__int64 v51; // x19
unsigned int v52; // w2
__int64 v53; // x0
cocos2d::CCArray *v54; // x0
signed int v55; // [xsp+88h] [xbp+88h]
int v56; // [xsp+90h] [xbp+90h]
char *v57; // [xsp+98h] [xbp+98h]
char *v58; // [xsp+98h] [xbp+98h]
int v59; // [xsp+98h] [xbp+98h]
signed int v60; // [xsp+98h] [xbp+98h]
char v61[8]; // [xsp+A8h] [xbp+A8h] BYREF
__int64 v62; // [xsp+B0h] [xbp+B0h] BYREF
__int64 v63[2]; // [xsp+B8h] [xbp+B8h] BYREF
void *v64; // [xsp+C8h] [xbp+C8h]
__int64 v65; // [xsp+D0h] [xbp+D0h] BYREF
__int64 v66; // [xsp+D8h] [xbp+D8h]
void *v67; // [xsp+E0h] [xbp+E0h]
v3 = *(_QWORD *)(a1 + 576);
*(float *)(a1 + 648) = -1.0;
v5 = (const char *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v3 + 1248LL))(v3);
v63[0] = 0;
v57 = (char *)v5;
v63[1] = 0;
v64 = nullptr;
v6 = strlen(v5);
std::string::__init(v63, v57, v6);
v65 = 0;
v66 = 0;
v67 = nullptr;
std::string::__init(&v65, &byte_11B8890, 0);
v7 = sub_6B7640((__int64)v63, (__int64)&v65);
if ( (v65 & 1) != 0 )
operator delete(v67);
if ( (v63[0] & 1) != 0 )
operator delete(v64);
if ( v7 )
goto LABEL_34;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v61);
v8 = *(cocos2d::CCLabelBMFont **)(a1 + 600);
if ( v8 )
{
v9 = *(_QWORD *)v8;
v10 = *(cocos2d::CCLabelBMFont **)(a1 + 600);
v11 = 0;
v12 = 0;
}
else
{
v41 = *(_QWORD *)(a1 + 616);
if ( !v41 )
return _stack_chk_guard;
v42 = *(cocos2d::CCArray **)(*(_QWORD *)(v41 + 608) + 648LL);
if ( !(unsigned int)cocos2d::CCArray::count(v42) )
goto LABEL_34;
if ( (unsigned int)cocos2d::CCArray::count(v42) == 1 )
{
v11 = 0;
v12 = 0;
v8 = (cocos2d::CCLabelBMFont *)cocos2d::CCArray::objectAtIndex(v42, 0);
}
else
{
v60 = 0;
v43 = 0;
v11 = cocos2d::CCArray::count(v42);
v44 = -1.0;
while ( v43 < (unsigned int)cocos2d::CCArray::count(v42) )
{
v45 = cocos2d::CCArray::objectAtIndex(v42, v43);
sub_6B77E8(v45);
v47 = vabds_f32(v46, a2[1]);
if ( v44 > v47 )
{
v60 = v43;
v8 = (cocos2d::CCLabelBMFont *)v45;
v44 = v47;
++v43;
}
else
{
if ( v44 < 0.0 )
{
v60 = v43;
v8 = (cocos2d::CCLabelBMFont *)v45;
v44 = v47;
}
++v43;
}
}
if ( v60 )
{
v52 = 0;
v12 = 0;
do
{
v55 = v52 + 1;
v53 = cocos2d::CCArray::objectAtIndex(v42, v52);
v54 = (cocos2d::CCArray *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v53 + 488LL))(v53);
v12 += cocos2d::CCArray::count(v54);
v52 = v55;
}
while ( v55 < v60 );
}
else
{
v12 = 0;
}
}
v9 = *(_QWORD *)v8;
v10 = v8;
}
v13 = (*(__int64 (__fastcall **)(cocos2d::CCLabelBMFont *))(v9 + 192))(v10);
*(__n128 *)&v14 = cocos2d::CCPoint::operator=(v61, v13);
v15 = *a2;
v16 = (cocos2d::CCNode *)(*(__int64 (__fastcall **)(cocos2d::CCLabelBMFont *, long double))(*(_QWORD *)v8 + 512LL))(
v8,
v14);
v17 = (const cocos2d::CCPoint *)(*(__int64 (__fastcall **)(cocos2d::CCLabelBMFont *))(*(_QWORD *)v8 + 192LL))(v8);
cocos2d::CCNode::convertToWorldSpace(&v62, v16, v17);
v18 = *(float *)&v62;
v19 = (*(__int64 (__fastcall **)(cocos2d::CCLabelBMFont *))(*(_QWORD *)v8 + 512LL))(v8);
for ( i = 1.0; v19; v19 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v19 + 512LL))(v19) )
i = i * (*(float (__fastcall **)(__int64))(*(_QWORD *)v19 + 136LL))(v19);
v21 = 0;
v22 = 0;
v23 = (cocos2d::CCArray *)(*(__int64 (__fastcall **)(cocos2d::CCLabelBMFont *))(*(_QWORD *)v8 + 488LL))(v8);
while ( v21 < (unsigned int)cocos2d::CCArray::count(v23) )
{
v24 = v21++;
v25 = cocos2d::CCArray::objectAtIndex(v23, v24);
if ( (*(unsigned __int8 (__fastcall **)(__int64))(*(_QWORD *)v25 + 352LL))(v25) )
++v22;
}
v26 = v22;
if ( !v22 )
goto LABEL_34;
v56 = v22 - 1;
v27 = (cocos2d::CCSprite *)cocos2d::CCArray::objectAtIndex(v23, v22 - 1);
cocos2d::CCLabelBMFont::getLetterPosXRight(v8, v27, 0.0);
v29 = v18
- (float)((float)(i * v28)
* *(float *)(*(__int64 (__fastcall **)(cocos2d::CCLabelBMFont *))(*(_QWORD *)v8 + 304LL))(v8));
if ( v11 > 1 )
{
v30 = (const char *)(*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 576) + 1248LL))(*(_QWORD *)(a1 + 576));
v65 = 0;
v58 = (char *)v30;
v66 = 0;
v67 = nullptr;
v31 = strlen(v30);
std::string::__init(&v65, v58, v31);
v32 = v12 + v22 - 1;
if ( *(int *)(a1 + 504) > 0 )
v32 = CCTextInputNode::displayToRawIndex((CCTextInputNode *)a1, v32);
v33 = sub_6B7D64((__int64)&v65, v32);
if ( (v65 & 1) != 0 )
{
if ( v33 < (int)v66 )
{
if ( *((_BYTE *)v67 + v33) == 10 )
--v22;
}
else
{
--v22;
}
operator delete(v67);
}
else if ( v33 < (unsigned __int8)v65 >> 1 )
{
if ( *((_BYTE *)&v65 + v33 + 1) == 10 )
--v22;
}
else
{
--v22;
}
}
v34 = 0;
v59 = 0;
while ( 1 )
{
v35 = (cocos2d::CCSprite *)cocos2d::CCArray::objectAtIndex(v23, v34);
if ( (*(unsigned __int8 (__fastcall **)(cocos2d::CCSprite *))(*(_QWORD *)v35 + 352LL))(v35) )
break;
LABEL_25:
if ( ++v34 >= v26 )
goto LABEL_33;
}
cocos2d::CCLabelBMFont::getLetterPosXRight(v8, v35, *(float *)(a1 + 468));
v37 = v29 + (float)(i * v36);
if ( v15 > v37 )
{
if ( v56 == v34 && v11 > 1 )
{
v38 = *(_QWORD *)(a1 + 576);
v39 = v12 + v22;
if ( *(int *)(a1 + 504) > 0 )
v39 = CCTextInputNode::displayToRawIndex((CCTextInputNode *)a1, v12 + v22);
*(_DWORD *)(v38 + 752) = v39;
v59 = 1;
CCTextInputNode::updateBlinkLabel((CCTextInputNode *)a1);
}
goto LABEL_25;
}
cocos2d::CCLabelBMFont::getLetterPosXLeft(v8, v35);
if ( (float)(v37 - v15) < (float)(v15 - (float)(v29 + (float)(i * v48))) )
++v34;
if ( v34 > v22 )
v49 = v22;
else
v49 = v34;
if ( v49 < v26 || v11 > 1 )
{
v50 = v49 + v12;
v51 = *(_QWORD *)(a1 + 576);
if ( *(int *)(a1 + 504) > 0 )
v50 = CCTextInputNode::displayToRawIndex((CCTextInputNode *)a1, v50);
*(_DWORD *)(v51 + 752) = v50;
CCTextInputNode::updateBlinkLabel((CCTextInputNode *)a1);
return _stack_chk_guard;
}
LABEL_33:
if ( v59 )
return _stack_chk_guard;
LABEL_34:
*(_DWORD *)(*(_QWORD *)(a1 + 576) + 752LL) = -1;
CCTextInputNode::updateBlinkLabel((CCTextInputNode *)a1);
return _stack_chk_guard;
}