//
// CCTextInputNode::onTextFieldInsertText from 0x2fae14 to 0x2faffe (490 bytes)
//
// 1 xrefs:
// > `non-virtual thunk to'CCTextInputNode::onTextFieldInsertText @ 0x2fb00c
//
// 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::onTextFieldInsertText(
CCTextInputNode *a1,
cocos2d::CCTextFieldTTF *a2,
const char *a3,
int a4,
cocos2d::enumKeyCodes a5)
{
cocos2d::enumKeyCodes v7; // r5
cocos2d::CCTextFieldTTF *m_textField; // r2
int m_uCursorPos; // r3
unsigned int i; // r10
unsigned int v12; // r2
unsigned int m_maxLabelLength; // r3
char *v14; // r2
char v15; // r4
int v16; // r4
int v18; // [sp+4h] [bp-20h]
int v19; // [sp+8h] [bp-1Ch] BYREF
char *v20; // [sp+Ch] [bp-18h] BYREF
_BYTE v21[4]; // [sp+10h] [bp-14h] BYREF
_BYTE v22[4]; // [sp+14h] [bp-10h] BYREF
char v23[4]; // [sp+18h] [bp-Ch] BYREF
v7 = a5;
switch ( a5 )
{
case KEY_ArrowLeft:
v7 = KEY_Left;
goto LABEL_8;
case KEY_ArrowRight:
v7 = KEY_Right;
goto LABEL_8;
case KEY_Left:
case KEY_Right:
LABEL_8:
m_textField = a1->m_textField;
m_uCursorPos = m_textField->m_uCursorPos;
if ( v7 != KEY_Left )
{
if ( m_uCursorPos < 0 )
m_uCursorPos = -1;
else
++m_uCursorPos;
if ( m_textField->m_nCharCount <= m_uCursorPos )
m_uCursorPos = -1;
goto LABEL_18;
}
if ( m_uCursorPos >= 0 )
{
if ( !m_uCursorPos )
{
LABEL_18:
m_textField->m_uCursorPos = m_uCursorPos;
CCTextInputNode::updateBlinkLabel(a1);
return 1;
}
}
else
{
m_uCursorPos = m_textField->m_nCharCount;
}
--m_uCursorPos;
goto LABEL_18;
}
if ( a3 && strlen(a3) > 1 )
{
sub_776584((int)&v19, (char *)a3);
sub_776584((int)&v20, (char *)&unk_939830);
sub_775C20(v21, &a1->m_allowedChars);
for ( i = 0; i < *(_DWORD *)(v19 - 12); ++i )
{
v18 = *(unsigned __int8 *)sub_7757BC(&v19, i);
if ( sub_774910(v21, v18, 0) != -1 )
sub_77458C(&v20, v18);
}
v12 = *((_DWORD *)v20 - 3);
if ( v12 )
{
m_maxLabelLength = a1->m_maxLabelLength;
if ( v12 >= m_maxLabelLength )
{
sub_776158(v22, &v20, 0, m_maxLabelLength - 1);
sub_774794(&v20, v22);
sub_774008(v22);
}
sub_776584((int)v23, v20);
CCTextInputNode::setString((int)a1, v23, v14);
sub_774008(v23);
a1->onClickTrackNode(a1, 0);
sub_774008(v21);
sub_774008(&v20);
sub_774008(&v19);
return 1;
}
sub_774008(v21);
sub_774008(&v20);
sub_774008(&v19);
}
if ( *a3 == 10 )
return 0;
sub_775C20(v23, &a1->m_allowedChars);
if ( sub_7748A0((int)v23, (char *)a3) == -1 )
{
v15 = 1;
}
else
{
v16 = a1->m_maxLabelLength;
v15 = a2->m_nCharCount >= v16 && v16 > 0;
}
sub_774008(v23);
return v15;
}