using UnityEngine; // User don't have to use this directly, so there is no need to have this in global namespace namespace CarbonInput { /// /// Describes a mapping for a single gamepad button. /// For normal gamepads, IsWrapper is false and therefor the Button attribute is used. /// If IsWrapper is set to true, the KeyCode is used. /// [System.Serializable] public class ButtonMapping { /// /// If is this is the joystick button id. /// public int Button; /// /// If is this is the key used to emulate this gamepad button. /// public KeyCode Key; /// /// Defines if this mapping is a wrapper or not. /// public ButtonType Type = ButtonType.Default; public ButtonMapping() { } /// /// Copy constructor. /// /// public ButtonMapping(ButtonMapping other) { CopyFrom(other); } /// /// Copy all values from the parameter. /// /// public void CopyFrom(ButtonMapping other) { Button = other.Button; Key = other.Key; Type = other.Type; } /// /// Defines if a button is wrapper or not. /// public enum ButtonType { /// /// Button is a real gamepad button. /// Default, /// /// Uses a keyboard key to emulate a gamepad button. /// Wrapper } } /// /// Describes a mapping for a single gamepad axis. /// Every axis can be inverted. /// [System.Serializable] public class AxisMapping { /// /// Index of gamepad axis, used if Type is Default or Clamped. /// Used as button index if Type is ButtonWrapper or ButtonWrapper2. /// public int Axis; /// /// Only used if Type is ButtonWrapper2. /// Button index for positive value. /// public int Alternative; /// /// Whether this axis will be inverted. /// public bool Invert = false; /// /// Defines how this mapping behaves. /// public AxisType Type = AxisType.Default; /// /// If Type is ButtonWrapper, this is the value returned if the button is not pressed. /// If Type is Clamped, this is the lower bound of the axis. /// public float Min = 0.0f; /// /// If Type is ButtonWrapper, this is the value returned if the button is pressed. /// If Type is Clamped, this is the upper bound of the axis. /// public float Max = 1.0f; /// /// Used for KeyWrapper. Axis value is -1 if this key is pressed and Key2 is not pressed. /// public KeyCode Key1; /// /// Used for KeyWrapper. Axis value is 1 if this key is pressed and Key1 is not pressed. /// public KeyCode Key2; public AxisMapping() { } /// /// Copy constructor. /// /// public AxisMapping(AxisMapping other) { CopyFrom(other); } /// /// Copy all values from the parameter. /// /// public void CopyFrom(AxisMapping other) { Axis = other.Axis; Alternative = other.Alternative; Invert = other.Invert; Type = other.Type; Min = other.Min; Max = other.Max; Key1 = other.Key1; Key2 = other.Key2; } /// /// Enumeration of all possible axis types. /// public enum AxisType { /// /// Axis is a normal gamepad axis. /// Default, /// /// Gamepad does not have this axis, but it has a button for that axis /// ButtonWrapper, /// /// Gamepad does not have anything for this, fallback to KeyCodes /// KeyWrapper, /// /// The range of this axis is not in the normal range. /// Clamped, /// /// Gamepad does not have this axis, but it can be emulated by two buttons. /// ButtonWrapper2, /// /// Gamepad axis goes from -1 to 1, but it should go from 0 to 1. /// TriggerLimiter } } }