//
// CCTextInputNode::onTextFieldAttachWithIME from 0x5a4bc0 to 0x5a5024 (1124 bytes)
//
// 3 xrefs:
// > `non-virtual thunk to'CCTextInputNode::onTextFieldAttachWithIME @ 0x5a5028
// > ??> @ 0x517f8
// > ??> @ 0x1141348
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
bool CCTextInputNode::onTextFieldAttachWithIME(CCTextInputNode *a1, cocos2d::CCTextFieldTTF *a2)
{
cocos2d::CCLabelBMFont *m_cursor; // x0
char *v4; // x0
_DWORD *v5; // x23
cocos2d::CCPoint origin; // x27
unsigned __int64 v7; // x21
unsigned __int64 v8; // x28
size_t v9; // x2
int v10; // w20
__int64 v11; // x21
__int64 *v12; // x0
char *v13; // x0
cocos2d::CCLabelBMFont *m_textLabel; // x0
TextInputDelegate *m_delegate; // x0
unsigned int *v17; // x27
int v18; // w1
unsigned int *v19; // x23
int v20; // w1
cocos2d::CCDirector *v21; // x0
const cocos2d::CCPoint *v22; // x0
float v23; // s0
TextInputDelegate *v24; // x0
const char *v25; // x0
void *v26; // x0
TextArea *m_textArea; // x20
void *v28; // x23
unsigned int *v29; // x21
int v30; // w0
unsigned int *v31; // x1
int v32; // w2
float v33; // [xsp+8Ch] [xbp+8Ch]
void *v34; // [xsp+90h] [xbp+90h] BYREF
cocos2d::CCRect v35; // [xsp+98h] [xbp+98h] BYREF
cocos2d::CCSize WinSize; // 0:kr00_8.8
m_cursor = a1->m_cursor;
if ( m_cursor )
m_cursor->setVisible(m_cursor, 1);
a1->m_selected = (unsigned __int8)&dword_0 + 1;
PlatformToolbox::setKeyboardState((bool)&dword_0 + 1);
if ( a1->m_numberInput )
{
v25 = (const char *)a1->m_textField->getString(a1->m_textField);
if ( atof(v25) == 0.0 )
{
sub_D153B8((int)&v35, &byte_F288A0);
CCTextInputNode::setString(a1, (const unsigned __int8 **)&v35);
v26 = (void *)(*(_QWORD *)&v35.origin - 24LL);
if ( (__int64 *)(*(_QWORD *)&v35.origin - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v31 = (unsigned int *)(*(_QWORD *)&v35.origin - 8LL);
do
v32 = __ldaxr(v31);
while ( __stlxr(v32 - 1, v31) );
}
else
{
v32 = *(_DWORD *)(*(_QWORD *)&v35.origin - 8LL);
*(_DWORD *)(*(_QWORD *)&v35.origin - 8LL) = v32 - 1;
}
if ( v32 <= 0 )
operator delete(v26);
}
}
}
v4 = (char *)a1->m_textField->getString(a1->m_textField);
sub_D153B8((int)&v34, v4);
sub_D153B8((int)&v35, &byte_F288A0);
v5 = v34;
origin = v35.origin;
v7 = *((_QWORD *)v34 - 3);
v8 = *(_QWORD *)(*(_QWORD *)&v35.origin - 24LL);
if ( v8 > v7 )
v9 = *((_QWORD *)v34 - 3);
else
v9 = *(_QWORD *)(*(_QWORD *)&v35.origin - 24LL);
v10 = memcmp(v34, *(const void **)&v35.origin, v9);
if ( v10 || (v10 = 0x7FFFFFFF, v11 = v7 - v8, v11 > 0x7FFFFFFF) )
{
v12 = (__int64 *)(*(_QWORD *)&origin - 24LL);
if ( (__int64 *)(*(_QWORD *)&origin - 24LL) == &qword_124B6B0 )
goto LABEL_10;
}
else
{
v12 = (__int64 *)(*(_QWORD *)&origin - 24LL);
if ( v11 >= (__int64)0xFFFFFFFF80000000LL )
v10 = v11;
else
v10 = 0x80000000;
if ( v12 == &qword_124B6B0 )
{
LABEL_10:
v13 = (char *)(v5 - 6);
if ( v5 - 6 == (_DWORD *)&qword_124B6B0 )
goto LABEL_11;
goto LABEL_29;
}
}
if ( &pthread_create )
{
v17 = (unsigned int *)(*(_QWORD *)&origin - 8LL);
do
v18 = __ldaxr(v17);
while ( __stlxr(v18 - 1, v17) );
}
else
{
v18 = *(_DWORD *)(*(_QWORD *)&origin - 8LL);
*(_DWORD *)(*(_QWORD *)&origin - 8LL) = v18 - 1;
}
if ( v18 <= 0 )
operator delete(v12);
v5 = v34;
v13 = (char *)v34 - 24;
if ( (char *)v34 - 24 != (char *)&qword_124B6B0 )
{
LABEL_29:
if ( &pthread_create )
{
v19 = v5 - 2;
do
v20 = __ldaxr(v19);
while ( __stlxr(v20 - 1, v19) );
}
else
{
v20 = *(v5 - 2);
*(v5 - 2) = v20 - 1;
}
if ( v20 <= 0 )
operator delete(v13);
}
LABEL_11:
if ( !v10 )
{
m_textLabel = a1->m_textLabel;
if ( m_textLabel )
{
m_textLabel->setString(m_textLabel, (const unsigned __int8 *)" ");
}
else
{
m_textArea = a1->m_textArea;
if ( m_textArea )
{
sub_D153B8((int)&v35, " ");
TextArea::setString((__int64)m_textArea, (const void **)&v35);
v28 = (void *)(*(_QWORD *)&v35.origin - 24LL);
if ( (__int64 *)(*(_QWORD *)&v35.origin - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v29 = (unsigned int *)(*(_QWORD *)&v35.origin - 8LL);
do
v30 = __ldaxr(v29);
while ( __stlxr(v30 - 1, v29) );
}
else
{
v30 = *(_DWORD *)(*(_QWORD *)&v35.origin - 8LL);
*(_DWORD *)(*(_QWORD *)&v35.origin - 8LL) = v30 - 1;
}
if ( v30 <= 0 )
operator delete(v28);
}
}
}
CCTextInputNode::updateBlinkLabel(a1);
}
m_delegate = a1->m_delegate;
if ( m_delegate )
m_delegate->textInputOpened(m_delegate, a1);
if ( a1->m_forceOffset )
{
v21 = cocos2d::CCDirector::sharedDirector();
WinSize = cocos2d::CCDirector::getWinSize(v21);
v22 = (const cocos2d::CCPoint *)((__int64 (__fastcall *)(cocos2d::CCTextFieldTTF *, float, float))a1->m_textField->getAnchorPoint)(
a1->m_textField,
WinSize.width,
WinSize.height);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v34, v22);
sub_5951D8((__int64)a1, (float *)&v34, &v35);
v35.origin.y = v35.origin.y - 4.0;
cocos2d::CCRect::getMinY(&v35);
v24 = a1->m_delegate;
if ( v24 )
v24->textInputShouldOffset(v24, a1, -(float)(v23 - (float)(v33 * 0.5)));
}
return 0;
}