//
// UILayer::handleKeypress from 0x1004c8fc0 to 0x1004c931a (858 bytes)
//
// 6 xrefs:
// > UILayer::keyDown @ 0x1004c94da
// > sub_1004C94E0 @ 0x1004c94f1
// > sub_1004C9500 @ 0x1004c9511
// > UILayer::keyUp @ 0x1004c9527
// > sub_1004C9530 @ 0x1004c953e
// > sub_1004C9550 @ 0x1004c955e
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
// local variable allocation has failed, the output may be wrong!
void __fastcall UILayer::handleKeypress(UILayer *a1, cocos2d::enumKeyCodes a2, bool a3, double a4)
{
GJBaseGameLayer *m_gameLayer; // rdi
int v5; // esi
GJBaseGameLayer *v6; // rdi
int v7; // esi
bool m_editorMode; // al
GameManager *v9; // rax
GameManager *v10; // rax
cocos2d::CCDirector *v11; // rax
char v12; // bl
PlayLayer *m_playLayer; // rdi
GameManager *v14; // rax
GameManager *v15; // rax
GameManager *v16; // rax
switch ( a2 )
{
case 1001:
case 1013:
LABEL_3:
if ( !a3 )
{
a1->m_p1Jumping = 0;
m_gameLayer = a1->m_gameLayer;
v5 = 1;
a3 = 0;
goto LABEL_19;
}
if ( !a1->m_p1Jumping )
{
a1->m_p1Jumping = 1;
m_gameLayer = a1->m_gameLayer;
v5 = 1;
a3 = 1;
goto LABEL_19;
}
return;
case 1002:
case 1015:
LABEL_14:
if ( !a3 )
{
a1->m_p2Jumping = 0;
v6 = a1->m_gameLayer;
v7 = 1;
a3 = 0;
goto LABEL_29;
}
if ( !a1->m_p2Jumping )
{
a1->m_p2Jumping = 1;
v6 = a1->m_gameLayer;
v7 = 1;
a3 = 1;
goto LABEL_29;
}
return;
case 1003:
LABEL_20:
if ( a3 )
{
m_editorMode = a1->m_editorMode;
goto LABEL_25;
}
return;
case 1004:
case 1005:
case 1006:
case 1008:
case 1011:
case 1012:
case 1014:
case 1016:
case 1017:
case 1018:
case 1019:
case 1020:
case 1021:
case 1022:
case 1023:
case 1024:
case 1029:
case 1030:
case 1031:
case 1032:
case 1037:
case 1038:
case 1039:
case 1040:
case 1042:
return;
case 1007:
LABEL_22:
if ( a3 )
{
m_editorMode = a1->m_editorMode;
if ( m_editorMode || a1->m_checkpointBtnDown )
{
LABEL_25:
if ( !m_editorMode && a1->m_gameLayer->m_isPracticeMode )
UILayer::onDeleteCheck(a1, *(cocos2d::CCObject **)&a2);
}
else
{
a1->m_checkpointBtnDown = 1;
if ( a1->m_gameLayer->m_isPracticeMode )
UILayer::onCheck(a1, *(cocos2d::CCObject **)&a2);
}
}
else
{
a1->m_checkpointBtnDown = 0;
}
return;
case 1009:
case 1010:
LABEL_9:
if ( a3
&& !a1->m_editorMode
&& (!GameManager::sharedState()->m_playLayer
|| (int)GameManager::sharedState()->m_playLayer->m_gameState.m_pauseCounter <= 2) )
{
UILayer::doPause(a1);
}
return;
case 1025:
case 1033:
LABEL_8:
m_gameLayer = a1->m_gameLayer;
v5 = 2;
goto LABEL_19;
case 1026:
case 1034:
case 1041:
LABEL_6:
v6 = a1->m_gameLayer;
v7 = 2;
goto LABEL_29;
case 1027:
case 1035:
LABEL_17:
m_gameLayer = a1->m_gameLayer;
v5 = 3;
LABEL_19:
GJBaseGameLayer::queueButton(m_gameLayer, v5, a3, 0, a4);
return;
case 1028:
case 1036:
case 1043:
LABEL_7:
v6 = a1->m_gameLayer;
v7 = 3;
LABEL_29:
GJBaseGameLayer::queueButton(v6, v7, a3, 1, a4);
break;
default:
*(_QWORD *)&a2 = (unsigned int)(a2 - 27);
switch ( *(_QWORD *)&a2 )
{
case 0LL:
goto LABEL_9;
case 5LL:
case 0x3CLL:
goto LABEL_3;
case 0xALL:
goto LABEL_6;
case 0xBLL:
goto LABEL_14;
case 0xCLL:
goto LABEL_7;
case 0x26LL:
goto LABEL_8;
case 0x29LL:
goto LABEL_17;
case 0x35LL:
if ( a3 && !a1->m_editorMode )
{
v14 = GameManager::sharedState();
if ( GameManager::getGameVariable(v14, "0163")
&& GameManager::sharedState()->m_playLayer
&& GameManager::sharedState()->m_playLayer->m_isPracticeMode )
{
v15 = GameManager::sharedState();
GameManager::toggleGameVariable(v15, "0166");
v16 = GameManager::sharedState();
PlayLayer::updateDebugDrawSettings(v16->m_playLayer);
}
}
break;
case 0x37LL:
if ( a3 && !a1->m_editorMode )
{
v9 = GameManager::sharedState();
if ( GameManager::getGameVariable(v9, "0163") )
{
if ( GameManager::sharedState()->m_playLayer )
{
v10 = GameManager::sharedState();
if ( PlayLayer::canPauseGame(v10->m_playLayer) )
{
if ( ((unsigned __int8 (__fastcall *)(CCMenuItemSpriteExtra *, double))a1->m_pauseBtn->isEnabled)(
a1->m_pauseBtn,
a4) )
{
*(_QWORD *)&a1->m_p1TouchId = -1;
UILayer::resetUINodeState(a1);
v11 = cocos2d::CCDirector::sharedDirector();
v12 = *(_BYTE *)(((__int64 (__fastcall *)(cocos2d::CCDirector *))v11->getKeyboardDispatcher)(v11)
+ 89);
m_playLayer = GameManager::sharedState()->m_playLayer;
if ( v12 == 1 )
PlayLayer::fullReset(m_playLayer);
else
((void (__fastcall *)(PlayLayer *))m_playLayer->resetLevel)(m_playLayer);
}
}
}
}
}
break;
case 0x3DLL:
goto LABEL_20;
case 0x3FLL:
goto LABEL_22;
default:
return;
}
break;
}
}