mirror of
https://github.com/ps4-switch-emu/ps4-switch-emu.git
synced 2026-10-20 09:01:22 +02:00
Builds the emulator core (submodule eden/) for jailbroken PS4 consoles and packages it as a .pkg. DolphinPS4 (vendor/DolphinPS4) provides the PS4 runtime and the Vulkan driver patch.
76 lines
2.2 KiB
C++
76 lines
2.2 KiB
C++
/*
|
|
** Sample Framework for deko3d Applications
|
|
** CApplication.cpp: Wrapper class containing common application boilerplate
|
|
*/
|
|
#include "CApplication.h"
|
|
|
|
// PS4 Switch Emu test: when non-zero, run() returns after this many nanoseconds (set by main.cpp).
|
|
u64 g_run_limit_ns = 0;
|
|
|
|
CApplication::CApplication()
|
|
{
|
|
appletLockExit();
|
|
appletSetFocusHandlingMode(AppletFocusHandlingMode_NoSuspend);
|
|
}
|
|
|
|
CApplication::~CApplication()
|
|
{
|
|
appletSetFocusHandlingMode(AppletFocusHandlingMode_SuspendHomeSleep);
|
|
appletUnlockExit();
|
|
}
|
|
|
|
void CApplication::run()
|
|
{
|
|
u64 tick_ref = armGetSystemTick();
|
|
u64 tick_saved = tick_ref;
|
|
bool focused = appletGetFocusState() == AppletFocusState_InFocus;
|
|
|
|
onOperationMode(appletGetOperationMode());
|
|
|
|
for (;;)
|
|
{
|
|
u32 msg = 0;
|
|
Result rc = appletGetMessage(&msg);
|
|
if (R_SUCCEEDED(rc))
|
|
{
|
|
bool should_close = !appletProcessMessage(msg);
|
|
if (should_close)
|
|
return;
|
|
|
|
switch (msg)
|
|
{
|
|
case AppletMessage_FocusStateChanged:
|
|
{
|
|
bool old_focused = focused;
|
|
AppletFocusState state = appletGetFocusState();
|
|
focused = state == AppletFocusState_InFocus;
|
|
|
|
onFocusState(state);
|
|
if (focused == old_focused)
|
|
break;
|
|
if (focused)
|
|
{
|
|
appletSetFocusHandlingMode(AppletFocusHandlingMode_NoSuspend);
|
|
tick_ref += armGetSystemTick() - tick_saved;
|
|
}
|
|
else
|
|
{
|
|
tick_saved = armGetSystemTick();
|
|
appletSetFocusHandlingMode(AppletFocusHandlingMode_SuspendHomeSleepNotify);
|
|
}
|
|
break;
|
|
}
|
|
case AppletMessage_OperationModeChanged:
|
|
onOperationMode(appletGetOperationMode());
|
|
break;
|
|
}
|
|
}
|
|
|
|
const u64 ns = armTicksToNs(armGetSystemTick() - tick_ref);
|
|
if (focused && !onFrame(ns))
|
|
break;
|
|
if (g_run_limit_ns && ns >= g_run_limit_ns)
|
|
break;
|
|
}
|
|
}
|