private void ConectarDispositivo()
        {
            var helper = new System.Windows.Interop.WindowInteropHelper(_view);

            _dispositivo = new Device(DispositivoSelecionado.Guid);

            if (_dispositivo.DeviceInformation.InstanceName.Contains("XBOX"))
            {
                _controleXbox = true;
            }

            // Set joystick axis ranges.
            var eixos = _dispositivo.GetObjects(DeviceObjectTypeFlags.Axis);

            // Configura os eixos já para o PWM
            foreach (DeviceObjectInstance doi in eixos)
            {
                InputRange inputRange = new InputRange(0, 255);

                // Eixo do volante
                if (doi.Name.Contains("Wheel axis"))
                {
                    inputRange = new InputRange(-255, 255);
                }

                if (doi.Name.Contains("X Axis") && _controleXbox)
                {
                    inputRange = new InputRange(-255, 255);
                }

                if (doi.Name.Contains("Z Axis") && _controleXbox)
                {
                    inputRange = new InputRange(-255, 255);
                }

                _dispositivo.Properties.SetRange(ParameterHow.ById, doi.ObjectId, inputRange);
            }

            _dispositivo.Properties.AxisModeAbsolute = true;

            // _dispositivo.SetCooperativeLevel(helper.Handle, CooperativeLevelFlags.NonExclusive | CooperativeLevelFlags.Background);

            _dispositivo.SetDataFormat(DeviceDataFormat.Joystick);

            // _dispositivo.Properties.BufferSize = 128;
            _dispositivo.Acquire();
        }
 public ModePowerDownState(Device device)
 {
     Initialize();
     this.Device = device;
 }
 public Door(Device device, string name)
     : base(name)
 {
     _device = device;
     CurrentState = new DoorStates.CloseState(this);
 }
 public Door(Device device, string name)
     : base(name)
 {
     _device = device;
     CurrentState = new DoorStates.CloseState(this);
 }