Whats Wrong With This? January 20, 2010 01:35PM | Registered: 14 years ago Posts: 18 |
#include#include #include #include #include static void *xfb = NULL; static GXRModeObj *rmode = NULL; //--------------------------------------------------------------------------------- int main(int argc, char **argv) { //--------------------------------------------------------------------------------- // Initialise the video system VIDEO_Init(); //Initialise Wii Light WIILIGHT_Init(); // This function initialises the attached controllers WPAD_Init(); // Obtain the preferred video mode from the system // This will correspond to the settings in the Wii menu rmode = VIDEO_GetPreferredMode(NULL); // Allocate memory for the display in the uncached region xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); // Initialise the console, required for printf console_init(xfb,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ); //Initialise the Wii Mote WPAD_Init(); WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR); for(;;) { WPAD_ScanPads(); u16 btnsdown = WPAD_ButtonsDown(0); u16 btnsheld = WPAD_ButtonsHeld(0); // Infrared calculation ir_t ir; // The struct for infrared WPAD_IR(WPAD_CHAN_0, &ir); // Let's get our infrared data if(btnsdown & WPAD_BUTTON_HOME) exit(0); // Factory function // Set up the video registers with the chosen mode VIDEO_Configure(rmode); // Tell the video hardware where our display memory is VIDEO_SetNextFramebuffer(xfb); // Make the display visible VIDEO_SetBlack(FALSE); // Flush the video register changes to the hardware VIDEO_Flush(); // Wait for Video setup to complete VIDEO_WaitVSync(); if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync(); // The console understands VT terminal escape codes // This positions the cursor on row 2, column 0 // we can use variables for this with format codes too // e.g. printf ("\x1b[%d;%dH", row, column ); printf("\x1b[2;0H"); WIILIGHT_SetLevel(255); WIILIGHT_TurnOn(); Printf("Press (A) To Switch On And Off The Wii Disk Drive Light"); while(1) { // Call WPAD_ScanPads each loop, this reads the latest controller states WPAD_ScanPads(); // WPAD_ButtonsDown tells us which buttons were pressed in this loop // this is a "one shot" state which will not fire again until the button has been released u32 pressed = WPAD_ButtonsDown(0); // We return to the launcher application via exit if ( pressed & WPAD_BUTTON_HOME ) exit(0); //Toggles The Wii Disk Drive Light if ( pressed & WPAD_BUTTON_A ) WIILIGHT-Toggle(); // Wait for the next frame VIDEO_WaitVSync(); } return 0; }
> "make" template.c c:/devkitPro/examples/wii/template/source/template.c: In function 'main': c:/devkitPro/examples/wii/template/source/template.c:43: warning: unused variable 'btnsheld' c:/devkitPro/examples/wii/template/source/template.c:95: error: expected declaration or statement at end of input make[1]: *** [template.o] Error 1 "make": *** [build] Error 2 > Process Exit Code: 2 > Time Taken: 00:01 [/code What have I done wrong? -Tom
Re: Whats Wrong With This? January 20, 2010 02:43PM | Registered: 15 years ago Posts: 175 |
Re: Whats Wrong With This? January 20, 2010 07:08PM | Registered: 15 years ago Posts: 175 |
Re: Whats Wrong With This? January 20, 2010 11:56PM | Registered: 14 years ago Posts: 234 |
for(;;) { WPAD_ScanPads(); u16 btnsdown = WPAD_ButtonsDown(0); u16 btnsheld = WPAD_ButtonsHeld(0); // Infrared calculation ir_t ir; // The struct for infrared WPAD_IR(WPAD_CHAN_0, &ir); // Let's get our infrared data if(btnsdown & WPAD_BUTTON_HOME) exit(0); // Factory function // Set up the video registers with the chosen mode VIDEO_Configure(rmode); // Tell the video hardware where our display memory is VIDEO_SetNextFramebuffer(xfb); // Make the display visible VIDEO_SetBlack(FALSE); // Flush the video register changes to the hardware VIDEO_Flush(); // Wait for Video setup to complete VIDEO_WaitVSync(); if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync(); // The console understands VT terminal escape codes // This positions the cursor on row 2, column 0 // we can use variables for this with format codes too // e.g. printf ("\x1b[%d;%dH", row, column ); printf("\x1b[2;0H");