Wiimote Power Button December 07, 2008 09:48PM | Admin Registered: 16 years ago Posts: 5,132 |
Re: Wiimote Power Button December 07, 2008 11:23PM | Registered: 15 years ago Posts: 13 |
void WPAD_SetPowerButtonCallback(WPADShutdownCallback cb);
typedef void (*WPADShutdownCallback)(s32 chan);
// WPADShutdownCallback void doPadPowerOff( s32 chan ) { if ( chan == WPAD_CHAN_0 ) SYS_ResetSystem( SYS_POWEROFF, 0, 0 ); return; }
WPAD_SetPowerButtonCallback( doPadPowerOff );I hope this helps.
Re: Wiimote Power Button December 19, 2008 04:41PM | Admin Registered: 16 years ago Posts: 5,132 |
Re: Wiimote Power Button December 19, 2008 07:29PM | Registered: 15 years ago Posts: 441 |
Re: Wiimote Power Button December 19, 2008 07:38PM | Registered: 15 years ago Posts: 13 |
// Replaced "<" with "(" here to make it work with the forums. #include (iostream> #include (gccore.h> #include (wiiuse/wpad.h> using namespace std; bool bPowerOff = false; // Poweroff flag. bool bReset = false; // Reset flag. //==================================================================== // Reset callback function. //==================================================================== void doSystemReset( void ) { bReset = true; return; } //==================================================================== // PowerOff callback function. //==================================================================== void doPowerOff( void ) { bPowerOff = true; return; } //==================================================================== // PowerOff callback function for the Wii Remote power button. //==================================================================== void doPadPowerOff( s32 chan ) { if ( chan == WPAD_CHAN_0 ) bPowerOff = true; return; } //==================================================================== // Main program. //==================================================================== int main ( int* argc, char** argv ) { // Initialise the video system, etc. here. // ... // Set Reset and Shutdown Callbacks. SYS_SetResetCallback( doSystemReset ); SYS_SetPowerCallback( doPowerOff ); WPAD_SetPowerButtonCallback( doPadPowerOff ); // Run the main loop. while ( !bReset && !bPowerOff ) { // Do whatever you want your programme to do here. // ... } // Reset the system. if ( bReset ) SYS_ResetSystem( SYS_RESTART, 0, 0 ); // Shut the system down. if ( bPowerOff ) SYS_ResetSystem( SYS_POWEROFF, 0, 0 ); return 0; }
Re: Wiimote Power Button December 19, 2008 10:04PM | Registered: 16 years ago Posts: 175 |
Re: Wiimote Power Button February 15, 2009 06:26AM | Registered: 16 years ago Posts: 78 |
static signed int shutdownType = -1; /* Not 0 as ogc/system.h uses that for SYS_RESTART */ static void WiiResetCB(void) { shutdownType = SYS_RESTART; } static void WiiPowerCB(void) { shutdownType = SYS_POWEROFF; } static void WiimotePowerCB(int chan) { shutdownType = SYS_POWEROFF; } extern void Init_Controllers(void) { /* Irrelevant code removed */ SYS_SetResetCallback(WiiResetCB); SYS_SetPowerCallback(WiiPowerCB); WPAD_SetPowerButtonCallback(WiimotePowerCB); /* Irrelevant code removed */ } extern void Check_Controllers(void) { /* Irrelevant code removed */ if (shutdownType != -1) { Shutdown(shutdownType); } /* Irrelevant code removed */ }
extern void Shutdown(const signed int shutdownType) { /* Shutdown various things before exit */ SYS_ResetSystem(shutdownType, 0, 0); }
if (shutdownType != -1) { Shutdown(shutdownType); }from Check_Controllers() I still get instant crash when I press power or reset.
Re: Wiimote Power Button February 15, 2009 04:05PM | Admin Registered: 16 years ago Posts: 5,132 |
bool shutdown = false; //If true shotdown the wii // WPADShutdownCallback void doPadPowerOff(s32 chan){ if(chan == WPAD_CHAN_0) shutdown = true; return; }
WPAD_SetPowerButtonCallback(doPadPowerOff);//Set up power button
if(shutdown == true) SYS_ResetSystem( SYS_POWEROFF, 0, 0 );
Re: Wiimote Power Button February 15, 2009 11:03PM | Registered: 16 years ago Posts: 78 |
Re: Wiimote Power Button February 15, 2009 11:47PM | Admin Registered: 16 years ago Posts: 5,132 |