Page 1 of 1

Nunchuck

Posted: Tue Sep 07, 2010 3:59 pm
by Ghost6765
Recently I put a post that got disapproved by Izhido and I did what he said (To Try & Find Out Myself In The Examples Folder) but I still can't find out how to use the Nunchuck in my games? Does someone else know?






I put ? marks like you said Wintermute

Re: Nunchuck

Posted: Tue Sep 07, 2010 5:53 pm
by Izhido
Amazing. I was completely sure there was code in there showing input devices. Guess I was wrong, after all :D .

Anyway, try this:

Code: Select all

	expansion_t e;
	int nx;
	int ny;

	WPAD_Expansion(WPAD_CHAN_0, &e);
	if(e.type != WPAD_EXP_NUNCHUK)
	{
		iprintf("Nunchuk not attached to Wiimote 0");
	}
	nx = e.nunchuk.js.pos.x - e.nunchuk.js.center.x;
	ny = e.nunchuk.js.pos.y - e.nunchuk.js.center.y;

nx and ny should contain valid values for the nunchuk's joystick. Check the "expansion_t" structure in libogc's header files. All the keys & controls for the expansion devices (like the nunchuk) should be right there.

Of course, be sure to call WPAD_Init() before attempting to use this code in your application.

Hope that helps.

Re: Nunchuck

Posted: Fri Sep 10, 2010 9:42 pm
by Ghost6765
These are all the questions I have: How to do movement?

Re: Nunchuck

Posted: Sat Sep 11, 2010 12:07 am
by Izhido
How do you define "movement" ? What actions are you performing with the nunchuk that cause what you're calling "movement", and what do you expect from your app when you do that?

Re: Nunchuck

Posted: Sat Sep 11, 2010 10:30 am
by Ghost6765
I mean if you push the control stick (UP, DOWN, LEFT or RIGHT) The sprite on screen will do so. I think it is the values that you said but I don't know how to use them.