private void AssignToXinputPlayer(int player) { device.BeginReading(); device.GetStatus(); targetXDevice = player; ConnectionState = DeviceState.Connected_XInput; RefreshState(); }
private void XOption_Click(object sender, RoutedEventArgs e) { if ((device.DataStream as WinBtStream).OpenConnection() && device.DataStream.CanRead) { device.BeginReading(); device.GetStatus(); int tmp = 0; if (int.TryParse(((MenuItem)sender).Name.Replace("XOption", ""), out tmp)) { targetXDevice = tmp; ConnectionState = DeviceState.Connected_XInput; } } }
public void disconnect() { //this step is actually not needed for the disconnect function to execute //currently in v3.3.560, WiinUSoft will be left in a glitched state if a device is disconnected that does not have an actively open DataStream //this is because the device dispose procedure is occurs executed with an actively read data stream is interupted bool wasConnected = Connected; if (wasConnected || ((device.DataStream as WinBtStream).OpenConnection() && device.DataStream.CanRead)) { if (!wasConnected) { device.BeginReading(); } } //controller disconnect function used to disconnect bluetooth device by mac address long lbtAddr = Convert.ToInt64(deviceMac.Replace(":", ""), 16); bool success = false; int IOCTL_BTH_DISCONNECT_DEVICE = 0x41000c; int bytesReturned = 0; var radioParams = new NativeImports.BLUETOOTH_FIND_RADIO_PARAMS(); radioParams.Initialize(); IntPtr hRadio; //handle of bluetooth radio, close with CloseHandle() IntPtr hFind; //handle needed to pass into BluetoothFindNextRadio, close with BluetoothFindRadioClose() // Get first BT Radio and execute commands hFind = NativeImports.BluetoothFindFirstRadio(ref radioParams, out hRadio); if (hRadio != IntPtr.Zero) { do { //commands to execute per BT Radio success = NativeImports.DeviceIoControl(hRadio, IOCTL_BTH_DISCONNECT_DEVICE, ref lbtAddr, 8, IntPtr.Zero, 0, ref bytesReturned, IntPtr.Zero); NativeImports.CloseHandle(hRadio); // Repeat commands if more BT Radio's exist } while (NativeImports.BluetoothFindNextRadio(ref hFind, out hRadio)); //close hFind that was used with BluetoothFindNextRadio() NativeImports.BluetoothFindRadioClose(hFind); } userDisconnecting = success; }
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; }
private void _btnConnect_Click(object sender, RoutedEventArgs e) { if (_nintroller != null) { _nintroller.ExtensionChange -= ExtensionChange; //_nintroller.StateChange -= StateChange; _nintroller.StateUpdate -= StateUpdate; _nintroller.Disconnect(); _nintroller = null; _stackDigitalInputs.Children.Clear(); _stackAnalogInputs.Children.Clear(); _btnConnect.Content = "Connect"; } else if (_comboBoxDeviceList.SelectedItem != null) { _nintroller = new Nintroller((string)_comboBoxDeviceList.SelectedItem); bool success = _nintroller.Connect(); if (!success) { Debug.WriteLine("Failed to connect"); _nintroller = null; } else { _btnConnect.Content = "Disconnect"; _nintroller.ExtensionChange += ExtensionChange; _nintroller.StateUpdate += StateUpdate; _nintroller.BeginReading(); _nintroller.GetStatus(); _nintroller.SetPlayerLED(1); } } }
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; }