//
// CCTextInputNode::onTextFieldInsertText from 0x10016d7a0 to 0x10016db0c (876 bytes)
//
// 2 xrefs:
// > sub_10016DB7C @ 0x10016db80
// > ??> @ 0x10079fa80
//
// 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::onTextFieldInsertText(
CCTextInputNode *a1,
cocos2d::CCTextFieldTTF *a2,
const char *a3,
int a4,
cocos2d::enumKeyCodes a5)
{
cocos2d::enumKeyCodes v6; // w8
int v7; // w10
cocos2d::CCTextFieldTTF *m_textField; // x8
int m_uCursorPos; // w9
bool v10; // cf
int v11; // w9
int v12; // w1
int v15; // w9
bool v16; // w21
std::string::size_type size; // x8
std::string::size_type i; // x22
std::string::value_type v20; // w23
std::string::size_type v21; // x8
char v22; // w8
std::string::size_type v23; // x9
std::string::size_type m_maxLabelLength; // x10
std::string *p_str; // x1
char v26; // w22
int v27; // w26
__int128 v28; // kr00_16
std::string *p_m_allowedChars; // x27
signed __int64 v30; // x25
signed __int64 v31; // x0
signed __int64 v32; // x23
char *v33; // x28
int v34; // w24
std::string *v35; // x0
char *v36; // x0
char *v37; // x25
int v38; // w9
void *__p[2]; // [xsp+0h] [xbp-E0h] BYREF
char v41; // [xsp+17h] [xbp-C9h]
std::string v42; // [xsp+18h] [xbp-C8h] BYREF
std::string __dst; // [xsp+30h] [xbp-B0h] BYREF
std::string __str; // [xsp+50h] [xbp-90h] BYREF
std::string m_allowedChars; // [xsp+70h] [xbp-70h] BYREF
std::allocator __a; // [xsp+8Fh] [xbp-51h] BYREF
if ( a5 == KEY_ArrowRight )
v6 = KEY_Right;
else
v6 = a5;
if ( a5 == KEY_ArrowLeft )
v7 = 37;
else
v7 = v6;
if ( (v7 | 2) == 0x27 )
{
m_textField = a1->m_textField;
m_uCursorPos = m_textField->m_uCursorPos;
if ( v7 == 37 )
{
if ( m_uCursorPos < 0 )
{
v12 = m_textField->m_nCharCount - 1;
}
else
{
v10 = m_uCursorPos != 0;
v11 = m_uCursorPos - 1;
if ( v10 )
v12 = v11;
else
v12 = 0;
}
}
else
{
if ( m_uCursorPos >= 0 )
v15 = m_uCursorPos + 1;
else
v15 = -1;
if ( v15 >= m_textField->m_nCharCount )
v12 = -1;
else
v12 = v15;
}
m_textField->m_uCursorPos = v12;
CCTextInputNode::updateBlinkLabelToChar(a1, v12);
return 1;
}
if ( a3 && strlen(a3) >= 2 )
{
sub_100009900(&m_allowedChars, (char *)a3);
sub_100009900(&__str, "");
if ( a1->m_allowedChars.m_data.m_short.shortStorage.__elems_[22] < 0 )
sub_1000097D0(&__dst, (void *)a1->m_allowedChars.m_data.m_long.capacitym1, a1->m_allowedChars.m_data.m_long.size);
else
__dst = (std::string)a1->m_allowedChars;
size = HIBYTE(m_allowedChars.__r_.__value_.__r.__words[2]);
if ( (m_allowedChars.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
size = m_allowedChars.__r_.__value_.__l.__size_;
if ( size )
{
for ( i = 0; i < v21; ++i )
{
v20 = *std::string::at(&m_allowedChars, i);
if ( std::string::find(&__dst, v20, 0) != -1 )
std::string::push_back(&__str, v20);
v21 = HIBYTE(m_allowedChars.__r_.__value_.__r.__words[2]);
if ( (m_allowedChars.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
v21 = m_allowedChars.__r_.__value_.__l.__size_;
}
}
v22 = HIBYTE(__str.__r_.__value_.__r.__words[2]);
if ( (SHIBYTE(__str.__r_.__value_.__r.__words[2]) & 0x8000000000000000LL) != 0 )
{
v23 = __str.__r_.__value_.__l.__size_;
if ( __str.__r_.__value_.__l.__size_ )
goto LABEL_41;
}
else if ( *((_BYTE *)&__str.__r_.__value_.__s + 23) )
{
v23 = SHIBYTE(__str.__r_.__value_.__r.__words[2]);
LABEL_41:
m_maxLabelLength = a1->m_maxLabelLength;
if ( v23 >= m_maxLabelLength )
{
std::string::basic_string(&v42, &__str, 0, m_maxLabelLength - 1, &__a);
if ( SHIBYTE(__str.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__str.__r_.__value_.__l.__data_);
__str = v42;
v22 = HIBYTE(v42.__r_.__value_.__r.__words[2]);
}
if ( v22 >= 0 )
p_str = &__str;
else
p_str = (std::string *)__str.__r_.__value_.__r.__words[0];
sub_100009900(__p, (char *)p_str);
CCTextInputNode::setString(a1, (__int64 **)__p);
if ( v41 < 0 )
operator delete(__p[0]);
v26 = 0;
LABEL_52:
if ( SHIBYTE(__dst.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__dst.__r_.__value_.__l.__data_);
if ( SHIBYTE(__str.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__str.__r_.__value_.__l.__data_);
if ( SHIBYTE(m_allowedChars.__r_.__value_.__r.__words[2]) < 0 )
operator delete(m_allowedChars.__r_.__value_.__l.__data_);
if ( (v26 & 1) == 0 )
return 1;
goto LABEL_59;
}
v26 = 1;
goto LABEL_52;
}
LABEL_59:
if ( *a3 == 10 )
return 0;
if ( a1->m_allowedChars.m_data.m_short.shortStorage.__elems_[22] < 0 )
sub_1000097D0(
&m_allowedChars,
(void *)a1->m_allowedChars.m_data.m_long.capacitym1,
a1->m_allowedChars.m_data.m_long.size);
else
m_allowedChars = (std::string)a1->m_allowedChars;
v27 = SHIBYTE(m_allowedChars.__r_.__value_.__r.__words[2]);
v28 = *(_OWORD *)&m_allowedChars.__r_.__value_.__l.__data_;
if ( (m_allowedChars.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
p_m_allowedChars = &m_allowedChars;
else
p_m_allowedChars = (std::string *)m_allowedChars.__r_.__value_.__r.__words[0];
if ( (m_allowedChars.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v30 = HIBYTE(m_allowedChars.__r_.__value_.__r.__words[2]);
else
v30 = m_allowedChars.__r_.__value_.__l.__size_;
v31 = strlen(a3);
if ( v31 )
{
v32 = v31;
if ( v30 >= v31 )
{
v33 = (char *)p_m_allowedChars + v30;
v34 = *a3;
v35 = p_m_allowedChars;
do
{
if ( v30 - v32 == -1 )
break;
v36 = (char *)memchr(v35, v34, v30 - v32 + 1);
if ( !v36 )
break;
v37 = v36;
if ( !memcmp(v36, a3, v32) )
{
v16 = 1;
if ( v37 == v33 || v37 - (char *)p_m_allowedChars == -1 )
goto LABEL_87;
goto LABEL_81;
}
v35 = (std::string *)(v37 + 1);
v30 = v33 - (v37 + 1);
}
while ( v30 >= v32 );
}
v16 = 1;
}
else
{
LABEL_81:
v38 = a1->m_maxLabelLength;
v16 = a2->m_nCharCount >= v38 && v38 > 0;
}
LABEL_87:
if ( v27 < 0 )
operator delete((void *)v28);
return v16;
}