/// <summary> /// Starts the emulation of the device /// </summary> public int Start(Action onStop = null) { if (!HasXOutputInstalled) { return(0); } if (controller != null) { controller.FeedbackReceived -= ControllerFeedbackReceived; } if (xOutputManager.Stop(controllerCount)) { // Wait for unplugging Thread.Sleep(10); } controllerCount = xOutputManager.Start(); if (controllerCount != 0) { threadContext = ThreadCreator.Create($"Emulated controller {controllerCount} output refresher", token => ReadAndReportValues(token, onStop)).Start(); running = true; logger.Info($"Emulation started on {ToString()}."); if (ForceFeedbackSupported) { logger.Info($"Force feedback mapping is connected on {ToString()}."); controller = ((VigemDevice)xOutputManager.XOutputDevice).GetController(controllerCount); controller.FeedbackReceived += ControllerFeedbackReceived; } } return(controllerCount); }
/// <summary> /// Starts the emulation of the device /// </summary> public int Start(Action onStop = null) { Stop(); client = xOutputManager.Start(); threadContext = ThreadCreator.Create($"Emulated controller output refresher", token => ReadAndReportValues(onStop, token)).Start(); running = true; logger.Info($"Emulation started on {ToString()}."); logger.Info($"Force feedback mapping is connected on {ToString()}."); client.Feedback += FeedbackReceived; // TODO return(1); }
/// <summary> /// Starts the emulation of the device /// </summary> public int Start(Action onStop = null) { if (!HasXOutputInstalled) { return(0); } if (controller != null) { controller.FeedbackReceived -= ControllerFeedbackReceived; } if (xOutputManager.Stop(controllerCount)) { // Wait for unplugging Thread.Sleep(10); } controllerCount = xOutputManager.Start(); if (controllerCount != 0) { thread = ThreadHelper.CreateAndStart(new ThreadStartParameters { Name = $"Emulated controller {controllerCount} output refresher", IsBackground = true, Task = () => ReadAndReportValues(), Error = (ex) => { logger.Error("Failed to read from device", ex); Stop(); }, Finally = onStop, }); running = true; logger.Info($"Emulation started on {ToString()}."); if (ForceFeedbackSupported) { logger.Info($"Force feedback mapping is connected on {ToString()}."); controller = ((VigemDevice)xOutputManager.XOutputDevice).GetController(controllerCount); controller.FeedbackReceived += ControllerFeedbackReceived; } } return(controllerCount); }