//
// KeybindingsLayer::init from 0x997494 to 0x997bc8 (1844 bytes)
//
// 4 xrefs:
// > KeybindingsLayer::create @ 0x997e68
// > LevelBindingsLayer::init @ 0xcf0dd4
// > LevelBindingsLayer::init @ 0xcf0e00
// > ??> @ 0xa9b88
//
// 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 12:58:03 +0000
//
__int64 __fastcall KeybindingsLayer::init(KeybindingsLayer *this, GameSettingsLayer *a2)
{
unsigned __int8 v4; // w0
unsigned int v5; // w23
cocos2d::CCDirector *v6; // x0
cocos2d::CCDirector *v7; // x0
float v8; // s10
float v9; // s8
__int64 v10; // x21
void (__fastcall *v11)(__int64, __int64 *); // x25
ScrollableContentLayer *v12; // x21
cocos2d::CCMenu *v13; // x0
__int64 v14; // x0
float v15; // s10
float v16; // s8
__int64 v17; // x21
void (__fastcall *v18)(__int64, __int64 *); // x25
void (__fastcall *v19)(__int64, __int64 *); // x2
void (__fastcall *v20)(__int64, __int64 *); // x25
const char *v21; // x4
__int64 v22; // x0
__int64 v23; // x21
__int64 v24; // x25
void (__fastcall *v25)(__int64, __int64 *); // x27
const char *v26; // x1
__int64 v27; // x25
__int64 v28; // x0
__int64 v29; // x25
cocos2d::CCNode *v30; // x28
void (__fastcall *v31)(__int64, __int64 *); // x27
const char *v32; // x1
__int64 v33; // x25
__int64 v34; // x25
cocos2d::CCNode *v35; // x28
void (__fastcall *v36)(__int64, __int64 *); // x27
size_t v37; // x2
char *v38; // x1
_QWORD *v39; // x20
int v40; // w0
const char *v41; // x1
size_t v42; // x0
__int64 v43; // x1
__int64 v44; // x2
_QWORD *v46; // x0
char *v47; // [xsp+88h] [xbp+88h]
_BYTE v48[8]; // [xsp+90h] [xbp+90h] BYREF
__int64 v49; // [xsp+98h] [xbp+98h]
__int64 v50; // [xsp+A0h] [xbp+A0h] BYREF
_BYTE v51[8]; // [xsp+A8h] [xbp+A8h] BYREF
__int64 v52[2]; // [xsp+B0h] [xbp+B0h] BYREF
__int64 v53; // [xsp+C0h] [xbp+C0h] BYREF
__int64 v54; // [xsp+C8h] [xbp+C8h]
void *v55; // [xsp+D0h] [xbp+D0h]
v4 = SetupTriggerPopup::init(this, nullptr, nullptr, 400.0, 280.0, 7, 0.0);
v5 = v4;
if ( !v4 )
return v5;
*((_QWORD *)this + 136) = a2;
if ( a2 )
cocos2d::CCObject::retain(a2);
if ( !*((_QWORD *)this + 137) )
{
v46 = (_QWORD *)operator new(8u);
*v46 = off_1474950;
*((_QWORD *)this + 137) = v46;
*((_BYTE *)this + 1104) = 1;
}
SetupTriggerPopup::preSetup(this);
qmemcpy(v48, "PWi", 3);
SetupTriggerPopup::setCustomBGColor(this, v48);
*((_BYTE *)this + 596) = 1;
TabbedPopupLayer::addCloseButton(this);
v6 = (cocos2d::CCDirector *)(*(__int64 (__fastcall **)(KeybindingsLayer *))(*(_QWORD *)this + 1512LL))(this);
v7 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v6);
cocos2d::CCDirector::getWinSize(&v50, v7);
v8 = (float)(*((float *)&v50 + 1) * 0.5) + -128.0;
v9 = *((float *)this + 183) - 30.0;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)v52, v9, (float)((float)(*((float *)&v50 + 1) * 0.5) + 96.0) - v8);
v10 = ScrollableContentLayer::create((const cocos2d::CCSize *)v52);
*((_QWORD *)this + 142) = v10;
v11 = *(void (__fastcall **)(__int64, __int64 *))(*(_QWORD *)v10 + 184LL);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v52, -(float)((float)(v9 * 0.5) - (float)(*(float *)&v50 * 0.5)), v8);
v11(v10, v52);
v12 = *((ScrollableContentLayer **)this + 142);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v52, 2.0, 0.0);
ScrollableContentLayer::setThumbOffset(v12, (__int64)v52);
v13 = (cocos2d::CCMenu *)(*(__int64 (__fastcall **)(_QWORD, _QWORD, __int64))(**((_QWORD **)this + 73) + 464LL))(
*((_QWORD *)this + 73),
*((_QWORD *)this + 142),
5);
v14 = cocos2d::CCMenu::create(v13);
*((_QWORD *)this + 143) = v14;
(*(void (__fastcall **)(__int64, void *))(*(_QWORD *)v14 + 296LL))(v14, &unk_155D270);
(*(void (__fastcall **)(_QWORD, void *))(**((_QWORD **)this + 143) + 320LL))(*((_QWORD *)this + 143), &unk_155D278);
(*(void (__fastcall **)(_QWORD, void *))(**((_QWORD **)this + 143) + 184LL))(*((_QWORD *)this + 143), &unk_155D270);
(*(void (__fastcall **)(_QWORD, _QWORD, __int64))(**(_QWORD **)(*((_QWORD *)this + 142) + 416LL) + 464LL))(
*(_QWORD *)(*((_QWORD *)this + 142) + 416LL),
*((_QWORD *)this + 143),
2);
v15 = (float)(*((float *)&v50 + 1) * 0.5) + 80.0;
v16 = *((float *)this + 183) - 30.0;
cocos2d::CCRect::CCRect((cocos2d::CCRect *)v52, 0.0, 0.0, 40.0, 40.0);
v17 = cocos2d::extension::CCScale9Sprite::create("square02_small.png", v52);
v18 = *(void (__fastcall **)(__int64, __int64 *))(*(_QWORD *)v17 + 320LL);
cocos2d::CCSize::CCSize((cocos2d::CCSize *)v52, v16, 30.0);
v18(v17, v52);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v17 + 912LL))(v17, 100);
v19 = *(void (__fastcall **)(__int64, __int64 *))(*(_QWORD *)v17 + 960LL);
LOWORD(v52[0]) = 0;
BYTE2(v52[0]) = 0;
v19(v17, v52);
v20 = *(void (__fastcall **)(__int64, __int64 *))(*(_QWORD *)v17 + 184LL);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v52, *(float *)&v50 * 0.5, v15);
v20(v17, v52);
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)v17 + 344LL))(v17, 0);
(*(void (__fastcall **)(_QWORD, __int64, _QWORD))(**((_QWORD **)this + 73) + 464LL))(*((_QWORD *)this + 73), v17, 0);
*((_QWORD *)this + 140) = v17;
v22 = CCTextInputNode::create(
(CCTextInputNode *)"Search...",
v16 - 20.0,
30.0,
"Thonburi",
(const char *)&dword_14,
"bigFont.fnt",
v21);
*((_QWORD *)this + 139) = v22;
LOWORD(v49) = -26986;
BYTE2(v49) = -106;
CCTextInputNode::setLabelPlaceholderColor(v22, v49);
CCTextInputNode::setLabelPlaceholderScale(*((CCTextInputNode **)this + 139), 0.4);
CCTextInputNode::setMaxLabelScale(*((CCTextInputNode **)this + 139), 0.4);
CCTextInputNode::setMaxLabelWidth(*((CCTextInputNode **)this + 139), v16 - 60.0);
*(_QWORD *)(*((_QWORD *)this + 139) + 584LL) = (char *)this + 544;
v53 = 0;
v23 = *((_QWORD *)this + 139);
v54 = 0;
v55 = nullptr;
std::string::__init(
&v53,
" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,-!?:;)(/\\\"'`*=+-_%[]<>|@&^#{}%$~",
0x61u);
CCTextInputNode::setAllowedChars(v23, (__int64)&v53);
if ( (v53 & 1) != 0 )
operator delete(v55);
v24 = *((_QWORD *)this + 139);
v25 = *(void (__fastcall **)(__int64, __int64 *))(*(_QWORD *)v24 + 184LL);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v52, *(float *)&v50 * 0.5, v15);
v25(v24, v52);
(*(void (__fastcall **)(_QWORD, _QWORD))(**((_QWORD **)this + 139) + 1000LL))(*((_QWORD *)this + 139), 0);
(*(void (__fastcall **)(_QWORD, _QWORD))(**((_QWORD **)this + 139) + 344LL))(*((_QWORD *)this + 139), 0);
(*(void (__fastcall **)(_QWORD, _QWORD, __int64))(**((_QWORD **)this + 73) + 464LL))(
*((_QWORD *)this + 73),
*((_QWORD *)this + 139),
1);
v27 = cocos2d::CCSprite::createWithSpriteFrameName((cocos2d::CCSprite *)"GJ_longBtn07_001.png", v26);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v27 + 160LL))(v27, 0.6);
v28 = CCMenuItemSpriteExtra::create(v27, 0, (__int64)this, (__int64)KeybindingsLayer::onClearSearch, 0);
*((_QWORD *)this + 141) = v28;
(*(void (__fastcall **)(_QWORD, __int64))(**((_QWORD **)this + 69) + 456LL))(*((_QWORD *)this + 69), v28);
v29 = *((_QWORD *)this + 141);
v30 = *((cocos2d::CCNode **)this + 69);
v31 = *(void (__fastcall **)(__int64, __int64 *))(*(_QWORD *)v29 + 184LL);
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)v51,
(float)((float)(v16 * 0.5) + (float)(*(float *)&v50 * 0.5)) - 24.0,
v15);
cocos2d::CCNode::convertToNodeSpace(v52, v30, (const cocos2d::CCPoint *)v51);
v31(v29, v52);
(*(void (__fastcall **)(_QWORD, _QWORD))(**((_QWORD **)this + 141) + 344LL))(*((_QWORD *)this + 141), 0);
v33 = cocos2d::CCSprite::createWithSpriteFrameName((cocos2d::CCSprite *)"GJ_optionsBtn02_001.png", v32);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v33 + 160LL))(v33, 0.7);
v34 = CCMenuItemSpriteExtra::create(v33, 0, (__int64)this, (__int64)KeybindingsLayer::onSettings, 0);
(*(void (__fastcall **)(_QWORD, __int64))(**((_QWORD **)this + 69) + 456LL))(*((_QWORD *)this + 69), v34);
v35 = *((cocos2d::CCNode **)this + 69);
v36 = *(void (__fastcall **)(__int64, __int64 *))(*(_QWORD *)v34 + 184LL);
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)v51,
(float)((float)(*((float *)this + 183) * 0.5) + (float)(*(float *)&v50 * 0.5)) - 20.0,
(float)((float)(*((float *)this + 184) * 0.5) + (float)(*((float *)&v50 + 1) * 0.5)) - 20.0);
cocos2d::CCNode::convertToNodeSpace(v52, v35, (const cocos2d::CCPoint *)v51);
v36(v34, v52);
SetupTriggerPopup::postSetup(this);
if ( (__int64 *)((char *)this + 1160) != &KeybindingsLayer::s_lastSearchText )
{
if ( (KeybindingsLayer::s_lastSearchText & 1) != 0 )
{
v38 = (char *)qword_155D2B0;
v37 = qword_155D2A8;
}
else
{
v37 = (unsigned __int8)KeybindingsLayer::s_lastSearchText >> 1;
v38 = (char *)&KeybindingsLayer::s_lastSearchText + 1;
}
std::string::assign((__int64 *)this + 145, v38, v37);
}
v39 = *((_QWORD **)this + 139);
if ( v39 )
{
v40 = *((unsigned __int8 *)this + 1160);
if ( (v40 & 1) != 0 )
{
if ( *((_QWORD *)this + 146) )
{
v41 = *((const char **)this + 147);
goto LABEL_16;
}
}
else if ( v40 >> 1 )
{
v41 = (char *)this + 1161;
LABEL_16:
v47 = (char *)v41;
v53 = 0;
v54 = 0;
v55 = nullptr;
v42 = strlen(v41);
std::string::__init(&v53, v47, v42);
CCTextInputNode::setString(v39, (char *)&v53);
if ( (v53 & 1) != 0 )
operator delete(v55);
}
}
if ( KeybindingsLayer::s_lastActiveTab < 0 )
{
v43 = 0;
}
else if ( KeybindingsLayer::s_lastActiveTab >= (int)(954437177
* ((__int64)(*((_QWORD *)this + 128) - *((_QWORD *)this + 127)) >> 3)) )
{
v43 = 0;
}
else
{
v43 = (unsigned int)KeybindingsLayer::s_lastActiveTab;
}
v44 = *(_QWORD *)this;
*((_DWORD *)this + 266) = -1;
(*(void (__fastcall **)(KeybindingsLayer *, __int64))(v44 + 1504))(this, v43);
return v5;
}