rmontanezjr / wjoy

Automatically exported from code.google.com/p/wjoy
0 stars 0 forks source link

10-bit IR data is unpacked/repacked incorrectly #44

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
http://wiibrew.org/wiki/Wiimote#IR_Camera  The IR data is not repacking the 
bits properly.

This seems to work properly for one point; I don't have a 2nd-4th point 
generator yet (IR light source) to verify

- (void)handle10ByteIRData:(const uint8_t*)data
 ...

        uint16_t x = data[0] | (((data[2] >> 4) & 0x3) << 8);
        uint16_t y = data[1] | (((data[2] >> 6) & 0x3) << 8);

...
        x = data[3] | (((data[2] >> 0) & 0x3) << 8);
        y = data[4] | (((data[2] >> 2) & 0x3) << 8);

Yes, you could be more fancy and shift only once and mask in-place.

Original issue reported on code.google.com by mikep...@gmail.com on 10 Feb 2014 at 5:34

GoogleCodeExporter commented 9 years ago
Found a 2nd incandescent bulb; seems to work.

Original comment by mikep...@gmail.com on 10 Feb 2014 at 5:48

GoogleCodeExporter commented 9 years ago
Thanks, Mike!

All IR reports handling was completely broken. I fixed it and commit all 
changes to svn. Can you test it?

PS: BIG thanks for this report.

Original comment by alexandr.serkov on 10 Feb 2014 at 8:06

GoogleCodeExporter commented 9 years ago
Of course!  Works great; how do I go about enabling 12-byte reporting so I can 
test that.

Original comment by mikep...@gmail.com on 11 Feb 2014 at 6:35

GoogleCodeExporter commented 9 years ago
Simple way to enable 12-byte mode:

in WiimoteIPPart.m in method - (NSSet*)allowedReportTypeSet; change:

    if(allowedReportTypeSet == nil)
    {
        allowedReportTypeSet = [[NSSet alloc] initWithObjects:
            [NSNumber numberWithInteger:WiimoteDeviceReportTypeButtonAndAccelerometerAndIR12BytesState],
            [NSNumber numberWithInteger:WiimoteDeviceReportTypeButtonAndIR10BytesAndExtension9BytesState],
            [NSNumber numberWithInteger:WiimoteDeviceReportTypeButtonAndAccelerometerAndIR10BytesAndExtension6Bytes],
            nil];
    }

to

    if(allowedReportTypeSet == nil)
    {
        allowedReportTypeSet = [[NSSet alloc] initWithObjects:
            [NSNumber numberWithInteger:WiimoteDeviceReportTypeButtonAndAccelerometerAndIR12BytesState],
            nil];
    }

or comment unnecessary modes.

Original comment by alexandr.serkov on 11 Feb 2014 at 6:52

GoogleCodeExporter commented 9 years ago

Original comment by alexandr.serkov on 18 Apr 2014 at 8:29