diff options
Diffstat (limited to 'backends/platform/psp/psp_main.cpp')
-rw-r--r-- | backends/platform/psp/psp_main.cpp | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/backends/platform/psp/psp_main.cpp b/backends/platform/psp/psp_main.cpp index 0af7ebf269..37080c7bf9 100644 --- a/backends/platform/psp/psp_main.cpp +++ b/backends/platform/psp/psp_main.cpp @@ -31,10 +31,14 @@ #include <pspdebug.h> #endif +#include <psppower.h> + #include <common/system.h> #include <engines/engine.h> #include <base/main.h> #include <base/plugins.h> +#include "backends/platform/psp/powerman.h" + #include "osys_psp_gu.h" #include "./trace.h" @@ -91,17 +95,36 @@ void loaderInit() { #endif /* Exit callback */ -SceKernelCallbackFunction exit_callback(int /*arg1*/, int /*arg2*/, void * /*common*/) { +int exit_callback(void) { sceKernelExitGame(); return 0; } +/* Function for handling suspend/resume */ +void power_callback(int , int powerinfo) { + if (powerinfo & PSP_POWER_CB_POWER_SWITCH || powerinfo & PSP_POWER_CB_SUSPENDING) { + PowerMan.suspend(); + } else if (powerinfo & PSP_POWER_CB_RESUME_COMPLETE) { + PowerMan.resume(); + } +} + /* Callback thread */ int CallbackThread(SceSize /*size*/, void *arg) { int cbid; cbid = sceKernelCreateCallback("Exit Callback", (SceKernelCallbackFunction)exit_callback, NULL); sceKernelRegisterExitCallback(cbid); + /* Set up callbacks for PSPIoStream */ + + cbid = sceKernelCreateCallback("Power Callback", (SceKernelCallbackFunction)power_callback, 0); + if (cbid >= 0) { + if(scePowerRegisterCallback(-1, cbid) < 0) { + PSPDebugTrace("SetupCallbacks(): Couldn't register callback for power_callback\n"); + } + } else { + PSPDebugTrace("SetupCallbacks(): Couldn't create a callback for power_callback\n"); + } sceKernelSleepThreadCB(); return 0; @@ -119,6 +142,8 @@ int SetupCallbacks(void) { #undef main int main(void) { + PowerManager::instance(); // Setup power manager + SetupCallbacks(); static const char *argv[] = { "scummvm", NULL }; @@ -131,6 +156,8 @@ int main(void) { g_system->quit(); // TODO: Consider removing / replacing this! + PowerManager::destroy(); // get rid of PowerManager + sceKernelSleepThread(); return res; |