Exemplo n.º 1
0
        protected void ParseExtensionData(byte[] buffer, int offset, int count)
        {
            for (int i = offset; i < offset + count; i++)
            {
                buffer[i] = (byte)((buffer[i] ^ 0x17) + 0x17 & 0xFF);
            }

            _Stick.Raw.X = buffer[offset + 0];
            _Stick.Raw.Y = buffer[offset + 1];
            _Stick.Calibration.Calibrate(_Stick.Raw, _Stick.Calibrated);

            _Accelerometer.Raw.X = (ushort)((buffer[offset + 2] << 2) + ((buffer[offset + 5] >> 2) & 0x03));
            _Accelerometer.Raw.Y = (ushort)((buffer[offset + 3] << 2) + ((buffer[offset + 5] >> 4) & 0x03));
            _Accelerometer.Raw.Z = (ushort)((buffer[offset + 4] << 2) + ((buffer[offset + 5] >> 6) & 0x03));

            _Accelerometer.Calibration.Calibrate(_Accelerometer.Raw, _Accelerometer.Calibrated);

            _Buttons =
                ((buffer[offset + 5] & 0x01) != 0 ? NunchukButtons.None : NunchukButtons.Z) |
                ((buffer[offset + 5] & 0x02) != 0 ? NunchukButtons.None : NunchukButtons.C);
        }
Exemplo n.º 2
0
        protected void ParseExtensionData(byte[] buffer, int offset, int count)
        {
            for (int i = offset; i < offset + count; i++)
            {
                buffer[i] = (byte)((buffer[i] ^ 0x17) + 0x17 & 0xFF);
            }

            _Stick.Raw.X = buffer[offset + 0];
            _Stick.Raw.Y = buffer[offset + 1];
            _Stick.Calibration.Calibrate(_Stick.Raw, _Stick.Calibrated);

            _Accelerometer.Raw.X = (ushort)((buffer[offset + 2] << 2) + ((buffer[offset + 5] >> 2) & 0x03));
            _Accelerometer.Raw.Y = (ushort)((buffer[offset + 3] << 2) + ((buffer[offset + 5] >> 4) & 0x03));
            _Accelerometer.Raw.Z = (ushort)((buffer[offset + 4] << 2) + ((buffer[offset + 5] >> 6) & 0x03));

            _Accelerometer.Calibration.Calibrate(_Accelerometer.Raw, _Accelerometer.Calibrated);

            _Buttons =
                ((buffer[offset + 5] & 0x01) != 0 ? NunchukButtons.None : NunchukButtons.Z) |
                ((buffer[offset + 5] & 0x02) != 0 ? NunchukButtons.None : NunchukButtons.C);
        }