/// <summary> /// Sets calibrations based on the ToString of this class. /// </summary> /// <param name="storageString"></param> public void SetCalibrations(string storageString) { if (string.IsNullOrEmpty(storageString)) { return; } string[] chunks = storageString.Split(new char[] { '-' }); foreach (string calStr in chunks) { if (calStr.StartsWith("wm")) { WiimoteCalibration.SetCalibration(calStr); } else if (calStr.StartsWith("nun")) { NunchukCalibration.SetCalibration(calStr); } else if (calStr.StartsWith("cls")) { ClassicCalibration.SetCalibration(calStr); } else if (calStr.StartsWith("ccp")) { ClassicProCalibration.SetCalibration(calStr); } else if (calStr.StartsWith("pro")) { ProCalibration.SetCalibration(calStr); } else if (calStr.StartsWith("gcn")) { GameCubeAdapterCalibration.SetCalibration(calStr); } else if (calStr.StartsWith("gut")) { GuitarCalibration.SetCalibration(calStr); } } }
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; }