public void SetItem(Config.Axis inputAxis, Action <float> setLocoAxis, float minDelta = 0.005f)
        {
            if (inputAxis != null && !inputAxis.AxisName.Equals(""))
            {
                // Update the current values as regaining focus also sets axis to 50%
                if (!Main.hasFocusPrev && Main.hasFocus)
                {
                    previousInput     = GetValue(inputAxis);
                    inDeadZoneChanged = false;
                }

                currentInput = GetValue(inputAxis);

                // Only update item if we have changed by an amount or we enter/exit deadzones
                // This allows other input methods to still be used
                // minDelta should probably be configurable in case user inputs are more jittery when left in a fixed position
                if ((Math.Abs(previousInput - currentInput) > minDelta) || inDeadZoneChanged)
                {
                    setLocoAxis(currentInput);
                    if (inputAxis.Debug)
                    {
                        Main.mod.Logger.Log(string.Format("Axis: {0}, Value: {1}", inputAxis.AxisName, currentInput));
                    }
                    previousInput = currentInput;
                }
            }
        }
        // Might be better to use direct input for better control over attached devices
        private float GetValue(Config.Axis axis)
        {
            // Should use a mapping from the AxisName to an axis number cause this axis entered might not exist
            float value = UnityEngine.Input.GetAxisRaw(axis.AxisName) * axis.Scaling;

            InDeadZone(axis, value);
            DeadZoneScaling(axis, ref value);

            if (axis.FullRange)
            {
                value = (value + 1f) / 2f;
            }

            return(value);
        }
 private void DeadZoneScaling(Config.Axis axis, ref float value)
 {
     // Deadzone scaling
     if (Math.Abs(value) <= axis.DeadZoneCentral)
     {
         value = 0f;
     }
     else
     {
         float range = 1f - axis.DeadZoneCentral - axis.DeadZoneEnds;
         if (range == 0)
         {
             value = 0;
         }
         if (value > 0)
         {
             value = Math.Min(1f, (value - axis.DeadZoneCentral) / range);
         }
         else
         {
             value = Math.Max(-1f, (value + axis.DeadZoneCentral) / range);
         }
     }
 }
 private void InDeadZone(Config.Axis axis, float value)
 {
     inDeadZonePrev    = inDeadZone;
     inDeadZone        = Math.Abs(value) >= (1f - axis.DeadZoneEnds) || Math.Abs(value) <= axis.DeadZoneCentral;
     inDeadZoneChanged = inDeadZone != inDeadZonePrev;
 }