//
// KeybindingsLayer::init from 0x1403d57f0 to 0x1403d6049 (2137 bytes)
//
// 5 xrefs:
// > KeybindingsLayer::create @ 0x1403d5695
// > LevelBindingsLayer::create @ 0x14044c6a2
// > ??> @ 0x1408c3914
// > ??> @ 0x1408c3928
// > ??> @ 0x1409249c8
//
// This function is hookable on this platform (idp: pc, 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 11:31:36 +0000
//
char __fastcall KeybindingsLayer::init(__int64 *a1, cocos2d::CCObject *a2, __int64 a3, int a4)
{
char result; // al
_QWORD *v7; // rax
__int64 v8; // rax
__int64 v9; // rcx
__int64 v10; // rax
__int64 v11; // rcx
__int64 v12; // rax
float v13; // xmm7_4
float v14; // xmm6_4
const struct cocos2d::CCSize *v15; // rax
cocos2d::CCObject *v16; // rax
float v17; // xmm1_4
cocos2d::CCObject *v18; // rdi
__int64 v19; // rbx
__int64 v20; // rax
__int64 v21; // rbx
__int64 v22; // rax
__int64 v23; // rdx
__int64 v24; // rcx
__int64 v25; // rax
float v26; // xmm7_4
float v27; // xmm9_4
__int64 v28; // rax
_QWORD *v29; // rdi
__int64 v30; // rbx
__int64 v31; // rax
__int64 v32; // rdx
void (__fastcall *v33)(_QWORD *, __int64); // r8
void (__fastcall **v34)(__int64, __int16 *); // rax
__int64 v35; // rbx
__int64 v36; // rax
__int64 v37; // rdx
__int64 v38; // rcx
char *v39; // rax
__int64 v40; // rcx
__int64 v41; // rcx
__int64 v42; // rcx
__int64 v43; // rax
__int64 *v44; // rbx
__int64 v45; // rdi
__int64 v46; // rax
struct cocos2d::CCSprite *v47; // rax
cocos2d::CCObject *v48; // rax
__int64 v49; // rcx
__int64 *v50; // rdi
__int64 v51; // rbx
__int64 v52; // rsi
__int64 v53; // rax
__int64 v54; // rax
struct cocos2d::CCSprite *v55; // rax
cocos2d::CCObject *v56; // rsi
__int64 v57; // rdi
__int64 v58; // rbx
__int64 v59; // rax
__int64 v60; // rax
void **v61; // rdx
_QWORD *v62; // rbx
size_t v63; // r8
unsigned int v64; // r8d
__int64 v65; // rax
float v66; // [rsp+40h] [rbp-59h] BYREF
float v67; // [rsp+44h] [rbp-55h]
__int128 v68; // [rsp+48h] [rbp-51h] BYREF
__int64 v69; // [rsp+58h] [rbp-41h]
__int64 v70; // [rsp+60h] [rbp-39h]
__int16 v71; // [rsp+110h] [rbp+77h] BYREF
char v72; // [rsp+112h] [rbp+79h]
_BYTE v73[3]; // [rsp+118h] [rbp+7Fh] BYREF
result = SetupTriggerPopup::init((_DWORD)a1, 0, 0, a4, 1133248512, 7, 0);
if ( result )
{
a1[134] = (__int64)a2;
if ( a2 )
cocos2d::CCObject::retain(a2);
if ( !a1[135] )
{
v7 = operator new(8u);
*v7 = &GlobalKeybindSource::`vftable';
a1[135] = (__int64)v7;
*((_BYTE *)a1 + 1088) = 1;
}
v8 = *a1;
*((_BYTE *)a1 + 744) = 1;
(*(void (__fastcall **)(__int64 *))(v8 + 1096))(a1);
v9 = a1[73];
v71 = 22352;
qmemcpy(v73, "PWi", sizeof(v73));
v10 = (*(__int64 (__fastcall **)(__int64, __int64))(*(_QWORD *)v9 + 472LL))(v9, 3);
if ( v10 )
(**(void (__fastcall ***)(__int64, _BYTE *))(v10 + 320))(v10 + 320, v73);
*((_BYTE *)a1 + 596) = 1;
TabbedPopupLayer::addCloseButton(a1);
(*(void (__fastcall **)(__int64 *))(*a1 + 1208))(a1);
v12 = cocos2d::CCDirector::sharedDirector(v11);
cocos2d::CCDirector::getWinSize(v12, &v66);
v13 = *((float *)a1 + 183) - 30.0;
v14 = (float)(v67 * 0.5) - 128.0;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v71, v13, (float)((float)(v67 * 0.5) + 96.0) - v14);
v16 = ScrollableContentLayer::create(v15);
v17 = v66 * 0.5;
v18 = v16;
a1[140] = (__int64)v16;
v19 = *(_QWORD *)v16;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v71, v17 - (float)(v13 * 0.5), v14);
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(v19 + 184))(v18, v20);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v71, 2.0, 0.0);
v21 = a1[140];
cocos2d::CCPoint::operator=(v21 + 500, v22);
ScrollableContentLayer::updateScrollThumb(v21, v23);
(*(void (__fastcall **)(__int64, __int64, __int64))(*(_QWORD *)a1[73] + 456LL))(a1[73], a1[140], 5);
v25 = cocos2d::CCMenu::create(v24);
a1[141] = v25;
(*(void (__fastcall **)(__int64, void *))(*(_QWORD *)v25 + 288LL))(v25, &unk_14090AE50);
(*(void (__fastcall **)(__int64, void *))(*(_QWORD *)a1[141] + 312LL))(a1[141], &unk_14090AE68);
(*(void (__fastcall **)(__int64, void *))(*(_QWORD *)a1[141] + 184LL))(a1[141], &unk_14090AE50);
(*(void (__fastcall **)(_QWORD, __int64, __int64))(**(_QWORD **)(a1[140] + 416) + 456LL))(
*(_QWORD *)(a1[140] + 416),
a1[141],
2);
v26 = *((float *)a1 + 183) - 30.0;
v27 = (float)(v67 * 0.5) + 80.0;
cocos2d::CCRect::CCRect((cocos2d::CCRect *)&v68, 0.0, 0.0, 40.0, 40.0);
v29 = (_QWORD *)cocos2d::extension::CCScale9Sprite::create("square02_small.png", v28);
v30 = *v29;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v71, v26, 30.0);
(*(void (__fastcall **)(_QWORD *, __int64))(v30 + 312))(v29, v31);
v32 = v29[40];
v33 = *(void (__fastcall **)(_QWORD *, __int64))(v32 + 40);
LOBYTE(v32) = 100;
v33(v29 + 40, v32);
v71 = 0;
v34 = (void (__fastcall **)(__int64, __int16 *))v29[40];
v72 = 0;
(*v34)((__int64)(v29 + 40), &v71);
v35 = *v29;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v71, v66 * 0.5, v27);
(*(void (__fastcall **)(_QWORD *, __int64))(v35 + 184))(v29, v36);
(*(void (__fastcall **)(_QWORD *, _QWORD))(*v29 + 336LL))(v29, 0);
(*(void (__fastcall **)(__int64, _QWORD *, _QWORD))(*(_QWORD *)a1[73] + 456LL))(a1[73], v29, 0);
a1[138] = (__int64)v29;
v39 = CCTextInputNode::create(v38, v37, (__int64)"Search...");
a1[137] = (__int64)v39;
v71 = -26986;
*((_WORD *)v39 + 286) = -26986;
v39[574] = -106;
CCTextInputNode::refreshLabel((__int64)v39);
v40 = a1[137];
*(_DWORD *)(v40 + 568) = 1053609165;
CCTextInputNode::refreshLabel(v40);
v41 = a1[137];
*(_DWORD *)(v41 + 564) = 1053609165;
CCTextInputNode::refreshLabel(v41);
v42 = a1[137];
*(float *)(v42 + 560) = v26 - 60.0;
CCTextInputNode::refreshLabel(v42);
v43 = a1[137];
v68 = 0;
*(_QWORD *)(v43 + 600) = a1 + 68;
v69 = 0;
v70 = 0;
*(_QWORD *)&v68 = sub_14003D460(0x70u);
v69 = 97;
v70 = 111;
strcpy(
(char *)v68,
" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,-!?:;)(/\\\"'`*=+-_%[]<>|@&^#{}%$~");
CCTextInputNode::setAllowedChars(a1[137], (void **)&v68);
v44 = (__int64 *)a1[137];
v45 = *v44;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v71, v66 * 0.5, v27);
(*(void (__fastcall **)(__int64 *, __int64))(v45 + 184))(v44, v46);
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)a1[137] + 920LL))(a1[137], 0);
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)a1[137] + 336LL))(a1[137], 0);
(*(void (__fastcall **)(__int64, __int64, __int64))(*(_QWORD *)a1[73] + 456LL))(a1[73], a1[137], 1);
v47 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_longBtn07_001.png");
LODWORD(v44) = (_DWORD)v47;
(*(void (__fastcall **)(struct cocos2d::CCSprite *))(*(_QWORD *)v47 + 160LL))(v47);
v48 = CCMenuItemSpriteExtra::create((int)v44, 0, (int)a1, (__int64)KeybindingsLayer::onClearSearch);
v49 = a1[69];
a1[139] = (__int64)v48;
(*(void (__fastcall **)(__int64, cocos2d::CCObject *))(*(_QWORD *)v49 + 464LL))(v49, v48);
v50 = (__int64 *)a1[139];
v51 = a1[69];
v52 = *v50;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v71, (float)((float)(v26 * 0.5) + (float)(v66 * 0.5)) - 24.0, v27);
cocos2d::CCNode::convertToNodeSpace(v51, &v68, v53);
(*(void (__fastcall **)(__int64 *, __int64))(v52 + 184))(v50, v54);
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)a1[139] + 336LL))(a1[139], 0);
v55 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_optionsBtn02_001.png");
LODWORD(v51) = (_DWORD)v55;
(*(void (__fastcall **)(struct cocos2d::CCSprite *))(*(_QWORD *)v55 + 160LL))(v55);
v56 = CCMenuItemSpriteExtra::create(v51, 0, (int)a1, (__int64)KeybindingsLayer::onSettings);
(*(void (__fastcall **)(__int64, cocos2d::CCObject *))(*(_QWORD *)a1[69] + 464LL))(a1[69], v56);
v57 = *(_QWORD *)v56;
v58 = a1[69];
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)&v71,
(float)((float)(*((float *)a1 + 183) * 0.5) + (float)(v66 * 0.5)) - 20.0,
(float)((float)(*((float *)a1 + 184) * 0.5) + (float)(v67 * 0.5)) - 20.0);
cocos2d::CCNode::convertToNodeSpace(v58, &v68, v59);
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(v57 + 184))(v56, v60);
(*(void (__fastcall **)(__int64 *))(*a1 + 1136))(a1);
v61 = &qword_1408FE4A8;
v62 = a1 + 143;
*((_BYTE *)a1 + 744) = 0;
if ( a1 + 143 != (__int64 *)&qword_1408FE4A8 )
{
if ( (unsigned __int64)qword_1408FE4C0 > 0xF )
v61 = (void **)qword_1408FE4A8;
sub_1400405A0((void **)a1 + 143, v61, qword_1408FE4B8);
}
if ( a1[137] && a1[145] )
{
if ( (unsigned __int64)a1[146] > 0xF )
v62 = (_QWORD *)*v62;
v69 = 0;
v68 = 0;
v70 = 0;
v63 = -1;
do
++v63;
while ( *((_BYTE *)v62 + v63) );
sub_14003D230(&v68, v62, v63);
CCTextInputNode::setString((_QWORD *)a1[137], &v68);
}
v64 = dword_140909798;
if ( dword_140909798 < 0 || dword_140909798 >= (int)((a1[126] - a1[125]) / 88) )
v64 = 0;
v65 = *a1;
*((_DWORD *)a1 + 262) = -1;
(*(void (__fastcall **)(__int64 *, _QWORD))(v65 + 1200))(a1, v64);
return 1;
}
return result;
}