Beispiel #1
0
 public override void Dispose()
 {
     try
     {
         myController.Disconnect();
         myController.Dispose();
         myViGEmClient.Dispose();
     }
     catch
     {
     }
 }
Beispiel #2
0
        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();
        }
Beispiel #3
0
 /// <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);
     }
 }
Beispiel #4
0
 private void Dispose(bool disposing)
 {
     if (!disposing)
     {
         return;
     }
     try
     {
         _controller.Disconnect();
         _client.Dispose();
     }
     catch (Exception)
     {
         // ignored
     }
 }
Beispiel #5
0
        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;
            }
        }
Beispiel #7
0
        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;
        }
Beispiel #8
0
 public void Close()
 {
     Installed = false;
     client.Dispose();
 }