public MainWindow() { InitializeComponent(); _xboxDataProvider = new XboxJoystickDataProvider(); _network = Network.Load(NeuronWeightsGenerator.Program.NetworkFile); if (!ConnectDevice()) { _timer.Elapsed += (sender, args) => ConnectDevice(); _timer.Start(); } }
private void Worker() { //if (InitializePort(_portName, 115200)) { Console.WriteLine("\nConnected to {0}\n", _portName); _xboxDataProvider = new XboxJoystickDataProvider(); if (_xboxDataProvider.OpenDevice()) { _xboxDataProvider.OnPackageAvailableEvent += OnPackageAvailable; Console.WriteLine("Joystick found and opened."); Thread.CurrentThread.Join(); } else { _port.Close(); Console.WriteLine("Could not find a joystick."); Console.ReadKey(); } } }