/*---------------------------------------------------------------------------* Project: Wii Connect 24 API demos File: Schedule.c Copyright 2006 Nintendo. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. $Log: Schedule.c,v $ Revision 1.2 2007/10/26 08:05:57 seiki_masashi Support for REXDEMOGetAnyMixedPadTrigger. Revision 1.1 2006/09/27 08:56:17 torigoe_nobutaka Moved from nwc24demo/src. Revision 1.9 2006/09/19 07:56:29 terui Added feature for executing NWC24TrySuspendScheduler(). Revision 1.8 2006/09/05 10:57:10 yosizaki Changed to use demos/share. Revision 1.7 2006/08/30 13:40:03 terui Supported REXDEMO library once again. Revision 1.6 2006/08/30 10:28:38 terui Added support for REXDEMO library. Revision 1.5 2006/08/25 04:26:48 terui Deleted demo functions that require network settings. Revision 1.4 2006/08/24 12:34:17 terui Added a feature for changing network settings and cleaned up code for debugging. Revision 1.3 2006/08/24 09:32:11 terui Standardized on-screen display format with other demos. Revision 1.2 2006/08/14 14:39:50 yasu Suppressed return value ignored warnings. Revision 1.1 2006/07/18 08:51:45 terui Initial upload $NoKeywords: $ *---------------------------------------------------------------------------*/ #include "rexdemo/graphic.h" #include "rexdemo/demokpad.h" #include /*---------------------------------------------------------------------------* Function Prototype *---------------------------------------------------------------------------*/ static void ReportUsage( void ); /*===========================================================================*/ /*---------------------------------------------------------------------------* Name : Main Description : Entry point at time of program start. Arguments : None Returns : int - Returns the result of the process. *---------------------------------------------------------------------------*/ int main( void ) { REXDEMOKPadInit(); REXDEMOInitScreen(FALSE); ReportUsage(); while( TRUE ) { REXDEMOKPadRead(); /* (1) button */ if( REXDEMOGetAnyMixedPadTrigger() & (KPAD_BUTTON_1 | (PAD_BUTTON_X << 16)) ) { s32 result = NWC24SuspendScheduler(); if( result >= 0 ) { REXDEMOReport( "NWC24SuspendScheduler() success (%d)\n", result ); } else { REXDEMOError( "NWC24SuspendScheduler() failure (%d)\n", result ); } } /* (2) button */ if( REXDEMOGetAnyMixedPadTrigger() & (KPAD_BUTTON_2 | (PAD_BUTTON_Y << 16)) ) { s32 result = NWC24ResumeScheduler(); if( result >= 0 ) { REXDEMOReport( "NWC24ResumeScheduler() success (%d)\n", result ); } else { REXDEMOError( "NWC24ResumeScheduler() failure (%d)\n", result ); } } /* (A) button */ if( REXDEMOGetAnyMixedPadTrigger() & (KPAD_BUTTON_A | (PAD_BUTTON_A << 16)) ) { s32 result = NWC24TrySuspendScheduler(); if( result >= 0 ) { REXDEMOReport( "NWC24TrySuspendScheduler() success (%d)\n", result ); } else { REXDEMOError( "NWC24TrySuspendScheduler() failure (%d)\n", result ); } } /* (cross) button */ if( REXDEMOGetAnyMixedPadTrigger() & ( KPAD_BUTTON_UP | KPAD_BUTTON_DOWN | KPAD_BUTTON_LEFT | KPAD_BUTTON_RIGHT | (PAD_BUTTON_UP << 16) | (PAD_BUTTON_DOWN << 16) | (PAD_BUTTON_LEFT << 16) | (PAD_BUTTON_RIGHT << 16)) ) { u32 mailSpan; u32 downloadSpan; NWC24Err result; result = NWC24GetScheduleSpan( &mailSpan, &downloadSpan ); if( result == NWC24_OK ) { REXDEMOReport( "NWC24GetScheduleSpan() success\n" ); /* (up) button */ if( REXDEMOGetAnyMixedPadTrigger() & (KPAD_BUTTON_UP | (PAD_BUTTON_UP << 16)) ) { mailSpan ++; } /* (down) button */ if( REXDEMOGetAnyMixedPadTrigger() & (KPAD_BUTTON_DOWN | (PAD_BUTTON_DOWN << 16)) ) { mailSpan --; } /* (left) button */ if( REXDEMOGetAnyMixedPadTrigger() & (KPAD_BUTTON_LEFT | (PAD_BUTTON_LEFT << 16)) ) { downloadSpan --; } /* (right) button */ if( REXDEMOGetAnyMixedPadTrigger() & (KPAD_BUTTON_RIGHT | (PAD_BUTTON_RIGHT << 16)) ) { downloadSpan ++; } result = NWC24SetScheduleSpan( mailSpan, downloadSpan ); if( result == NWC24_OK ) { REXDEMOReport( "NWC24SetScheduleSpan() success\n" ); if( mailSpan > 0 ) { REXDEMOReport( " Automatic checking mail span: %d %s\n", mailSpan, ( mailSpan > 1 ? "minutes" : "minute" ) ); } else { REXDEMOWarning( " Doesn't check mail automatically\n" ); } if( downloadSpan > 0 ) { REXDEMOReport( " Automatic downloading span: %d %s\n", downloadSpan, ( downloadSpan > 1 ? "minutes" : "minute" ) ); } else { REXDEMOWarning( " Doesn't download automatically\n" ); } } else { REXDEMOError( "NWC24SetScheduleSpan() failure (%d)\n", result ); } } else { REXDEMOError( "NWC24GetScheduleSpan() failure (%d)\n", result ); } } /* (home) button */ if( REXDEMOGetAnyMixedPadTrigger() & (KPAD_BUTTON_HOME | (PAD_BUTTON_START << 16)) ) { ReportUsage(); } /* Waiting for rendering & V-blank */ REXDEMOWaitRetrace(); } OSHalt( "End of demo\n" ); return 0; } /*---------------------------------------------------------------------------* Name : ReportUsage Description : Outputs how to operate the demo program. Arguments : None Returns : None *---------------------------------------------------------------------------*/ static void ReportUsage( void ) { REXDEMOUsage( "----------------------------------------\n" ); REXDEMOUsage( " NWC24 schedule demo\n" ); REXDEMOUsage( " ---- Usage ----\n" ); REXDEMOUsage( " (1) : Suspend scheduler\n" ); REXDEMOUsage( " (2) : Resume scheduler\n" ); REXDEMOUsage( " (A) : TrySuspend scheduler\n" ); REXDEMOUsage( " (U) : Increment mail check span\n" ); REXDEMOUsage( " (D) : Decrement mail check span\n" ); REXDEMOUsage( " (L) : Decrement download span\n" ); REXDEMOUsage( " (R) : Increment download span\n" ); REXDEMOUsage( "----------------------------------------\n" ); } /*---------------------------------------------------------------------------* End of file *---------------------------------------------------------------------------*/