Sleep on lid close
This commit is contained in:
parent
a14db0f1e8
commit
39c4ec8928
|
@ -32,6 +32,8 @@ void changeBacklight(s16 amount);
|
|||
Result oafInitAndRun(void);
|
||||
void oafUpdate(void);
|
||||
void oafFinish(void);
|
||||
void oafSleep(void);
|
||||
void oafWakeup(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 083c8ffa3f56a49802fa74b6afe45a96820f0439
|
||||
Subproject commit 15f7b8c5f33695f8f1610b007f10630293081592
|
|
@ -42,6 +42,8 @@ int main(void)
|
|||
{
|
||||
hidScanInput();
|
||||
if(hidGetExtraKeys(0) & (KEY_POWER_HELD | KEY_POWER)) break;
|
||||
if(hidGetExtraKeys(0) & KEY_SHELL) oafSleep();
|
||||
if(!(hidGetExtraKeys(0) & KEY_SHELL)) oafWakeup();
|
||||
|
||||
oafUpdate();
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "arm11/patch.h"
|
||||
#include "arm11/bitmap.h"
|
||||
|
||||
#include "arm11/drivers/interrupt.h"
|
||||
|
||||
#define OAF_WORK_DIR "sdmc:/3ds/open_agb_firm"
|
||||
#define OAF_SAVE_DIR "saves" // Relative to work dir.
|
||||
|
@ -94,6 +95,7 @@ static OafConfig g_oafConfig =
|
|||
14 // defaultSave
|
||||
};
|
||||
static KHandle g_frameReadyEvent = 0;
|
||||
static bool g_isSleeping = false;
|
||||
|
||||
|
||||
|
||||
|
@ -616,6 +618,7 @@ Result oafInitAndRun(void)
|
|||
|
||||
void oafUpdate(void)
|
||||
{
|
||||
if (g_isSleeping) return;
|
||||
const u32 *const maps = g_oafConfig.buttonMaps;
|
||||
const u32 kHeld = hidKeysHeld();
|
||||
u16 pressed = 0;
|
||||
|
@ -638,4 +641,31 @@ void oafFinish(void)
|
|||
LGYCAP_deinit(LGYCAP_DEV_TOP);
|
||||
g_frameReadyEvent = 0;
|
||||
LGY11_deinit();
|
||||
}
|
||||
|
||||
void oafSleep(void)
|
||||
{
|
||||
if(g_isSleeping) return;
|
||||
LGYCAP_stop(LGYCAP_DEV_TOP);
|
||||
IRQ_disable(IRQ_CDMA_EVENT0);
|
||||
clearEvent(g_frameReadyEvent);
|
||||
|
||||
CODEC_setVolumeOverride(-128);
|
||||
GFX_sleep();
|
||||
g_isSleeping = true;
|
||||
}
|
||||
|
||||
void oafWakeup(void)
|
||||
{
|
||||
if (!g_isSleeping) return;
|
||||
GFX_sleepAwake();
|
||||
// VRAM is cleared upon waking up
|
||||
// need to readjust screen after waking up
|
||||
adjustGammaTableForGba();
|
||||
|
||||
LGYCAP_start(LGYCAP_DEV_TOP);
|
||||
IRQ_enable(IRQ_CDMA_EVENT0);
|
||||
CODEC_setVolumeOverride(127);
|
||||
g_isSleeping = false;
|
||||
|
||||
}
|
Loading…
Reference in New Issue