public void Create() { ThreadContext context = ThreadCreator.Create("test", ThreadAction, true); ThreadResult result = context.Start().Cancel().Wait(); Assert.IsNull(result.Error); }
/// <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> /// Creates a new XDevice. /// </summary> /// <param name="source">Direct input device</param> /// <param name="mapper">DirectInput to XInput mapper</param> public WebXOutputDevice(XOutputManager xOutputManager) { this.xOutputManager = xOutputManager; sources = XInputHelper.Instance.GenerateSources((name, type) => new WebXOutputSource(name, type)); state = new DeviceState(sources, DPadCount); deviceInputChangedEventArgs = new DeviceInputChangedEventArgs(this); inputRefresher = ThreadCreator.Create("Keyboard input notification", InputRefresher).Start(); }
private void DispatchRefreshGameControllers(object sender, DeviceDisconnectedEventArgs e) { ThreadCreator.Create("Device list refresh delay", (token) => { Thread.Sleep(1000); dispatcher.Invoke(RefreshGameControllers); }).Start(); }
/// <summary> /// Creates a new keyboard device instance. /// </summary> public Keyboard() { sources = Enum.GetValues(typeof(Key)).OfType <Key>().Where(x => x != Key.None).OrderBy(x => x.ToString()).Select(x => new KeyboardSource(this, x.ToString(), x)).ToArray(); state = new DeviceState(sources, 0); deviceInputChangedEventArgs = new DeviceInputChangedEventArgs(this); inputConfig = new InputConfig(); inputRefresher = ThreadCreator.Create("Keyboard input notification", InputRefresher).SetApartmentState(ApartmentState.STA).Start(); }
/// <summary> /// Creates a new keyboard device instance. /// </summary> public Mouse() { sources = Enum.GetValues(typeof(MouseButton)).OfType <MouseButton>().Select(x => new MouseSource(this, x.ToString(), x)).ToArray(); state = new DeviceState(sources, 0); deviceInputChangedEventArgs = new DeviceInputChangedEventArgs(this); inputConfig = new InputConfig(); inputRefresher = ThreadCreator.Create("Mouse input notification", InputRefresher).Start(); }
public bool Handle(HttpListenerContext httpContext, CancellationToken cancellationToken) { if (!httpContext.Request.IsWebSocketRequest) { return(false); } ThreadCreator.Create("Websocket listener", (token) => HandleWebSocketAsync(httpContext, cancellationToken)).Start(); return(true); }
public async Task Start(string url, DeviceTypes deviceType, string emulator) { websocket = new ClientWebSocket(); cancellationTokenSource = new CancellationTokenSource(); string fullUrl = $"{url}{deviceType.ToString()}/{emulator}"; await websocket.ConnectAsync(new Uri(fullUrl), cancellationTokenSource.Token); ThreadCreator.Create("Device emulator", HandleWebsocket).Start(); }
/// <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); }
public void StartNamedPipe() { notifyThreadContext = ThreadCreator.Create("XOutputRunningAlreadyNamedPipe reader", ReadPipe).Start(); }