//
// UILayer::refreshDpad from 0x100051004 to 0x10005112c (296 bytes)
//
// 3 xrefs:
// > UILayer::togglePlatformerMode @ 0x100050db8
// > UILayer::reapplyLevelControls @ 0x100050fd8
// > PlayLayer::resume @ 0x10014c768
//
// 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 10:57:43 +0000
//
__int64 __fastcall UILayer::refreshDpad(__int64 result)
{
__int64 v1; // x29
__int64 v2; // x30
__int64 v3; // x19
__int64 v4; // x0
__int64 v5; // x8
__int64 GameVariable; // x0
int v7; // w22
__int64 v8; // x0
__int64 v9; // x0
__int64 v10; // x0
__int64 v11; // x0
__int64 v12; // x23
__int64 v13; // x20
char v14; // w24
__int64 v15; // x21
_QWORD *v16; // x1
_QWORD v17[5]; // [xsp+0h] [xbp-80h] BYREF
_QWORD v18[11]; // [xsp+28h] [xbp-58h] BYREF
if ( *(_BYTE *)(result + 596) == 1 )
{
v18[9] = v1;
v18[10] = v2;
v3 = result;
UILayer::resolveLevelControls(result);
v5 = *(_QWORD *)(v3 + 640);
if ( !v5 || *(_QWORD *)(v5 + 152) == *(_QWORD *)(v5 + 160) )
{
v8 = GameManager::sharedState(v4);
GameVariable = GameManager::getGameVariable(v8, "0113");
v7 = 0;
}
else
{
GameVariable = *(_DWORD *)(v5 + 68) != 0;
v7 = 1;
}
*(_BYTE *)(v3 + 625) = GameVariable;
v9 = GameManager::sharedState(GameVariable);
v10 = GameManager::prepareDPadSettings(v9);
v11 = cocos2d::CCDirector::sharedDirector(v10);
cocos2d::CCDirector::getWinSize(v18, v11);
v12 = 0;
v13 = 0;
v14 = *(_BYTE *)(v3 + 624);
do
{
v15 = sub_1002E75A0(*(_QWORD *)(v3 + 616), v13);
if ( v7
&& v13 < (int)(-286331153
* ((*(_QWORD *)(*(_QWORD *)(v3 + 640) + 160LL) - *(_QWORD *)(*(_QWORD *)(v3 + 640) + 152LL)) >> 2)) )
{
sub_1004F1A5C(v17);
v16 = v17;
}
else
{
v16 = (_QWORD *)sub_100050DD8(v13, *(unsigned __int8 *)(v3 + 624));
}
result = sub_1000514CC(v15, v16);
if ( (unsigned __int64)v13 > 2 )
break;
++v13;
v12 += 60;
}
while ( (v14 & 1) != 0 );
}
return result;
}