1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-11-30 15:52:15 +00:00
Atmosphere/troposphere/daybreak/nanovg/source/framework/CApplication.cpp
Adubbz 94eb2195d3
Added Daybreak, a system updater homebrew (#1073)
* Implemented a system updater homebrew (titled Daybreak)

* git subrepo pull ./troposphere/daybreak/nanovg

subrepo:
  subdir:   "troposphere/daybreak/nanovg"
  merged:   "c197ba2f"
upstream:
  origin:   "https://github.com/Adubbz/nanovg-deko.git"
  branch:   "master"
  commit:   "c197ba2f"
git-subrepo:
  version:  "0.4.1"
  origin:   "???"
  commit:   "???" (+1 squashed commits)

Squashed commits:

[232dc943] git subrepo clone https://github.com/Adubbz/nanovg-deko.git troposphere/daybreak/nanovg

subrepo:
  subdir:   "troposphere/daybreak/nanovg"
  merged:   "52bb784b"
upstream:
  origin:   "https://github.com/Adubbz/nanovg-deko.git"
  branch:   "master"
  commit:   "52bb784b"
git-subrepo:
  version:  "0.4.1"
  origin:   "???"
  commit:   "???"

* daybreak: switch to using hiddbg for home blocking (+1 squashed commits)

Squashed commits:

[4bfc7b0d] daybreak: block the home button during installation
2020-07-07 17:07:00 -07:00

69 lines
2 KiB
C++

/*
** Sample Framework for deko3d Applications
** CApplication.cpp: Wrapper class containing common application boilerplate
*/
#include "CApplication.h"
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_Focused;
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_Focused;
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;
}
}
if (focused && !onFrame(armTicksToNs(armGetSystemTick() - tick_ref)))
break;
}
}