//
// CCTextInputNode::insertAtCursor from 0x1001fbd54 to 0x1001fbfe4 (656 bytes)
//
// 2 xrefs:
// > CCTextInputNode::onTextFieldInsertText @ 0x1001fd8c8
// > EmotePickerPopup::onPickEmote @ 0x1004dbb44
//
// 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 11:00:43 +0000
//
void __fastcall CCTextInputNode::insertAtCursor(__int64 a1, __int64 a2)
{
void *v4; // x9
char v5; // w8
char *v6; // x0
int v7; // w20
int v8; // w8
void **v9; // x2
std::string::size_type v10; // x3
int v11; // w21
int v12; // w0
__int64 v13; // x8
int v14; // w9
__int64 v15; // x10
std::string *v16; // x9
int v17; // w11
__int64 v18; // x1
std::string::value_type v19; // t1
std::string __p; // [xsp+0h] [xbp-70h] BYREF
std::string v21; // [xsp+20h] [xbp-50h] BYREF
void *v22[2]; // [xsp+38h] [xbp-38h] BYREF
__int64 v23; // [xsp+48h] [xbp-28h]
if ( *(int *)(a1 + 504) >= 1 )
{
EmoteSprite::translateUnicodeEmoji(v22, a2);
if ( *(char *)(a2 + 23) < 0 )
operator delete(*(void **)a2);
*(_OWORD *)a2 = *(_OWORD *)v22;
*(_QWORD *)(a2 + 16) = v23;
}
sub_1001FC030(v22, a2, *(unsigned __int8 *)(a1 + 625), a1 + 472, *(unsigned __int8 *)(a1 + 624));
v4 = (void *)HIBYTE(v23);
v5 = HIBYTE(v23);
if ( v23 < 0 )
v4 = v22[1];
if ( v4 )
{
v6 = (char *)(*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 576) + 1248LL))(*(_QWORD *)(a1 + 576));
sub_100009900(&v21, v6);
if ( (*(_DWORD *)(*(_QWORD *)(a1 + 576) + 752LL) & 0x80000000) != 0 )
{
v8 = HIBYTE(v21.__r_.__value_.__r.__words[2]);
if ( (v21.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v7 = HIBYTE(v21.__r_.__value_.__r.__words[2]);
else
v7 = v21.__r_.__value_.__r.__words[1];
if ( (*((_BYTE *)&v21.__r_.__value_.__s + 23) & 0x80) == 0 )
goto LABEL_10;
}
else
{
v7 = sub_1001FC2D0(&v21);
v8 = HIBYTE(v21.__r_.__value_.__r.__words[2]);
if ( (*((_BYTE *)&v21.__r_.__value_.__s + 23) & 0x80) == 0 )
{
LABEL_10:
if ( v7 > v8 )
{
if ( !v8 )
goto LABEL_26;
goto LABEL_21;
}
if ( v7 > 0 )
{
LABEL_21:
if ( v7 <= (unsigned int)v8 )
goto LABEL_27;
goto LABEL_25;
}
LABEL_26:
v7 = 0;
goto LABEL_27;
}
}
if ( v7 <= SLODWORD(v21.__r_.__value_.__r.__words[1]) )
{
if ( v7 <= 0 )
goto LABEL_26;
}
else if ( SLODWORD(v21.__r_.__value_.__r.__words[1]) <= 0 )
{
goto LABEL_26;
}
v8 = v21.__r_.__value_.__r.__words[1];
if ( v7 <= SLODWORD(v21.__r_.__value_.__r.__words[1]) )
{
LABEL_27:
if ( v23 >= 0 )
v9 = v22;
else
v9 = (void **)v22[0];
if ( v23 >= 0 )
v10 = HIBYTE(v23);
else
v10 = (std::string::size_type)v22[1];
std::string::insert(&v21, v7, (const std::string::value_type *)v9, v10);
v11 = *(_DWORD *)(a1 + 592);
if ( v11 >= 1 && (int)sub_1001FC380(&v21) > v11 )
{
v12 = sub_1001FC2D0(&v21);
std::string::resize(&v21, v12, 0);
}
if ( SHIBYTE(v21.__r_.__value_.__r.__words[2]) < 0 )
sub_1000097D0(&__p, v21.__r_.__value_.__l.__data_, v21.__r_.__value_.__l.__size_);
else
__p = v21;
CCTextInputNode::setString((_QWORD *)a1, (__int64 *)&__p);
if ( SHIBYTE(__p.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__p.__r_.__value_.__l.__data_);
v13 = *(_QWORD *)(a1 + 576);
if ( (*(_DWORD *)(v13 + 752) & 0x80000000) == 0 )
{
v14 = HIBYTE(v23);
if ( v23 < 0 )
v14 = (int)v22[1];
LODWORD(v15) = v7 + v14;
v16 = (std::string *)v21.__r_.__value_.__r.__words[0];
if ( (v21.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v16 = &v21;
v17 = HIBYTE(v21.__r_.__value_.__r.__words[2]);
if ( (v21.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
v17 = v21.__r_.__value_.__r.__words[1];
if ( v17 >= (int)v15 )
v15 = (unsigned int)v15;
else
v15 = (unsigned int)v17;
if ( (int)v15 < 1 )
{
v18 = 0;
}
else
{
LODWORD(v18) = 0;
do
{
v19 = v16->__r_.__value_.__s.__data_[0];
v16 = (std::string *)((char *)v16 + 1);
if ( (v19 & 0xC0) == 0x80 )
v18 = (unsigned int)v18;
else
v18 = (unsigned int)(v18 + 1);
--v15;
}
while ( v15 );
}
*(_DWORD *)(v13 + 752) = v18;
sub_1001FCD10(a1, v18);
}
if ( SHIBYTE(v21.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v21.__r_.__value_.__l.__data_);
v5 = HIBYTE(v23);
goto LABEL_63;
}
LABEL_25:
v7 = v8;
goto LABEL_27;
}
LABEL_63:
if ( v5 < 0 )
operator delete(v22[0]);
}