Welcome! Log In Create A New Profile

Advanced

Nunchuk orientation

Posted by profetylen 
Nunchuk orientation
June 21, 2009 08:46PM
I have figured out how to get the orientiation from the wiimote with WPAD_Orientation(WPAD_CHAN_0, &orient), but how do I get it from the nunchuk?
Re: Nunchuk orientation
June 21, 2009 08:49PM
The orientation of its analog stick or the orientation of its internal accelerometer?
Re: Nunchuk orientation
June 21, 2009 08:56PM
The internal accelerometer. Has it only one? The wiimote has 2 or am I wrong?
Re: Nunchuk orientation
June 22, 2009 02:11AM
Technically, the wiimote has two microscopic accelerometers, both on the same die and thus, in the same chip. The nunchuck has a different chip, but I am still confident that it has a similar setup.
Re: Nunchuk orientation
June 22, 2009 12:22PM
Ok, but still; How can I know the nunchuk orientation?



Edited 1 time(s). Last edit at 06/22/2009 12:22PM by profetylen.
Re: Nunchuk orientation
June 22, 2009 12:41PM
from wiiuse.h

typedef struct nunchuk_t {
	struct accel_t accel_calib;		/**< nunchuk accelerometer calibration		*/
	struct joystick_t js;			/**< joystick calibration					*/

	int* flags;						/**< options flag (points to wiimote_t.flags) */

	ubyte btns;						/**< what buttons have just been pressed	*/
	ubyte btns_last;				/**< what buttons have just been pressed	*/
	ubyte btns_held;				/**< what buttons are being held down		*/
	ubyte btns_released;			/**< what buttons were just released this	*/

	struct vec3w_t accel;			/**< current raw acceleration data			*/
	struct orient_t orient;			/**< current orientation on each axis		*/
	struct gforce_t gforce;			/**< current gravity forces on each axis	*/
} nunchuk_t;

typedef struct expansion_t {
	int type;						/**< type of expansion attached				*/

	union {
		struct nunchuk_t nunchuk;
		struct classic_ctrl_t classic;
		struct guitar_hero_3_t gh3;
 		struct wii_board_t wb;
	};
} expansion_t;


Use WPAD_Expansion function to retrieve the expansion structure:

struct expansion_t exp;
WPAD_Expansion(0, &exp); /* first wiimote's expansion controller */


then you get access to the nunchuk's "orient"structure as usual:

exp->nunchuk.orient.yaw
exp->nunchuk.orient.roll
exp->nunchuk.orient.pitch

You should read the wiiuse documentation first, it always help.



Edited 1 time(s). Last edit at 06/22/2009 12:42PM by ekeeke.
Re: Nunchuk orientation
June 22, 2009 01:08PM
A-ha!

Thanks alot ekeeke! Didn't know there was documentation for wiiuse. I've always tried to understand from wiiuse.h.
Re: Nunchuk orientation
June 22, 2009 01:27PM
Quote
ekeeke
then you get access to the nunchuk's "orient"structure as usual:

exp->nunchuk.orient.yaw
exp->nunchuk.orient.roll
exp->nunchuk.orient.pitch

Hm, from what I can see you use it like this:

exp.nunchuk.orient.yaw
exp.nunchuk.orient.roll
exp.nunchuk.orient.pitch

I need no more help on this as everything works now, I just stated this for clarity.



Edited 1 time(s). Last edit at 06/22/2009 01:27PM by profetylen.
Sorry, only registered users may post in this forum.

Click here to login