Two bugs correction in the WiiRemote framewor

  • Hi!

    There is a bug in the Nunchuk calibration data, the array indices are not set correctly, and the read values are not correct.  Here is the solution:

    nunchukJoyStickCalibData.x_max = (dp[15] ^ 0x17) + 0x17;
    nunchukJoyStickCalibData.x_min = (dp[16] ^ 0x17) + 0x17;
    nunchukJoyStickCalibData.x_center = (dp[17] ^ 0x17) + 0x17;
    nunchukJoyStickCalibData.y_max = (dp[18] ^ 0x17) + 0x17;
    nunchukJoyStickCalibData.y_min = (dp[19] ^ 0x17) + 0x17;
    nunchukJoyStickCalibData.y_center = (dp[20] ^ 0x17) + 0x17;

    Also, there is a memory leak in the WiiRemoteFramework when closing the connection, if the channels' delegates are not set to nil.

    if (cchan){
        if ([wiiDevice isConnected]) do {

            // ---> set delegate to nil
            [cchan setDelegate:nil];

            ret = [cchan closeChannel];
        }while(ret != kIOReturnSuccess && trycount < 10);
        [cchan release];

    You also have to do the same for the ichan code right after that.

    I hope this will help!

    All the Best,

    • Jasen Jacobsen
      Jasen Jacobsen

      Thanks.  I made these changes in my branch.  They should get merged into the trunk when Hiroaki gets back.

      - Jasen.

    • Thanks, updated also.  In my version i've also added a callback to the delegate telling them calibration data has been received.  Seemed sensible to me?