/// <summary> /// Gets the Capabilities. /// </summary> /// <returns></returns> public XInputCapabilities GetCapabilities() { var capabilities = new XInputCapabilities(); XInputInterops.XInputGetCapabilities(_playerIndex, XInputConstants.XINPUT_FLAG_GAMEPAD, ref capabilities); return(capabilities); }
/// <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; } }
/// <summary> /// Updates the BatteryState. /// </summary> internal void UpdateBatteryState() { XInputBatteryInformation headset = new XInputBatteryInformation(), gamepad = new XInputBatteryInformation(); XInputInterops.XInputGetBatteryInformation(_playerIndex, (byte)BatteryDeviceType.BATTERY_DEVTYPE_GAMEPAD, ref gamepad); XInputInterops.XInputGetBatteryInformation(_playerIndex, (byte)BatteryDeviceType.BATTERY_DEVTYPE_HEADSET, ref headset); BatteryInformationHeadset = headset; BatteryInformationGamepad = gamepad; }
/// <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; }