wiiuse
Classes | Macros | Functions
Internal: Dynamics Functions

Classes

struct  vec3i_t
 

Macros

#define WIIMOTE_ACCEL_XBITS   2
 
#define WIIMOTE_ACCEL_YBITS   1
 
#define WIIMOTE_ACCEL_ZBITS   1
 
#define WIIMOTE_ACCEL_XSHIFT   0
 
#define WIIMOTE_ACCEL_YSHIFT   0
 
#define WIIMOTE_ACCEL_ZSHIFT   0
 
#define NUNCHUK_ACCEL_XSHIFT   0
 
#define NUNCHUK_ACCEL_YSHIFT   0
 
#define NUNCHUK_ACCEL_ZSHIFT   0
 
#define NUNCHUK_PASSTHROUGH_ACCEL_XSHIFT   0
 
#define NUNCHUK_PASSTHROUGH_ACCEL_YSHIFT   0
 
#define NUNCHUK_PASSTHROUGH_ACCEL_ZSHIFT   0
 

Functions

struct vec3i_t wiiuse_scale_calibration (const struct vec3b_t *cal, const struct vec3b_t *cal_lsb, int accel_xshift, int accel_yshift, int accel_zshift)
 Scale an 8-bit calibration point up to the raw accel value's scale, per axis, filling in any real extra-precision bits decoded for it along the way. More...
 
void calculate_orientation (struct accel_t *ac, struct vec3w_t *accel, struct orient_t *orient, int smooth, int accel_xshift, int accel_yshift, int accel_zshift)
 Calculate the roll, pitch, yaw. More...
 
void calculate_gforce (struct accel_t *ac, struct vec3w_t *accel, struct gforce_t *gforce, int accel_xshift, int accel_yshift, int accel_zshift)
 Calculate the gravity forces on each axis. More...
 
void calc_joystick_state (struct joystick_t *js, float x, float y)
 Calculate the angle and magnitude of a joystick. More...
 
void apply_smoothing (struct accel_t *ac, struct orient_t *orient, int type)
 

Detailed Description

Function Documentation

◆ calc_joystick_state()

void calc_joystick_state ( struct joystick_t *  js,
float  x,
float  y 
)

Calculate the angle and magnitude of a joystick.

Parameters
js[out] Pointer to a joystick_t structure.
xThe raw x-axis value.
yThe raw y-axis value.

◆ calculate_gforce()

void calculate_gforce ( struct accel_t *  ac,
struct vec3w_t *  accel,
struct gforce_t *  gforce,
int  accel_xshift,
int  accel_yshift,
int  accel_zshift 
)

Calculate the gravity forces on each axis.

Parameters
acAn accelerometer (accel_t) structure.
accel[in] Pointer to a vec3w_t structure that holds the raw acceleration data.
gforce[out] Pointer to a gforce_t structure that will hold the gravity force data.
accel_xshift[in] See calculate_orientation().
accel_yshift[in] See calculate_orientation().
accel_zshift[in] See calculate_orientation().

◆ calculate_orientation()

void calculate_orientation ( struct accel_t *  ac,
struct vec3w_t *  accel,
struct orient_t *  orient,
int  smooth,
int  accel_xshift,
int  accel_yshift,
int  accel_zshift 
)

Calculate the roll, pitch, yaw.

Parameters
acAn accelerometer (accel_t) structure.
accel[in] Pointer to a vec3w_t structure that holds the raw acceleration data.
orient[out] Pointer to a orient_t structure that will hold the orientation data.
rorient[out] Pointer to a orient_t structure that will hold the non-smoothed orientation data.
smoothIf smoothing should be performed on the angles calculated. 1 to enable, 0 to disable.
accel_xshift[in] Per-axis WIIUSE_ACCEL_10BIT decode shift; see dynamics.h.
accel_yshift[in] Per-axis WIIUSE_ACCEL_10BIT decode shift; see dynamics.h.
accel_zshift[in] Per-axis WIIUSE_ACCEL_10BIT decode shift; see dynamics.h.

Given the raw acceleration data from the accelerometer struct, calculate the orientation of the device and set it in the orient parameter.

◆ wiiuse_scale_calibration()

struct vec3i_t wiiuse_scale_calibration ( const struct vec3b_t *  cal,
const struct vec3b_t *  cal_lsb,
int  accel_xshift,
int  accel_yshift,
int  accel_zshift 
)

Scale an 8-bit calibration point up to the raw accel value's scale, per axis, filling in any real extra-precision bits decoded for it along the way.

accel_xshift/yshift/zshift is 0 (a no-op) unless WIIUSE_ACCEL_10BIT is defined, so this always matches the scale handle_wm_accel()/ nunchuk_event() decoded the raw value at - see dynamics.h.

cal_lsb holds real extra-precision bits decoded from EEPROM (Wii Remote only); it is 0 elsewhere, so ORing it in is then a no-op.