- Main Page
- Classes
- Files

- File List
- File Members

# flCallbacks.c

Go to the documentation of this file.

    00001 #include "flGlobal.h"
    00002 #if FL_CALLBACKS != 0
    00003 #include <pspkernel.h>
    00004 #include <psppower.h>
    00005 #include <pspdisplay.h>
    00006
    00007 #if FL_INCLUDE_ALL_C == 0
    00008 #include "flCallbacks.h"
    00009 #include "funcLib.h"
    00010
    00011 #if FL_DEBUG != 0
    00012 #include "flDebug.h"
    00013 #endif
    00014 #endif
    00015
    00016
    00017 #if FL_CALLBACKS_EXIT != 0
    00018 int callbackExit(int inArg1, int inArg2, void* inCommon) {
    00019      flTerminate();
    00020      return 0;
    00021 }
    00022 #endif
    00023
    00024 #if FL_CALLBACKS_POWER != 0
    00025 int callbackPower(int inUnknown, int inPowerFlags, void* inCommon) {
    00026      if((inPowerFlags & PSP_POWER_CB_POWER_SWITCH) || (inPowerFlags & PSP_POWER_CB_SUSPENDING)) {
    00027           #if FL_DEBUG_STATUS != 0
    00028           debugStatusLog("PSP suspending.");
    00029           #endif
    00030      } else if(inPowerFlags & PSP_POWER_CB_RESUMING) {
    00031           #if FL_DEBUG_STATUS != 0
    00032           debugStatusLog("PSP resuming from suspend.");
    00033           #endif
    00034      } else if(inPowerFlags & PSP_POWER_CB_RESUME_COMPLETE) {
    00035           #if FL_DEBUG_STATUS != 0
    00036           debugStatusLog("PSP resumed from suspend.");
    00037           #endif
    00038      } else if(inPowerFlags & PSP_POWER_CB_STANDBY) {
    00039           #if FL_DEBUG_STATUS != 0
    00040           debugStatusLog("PSP entering standby.");
    00041           #endif
    00042      } else {
    00043           #if FL_DEBUG_STATUS != 0
    00044           debugStatusLog("PSP performing unhandled power event.");
    00045           #endif
    00046      }
    00047      sceDisplayWaitVblankStart();
    00048
    00049      return 0;
    00050 }
    00051 #endif
    00052
    00053 int callbackCreateThread(SceSize args, void *argp) {
    00054      int tempCallbackID;
    00055
    00056          #if FL_CALLBACKS_EXIT != 0
    00057      tempCallbackID = sceKernelCreateCallback("Exit Callback", callbackExit, NULL);
    00058      if(tempCallbackID >= 0) {
    00059           sceKernelRegisterExitCallback(tempCallbackID);
    00060      } else {
    00061           #if FL_DEBUG_ERROR != 0
    00062           debugError("Unable to create exit callback.");
    00063           #endif
    00064           return 0;
    00065      }
    00066      #endif
    00067      #if FL_CALLBACKS_POWER != 0
    00068      tempCallbackID = sceKernelCreateCallback("Power Callback", callbackPower, NULL);
    00069      if(tempCallbackID >= 0) {
    00070           scePowerRegisterCallback(0, tempCallbackID);
    00071      } else {
    00072           #if FL_DEBUG_ERROR != 0
    00073           debugError("Unable to create power callback.");
    00074           #endif
    00075           return 0;
    00076      }
    00077      #endif
    00078
    00079      //while(flRunning) {
    00080           sceKernelSleepThreadCB();
    00081      //}
    00082
    00083      return 0;
    00084 }
    00085
    00086 int callbackInit() {
    00087      int tempThreadID = 0;
    00088
    00089      tempThreadID = sceKernelCreateThread("Update Thread", callbackCreateThread, 0x11, 0xFA0, PSP_THREAD_ATTR_USER, 0);
    00090      if(tempThreadID >= 0)
    00091           sceKernelStartThread(tempThreadID, 0, 0);
    00092
    00093      return tempThreadID;
    00094 }
    00095
    00096 #endif