added support to get X and Y values from nunchuck joystick

This commit is contained in:
Leif Berg
2013-03-01 10:04:19 -06:00
committed by Ryan Pavlik
parent 143b682b8e
commit b692edd958
2 changed files with 8 additions and 1 deletions

View File

@@ -180,6 +180,8 @@ void calc_joystick_state(struct joystick_t* js, float x, float y) {
*/
rx = applyCalibration(x, js->min.x, js->max.x, js->center.x);
ry = applyCalibration(y, js->min.y, js->max.y, js->center.y);
js->x = rx;
js->y = ry;
/* calculate the joystick angle and magnitude */
ang = RAD_TO_DEGREE(atan2f(ry, rx));
js->ang = ang + 180.0f;

View File

@@ -73,7 +73,10 @@
#define WIIUSE_MAJOR 0
#define WIIUSE_MINOR 14
#define WIIUSE_MICRO 0
#define WIIUSE_MICRO 2
#define WIIUSE_VERSION_TRANSFORM(MAJ, MIN, MICRO) (MAJ * 1000000 + MIN * 1000 + MICRO)
#define WIIUSE_HAS_VERSION(MAJ, MIN, MICRO) ( WIIUSE_VERSION_TRANSFORM(MAJ, MIN, MICRO) <= WIIUSE_VERSION_TRANSFORM(WIIUSE_MAJOR, WIIUSE_MINOR, WIIUSE_MICRO) )
#ifndef WIIUSE_PLATFORM
#if defined(_WIN32)
@@ -510,6 +513,8 @@ typedef struct joystick_t {
float ang; /**< angle the joystick is being held */
float mag; /**< magnitude of the joystick (range 0-1) */
float x; /**< horizontal position of the joystick (range [-1, 1] */
float y; /**< vertical position of the joystick (range [-1, 1] */
} joystick_t;