Exemple #1
0
        public bool Connect()
        {
            bool success = false;

            if (_info.DevicePath == "Dummy")
            {
                _dummy = new Shared.DummyDevice(Calibrations.Defaults.ProControllerDefault);
                var dumWin = new Windows.DummyWindow(_dummy);
                dumWin.Show();
                _nintroller   = new Nintroller(_dummy);
                OnDisconnect += () =>
                {
                    dumWin.Close();
                };
            }
            else
            {
                _stream     = new WinBtStream(_info.DevicePath);
                _nintroller = new Nintroller(_stream);//, deviceInfo.Type);
            }
            _nintroller.StateUpdate     += _nintroller_StateUpdate;
            _nintroller.ExtensionChange += _nintroller_ExtensionChange;
            _nintroller.LowBattery      += _nintroller_LowBattery;

            // TODO: Seems OpenConnection() can still succeed on toshiba w/o device connected
            if (_dummy != null || _stream.OpenConnection())
            {
                _nintroller.BeginReading();
                _nintroller.GetStatus();
                _nintroller.SetPlayerLED(1);

                // We need a function we can await for the type to come back
                // But the hint type may be present
                CreateController(_nintroller.Type);

                if (_controller != null)
                {
                    SetupController();

                    success = true;
                    _nintroller.SetReportType(InputReport.ExtOnly, true);
                }
                else
                {
                    // Controller type not supported or unknown, teardown?
                    //success = false;
                    success = true;
                }

                _nintroller.Disconnected += _nintroller_Disconnected;
            }
#if DEBUGz
            else
            {
                _controller = new ProControl(Calibrations.Defaults.ProControllerDefault);
                SetupController();
                success = true;
            }
        public bool Connect()
        {
            bool success = false;

            if (_info.DevicePath != null && _info.DevicePath.StartsWith("Dummy"))
            {
                if (_info.DevicePath.Contains("GCN"))
                {
                    var dummyGameCubeAdapter = new GameCubeAdapter();
                    dummyGameCubeAdapter.SetCalibration(Calibrations.CalibrationPreset.Default);
                    _dummy      = new DummyDevice(dummyGameCubeAdapter);
                    _nintroller = new Nintroller(_dummy, 0x0337);
                }
                else
                {
                    if (_info.DevicePath.Contains("Wiimote"))
                    {
                        _dummy = new DummyDevice(Calibrations.Defaults.WiimoteDefault);
                    }
                    else
                    {
                        _dummy = new DummyDevice(Calibrations.Defaults.ProControllerDefault);
                    }

                    _nintroller = new Nintroller(_dummy, _dummy.DeviceType);
                }

                var dumWin = new Windows.DummyWindow(_dummy);
                dumWin.Show();

                OnDisconnect += () =>
                {
                    dumWin.Close();
                };
            }
            else
            {
                if (_stream == null)
                {
                    _stream = new WinBtStream(_info.DevicePath);
                }

                _nintroller = new Nintroller(_stream, _info.PID);
            }

            _nintroller.StateUpdate     += _nintroller_StateUpdate;
            _nintroller.ExtensionChange += _nintroller_ExtensionChange;
            _nintroller.LowBattery      += _nintroller_LowBattery;

            // TODO: Seems OpenConnection() can still succeed on toshiba w/o device connected
            if (_dummy != null || _stream.OpenConnection())
            {
                _nintroller.BeginReading();

                if (_nintroller.Type != ControllerType.Other)
                {
                    _nintroller.GetStatus();
                    _nintroller.SetPlayerLED(1);
                }

                // We need a function we can await for the type to come back
                // But the hint type may be present
                CreateController(_nintroller.Type);

                if (_controller != null)
                {
                    UpdateAlignment();

                    success = true;
                    _nintroller.SetReportType(InputReport.ExtOnly, true);
                }
                else
                {
                    // Controller type not supported or unknown, teardown?
                    //success = false;
                    success = true;
                }

                _nintroller.Disconnected += _nintroller_Disconnected;
            }
#if DEBUGz
            else
            {
                _controller = new ProControl(Calibrations.Defaults.ProControllerDefault);
                SetupController();
                success = true;
            }