Пример #1
0
        public XInputCapabilities GetCapabilities()
        {
            XInputCapabilities capabilities = new XInputCapabilities();

            XInputNative.XInputGetCapabilities(_playerIndex, XInputConstants.XINPUT_FLAG_GAMEPAD, ref capabilities);
            return(capabilities);
        }
Пример #2
0
 public void Vibrate(XInputVibration strength, TimeSpan length)
 {
     XInputNative.XInputSetState(_playerIndex, ref strength);
     if (length != TimeSpan.MinValue)
     {
         _stopMotorTime        = DateTime.Now.Add(length);
         _stopMotorTimerActive = true;
     }
 }
Пример #3
0
        public void UpdateBatteryState()
        {
            XInputBatteryInformation headset = new XInputBatteryInformation(),
                                     gamepad = new XInputBatteryInformation();

            XInputNative.XInputGetBatteryInformation(_playerIndex, (byte)BatteryDeviceType.BATTERY_DEVTYPE_GAMEPAD, ref gamepad);
            XInputNative.XInputGetBatteryInformation(_playerIndex, (byte)BatteryDeviceType.BATTERY_DEVTYPE_HEADSET, ref headset);

            BatteryInformationHeadset = headset;
            BatteryInformationGamepad = gamepad;
        }
Пример #4
0
 public void Vibrate(XInputVibration strength)
 {
     _stopMotorTimerActive = false;
     try
     {
         XInputNative.XInputSetState(_playerIndex, ref strength);
     }
     catch (Exception)
     {
         // import errors
     }
 }
Пример #5
0
        public XInputCapabilities GetCapabilities()
        {
            XInputCapabilities capabilities = new XInputCapabilities();

            try
            {
                XInputNative.XInputGetCapabilities(_playerIndex, XInputConstants.XINPUT_FLAG_GAMEPAD, ref capabilities);
            }
            catch (Exception)
            {
                // import errors
            }

            return(capabilities);
        }
Пример #6
0
        public void Vibrate(XInputVibration strength, TimeSpan length)
        {
            try
            {
                XInputNative.XInputSetState(_playerIndex, ref strength);
            }
            catch (Exception)
            {
                // import errors
            }

            if (length != TimeSpan.MinValue)
            {
                _stopMotorTime        = DateTime.Now.Add(length);
                _stopMotorTimerActive = true;
            }
        }
Пример #7
0
        public void UpdateState()
        {
            int result = XInputNative.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
                };
                XInputNative.XInputSetState(_playerIndex, ref stopStrength);
            }

            // event motion check
            if (_eventMotion)
            {
                if (gamepadStateCurrent.Gamepad.bLeftTrigger < 20)
                {
                    _eventMotion = false;
                }
            }
            else
            {
                if (gamepadStateCurrent.Gamepad.bLeftTrigger > 190 &&
                    gamepadStateCurrent.Gamepad.bRightTrigger > 190)
                {
                    _eventMotion = true;

                    OnEventMotionTrigger?.Invoke();
                }
            }
        }
Пример #8
0
 public void Vibrate(XInputVibration strength)
 {
     _stopMotorTimerActive = false;
     XInputNative.XInputSetState(_playerIndex, ref strength);
 }