Ejemplo n.º 1
0
        public XInputCapabilities GetCapabilities()
        {
            XInputCapabilities capabilities = new XInputCapabilities();

            XInput.XInputGetCapabilities(_playerIndex, XInputConstants.XINPUT_FLAG_GAMEPAD, ref capabilities);
            return(capabilities);
        }
Ejemplo n.º 2
0
 public void Vibrate(XInputVibration strength, TimeSpan length)
 {
     XInput.XInputSetState(_playerIndex, ref strength);
     if (length != TimeSpan.MinValue)
     {
         _stopMotorTime        = DateTime.Now.Add(length);
         _stopMotorTimerActive = true;
     }
 }
Ejemplo n.º 3
0
        public void UpdateBatteryState()
        {
            XInputBatteryInformation headset = new XInputBatteryInformation(),
                                     gamepad = new XInputBatteryInformation();

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

            BatteryInformationHeadset = headset;
            BatteryInformationGamepad = gamepad;
        }
Ejemplo n.º 4
0
        //Updates the state for the controller
        public void UpdateState()
        {
            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);
            }
        }
Ejemplo n.º 5
0
 public void Vibrate(XInputVibration strength)
 {
     _stopMotorTimerActive = false;
     XInput.XInputSetState(_playerIndex, ref strength);
 }