예제 #1
0
        /// <summary>
        /// Updates the current states of this control.
        /// </summary>
        protected override void UpdateValues()
        {
            var value = 0f;

            foreach (var b in bindings)
            {
                if ((b.Value & ModifierFlags.Control) != 0 && !Input.GetKey(KeyCode.LeftControl))
                {
                    continue;
                }
                if ((b.Value & ModifierFlags.Alt) != 0 && !Input.GetKey(KeyCode.LeftAlt))
                {
                    continue;
                }
                if ((b.Value & ModifierFlags.Shift) != 0 && !Input.GetKey(KeyCode.LeftShift))
                {
                    continue;
                }

                if (BindingUtils.IsKeyCode(b.Key))
                {
                    value += BindingUtils.GetKCValue(b.Key) ? 1f : 0f;
                }
#if XBOX_ALLOWED
                else
                {
                    value += BindingUtils.GetXInputValue(b.Key, gpState);
                }
#endif
            }

            if (previousState == State.None && value != 0f)
            {
                state = State.Down;
            }
            else if ((previousState == State.Held || previousState == State.Down) && value == 0f)
            {
                state = State.Up;
            }
            else if (value != 0f)
            {
                state = State.Held;
            }
            else if (value == 0f)
            {
                state = State.None;
            }

            previousState = state;
        }
예제 #2
0
        /// <summary>
        /// Updates the current states of this control.
        /// </summary>
        protected override void UpdateValues()
        {
            foreach (var b in bindings)
            {
                if (BindingUtils.IsKeyCode(b.Key))
                {
                    rValue += BindingUtils.GetKCValue(b.Key) ? b.Value : 0f;
                }
#if XBOX_ALLOWED
                else
                {
                    rValue += BindingUtils.GetXInputValue(b.Key, gpState) * b.Value;
                }
#endif
            }
            value = Mathf.Clamp(rValue, -1f, 1f);
        }