65 lines
1.2 KiB
C
Raw Normal View History

2017-12-26 20:51:44 +01:00
#include <stdio.h>
#include <stdlib.h>
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspsdk.h>
#include <pspctrl.h>
PSP_MODULE_INFO("Pthread Test", 0, 1, 1);
extern void pte_test_main();
#ifdef JNS
#define printf pspDebugScreenPrintf
#endif
/* Exit callback */
int exit_callback(int arg1, int arg2, void *common)
{
2017-12-27 07:48:04 +01:00
sceKernelExitGame();
return 0;
2017-12-26 20:51:44 +01:00
}
/* Callback thread */
int CallbackThread(SceSize args, void *argp)
{
2017-12-27 07:48:04 +01:00
int cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
2017-12-26 20:51:44 +01:00
2017-12-27 07:48:04 +01:00
sceKernelSleepThreadCB();
2017-12-26 20:51:44 +01:00
2017-12-27 07:48:04 +01:00
return 0;
2017-12-26 20:51:44 +01:00
}
/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void)
{
2017-12-27 07:48:04 +01:00
int thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
if (thid >= 0)
2017-12-26 20:51:44 +01:00
sceKernelStartThread(thid, 0, 0);
2017-12-27 07:48:04 +01:00
return thid;
2017-12-26 20:51:44 +01:00
}
int main(void)
{
2017-12-27 07:48:04 +01:00
SceCtrlData pad;
2017-12-26 20:51:44 +01:00
2017-12-27 07:48:04 +01:00
pspDebugScreenInit();
SetupCallbacks();
2017-12-26 20:51:44 +01:00
2017-12-27 07:48:04 +01:00
pte_test_main();
2017-12-26 20:51:44 +01:00
2017-12-27 07:48:04 +01:00
while (1)
{
2017-12-26 20:51:44 +01:00
sceCtrlReadBufferPositive(&pad, 1);
if (pad.Buttons & PSP_CTRL_UP)
2017-12-27 07:48:04 +01:00
{
printf("Exiting...\n");
return 0;
}
2017-12-26 20:51:44 +01:00
2017-12-27 07:48:04 +01:00
}
return 0;
2017-12-26 20:51:44 +01:00
}