From 385ce797682c1d968d2aaba710db607d9f93440f Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 26 Sep 2013 17:10:56 -0500 Subject: [PATCH] Handle Wii-U Nunchuks: nearly useless calibration data (0, 127, 0) --- src/nunchuk.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/nunchuk.c b/src/nunchuk.c index 12ec0aa..29efdfe 100644 --- a/src/nunchuk.c +++ b/src/nunchuk.c @@ -98,6 +98,15 @@ int nunchuk_handshake(struct wiimote_t* wm, struct nunchuk_t* nc, byte* data, un nc->js.min.x, nc->js.max.x, nc->js.center.x, nc->js.min.y, nc->js.max.y, nc->js.center.y); + /* If the calibration data makes no sense, fake it. */ + if (nc->js.max.x < nc->js.center.x) { + nc->js.max.x = 255; + } + + if (nc->js.max.y < nc->js.center.y) { + nc->js.max.y = 255; + } + /* default the thresholds to the same as the wiimote */ nc->orient_threshold = wm->orient_threshold; nc->accel_threshold = wm->accel_threshold;