XInputSetState() static private method

Sets the Input state.
static private XInputSetState ( int dwUserIndex, XInputVibration &pVibration ) : int
dwUserIndex int The Index.
pVibration XInputVibration The Vibration.
return int
コード例 #1
0
        /// <summary>
        /// Updates the object.
        /// </summary>
        /// <param name="gameTime">The GameTime.</param>
        public void Update(GameTime gameTime)
        {
            int result = XInputInterops.XInputGetState(_playerIndex, ref _gamepadStateCurrent);

            IsAvailable = (result == 0);
            if (!IsAvailable)
            {
                return;
            }

            UpdateBatteryState();
            _gamepadStatePrev.Copy(_gamepadStateCurrent);

            if (_vibrationTime > 0)
            {
                _vibrationTime -= gameTime.ElapsedGameTime;
            }

            if (_vibrationTime <= 0 && !_vibrationStopped)
            {
                var stopStrength = new XInputVibration {
                    LeftMotorSpeed = 0, RightMotorSpeed = 0
                };
                XInputInterops.XInputSetState(_playerIndex, ref stopStrength);
                _vibrationStopped = true;
            }
        }
コード例 #2
0
 /// <summary>
 /// Vibrates the controller.
 /// </summary>
 /// <param name="strength">The Strength.</param>
 /// <param name="length">The Length.</param>
 internal void Vibrate(XInputVibration strength, float length)
 {
     XInputInterops.XInputSetState(_playerIndex, ref strength);
     _vibrationStopped = false;
     _vibrationTime    = length;
 }