Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't Read Nunchuck Data #43

Open
MustafaHaddara opened this issue Apr 4, 2017 · 3 comments
Open

Can't Read Nunchuck Data #43

MustafaHaddara opened this issue Apr 4, 2017 · 3 comments

Comments

@MustafaHaddara
Copy link

I'm trying to read the data off the Nunchuk but failing...I feel like there's some initialization function that I'm not calling or something like that, because the sample scene works fine for me.

Here's my code to find the Wiimote:

WiimoteManager.FindWiimotes();

if (!WiimoteManager.HasWiimote()) { return; }

wiimote = WiimoteManager.Wiimotes[0];

wiimote.SendPlayerLED(false, false, false, false);

wiimote.SendDataReportMode(InputDataType.REPORT_EXT21);
wiimote.SetupIRCamera(IRDataType.BASIC);

if (wiimote.current_ext != ExtensionController.NUNCHUCK) { 
    print("no nunchuck");
    print(wiimote.current_ext.ToString());
    return; 
}

print("wiimote has nunchuck");
print("Stick: " + wiimote.Nunchuck.stick[0] + ", " + wiimote.Nunchuck.stick[1]);

I always get the no nunchuck line printed, and wiimore.current_ext.ToString() is reported as NONE. AS far as I can tell, that is expected behaviour, as the nunchuck isn't even fully detected at this point; I don't see the An extension has been connected. debug message until after these messages are printed out.

Here's my code in my Update() method:

if (!WiimoteManager.HasWiimote()) { return; }
wiimote = WiimoteManager.Wiimotes[0];

int ret;
do {
    ret = wiimote.ReadWiimoteData();
} while (ret > 0);

if (wiimote.current_ext == ExtensionController.NUNCHUCK) {
    NunchuckData data = wiimote.Nunchuck;
    print("got nunchuk!");

    // Use nunchuck data
    // ...

} else {
    print(wiimote.current_ext.ToString());
}

In this case, I always drop into the else block, even after the "An extension has been connected" message is printed out.

I sprinkled in some debug statements in Wiimote.cs and noticed that in RespondIdentifyExtension, the val identifier has the hex value 0xFF00A4200000, which is almost the same as the value for ID_Nunchuck except the highest byte is FF instead of 00.

I'm not sure what is causing this. Am I missing an initialization function somewhere? Am I supposed to send some data to the wiimote before trying to read nunchuck data?

@freiSMS
Copy link

freiSMS commented May 8, 2017

Same problem =(

@NoteToSelfFindGoodNickname

I'm using WiiBuddy now from the Unity Asset Store. It comes without source code, but it works out of the box and recognizes the Nunchuck.

@longevity-software
Copy link

I had to set the data report mode to REPORT_BUTTONS_ACCEL_EXT16 to get Nunchuck data from my controller.
By default I was only getting switch data back from just the Wiimote.
I think a better description of what data is returned for each InputDataType would help greatly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants