Example #1
0
        private void OnWiimoteChanged(object sender, WiimoteChangedEventArgs args)
        {
            mx.WaitOne();

            try
            {
                if (isCalibrated)
                {
                    controller.StartHandling(args.WiimoteState);
                }
                else if (calibrating)
                {
                    isCalibrated = calibrator.Calibrate(args.WiimoteState);
                    calibrating  = !isCalibrated;
                    if (isCalibrated)
                    {
                        lastCalibrationData = calibrator.GetCalibrationData();
                    }
                    if (calibrator.HasChanged())
                    {
                        Notify();
                    }
                }
            }
            catch (UserTerminatedException)
            {
                wiimote.Disconnect();
            }

            mx.ReleaseMutex();
        }