public static bool SetTrigger(uint userIndex, XboxTrigger trigger, byte value)
        {
            if (!VirtualXboxController.IsOwned(userIndex))
            {
                return(false);
            }

            if (!NativeMethods.SetTrigger(userIndex, (uint)trigger, value))
            {
                return(false);
            }

            switch (trigger)
            {
            case XboxTrigger.Left:
                states[(int)userIndex - 1].LeftTriggerValue = value;
                break;

            case XboxTrigger.Right:
                states[(int)userIndex - 1].RightTriggerValue = value;
                break;

            default:
                throw new NotImplementedException(
                          "Not implemented Xbox trigger: " + trigger);
            }

            return(true);
        }
        public static void SetXboxTrigger(this Keybind _bind, XboxTrigger trigger)
        {
            var bind = _bind.Xbox;

            bind.XboxTrigger = trigger;
            _bind.Xbox       = bind;
        }
        public static float GetGamepadTriggerDelta(int index, XboxTrigger trigger)
        {
            var prev = GetLastState(index);
            var cur  = GetState(index);

            return(GetGamepadTrigger(cur, trigger) - GetGamepadTrigger(prev, trigger));
        }
Esempio n. 4
0
            public PresetTriggerVersionOne(XboxTrigger trigger, string key)
            {
                if (key == null)
                {
                    throw new ArgumentNullException("key");
                }

                this.Trigger     = trigger;
                this.KeyboardKey = key;
            }
Esempio n. 5
0
        private bool IsTriggerHighlighted(XboxTrigger trigger)
        {
            var triggerImage = this.GetTriggerImage(trigger);

            if (triggerImage != null)
            {
                return(triggerImage.Visibility == Visibility.Visible);
            }

            return(false);
        }
Esempio n. 6
0
    static float XboxTriggertoTriggerFloat(GamePadState state, XboxTrigger trigger)
    {
        switch (trigger)
        {
        case XboxTrigger.LeftTrigger:
            return(state.Triggers.Left);

        case XboxTrigger.RightTrigger:
            return(state.Triggers.Right);
        }
        return(0);
    }
        public static byte GetTriggerValue(uint userIndex, XboxTrigger trigger)
        {
            switch (trigger)
            {
            case XboxTrigger.Left:
                return(states[(int)userIndex - 1].LeftTriggerValue);

            case XboxTrigger.Right:
                return(states[(int)userIndex - 1].RightTriggerValue);

            default:
                throw new NotImplementedException(
                          "Not implemented xbox trigger: " + trigger);
            }
        }
        public static float GetGamepadTrigger(GamePadState state, XboxTrigger trigger)
        {
            switch (trigger)
            {
            case XboxTrigger.LeftTrigger:
                return(state.Triggers.Left);

            case XboxTrigger.RightTrigger:
                return(state.Triggers.Right);

            case XboxTrigger.None:
                return(0);
            }
            throw new InvalidOperationException("Attempted to read invalid trigger " + trigger);
        }
Esempio n. 9
0
        private void HighlightTrigger(XboxTrigger trigger)
        {
            Image triggerImage = this.GetTriggerImage(trigger);
            var   value        = this.XinputController.GetTriggerState((XinputTrigger)(uint)trigger);

            if (trigger == XboxTrigger.Left)
            {
                this.LtValueTextBlock.Text = value != 0 ? value.ToString() : string.Empty;
            }
            else
            {
                this.RtValueTextBlock.Text = value != 0 ? value.ToString() : string.Empty;
            }

            bool shouldHighlight = value > XboxTestSlot.TriggerDeadZone;

            this.SetImageVisibility(triggerImage, shouldHighlight);
        }
Esempio n. 10
0
        private Image GetTriggerImage(XboxTrigger trigger)
        {
            Image targetImage;

            switch (trigger)
            {
            case XboxTrigger.Left:
                targetImage = this.imageLT;
                break;

            case XboxTrigger.Right:
                targetImage = this.imageRT;
                break;

            default:
                throw new NotImplementedException(
                          "Not implemented xbox trigger: " + trigger);
            }

            return(targetImage);
        }
        public static float GetGamepadTrigger(int index, XboxTrigger trigger)
        {
            var cur = GetState(index);

            return(GetGamepadTrigger(cur, trigger));
        }
Esempio n. 12
0
 public float GetTrigger(XboxTrigger trigger)
 {
     return(XboxTriggertoTriggerFloat(gamePadState, trigger));
 }