get wiiRemote IR point problem
Posted: Tue Jun 10, 2008 4:18 pm
hello brother
I use the latest release of libogc (080603),
and when I use the wiiuse lib , I met some trouble here.
I want to get IR point ,but every time call function WPAD_ReadEvent(0, &wpads),
I got zero from dot[0].rx and dot[0].ry , the same as the other 3 LED.
I dont know what's wrong happened , please refer below code,thanks a lot!
good job!bravoļ¼
I use the latest release of libogc (080603),
and when I use the wiiuse lib , I met some trouble here.
I want to get IR point ,but every time call function WPAD_ReadEvent(0, &wpads),
I got zero from dot[0].rx and dot[0].ry , the same as the other 3 LED.
I dont know what's wrong happened , please refer below code,thanks a lot!
Code: Select all
#include <stdio.h>
#include <stdlib.h>
#include <gccore.h>
#include <ogcsys.h>
#include <unistd.h>
#include <wiiuse/wpad.h>
static void *xfb = NULL;
static GXRModeObj *rmode = NULL;
static WPADData wpads;
static int activeDot;
//---------------------------------------------------------------------------------
int main(int argc, char **argv) {
//---------------------------------------------------------------------------------
// Initialise the video system
VIDEO_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);
// 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");
printf("Hello World!");
WPAD_SetDataFormat(0,WPAD_FMT_BTNS_ACC_IR);
int irX1point = 0;
int irY1point = 0;
int irX2point = 0;
int irY2point = 0;
int irX3point = 0;
int irY3point = 0;
int irX4point = 0;
int irY4point = 0;
while(1) {
// Call WPAD_ScanPads each loop, this reads the latest controller states
WPAD_ScanPads();
WPAD_ReadEvent(0, &wpads);
// 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
irX1point = wpads.ir.dot[0].rx;
irY1point = wpads.ir.dot[0].ry;
irX1point = wpads.ir.dot[1].rx;
irY1point = wpads.ir.dot[1].ry;
irX1point = wpads.ir.dot[2].rx;
irY1point = wpads.ir.dot[2].ry;
irX1point = wpads.ir.dot[3].rx;
irY1point = wpads.ir.dot[3].ry;
printf("X1:%d, Y1:%d, X2:%d, Y2:%d, X3:%d, Y3:%d, X4:%d, Y4:%d\n", irX1point ,irY1point,irX2point ,irY2point,irX3point ,irY3point,irX4point ,irY4point);
u32 pressed = WPAD_ButtonsDown(0);
// We return to the launcher application via exit
if ( pressed & WPAD_BUTTON_HOME ) exit(0);
// Wait for the next frame
VIDEO_WaitVSync();
}
return 0;
}