示例#1
0
        public void UpdateState()
        {
            var result = XInput.XInputGetState(_playerIndex, ref _gamepadStateCurrent);

            IsConnected = (result == 0);

            UpdateBatteryState();
            if (_gamepadStateCurrent.PacketNumber != _gamepadStatePrev.PacketNumber)
            {
                OnStateChanged();
            }

            _gamepadStatePrev.Copy(_gamepadStateCurrent);

            if (_stopMotorTimerActive && (DateTime.Now >= _stopMotorTime))
            {
                var stopStrength = new XInputVibration {
                    LeftMotorSpeed = 0, RightMotorSpeed = 0
                };
                XInput.XInputSetState(_playerIndex, ref stopStrength);
            }
        }
示例#2
0
        public void UpdateState()
        {
            //XInputCapabilities X = new XInputCapabilities();
            int result = XInput.XInputGetState(_playerIndex, ref gamepadStateCurrent);

            IsConnected = (result == 0);

            //UpdateBatteryState();
            if (gamepadStateCurrent.PacketNumber != gamepadStatePrev.PacketNumber)
            {
                OnStateChanged();
            }
            gamepadStatePrev.Copy(gamepadStateCurrent);

            if (_stopMotorTimerActive && (DateTime.Now >= _stopMotorTime))
            {
                XInputVibration stopStrength = new XInputVibration()
                {
                    LeftMotorSpeed = 0, RightMotorSpeed = 0
                };
                XInput.XInputSetState(_playerIndex, ref stopStrength);
            }
        }