Well, when you start the exit callback's thread, assuming the callbacks from the psp-programming tutorials, it just sleeps. Now, when the home button is pressed, the thread by the name of "Exit Callback" is 'woken up', and you see the dialog. So... what you could do is...
Code: Select all
/* Exit callback */
int exit_callback(int arg1, int arg2, void *common) {
sceKernelExitGame();
return 0;
}
/* Callback thread */
int CallbackThread(SceSize args, void *argp) {
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void) {
int thid = 0;
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
if(thid >= 0) {
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
...
int callbackThreadId = SetupCallbacks();
...
// Menu pressed exit...
sceKernelWakeupThread(callbackThreadId);
Then if, the user presses the option to exit, the screen pops up. If the user presses 'Yes', exit_callback() is called, and you exit. Otherwise, the user presses 'No' and it should sleep the thread again. :)
Note: This is based off of assumptions, so if it doesn't work, don't blame me. :P
Edit: Fixed something that I wrote down wrong :/