]> Chaos Git - corbenik/ctrulib.git/commit
Add synchronization mechanism for entering sleep mode.
authorStapleButter <thetotalworm@gmail.com>
Thu, 18 Sep 2014 20:09:15 +0000 (22:09 +0200)
committerStapleButter <thetotalworm@gmail.com>
Thu, 18 Sep 2014 20:09:15 +0000 (22:09 +0200)
commit1f413a7d4485b8e1d1a69d32c83aa703f2c17898
tree16cf68eb57beafce263b0eef062d57b7813267af
parent643181018588f3455bdb16a2086e6be76234c960
Add synchronization mechanism for entering sleep mode.

When the APT status is APP_PREPARE_SLEEPMODE, the application main thread should call aptSignalReadyForSleep() to signal that it is ready to enter sleep mode, and then call aptWaitStatusEvent() as usual.

Example code:

APP_STATUS status;
while ((status = aptGetStatus()) != APP_EXITING)
{
if(status==APP_RUNNING)
{
// application logic here
}
else if(status == APP_SUSPENDING)
{
aptReturnToMenu();
}
else if(status == APP_PREPARE_SLEEPMODE)
{
aptSignalReadyForSleep();
aptWaitStatusEvent();
}
}

This maybe isn't the proper/recommended way to do sleep mode, but I tested it multiple times and it always worked reliably.

(note: maybe the sample code above will not work if GPU drawing is done in a separate thread, haven't tested that)
libctru/include/3ds/services/apt.h
libctru/source/services/apt.c