Path: blob/master/RSDKv5/RSDK/User/NX/NXCore.cpp
1163 views
#if RETRO_REV0212// release switch has the stack and other stuff predefined for the loop thread to use3// issue is it MUST be page-aligned (& 0xFFF of location must be 0), which we don't know how to do4// so bc we're using libNX we can pass null for it to do it for us5// uint8 messageLoopThreadStack[16384];67// Thread messageLoopThread;89// normally this func looks a little different10// but libNX sucks and won't properly thread things for us11// 4 am note: this literally doesn't work anyway fuck libNX we do a hack at the bottom12void MessageLoopThreadCB(SKU::NXCore *core)13{14uint32 msg = 0;15uint32 unknown = 0;1617while (R_SUCCEEDED(appletGetMessage(&msg))) {18appletProcessMessage(msg);19PrintLog(PRINT_NORMAL, "yo whatup %d", msg);2021switch (msg) {22case AppletMessage_ExitRequest: unknown = 1; break;2324case AppletMessage_FocusStateChanged:25core->focusState = appletGetFocusState();26if (engine.inFocus)27engine.inFocus = (core->focusState == AppletFocusState_InFocus) ? 1 : 2;28break;2930case AppletMessage_Resume:31// sub_71002813BC();32break;3334case AppletMessage_OperationModeChanged:35// if (appletGetOperationMode == AppletOperationMode_Console)36// sub_71002813BC();37break;3839case AppletMessage_PerformanceModeChanged: break;4041default: PrintLog(PRINT_NORMAL, "Unhandled message = 0x%08x\n", msg); break;42}43}44}4546SKU::NXCore *InitNXCore()47{48// Initalize API subsystems49NXCore *core = new NXCore;5051if (achievements)52delete achievements;53achievements = new NXAchievements;5455if (leaderboards)56delete leaderboards;57leaderboards = new NXLeaderboards;5859if (richPresence)60delete richPresence;61richPresence = new NXRichPresence;6263if (stats)64delete stats;65stats = new NXStats;6667if (userStorage)68delete userStorage;69userStorage = new NXUserStorage;7071// Setup default values7273memset(core->values, 0, sizeof(core->values));74core->values[0] = false;75core->valueCount = 1;7677core->focusState = appletGetFocusState();78if (engine.inFocus)79engine.inFocus = (core->focusState == AppletFocusState_InFocus) ? 1 : 2;80appletSetFocusHandlingMode(AppletFocusHandlingMode_NoSuspend);81// nn::oe::SetResumeNotificationEnabled(true);82// nn::oe::SetOperationModeChangedNotificationEnabled(true);8384// int32 rc = threadCreate(&messageLoopThread, MessageLoopThreadCB, userCore, NULL, 0x4000, 28, -2);85// PrintLog(PRINT_NORMAL, "%d %d", R_MODULE(rc), R_DESCRIPTION(rc));8687// threadStart(&messageLoopThread);8889return core;90}9192void NXCore::FrameInit()93{94MessageLoopThreadCB(this);9596// hack to ensure focus state97this->focusState = appletGetFocusState();98if (engine.inFocus)99engine.inFocus = (this->focusState == AppletFocusState_InFocus) ? 1 : 2;100101UserCore::FrameInit();102}103#endif104105106