(void)OSSetPowerCallback( PowerCallback ); static void PowerCallback() { s_shutdown = TRUE; } static void CheckSystemButton() { if( s_shutdown ) { OSReport("Power button was pushed.\n"); OSShutdownSystem(); } if (OSGetResetButtonState()) { OSReport("Reset button was pushed.\n"); OSRebootSystem(); } } In main loop: CheckSystemButton(); Other: static void ResetCallback(); static void PowerCallback(); static bool reset_called,power_called; OSSetResetCallback(ResetCallback); OSSetPowerCallback(PowerCallback); reset_called = false; power_called = false; static void ResetCallback() { reset_called = true; } static void PowerCallback() { power_called = true; } /* Process executed when returning from the HOME Menu */ switch( HBMGetSelectBtnNum() ) { case HBM_SELECT_HOMEBTN: break; /* Move to the Wii Menu */ case HBM_SELECT_BTN1: OSReport( "Return to WiiMenu.\n" ); OSReturnToMenu(); break; /* Reset */ case HBM_SELECT_BTN2: OSReport( "Reset.\n" ); OSRestart( 0 ); break; case 3: break; default: break; } /* Process executed when the RESET or Power Button is pressed */ if(reset_called) { /*When other than the HOME Menu, go straight on to reset */ if( homeBtnSwitch == OFF ) { OSRestart(0); } /* If the HOME Menu is running, reset after black-out */ else { HBMStartBlackOut(); } reset_called = false; } if(power_called) { OSReturnToMenu(); } Need to handle/hook: -OSReturnToMenu(); //Returns to the system menu -OSRestart(0); //Restarts the application. -OSRebootSystem(); //Reboots the entire system. -OSShutdownSystem(); //Shuts down the system void OSRebootSystem ( void ); void OSShutdownSystem ( void ); void OSRestart ( u32 resetCode ); void OSReturnToMenu ( void ); ?? void OSReturnToDataManager ( void ); ?? OSResetCallback OldResetCallback; OSPowerCallback OldPowerCallback; /* Set up callback functions */ OldResetCallback = OSSetResetCallback(ResetCallback); OldPowerCallback = OSSetPowerCallback(PowerCallback); reset_called = FALSE; power_called = FALSE; OSResetSW.h typedef void (*OSResetCallback)(void); typedef void (*OSPowerCallback)(void); BOOL OSGetResetButtonState( void ); //Checks the current state of the RESET Button. OSResetCallback OSSetResetCallback ( OSResetCallback callback ); OSPowerCallback OSSetPowerCallback ( OSPowerCallback callback ); typedef BOOL (* OSShutdownFunction )( BOOL final, u32 event ); typedef struct OSShutdownFunctionInfo OSShutdownFunctionInfo; struct OSShutdownFunctionInfo { // public OSShutdownFunction func; u32 priority; // private OSShutdownFunctionInfo* next; OSShutdownFunctionInfo* prev; }; void OSRegisterShutdownFunction ( OSShutdownFunctionInfo* info ); void OSUnregisterShutdownFunction ( OSShutdownFunctionInfo* info ); Flow: Disable interrupts when doing critical processing: BOOL interruptLevel = OSDisableInterrupts(); OSRestoreInterrupts(interruptLevel);