Exemple #1
0
        public void Detach()
        {
            stop_polling = true;

            if (xin != null)
            {
                xin.Disconnect(); xin.Dispose();
            }

            if (state > state_.NO_JOYCONS)
            {
                HIDapi.hid_set_nonblocking(handle, 0);

                Subcommand(0x40, new byte[] { 0x0 }, 1);
                //Subcommand(0x48, new byte[] { 0x0 }, 1); // Would turn off rumble?

                if (isUSB)
                {
                    byte[] a = Enumerable.Repeat((byte)0, 64).ToArray();
                    a[0] = 0x80; a[1] = 0x05; // Allow device to talk to BT again
                    HIDapi.hid_write(handle, a, new UIntPtr(2));
                    a[0] = 0x80; a[1] = 0x06; // Allow device to talk to BT again
                    HIDapi.hid_write(handle, a, new UIntPtr(2));
                }
            }
            if (state > state_.DROPPED)
            {
                HIDapi.hid_close(handle);
            }
            state = state_.NOT_ATTACHED;
        }
Exemple #2
0
        public void Dispose()
        {
            if (_InputThread.IsAlive)
            {
                Stop();
            }

            _Device.Dispose();
            _CTS.Dispose();

            _Target.Dispose();
        }
        public override void Disconnect()
        {
            if (forceFeedbackCall != null)
            {
                cont.FeedbackReceived -= forceFeedbackCall;
                forceFeedbackCall      = null;
            }

            cont.Disconnect();
            cont.Dispose();
            cont = null;
        }
 public override void Dispose()
 {
     try
     {
         myController.Disconnect();
         myController.Dispose();
         myViGEmClient.Dispose();
     }
     catch
     {
     }
 }
        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;
            }
        }