//
// CCTextInputNode::onTextFieldAttachWithIME from 0x10009fcd0 to 0x10009ffb7 (743 bytes)
//
// 2 xrefs:
// > sub_10009FFE0 @ 0x10009ffeb
// > ??> @ 0x1008b6c18
//
// 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 __fastcall CCTextInputNode::onTextFieldAttachWithIME(CCTextInputNode *a1, cocos2d::CCTextFieldTTF *a2)
{
__m128 v2; // xmm0
cocos2d::CCLabelBMFont *m_cursor; // rdi
const char *v5; // rax
const char *v6; // r15
size_t v7; // rax
size_t v8; // r14
char *v9; // r12
size_t v10; // r13
TextInputDelegate *m_delegate; // rdi
cocos2d::CCDirector *v12; // rsi
__int64 v13; // rsi
double v14; // xmm0_8
__int64 v15; // rsi
double v16; // xmm0_8
__int64 v17; // rax
double v18; // xmm0_8
TextInputDelegate *v19; // rdi
double v20; // xmm1_8
size_t v22; // r14
cocos2d::CCLabelBMFont *m_textLabel; // rdi
TextArea *m_textArea; // rdi
char v25; // [rsp+8h] [rbp-88h] BYREF
float v26; // [rsp+Ch] [rbp-84h]
_WORD v27[8]; // [rsp+10h] [rbp-80h] BYREF
void *__p; // [rsp+20h] [rbp-70h]
__int16 v29; // [rsp+28h] [rbp-68h] BYREF
char v30; // [rsp+2Ah] [rbp-66h]
void *v31; // [rsp+38h] [rbp-58h]
float v32[2]; // [rsp+44h] [rbp-4Ch] BYREF
float v33; // [rsp+4Ch] [rbp-44h]
size_t __dst; // [rsp+50h] [rbp-40h] BYREF
size_t v35; // [rsp+58h] [rbp-38h] BYREF
void *v36; // [rsp+60h] [rbp-30h]
double v37; // 0:xmm0_8.8
m_cursor = a1->m_cursor;
if ( m_cursor )
{
a2 = (cocos2d::CCTextFieldTTF *)1;
((void (__fastcall *)(cocos2d::CCLabelBMFont *, __int64))m_cursor->setVisible)(m_cursor, 1);
}
a1->m_selected = 1;
PlatformToolbox::setKeyboardState(1);
if ( a1->m_numberInput )
{
v5 = (const char *)((__int64 (__fastcall *)(cocos2d::CCTextFieldTTF *, cocos2d::CCTextFieldTTF *))a1->m_textField->getString)(
a1->m_textField,
a2);
*(double *)v2.i64 = atof(v5);
if ( *(double *)v2.i64 == 0.0 )
{
v27[0] = 0;
a2 = (cocos2d::CCTextFieldTTF *)v27;
CCTextInputNode::setString(a1, (__int64)v27, v2);
if ( (v27[0] & 1) != 0 )
operator delete(__p);
}
}
v6 = (const char *)((__int64 (__fastcall *)(cocos2d::CCTextFieldTTF *, cocos2d::CCTextFieldTTF *))a1->m_textField->getString)(
a1->m_textField,
a2);
v7 = strlen(v6);
if ( v7 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(*(double *)v2.i64);
v8 = v7;
if ( v7 >= 0x17 )
{
v10 = 26;
if ( (v7 | 7) != 0x17 )
v10 = (v7 | 7) + 1;
v9 = (char *)operator new(v10);
v36 = v9;
__dst = v10 + 1;
v35 = v8;
goto LABEL_14;
}
LOBYTE(__dst) = 2 * v7;
v9 = (char *)&__dst + 1;
if ( v7 )
LABEL_14:
memmove(v9, v6, v8);
v9[v8] = 0;
if ( (__dst & 1) == 0 )
{
if ( (unsigned __int8)__dst >> 1 )
goto LABEL_17;
LABEL_24:
m_textLabel = a1->m_textLabel;
if ( m_textLabel )
{
((void (__fastcall *)(cocos2d::CCLabelBMFont *, const std::string::value_type *))m_textLabel->setString)(
m_textLabel,
" ");
}
else
{
m_textArea = a1->m_textArea;
if ( m_textArea )
{
v29 = 8194;
v30 = 0;
TextArea::setString(m_textArea, &v29);
if ( (v29 & 1) != 0 )
operator delete(v31);
}
}
CCTextInputNode::updateBlinkLabelToChar(a1, a1->m_textField->m_uCursorPos);
m_delegate = a1->m_delegate;
if ( m_delegate )
goto LABEL_18;
goto LABEL_19;
}
v22 = v35;
operator delete(v36);
if ( !v22 )
goto LABEL_24;
LABEL_17:
m_delegate = a1->m_delegate;
if ( m_delegate )
LABEL_18:
((void (__fastcall *)(TextInputDelegate *, CCTextInputNode *))m_delegate->textInputOpened)(m_delegate, a1);
LABEL_19:
if ( a1->m_forceOffset )
{
v12 = cocos2d::CCDirector::sharedDirector();
*(cocos2d::CCSize *)&v37 = cocos2d::CCDirector::getWinSize((cocos2d::CCDirector *)&v25);
v13 = ((__int64 (__fastcall *)(cocos2d::CCTextFieldTTF *, cocos2d::CCDirector *, double))a1->m_textField->getAnchorPoint)(
a1->m_textField,
v12,
v37);
v14 = sub_10028CC60(v32);
sub_10028D130(&__dst, v13, v14);
v15 = ((__int64 (__fastcall *)(CCTextInputNode *))a1->getPosition)(a1);
v16 = sub_10028CC90();
v17 = ((__int64 (__fastcall *)(CCTextInputNode *, __int64, double))a1->getContentSize)(a1, v15, v16);
sub_10028CFF0(&v35, v17);
*(float *)&__dst = *(float *)&__dst - (float)(*(float *)&v35 * v32[0]);
*((float *)&__dst + 1) = (float)(*((float *)&__dst + 1) - (float)(*((float *)&v35 + 1) * v32[1])) + -4.0;
v33 = v26;
v18 = sub_10028D2C0(&__dst);
v19 = a1->m_delegate;
if ( v19 )
{
*(_QWORD *)&v20 = LODWORD(v33);
*(float *)&v20 = (float)(v33 * 0.5) - *(float *)&v18;
((void (__fastcall *)(TextInputDelegate *, CCTextInputNode *, double))v19->textInputShouldOffset)(v19, a1, v20);
}
}
return 0;
}