public void Update(DolphiimoteData rawData)
        {
            this.data = rawData;

            Acceleration = calibration.NormalizeAcceleration(DateTime.Now, rawData.acceleration.x, rawData.acceleration.y, rawData.acceleration.z);

            if (IsDataValid(WiimoteDataValid.MotionPlus))
            {
                MotionPlus = CalculateMotionPlus(rawData.motionplus);
                fuser.HandleIMUData(MotionPlus.Value.x, MotionPlus.Value.y, MotionPlus.Value.z, Acceleration.Value.x, Acceleration.Value.y, Acceleration.Value.z);
            }

            if (IsDataValid(WiimoteDataValid.Nunchuck))
            {
                Nunchuck = new Nunchuck
                {
                    Stick = calibration.NormalizeNunchuckStick(DateTime.Now,
                                                               rawData.nunchuck.stick_x,
                                                               rawData.nunchuck.stick_y),
                    Acceleration = calibration.NormalizeNunchuckAcceleration(DateTime.Now,
                                                                             rawData.nunchuck.x,
                                                                             rawData.nunchuck.y,
                                                                             rawData.nunchuck.z)
                };
            }
        }
Example #2
0
        public void Update(DolphiimoteData rawData)
        {
            this.data = rawData;

            Acceleration = calibration.NormalizeAcceleration(DateTime.Now, rawData.acceleration.x, rawData.acceleration.y, rawData.acceleration.z);

            if (IsDataValid(WiimoteDataValid.MotionPlus))
            {
                MotionPlus = CalculateMotionPlus(rawData.motionplus);
                fuser.HandleIMUData(MotionPlus.Value.x, MotionPlus.Value.y, MotionPlus.Value.z, Acceleration.Value.x, Acceleration.Value.y, Acceleration.Value.z);
            }

            if (IsDataValid(WiimoteDataValid.Nunchuck))
            {
                Nunchuck = new Nunchuck
                {
                    Stick = calibration.NormalizeNunchuckStick(DateTime.Now,
                                                               rawData.nunchuck.stick_x,
                                                               rawData.nunchuck.stick_y),
                    Acceleration = calibration.NormalizeNunchuckAcceleration(DateTime.Now,
                                                                             rawData.nunchuck.x,
                                                                             rawData.nunchuck.y,
                                                                             rawData.nunchuck.z),
                    Buttons = (NunchuckButtons)data.nunchuck.buttons
                };
            }
            if (IsDataValid(WiimoteDataValid.ClassicController))
            {
                ClassicController = new ClassicController
                {
                    RightStick = calibration.NormalizeClassicControllerRightStick(DateTime.Now,
                                                                                  map(rawData.classic_controller.right_stick_x, 0, CLASSIC_OTHER_MAX, 0, 200),
                                                                                  map(rawData.classic_controller.right_stick_y, 0, CLASSIC_OTHER_MAX, 0, 200)),
                    LeftStick = calibration.NormalizeClassicControllerLeftStick(DateTime.Now,
                                                                                map(rawData.classic_controller.left_stick_x, 0, CLASSIC_LEFT_STICK_MAX, 0, 200),
                                                                                map(rawData.classic_controller.left_stick_y, 0, CLASSIC_LEFT_STICK_MAX, 0, 200)),
                    RightTrigger = calibration.NormalizeClassicControllerRightTrigger(DateTime.Now,
                                                                                      map(rawData.classic_controller.right_trigger, 0, CLASSIC_OTHER_MAX, 0, 100)),
                    LeftTrigger = calibration.NormalizeClassicControllerLeftTrigger(DateTime.Now,
                                                                                    map(rawData.classic_controller.left_trigger, 0, CLASSIC_OTHER_MAX, 0, 100)),
                    Buttons = (ClassicControllerButtons)data.classic_controller.buttons
                };
            }
            if (IsDataValid(WiimoteDataValid.Guitar))
            {
                Guitar = new Guitar
                {
                    Stick = calibration.NormalizeGuitarStick(DateTime.Now,
                                                             rawData.guitar.stick_x,
                                                             rawData.guitar.stick_y),
                    Whammy = calibration.NormalizeGuitarWhammy(DateTime.Now,
                                                               rawData.guitar.whammy_bar),
                    IsGH3   = rawData.guitar.is_gh3 == 1,
                    TapBar  = new TapBar(rawData.guitar.tap_bar),
                    Buttons = (GuitarButtons)data.guitar.buttons
                };
            }
            if (IsDataValid(WiimoteDataValid.BalanceBoard))
            {
                BalanceBoard = new BalanceBoard
                {
                    sensors = new BalanceBoardSensorList
                    {
                        bottomLeft = new BalanceBoardSensor
                        {
                            calibration = new BalanceBoardSensorCalibration
                            {
                                kg00 = rawData.balance_board.calibration_kg0.bottom_left,
                                kg17 = rawData.balance_board.calibration_kg17.bottom_left,
                                kg34 = rawData.balance_board.calibration_kg34.bottom_left
                            },
                            kg  = rawData.balance_board.kg.bottom_left,
                            lb  = rawData.balance_board.lb.bottom_left,
                            raw = rawData.balance_board.raw.bottom_left
                        },
                        bottomRight = new BalanceBoardSensor
                        {
                            calibration = new BalanceBoardSensorCalibration
                            {
                                kg00 = rawData.balance_board.calibration_kg0.bottom_right,
                                kg17 = rawData.balance_board.calibration_kg17.bottom_right,
                                kg34 = rawData.balance_board.calibration_kg34.bottom_right
                            },
                            kg  = rawData.balance_board.kg.bottom_right,
                            lb  = rawData.balance_board.lb.bottom_right,
                            raw = rawData.balance_board.raw.bottom_right
                        },
                        topLeft = new BalanceBoardSensor
                        {
                            calibration = new BalanceBoardSensorCalibration
                            {
                                kg00 = rawData.balance_board.calibration_kg0.top_left,
                                kg17 = rawData.balance_board.calibration_kg17.top_left,
                                kg34 = rawData.balance_board.calibration_kg34.top_left
                            },
                            kg  = rawData.balance_board.kg.top_left,
                            lb  = rawData.balance_board.lb.top_left,
                            raw = rawData.balance_board.raw.top_left
                        },
                        topRight = new BalanceBoardSensor
                        {
                            calibration = new BalanceBoardSensorCalibration
                            {
                                kg00 = rawData.balance_board.calibration_kg0.top_right,
                                kg17 = rawData.balance_board.calibration_kg17.top_right,
                                kg34 = rawData.balance_board.calibration_kg34.top_right
                            },
                            kg  = rawData.balance_board.kg.top_right,
                            lb  = rawData.balance_board.lb.top_right,
                            raw = rawData.balance_board.raw.top_right
                        },
                    },
                    weight = new BalanceBoardWeight
                    {
                        kg  = rawData.balance_board.weight_kg,
                        lb  = rawData.balance_board.weight_lb,
                        raw = rawData.balance_board.raw.bottom_left + rawData.balance_board.raw.bottom_right + rawData.balance_board.raw.top_left + rawData.balance_board.raw.top_right
                    },
                    centerOfGravity = new AnalogStick(rawData.balance_board.center_of_gravity_x, rawData.balance_board.center_of_gravity_y)
                };
            }
        }