//
// KeybindingsLayer::init from 0x58a814 to 0x58ad70 (1372 bytes)
//
// 2 xrefs:
// > KeybindingsLayer::create @ 0x58afe0
// > LevelBindingsLayer::init @ 0x797920
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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 11:53:01 +0000
//
int __fastcall KeybindingsLayer::init(KeybindingsLayer *this, GameSettingsLayer *a2)
{
int v4; // r10
_DWORD *v5; // r0
cocos2d::CCDirector *v6; // r0
float v7; // s18
float v8; // s17
int v9; // r1
int v10; // r2
int v11; // r3
int *v12; // r0
float v13; // s17
int *v14; // r6
void (__fastcall *v15)(int *, _DWORD *); // r7
ScrollableContentLayer *v16; // r6
cocos2d::CCMenu *v17; // r0
int v18; // r0
float v19; // s17
float v20; // s19
float v21; // s17
int v22; // r6
void (__fastcall *v23)(int, _DWORD *); // r7
void (__fastcall *v24)(int, _DWORD *); // r3
void (__fastcall *v25)(int, _DWORD *); // r11
int *v26; // r0
int v27; // r1
int v28; // r11
int v29; // r6
void (__fastcall *v30)(int, _DWORD *); // r7
const char *v31; // r1
int v32; // r7
int v33; // r0
void (__fastcall *v34)(int, _DWORD *); // r11
const char *v35; // r1
int v36; // r5
int v37; // r6
void (__fastcall *v38)(int, _BYTE *); // r11
int v39; // r7
unsigned int v40; // r3
const char *v41; // r6
size_t v42; // r0
char *v44; // [sp+8h] [bp-5Ch]
cocos2d::CCPoint *v45; // [sp+10h] [bp-54h]
cocos2d::CCPoint *v46; // [sp+10h] [bp-54h]
int v47; // [sp+14h] [bp-50h]
_BYTE v48[4]; // [sp+18h] [bp-4Ch] BYREF
int v49; // [sp+1Ch] [bp-48h]
float v50; // [sp+20h] [bp-44h] BYREF
float v51; // [sp+24h] [bp-40h]
_BYTE v52[8]; // [sp+28h] [bp-3Ch] BYREF
_BYTE v53[8]; // [sp+30h] [bp-34h] BYREF
int (__fastcall *v54)(int, cocos2d::CCObject *, int, int); // [sp+38h] [bp-2Ch]
int v55; // [sp+3Ch] [bp-28h]
int v56; // [sp+40h] [bp-24h] BYREF
int v57; // [sp+44h] [bp-20h]
int v58; // [sp+48h] [bp-1Ch]
_DWORD v59[4]; // [sp+4Ch] [bp-18h] BYREF
v4 = SetupTriggerPopup::init(this, nullptr, nullptr, 400.0, 280.0, 7, 0.0);
if ( v4 )
{
*((_DWORD *)this + 188) = a2;
if ( a2 )
cocos2d::CCObject::retain(a2);
if ( !*((_DWORD *)this + 189) )
{
v5 = (_DWORD *)operator new(4u);
*v5 = &off_CB40E8;
*((_DWORD *)this + 189) = v5;
*((_BYTE *)this + 760) = 1;
}
SetupTriggerPopup::preSetup(this);
qmemcpy(v48, "PWi", 3);
SetupTriggerPopup::setCustomBGColor(this, v48);
*((_BYTE *)this + 468) = 1;
TabbedPopupLayer::addCloseButton(this);
v6 = (cocos2d::CCDirector *)(*(int (__fastcall **)(KeybindingsLayer *))(*(_DWORD *)this + 756))(this);
cocos2d::CCDirector::sharedDirector(v6);
cocos2d::CCDirector::getWinSize((cocos2d::CCDirector *)&v50);
v7 = (float)(v51 * 0.5) - 128.0;
v8 = *((float *)this + 139) - 30.0;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)v59, v8, (float)((float)(v51 * 0.5) + 96.0) - v7);
v12 = ScrollableContentLayer::create((const cocos2d::CCSize *)v59, v9, v10, v11);
v13 = (float)(v50 * 0.5) - (float)(v8 * 0.5);
*((_DWORD *)this + 194) = v12;
v14 = v12;
v15 = *(void (__fastcall **)(int *, _DWORD *))(*v12 + 92);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v59, v13, v7);
v15(v14, v59);
v16 = *((ScrollableContentLayer **)this + 194);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v59, 2.0, 0.0);
ScrollableContentLayer::setThumbOffset(v16, (int)v59);
v17 = (cocos2d::CCMenu *)(*(int (__fastcall **)(_DWORD, _DWORD, int))(**((_DWORD **)this + 115) + 232))(
*((_DWORD *)this + 115),
*((_DWORD *)this + 194),
5);
v18 = cocos2d::CCMenu::create(v17);
*((_DWORD *)this + 195) = v18;
(*(void (__fastcall **)(int, void *))(*(_DWORD *)v18 + 148))(v18, &unk_D2C3B4);
(*(void (__fastcall **)(_DWORD, void *))(**((_DWORD **)this + 195) + 160))(*((_DWORD *)this + 195), &unk_D2C3BC);
(*(void (__fastcall **)(_DWORD, void *))(**((_DWORD **)this + 195) + 92))(*((_DWORD *)this + 195), &unk_D2C3B4);
(*(void (__fastcall **)(_DWORD, _DWORD, int))(**(_DWORD **)(*((_DWORD *)this + 194) + 320) + 232))(
*(_DWORD *)(*((_DWORD *)this + 194) + 320),
*((_DWORD *)this + 195),
2);
v19 = *((float *)this + 139);
v20 = (float)(v51 * 0.5) + 80.0;
cocos2d::CCRect::CCRect((cocos2d::CCRect *)v59, 0.0, 0.0, 40.0, 40.0);
v21 = v19 - 30.0;
v22 = cocos2d::extension::CCScale9Sprite::create("square02_small.png", v59);
v23 = *(void (__fastcall **)(int, _DWORD *))(*(_DWORD *)v22 + 160);
cocos2d::CCSize::CCSize((cocos2d::CCSize *)v59, v21, 30.0);
v23(v22, v59);
(*(void (__fastcall **)(int, int))(*(_DWORD *)v22 + 456))(v22, 100);
v24 = *(void (__fastcall **)(int, _DWORD *))(*(_DWORD *)v22 + 480);
LOWORD(v59[0]) = 0;
BYTE2(v59[0]) = 0;
v24(v22, v59);
v25 = *(void (__fastcall **)(int, _DWORD *))(*(_DWORD *)v22 + 92);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v59, v50 * 0.5, v20);
v25(v22, v59);
(*(void (__fastcall **)(int, _DWORD))(*(_DWORD *)v22 + 172))(v22, 0);
(*(void (__fastcall **)(_DWORD, int, _DWORD))(**((_DWORD **)this + 115) + 232))(*((_DWORD *)this + 115), v22, 0);
*((_DWORD *)this + 192) = v22;
v26 = CCTextInputNode::create(
COERCE_CCTEXTINPUTNODE_(v21 - 20.0),
30.0,
"Search...",
"Thonburi",
(const char *)&dword_14,
"bigFont.fnt",
v44);
LOWORD(v49) = -26986;
BYTE2(v49) = -106;
v27 = v49;
*((_DWORD *)this + 191) = v26;
CCTextInputNode::setLabelPlaceholderColor((unsigned int)v26, v27);
CCTextInputNode::setLabelPlaceholderScale(*((_DWORD *)this + 191), 0.4);
CCTextInputNode::setMaxLabelScale(*((_DWORD *)this + 191), 0.4);
CCTextInputNode::setMaxLabelWidth(*((_DWORD *)this + 191), v21 - 60.0);
*(_DWORD *)(*((_DWORD *)this + 191) + 420) = (char *)this + 440;
v28 = *((_DWORD *)this + 191);
v56 = 0;
v57 = 0;
v58 = 0;
std::string::__init(
&v56,
" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,-!?:;)(/\\\"'`*=+-_%[]<>|@&^#{}%$~",
0x61u);
CCTextInputNode::setAllowedChars(v28, (unsigned __int8 *)&v56);
std::string::~string((int)&v56);
v29 = *((_DWORD *)this + 191);
v30 = *(void (__fastcall **)(int, _DWORD *))(*(_DWORD *)v29 + 92);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v59, v50 * 0.5, v20);
v30(v29, v59);
(*(void (__fastcall **)(_DWORD, _DWORD))(**((_DWORD **)this + 191) + 500))(*((_DWORD *)this + 191), 0);
(*(void (__fastcall **)(_DWORD, _DWORD))(**((_DWORD **)this + 191) + 172))(*((_DWORD *)this + 191), 0);
(*(void (__fastcall **)(_DWORD, _DWORD, int))(**((_DWORD **)this + 115) + 232))(
*((_DWORD *)this + 115),
*((_DWORD *)this + 191),
1);
v32 = cocos2d::CCSprite::createWithSpriteFrameName((cocos2d::CCSprite *)"GJ_longBtn07_001.png", v31);
(*(void (__fastcall **)(int, int))(*(_DWORD *)v32 + 80))(v32, 1058642330);
v55 = 0;
v54 = KeybindingsLayer::onClearSearch;
v33 = CCMenuItemSpriteExtra::create(v32, 0, (int)this, (int)KeybindingsLayer::onClearSearch, 0);
*((_DWORD *)this + 193) = v33;
(*(void (__fastcall **)(_DWORD, int))(**((_DWORD **)this + 111) + 228))(*((_DWORD *)this + 111), v33);
v47 = *((_DWORD *)this + 193);
v34 = *(void (__fastcall **)(int, _DWORD *))(*(_DWORD *)v47 + 92);
v45 = *((cocos2d::CCPoint **)this + 111);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v53, (float)((float)(v21 * 0.5) + (float)(v50 * 0.5)) - 24.0, v20);
cocos2d::CCNode::convertToNodeSpace((cocos2d::CCNode *)v59, v45);
v34(v47, v59);
(*(void (__fastcall **)(_DWORD, _DWORD))(**((_DWORD **)this + 193) + 172))(*((_DWORD *)this + 193), 0);
v36 = cocos2d::CCSprite::createWithSpriteFrameName((cocos2d::CCSprite *)"GJ_optionsBtn02_001.png", v35);
(*(void (__fastcall **)(int, int))(*(_DWORD *)v36 + 80))(v36, 1060320051);
v59[1] = 0;
v59[0] = KeybindingsLayer::onSettings;
v37 = CCMenuItemSpriteExtra::create(v36, 0, (int)this, (int)KeybindingsLayer::onSettings, 0);
(*(void (__fastcall **)(_DWORD, int))(**((_DWORD **)this + 111) + 228))(*((_DWORD *)this + 111), v37);
v38 = *(void (__fastcall **)(int, _BYTE *))(*(_DWORD *)v37 + 92);
v46 = *((cocos2d::CCPoint **)this + 111);
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)v52,
(float)((float)(*((float *)this + 139) * 0.5) + (float)(v50 * 0.5)) - 20.0,
(float)((float)(*((float *)this + 140) * 0.5) + (float)(v51 * 0.5)) - 20.0);
cocos2d::CCNode::convertToNodeSpace((cocos2d::CCNode *)v53, v46);
v38(v37, v53);
SetupTriggerPopup::postSetup(this);
std::string::operator=((unsigned __int8 *)this + 788, (unsigned __int8 *)&KeybindingsLayer::s_lastSearchText);
v39 = *((_DWORD *)this + 191);
if ( !v39 )
goto LABEL_13;
v40 = *((unsigned __int8 *)this + 788);
if ( (v40 & 1) != 0 )
{
if ( !*((_DWORD *)this + 198) )
goto LABEL_13;
v41 = *((const char **)this + 199);
}
else
{
if ( !(v40 >> 1) )
{
LABEL_13:
*((_DWORD *)this + 184) = -1;
(*(void (__fastcall **)(KeybindingsLayer *))(*(_DWORD *)this + 752))(this);
return v4;
}
v41 = (char *)this + 789;
}
v56 = 0;
v57 = 0;
v58 = 0;
v42 = strlen(v41);
std::string::__init(&v56, v41, v42);
CCTextInputNode::setString(v39, (int)&v56);
std::string::~string((int)&v56);
goto LABEL_13;
}
return v4;
}