Welcome! Log In Create A New Profile


[WiiuseCpp] Unable use IR Track

Posted by Flow 
[WiiuseCpp] Unable use IR Track
April 15, 2011 04:11PM
Hey all,

I'm starting a head tracking project using WiiUseCpp, I try to track one IR LED using the Wiimote, but I can't get it to work.

My code is quite basic, but I don't know why it doesn't work. I'm sure the Wiimote is switched on and working (I tested the rumble functions which are working).

Here is my code :

int main(int argc, char** argv)
    CWii wii;
    int numFound;

    printf("Searching for wiimotes...\n");

    //Find the wiimote (search for up to five seconds)
    numFound = wii.Find(5);

    // Connect to the wiimote
    std::vector& wiimotes = wii.Connect();

	// Get the Wiimote
	CWiimote &wiimote = *(wiimotes.begin());
	// Enable IR tracking
	// Set the sensibility at maximum

	// While the user doesn't press the 'q' key
	while(!GetKeyState('Q')) {
		// Get my dots
		std::vector &dots = wiimote.IR.GetDots();
		// Coords of these dots
		int x=0, y=0;

		// Print coords of all these dots
		for(unsigned int j=0; j<dots.size(); j++) {			
			dots.at(j).GetCoordinate(x, y);
			printf("x : %d\t y : %d\n", x, y);

		// Sleep for 10 ms

	return 0;

Does someone have an idea of what's wrong with it?
Re: [WiiuseCpp] Unable use IR Track
April 15, 2011 04:47PM
I don't have experience with the wiiusecpp library, but most variants of wiiuse require some kind of "update" function in your main loop.
Re: [WiiuseCpp] Unable use IR Track
April 15, 2011 05:22PM
Hey Daid, thanks for you answer!

Unfornately I tried to reload the wiimotes but the problem is still there.
Re: [WiiuseCpp] Unable use IR Track
April 15, 2011 05:34PM
Try adding a "wiimote.Poll();" call in your main loop.
Re: [WiiuseCpp] Unable use IR Track
April 15, 2011 05:43PM
Hey daid!

Indeed, that was the problem, (the method "Poll" is actually called on the wii and not the wiimote)!

Thanks a lot for your help :)
Sorry, only registered users may post in this forum.

Click here to login