Skip to content

Game.Settings.SettingsUIGamepadBindingAttribute

Assembly: Assembly-CSharp
Namespace: Game.Settings

Type: class

Base: SettingsUIKeybindingAttribute

Summary:
Attribute used to define a gamepad binding for a settings UI property. It specifies a default gamepad button/axis/vector2 binding (BindingGamepad), and optional modifier stick presses (leftStick / rightStick). The attribute sets up the underlying input device (Gamepad) and action type (Button / Axis / Vector2) via the base SettingsUIKeybindingAttribute constructors, and exposes the control path and modifier control paths used by the input system.


Fields

  • public readonly BindingGamepad defaultKey
    Holds the default gamepad binding (BindingGamepad enum) for the annotated setting. If left as BindingGamepad.None the attribute’s control path will be an empty string.

  • public readonly bool leftStick
    If true, the attribute will include the left stick press ("/leftStickPress") as a possible modifier control.

  • public readonly bool rightStick
    If true, the attribute will include the right stick press ("/rightStickPress") as a possible modifier control.

Properties

  • public override string control { get; }
    Returns the input system control path corresponding to the configured defaultKey. The mapping (BindingGamepad -> control path) includes:
  • BindingGamepad.None => ""
  • BindingGamepad.DpadUp => "/dpad/up"
  • BindingGamepad.DpadDown => "/dpad/down"
  • BindingGamepad.DpadLeft => "/dpad/left"
  • BindingGamepad.DpadRight => "/dpad/right"
  • BindingGamepad.North => "/buttonNorth"
  • BindingGamepad.East => "/buttonEast"
  • BindingGamepad.South => "/buttonSouth"
  • BindingGamepad.West => "/buttonWest"
  • BindingGamepad.LeftShoulder => "/leftShoulder"
  • BindingGamepad.RightShoulder => "/rightShoulder"
  • BindingGamepad.Start => "/start"
  • BindingGamepad.Select => "/select"
  • BindingGamepad.LeftTrigger => "/leftTrigger"
  • BindingGamepad.RightTrigger => "/rightTrigger"
  • BindingGamepad.LeftStickUp => "/leftStick/up"
  • BindingGamepad.LeftStickDown => "/leftStick/down"
  • BindingGamepad.LeftStickLeft => "/leftStick/left"
  • BindingGamepad.LeftStickRight => "/leftStick/right"
  • BindingGamepad.RightStickUp => "/rightStick/up"
  • BindingGamepad.RightStickDown => "/rightStick/down"
  • BindingGamepad.RightStickLeft => "/rightStick/left"
  • BindingGamepad.RightStickRight => "/rightStick/right"
  • any other value => ""

  • public override IEnumerable<string> modifierControls { get; }
    Enumerates modifier control paths based on leftStick/rightStick flags:

  • if leftStick is true -> yields "/leftStickPress"
  • if rightStick is true -> yields "/rightStickPress" These are typically used as modifier buttons for compound keybindings.

Constructors

  • public SettingsUIGamepadBindingAttribute(string actionName = null)
    Creates a button action binding attribute for gamepad device. Calls base with InputManager.DeviceType.Gamepad, ActionType.Button and ActionComponent.Press. Use when defaultKey or specific component not required.

  • public SettingsUIGamepadBindingAttribute(AxisComponent component, string actionName = null)
    Creates an axis action binding attribute for a specified AxisComponent on a gamepad.

  • public SettingsUIGamepadBindingAttribute(Vector2Component component, string actionName = null)
    Creates a Vector2 action binding attribute for a specified Vector2Component on a gamepad (e.g., left/right stick axes).

  • public SettingsUIGamepadBindingAttribute(BindingGamepad defaultKey, string actionName = null, bool leftStick = false, bool rightStick = false)
    Sets a default BindingGamepad value and optional modifier stick flags for a button action. Calls the button constructor internally.

  • public SettingsUIGamepadBindingAttribute(BindingGamepad defaultKey, AxisComponent component, string actionName = null, bool leftStick = false, bool rightStick = false)
    Sets a default BindingGamepad and creates an axis action binding for the provided AxisComponent. Also accepts modifier stick flags.

  • public SettingsUIGamepadBindingAttribute(BindingGamepad defaultKey, Vector2Component component, string actionName = null, bool leftStick = false, bool rightStick = false)
    Sets a default BindingGamepad and creates a Vector2 action binding for the provided Vector2Component. Also accepts modifier stick flags.

  • [Obsolete] public SettingsUIGamepadBindingAttribute(GamepadButton defaultKey, string actionName = null, bool leftStick = false)
    Obsolete constructor kept for compatibility. Internally converts GamepadButton to BindingGamepad by adding 1 to the enum value ((BindingGamepad)(defaultKey + 1)). Prefer constructors taking BindingGamepad.

  • [Obsolete] public SettingsUIGamepadBindingAttribute(GamepadButton defaultKey, AxisComponent component, string actionName = null, bool leftStick = false)
    Obsolete axis constructor that converts GamepadButton to BindingGamepad.

  • [Obsolete] public SettingsUIGamepadBindingAttribute(GamepadButton defaultKey, Vector2Component component, string actionName = null, bool leftStick = false)
    Obsolete vector2 constructor that converts GamepadButton to BindingGamepad.

Notes on constructors: all non-obsolete overloads call into the appropriate base SettingsUIKeybindingAttribute constructor, specifying InputManager.DeviceType.Gamepad and the desired ActionType/ActionComponent.

Methods

  • This attribute class does not declare additional public methods beyond the property getters and constructors. Its behavior is provided by the base SettingsUIKeybindingAttribute and the overridden properties control and modifierControls.

Usage Example

// Button binding with default north button and left stick press as modifier
[SettingsUIGamepadBindingAttribute(BindingGamepad.North, actionName: "Confirm", leftStick: true)]
public string ConfirmBinding { get; set; }

// Axis binding (example)
[SettingsUIGamepadBindingAttribute(AxisComponent.LeftTrigger, actionName: "Throttle")]
public string ThrottleBinding { get; set; }

// Vector2 binding for left stick, default using left stick directions (no defaultKey)
[SettingsUIGamepadBindingAttribute(Vector2Component.LeftStick, actionName: "Move", leftStick: false)]
public string MoveBinding { get; set; }

If you need, I can also produce a quick reference mapping of the BindingGamepad enum values to their meaning (if you provide that enum), or an example showing how the settings UI reads these attributes.