Changes

Jump to navigation Jump to search
1,101 bytes added ,  08:32, 21 November 2008
How to use the callback function for Power and Reset
Line 49: Line 49:  
Or use SYS_RETURNTOMENU for a "soft" return to the system menu, SYS_POWEROFF to shut down the wii (automatically to the appropriate Idle or Standby mode, depending on the WC24 setting), or SYS_POWEROFF_STANDBY or _IDLE to specify the mode and override the system setting.
 
Or use SYS_RETURNTOMENU for a "soft" return to the system menu, SYS_POWEROFF to shut down the wii (automatically to the appropriate Idle or Standby mode, depending on the WC24 setting), or SYS_POWEROFF_STANDBY or _IDLE to specify the mode and override the system setting.
    +
===How to use the callback function for Power and Reset===
 +
This is just a way of doing this stuff, feel free to change the code.
 +
<source lang="c">
 +
u8 HWButton = 0;
 +
 +
/**
 +
* Callback for the reset button on the Wii.
 +
*/
 +
void WiiResetPressed()
 +
{
 +
HWButton = SYS_RETURNTOMENU;
 +
}
 +
 +
/**
 +
* Callback for the power button on the Wii.
 +
*/
 +
void WiiPowerPressed()
 +
{
 +
HWButton = SYS_POWEROFF_STANDBY;
 +
}
 +
 +
/**
 +
* Callback for the power button on the Wiimote.
 +
* @param[in] chan The Wiimote that pressed the button
 +
*/
 +
void WiimotePowerPressed(s32 chan)
 +
{
 +
HWButton = SYS_POWEROFF_STANDBY;
 +
}
 +
 +
/**
 +
* Entry point.
 +
* @param[in] argc The number of arguments invoked with the program
 +
* @param[in] argv The array containing the arguments
 +
* @return 0 on clean exit, an error code otherwise
 +
*/
 +
int main(int argc, char **argv)
 +
{
 +
// Initialization
 +
 +
SYS_SetResetCallback(WiiResetPressed);
 +
SYS_SetPowerCallback(WiiPowerPressed);
 +
WPAD_SetPowerButtonCallback(WiimotePowerPressed);
 +
 +
while(1)
 +
{
 +
// Do Stuff Here
 +
if(HWButton)
 +
break;
 +
}
 +
 +
if(HWButton)
 +
{
 +
SYS_ResetSystem(HWButton, 0, 0);
 +
}
 +
 +
return 0;
 +
}
 +
</source>
 
[[Category:Development]]
 
[[Category:Development]]
3,027

edits

Navigation menu