//
// KeybindCapturePopup::keyDown from 0xcf7e84 to 0xcf7fdc (344 bytes)
//
// 3 xrefs:
// > `non-virtual thunk to'KeybindCapturePopup::keyDown @ 0xcf7fe0
// > ??> @ 0x544d8
// > ??> @ 0x15049e8
//
// 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 13:06:49 +0000
//
__int64 __fastcall KeybindCapturePopup::keyDown(__int64 a1, int a2)
{
unsigned __int16 v2; // w20
__int64 result; // x0
__int64 v5; // x0
cocos2d::CCDirector *v6; // x0
unsigned __int8 v7; // w22
__int64 v8; // x0
cocos2d::CCDirector *v9; // x0
unsigned __int8 v10; // w21
__int64 v11; // x0
__int64 v12; // x0
GJKeybindManager *v13; // x0
int v14; // w20
ControllerInputNode *v15; // x0
bool *v16; // x2
CCMenuItemToggler *v17; // x0
v2 = a2;
if ( a2 == 27 )
return (*(__int64 (__fastcall **)(__int64, _QWORD))(*(_QWORD *)a1 + 1368LL))(a1, 0);
if ( a2 > 27 )
{
result = (unsigned int)(a2 - 160);
if ( (unsigned int)result <= 3 )
return result;
}
else
{
result = (unsigned int)(a2 - 16);
if ( (unsigned int)result <= 2 )
return result;
}
v5 = cocos2d::CCDirector::sharedDirector((cocos2d::CCDirector *)result);
v6 = (cocos2d::CCDirector *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v5 + 192LL))(v5);
v7 = *((_BYTE *)v6 + 129);
v8 = cocos2d::CCDirector::sharedDirector(v6);
v9 = (cocos2d::CCDirector *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v8 + 192LL))(v8);
v10 = *((_BYTE *)v9 + 130);
v11 = cocos2d::CCDirector::sharedDirector(v9);
v12 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v11 + 192LL))(v11);
v13 = (GJKeybindManager *)GJKeybindManager::encodeChord(v2, v7, v10, *(_BYTE *)(v12 + 128));
v14 = (int)v13;
if ( !*(_BYTE *)(a1 + 1055)
|| (result = GJKeybindManager::isControllerChord(v13), *(unsigned __int8 *)(a1 + 1054) == (unsigned __int8)result) )
{
if ( *(_BYTE *)(a1 + 1053) && v14 == *(_DWORD *)(a1 + 1048) )
{
return KeybindCapturePopup::onSet(a1, nullptr);
}
else
{
v15 = *(ControllerInputNode **)(a1 + 1072);
*(_DWORD *)(a1 + 1048) = v14;
*(_BYTE *)(a1 + 1053) = 0;
if ( v15 )
{
ControllerInputNode::setController2(v15, !(v14 & 1));
ControllerInputNode::setActiveKey(
*(ControllerInputNode **)(a1 + 1072),
(unsigned __int16)v14 - (unsigned int)!(v14 & 1),
v16);
v17 = *(CCMenuItemToggler **)(a1 + 1080);
if ( v17 )
CCMenuItemToggler::toggle(v17, !(v14 & 1));
}
return KeybindCapturePopup::updateChordDisplay((KeybindCapturePopup *)a1);
}
}
return result;
}