예제 #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;
        }
예제 #2
0
        public void Dispose()
        {
            if (_InputThread.IsAlive)
            {
                Stop();
            }

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

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

            cont.Disconnect();
            cont.Dispose();
            cont = null;
        }
예제 #4
0
 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;
            }
        }