Vixen
02b45cc4
csharp
public sealed class InputRebindingOperation

"Press the key you want to use for this."

No guide page documents this yet — the page shows what the code says about itself.

Remarks

This is what the action model exists for. Everything else in this assembly can be approximated by polling a device; rebinding cannot, because it needs to know what every action is bound to, which bindings belong to the scheme the player is configuring, and how to write the answer somewhere that survives a patch.

The actions are disabled while it runs, and that is not a nicety: the key the player presses to choose a new "jump" would otherwise also make the character jump, and the menu behind the dialog would act on every candidate.

A conflict stops the operation rather than resolving it. Whether binding "crouch" to the key "jump" already uses should refuse, swap the two, or be allowed is a game's decision — a shooter and a strategy game answer it differently — so the operation reports Blocked with the conflicts listed and waits for ApplyAnyway or Cancel.

Fields and properties (12)

  • public InputActions Actions

    The asset the action belongs to.

  • public InputAction Action

    The action being rebound.

  • public int BindingIndex

    Which of its bindings.

  • public int PartIndex

    Which composite part, or -1.

  • public InputRebindingState State

    Where the operation has got to.

  • public InputControl SelectedControl

    The control the player chose, once there is one.

  • public IReadOnlyList<InputBindingConflict> Conflicts

    The actions already bound to SelectedControl.

  • public float Threshold

    How far an analogue control must move before it counts as the answer.

  • public float SettleTime

    How long a control must stay actuated before it is accepted, in seconds.

  • public bool AllowConflicts

    Whether a control already bound elsewhere is accepted without asking.

  • public bool DisableActionsWhileListening

    Whether to turn the asset's maps off while listening.

  • public string? ConflictScheme

    Which scheme's bindings conflicts are looked for in, or for all.

Events (2)

  • public Action<InputRebindingOperation>? Finished

    Raised when the operation reaches a terminal state, whichever one.

  • public Action<InputRebindingOperation>? CandidateSelected

    Raised each time a candidate control is accepted, before conflicts are considered.

Methods (7)

  • public InputRebindingOperation(InputActions actions, InputAction action, int bindingIndex, int partIndex = -1)

    Prepares a rebinding.

  • public InputRebindingOperation Excluding(InputControl control)

    Refuses a control — Escape, the pointer, whatever the game reserves.

  • public InputRebindingOperation WithDevice(InputDeviceKind kind)

    Limits the operation to one family of device.

  • public InputRebindingOperation Start()

    Starts listening.

  • public void Update(InputDeviceSet devices, double time)

    Looks at what is actuated and decides whether it is the answer.

  • public void ApplyAnyway()

    Applies a binding that conflicts with another, having asked the player.

  • public void Cancel()

    Gives up, leaving the binding as it was.

Used by (2)

  • InputRebindingTestsVixen.Input.Tests
  • InputServiceVixen.Input