/*---------------------------------------------------------------------------* Project: WPAD demo program File: extension.c Copyright (C) 2005-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: check.c,v $ Revision 1.4 06/17/2006 05:38:33 ekwon Corrected BD_ADDR length. Revision 1.3 06/16/2006 14:44:55 ekwon Simple demo for retrieving unique BD ADDR of each connected device. Revision 1.1 06/15/2006 04:25:35 ekwon preliminary checkins for event handling demos. *---------------------------------------------------------------------------*/ #include #include #include #include #include #include #include #include #define DEMO_USE_MEMLIB=1 // This turns on the DEMO library's MEM heaps. #include #define SCREEN_WIDTH 320 #define SCREEN_HEIGHT 240 #define FONT_HEIGHT 9 /*---------------------------------------------------------------------------* * Function prototypes *---------------------------------------------------------------------------*/ // MEM2 memory allocation routines. The application must provide these to // WPAD, so it can setup the data transfer buffer. This buffer must reside // in MEM2. static void *myAlloc (u32 size); static u8 myFree (void *ptr); // internal functions static void initialize (void); /*---------------------------------------------------------------------------* * Local Data *---------------------------------------------------------------------------*/ /*===========================================================================* * F U N C T I O N D E F I N I T I O N S *===========================================================================*/ /*---------------------------------------------------------------------------* * Name : main() * Description : * Arguments : None. * Returns : None. *---------------------------------------------------------------------------*/ int main( void ) { s16 y; u8 num_paired; s32 wpad_state; u8 addr[WPAD_ADDR_LEN]; s32 status; u32 type; int i; initialize(); // - We must now register memory allocation/free functions // for MEM2. // - WPAD requires some memory in MEM2 for data transfers // between the controller and WPAD driver stack. // - Memory allocation only occurs once, at the initialization. // - Memory usage is on the order of 1KB. // - NOTE: We are using the MEM library allocators defined by // the DEMO library. // WPADRegisterAllocator(myAlloc, myFree); // Initialize WPAD! WPADInit(); // The WPAD initialization process is asynchronous. // So we should wait until it's completed. do { wpad_state = WPADGetStatus(); } while (WPAD_STATE_SETUP != wpad_state); while(1) { num_paired = WPADGetRegisteredDevNum(); DEMOBeforeRender(); y = 30; DEMOPrintf(5, y, 0, "%1d device(s) paired to this host.", (u32)num_paired); y+=FONT_HEIGHT; y+=FONT_HEIGHT; DEMOPrintf(5, y, 0, "Addresses of connected devices:"); y+=FONT_HEIGHT; for (i=0; i