Пример #1
0
        private void WorkerThread()
        {
            while (true)
            {
                switch (_hwState)
                {
                case HardwareStates.find_device:
                    Thread.Sleep(1000);
                    FindDevice();

                    if (_hidInterface.DeviceIsPresent())
                    {
                        _hwState = HardwareStates.enumerate_device;
                    }
                    break;

                case HardwareStates.enumerate_device:
                    EnumerateDevice();

                    if (_hidInterface.DeviceIsEnumerated())
                    {
                        _hwState = HardwareStates.device_enumerated;
                    }
                    else
                    {
                        _hwState = HardwareStates.find_device;
                    }
                    break;

                case HardwareStates.device_enumerated:
                    if (_devicePollCounter++ > 1000)
                    {
                        _devicePollCounter = 0;
                        PollDevice();
                    }

                    if (!_hidInterface.DeviceIsPresent())
                    {
                        _hidInterface.DisposeDevice();
                        _hwState = HardwareStates.find_device;
                    }
                    break;
                }

                if (_hidInterface.HasData())
                {
                    SetData(_hidInterface.GetData());
                }

                Thread.Sleep(2);
            }
        }
Пример #2
0
 /// <summary>
 /// This function reverts the current state to the previous value as an
 /// overridden state without affecting the current state index.
 /// </summary>
 public void RevertToPreviousState()
 {
     this._InOverrideMode = true;
     this._OverrideState  = this._PreviousState;
 }