internal float GetValue(InputDevice device)
        {
            if (device == null)
            {
                return(0f);
            }
            float value = device.GetControl(Control).Value;

            return(InputRange.Remap(value, SourceRange, InputRangeType.ZeroToOne));
        }
Exemple #2
0
 public float MapValue(float value)
 {
     if (Raw)
     {
         value *= Scale;
         value  = ((!SourceRange.Excludes(value)) ? value : 0f);
     }
     else
     {
         value = Mathf.Clamp(value * Scale, -1f, 1f);
         value = InputRange.Remap(value, SourceRange, TargetRange);
     }
     if (Invert)
     {
         value = 0f - value;
     }
     return(value);
 }
Exemple #3
0
        public float MapValue(float value)
        {
            if (Raw)
            {
                value = value * Scale;
                value = SourceRange.Excludes(value) ? 0.0f : value;
            }
            else
            {
                // Scale value and clamp to a legal range.
                value = Mathf.Clamp(value * Scale, -1.0f, 1.0f);

                // Remap from source range to target range.
                value = InputRange.Remap(value, SourceRange, TargetRange);
            }

            if (Invert)
            {
                value = -value;
            }

            return(value);
        }