Esempio n. 1
0
 public override float EvaluateMagnitude(ref InputBindingCompositeContext context)
 {
     if (context.ReadValueAsButton(modifier1) && context.ReadValueAsButton(modifier2))
     {
         return(context.EvaluateMagnitude(binding));
     }
     return(default);
Esempio n. 2
0
        /// <inheritdoc />
        public override Vector2 ReadValue(ref InputBindingCompositeContext context)
        {
            var mode = this.mode;

            if (mode == Mode.Analog)
            {
                var upValue    = context.ReadValue <float>(up);
                var downValue  = context.ReadValue <float>(down);
                var leftValue  = context.ReadValue <float>(left);
                var rightValue = context.ReadValue <float>(right);

                return(DpadControl.MakeDpadVector(upValue, downValue, leftValue, rightValue));
            }

            var upIsPressed    = context.ReadValueAsButton(up);
            var downIsPressed  = context.ReadValueAsButton(down);
            var leftIsPressed  = context.ReadValueAsButton(left);
            var rightIsPressed = context.ReadValueAsButton(right);

            // Legacy. We need to reference the obsolete member here so temporarily
            // turn of the warning.
            #pragma warning disable CS0618
            if (!normalize) // Was on by default.
            {
                mode = Mode.Digital;
            }
            #pragma warning restore CS0618

            return(DpadControl.MakeDpadVector(upIsPressed, downIsPressed, leftIsPressed, rightIsPressed, mode == Mode.DigitalNormalized));
        }
Esempio n. 3
0
    public override myCompositData ReadValue(ref InputBindingCompositeContext context)
    {
        var press      = context.ReadValueAsButton(this.press);
        var pressCount = context.ReadValue <int>(this.pressCount);
        var position   = context.ReadValue <Vector2, Vector2MagnitudeComparer>(this.position);
        var delta      = context.ReadValue <Vector2, Vector2MagnitudeComparer>(this.delta);
        var radius     = context.ReadValue <Vector2, Vector2MagnitudeComparer>(this.radius);

        var tap = context.ReadValueAsButton(this.tap);
        //var phase = context.ReadValue<UnityEngine.InputSystem.TouchPhase>(this.phase);
        var startPosition = context.ReadValue <Vector2, Vector2MagnitudeComparer>(this.startPosition);
        var startTime     = context.ReadValue <double>(this.startTime);

        var scroll = context.ReadValue <Vector2, Vector2MagnitudeComparer>(this.scroll);

        return(new myCompositData()
        {
            Press = press,
            PressCount = pressCount,
            Position = position,
            Delta = delta,
            Radius = radius,

            Tap = tap,
            StartPosition = startPosition,
            StartTime = startTime,

            Scroll = scroll
        });
    }
Esempio n. 4
0
        /// <summary>
        /// Return the value of the <see cref="button"/> part while both <see cref="modifier1"/> and <see cref="modifier2"/>
        /// are pressed. Otherwise return 0.
        /// </summary>
        /// <param name="context">Evaluation context passed in from the input system.</param>
        /// <returns>The current value of the composite.</returns>
        public override float ReadValue(ref InputBindingCompositeContext context)
        {
            if (context.ReadValueAsButton(modifier1) && context.ReadValueAsButton(modifier2))
            {
                return(context.ReadValue <float>(button));
            }

            return(default);
Esempio n. 5
0
        /// <inheritdoc />
        public override Vector2 ReadValue(ref InputBindingCompositeContext context)
        {
            var upIsPressed    = context.ReadValueAsButton(up);
            var downIsPressed  = context.ReadValueAsButton(down);
            var leftIsPressed  = context.ReadValueAsButton(left);
            var rightIsPressed = context.ReadValueAsButton(right);

            return(DpadControl.MakeDpadVector(upIsPressed, downIsPressed, leftIsPressed, rightIsPressed, normalize));
        }
Esempio n. 6
0
        }                      // Trigger static constructor.

        public override float EvaluateMagnitude(ref InputBindingCompositeContext context)
        {
            var modifierCurrentlyActive = context.ReadValueAsButton(Trigger);

            if (modifierActive && !modifierCurrentlyActive)
            {
                modifierActive = false;
            }
            else if (!modifierActive && modifierCurrentlyActive)
            {
                modifierActive = true;
                totalDelta     = Vector2.zero;
            }

            if (modifierActive)
            {
                var val = ReadValue(ref context);
                if (val.x != 0 || val.y != 0)
                {
                    return(1);
                }
            }

            return(0);
        }
Esempio n. 7
0
 public override Vector2 ReadValue(ref InputBindingCompositeContext context)
 {
     if (context.ReadValueAsButton(modifier))
     {
         return(context.ReadValue <Vector2, Vector2MagnitudeComparer>(vector2));
     }
     return(default);
Esempio n. 8
0
 public override Vector2 ReadValue(ref InputBindingCompositeContext context)
 {
     if (context.ReadValueAsButton(MouseButton))
     {
         return(context.ReadValue <Vector2, Vector2MagnitudeComparer>(MouseVector)); //hack
     }
     return(default);
Esempio n. 9
0
        public override Vector2 ReadValue(ref InputBindingCompositeContext context)
        {
            var b = context.ReadValueAsButton(Button);
            var x = context.ReadValue <float>(Axis1);
            var y = context.ReadValue <float>(Axis2);
            var v = new Vector2(x, y);

            return(b && v.magnitude > 0.0f ? v : default);
Esempio n. 10
0
        /// <inheritdoc/>
        public override Vector3 ReadValue(ref InputBindingCompositeContext context)
        {
            if (mode == Mode.Analog)
            {
                var upValue       = context.ReadValue <float>(up);
                var downValue     = context.ReadValue <float>(down);
                var leftValue     = context.ReadValue <float>(left);
                var rightValue    = context.ReadValue <float>(right);
                var forwardValue  = context.ReadValue <float>(forward);
                var backwardValue = context.ReadValue <float>(backward);

                return(new Vector3(rightValue - leftValue, upValue - downValue, forwardValue - backwardValue));
            }
            else
            {
                var upValue       = context.ReadValueAsButton(up) ? 1f : 0f;
                var downValue     = context.ReadValueAsButton(down) ? -1f : 0f;
                var leftValue     = context.ReadValueAsButton(left) ? -1f : 0f;
                var rightValue    = context.ReadValueAsButton(right) ? 1f : 0f;
                var forwardValue  = context.ReadValueAsButton(forward) ? 1f : 0f;
                var backwardValue = context.ReadValueAsButton(backward) ? -1f : 0f;

                var vector = new Vector3(leftValue + rightValue, upValue + downValue, forwardValue + backwardValue);

                if (mode == Mode.DigitalNormalized)
                {
                    vector = vector.normalized;
                }

                return(vector);
            }
        }
Esempio n. 11
0
        public override PointerInput ReadValue(ref InputBindingCompositeContext context)
        {
            var contact   = context.ReadValueAsButton(this.contact);
            var pointerId = context.ReadValue <int>(inputId);
            var position  = context.ReadValue <Vector2, Vector2MagnitudeComparer>(this.position);

            return(new PointerInput
            {
                Contact = contact,
                InputId = pointerId,
                Position = position,
            });
        }
Esempio n. 12
0
    public override MouseDragCompositeResult ReadValue(ref InputBindingCompositeContext context)
    {
        if (context.ReadValueAsButton(modifier))
        {
            var newDelta    = context.ReadValue <Vector2, Vector2MagnitudeComparer>(this.delta, comparer);
            var newPosition = context.ReadValue <Vector2, Vector2MagnitudeComparer>(this.position, comparer);

            return(new MouseDragCompositeResult
            {
                delta = newDelta,
                position = newPosition,
            });
        }
        return(default);
Esempio n. 13
0
        public override PointerInput ReadValue(ref InputBindingCompositeContext context)
        {
            var contact   = context.ReadValueAsButton(this.contact);
            var pointerId = context.ReadValue <int>(inputId);
            var pressure  = context.ReadValue <float>(this.pressure);
            var radius    = context.ReadValue <Vector2, Vector2MagnitudeComparer>(this.radius);
            var tilt      = context.ReadValue <Vector2, Vector2MagnitudeComparer>(this.tilt);
            var position  = context.ReadValue <Vector2, Vector2MagnitudeComparer>(this.position);
            var twist     = context.ReadValue <float>(this.twist);

            return(new PointerInput
            {
                Contact = contact,
                InputId = pointerId,
                Position = position,
                Tilt = tilt != default ? tilt : (Vector2?)null,
                Pressure = pressure > 0 ? pressure : (float?)null,
                Radius = radius.sqrMagnitude > 0 ? radius : (Vector2?)null,
                Twist = twist > 0 ? twist : (float?)null,
            });
 /// <summary>
 /// Return the value of the <see cref="button"/> part multiplied by 1 or -1 depending if <see cref="modifier"/> is pressed.
 /// </summary>
 /// <param name="context">Evaluation context passed in from the input system.</param>
 /// <returns>The current value of the composite.</returns>
 public override float ReadValue(ref InputBindingCompositeContext context)
 {
     return(context.ReadValue <float>(button) * (context.ReadValueAsButton(modifier) ? -1 : 1));
 }
Esempio n. 15
0
 public override Vector3 ReadValue(ref InputBindingCompositeContext context)
 {
     if (!context.ReadValueAsButton(modifier))
     {
         return(default);
 public override Vector2 ReadValue(ref InputBindingCompositeContext context)
 {
     return(context.ReadValueAsButton(button) ? context.ReadValue <Vector2, Vector2MagnitudeComparer>(delta) : default);