public override void Dispose() { try { myController.Disconnect(); myController.Dispose(); myViGEmClient.Dispose(); } catch { } }
public void Dispose() { // When calling Stop() the device will get removed from the dictionary, do this to avoid exceptions in enumeration var devices = _Gamepads.Values.ToArray(); foreach (var device in devices) { device.Stop(); device.Dispose(); } _ViGEmClient.Dispose(); }
/// <summary>Returns true if ViGEmBus is installed, false otherwise</summary> public static bool ViGEmBusIsInstalled() { try { var client = new ViGEmClient(); client.Dispose(); return(true); } catch (Nefarius.ViGEm.Client.Exceptions.VigemBusNotFoundException) { return(false); } }
private void Dispose(bool disposing) { if (!disposing) { return; } try { _controller.Disconnect(); _client.Dispose(); } catch (Exception) { // ignored } }
public void Dispose() { _Logger.Information("Cleaning up running gamepads"); // When calling Stop() the device will get removed from the dictionary, do this to avoid exceptions in enumeration var devices = _Gamepads.Values.ToArray(); foreach (var device in devices) { device.Stop(); device.Dispose(); } _Logger.Information("Deinitializing ViGEm client"); _ViGEmClient.Dispose(); }
private bool disposedValue = false; // To detect redundant calls protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { // Must release the controller if (Initialized) { ctrl.Disconnect(); ctrl.Dispose(); client.Dispose(); } } disposedValue = true; } }
void OnStartEmulation(object arg) { var client = new ViGEmClient(); var controller = client.CreateXbox360Controller(); controller.AutoSubmitReport = false; controller.Connect(); emulationCancellation = new CancellationTokenSource(); var token = emulationCancellation.Token; Task.Run(async() => { var prevState = new GamepadState(); try { var gamepad = (GamepadDevice)DeviceManager.GetDevice(Path, Id); while (!token.IsCancellationRequested) { var state = await gamepad.GetStateAsync(token); if (token.IsCancellationRequested || prevState == state && state.IsDefault) { continue; } controller.ResetReport(); SetReport(controller, state); controller.SubmitReport(); prevState = state; } } finally { client.Dispose(); IsEmulated = false; } }, token); IsEmulated = true; }
public void Close() { Installed = false; client.Dispose(); }