added support to get X and Y values from nunchuck joystick
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user