Skip to content

Commit bccb582

Browse files
committed
More work on bindings pages
Also added table to action types page
1 parent 4a2c0c5 commit bccb582

File tree

3 files changed

+41
-85
lines changed

3 files changed

+41
-85
lines changed

Packages/com.unity.inputsystem/Documentation~/binding-conflicts.md

Lines changed: 26 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,53 @@
11

2-
## Binding conflict resolution
2+
# Binding conflicts
33

4-
For Value type actions, the Input System continuously monitors all the Controls which are bound to the Action, and then chooses the one which is the most actuated to be the Control driving the Action, and report the values from that Control in callbacks, triggered whenever the value changes. If a different bound Control actuated more, then that Control becomes the Control driving the Action, and the Action starts reporting values from that Control. This process is called conflict resolution. This is useful if you want to allow different Controls to control an Action in the game, but only take input from one Control at the same time.
4+
A binding conflict is when an [action](./actions.md) with more than one [control](./controls.md) [bound](./bindings.md) to it recieves values from multiple controls.
55

6-
For more information, see: [Dealing with binding conflicts](./dealing-with-binding-conflicts.md).
6+
For example, if the left and right triggers of a gamepad are both bound to an "accelerate" action in your game, each trigger could be pressed in to different amounts. This conflict of recieving two different values for the same action is resolved by the Input System.
77

8+
## Conflict Resolution
89

10+
For [value type actions](./action-and-control-types.md), the Input System continuously monitors all the controls bound to the action, and then chooses the one which is the **most actuated** to be the control driving the action. Most actuated means the largest absolute value is being reported, whether positive or negative in the case of a 1D axis, and regardless of direction in the case of 2D and 3D axes. The value of the most actuated control is reported in callbacks, and triggered whenever the value changes.
911

10-
There are two situations where a given input may lead to ambiguity:
12+
If a different bound control is actuated more, that control becomes the control driving the action. This process is called **conflict resolution**. This is useful if you want to allow different Controls to control an Action in the game, but only take input from one Control at the same time.
1113

12-
1. Several Controls are bound to the same Action and more than one is feeding input into the Action at the same time. Example: an Action that is bound to both the left and right trigger on a Gamepad and both triggers are pressed.
13-
2. The input is part of a sequence of inputs and there are several possible such sequences. Example: one Action is bound to the `B` key and another Action is bound to `Shift-B`.
14-
15-
#### Multiple, concurrently used Controls
16-
17-
>__Note:__ This section does not apply to [`PassThrough`](RespondingToActions.md#pass-through) Actions as they are by design meant to allow multiple concurrent inputs.
18-
19-
For a [`Button`](RespondingToActions.md#button) or [`Value`](RespondingToActions.md#value) Action, there can only be one Control at any time that is "driving" the Action. This Control is considered the [`activeControl`](../api/UnityEngine.InputSystem.InputAction.html#UnityEngine_InputSystem_InputAction_activeControl).
14+
## Ambiguous situations
2015

21-
When an Action is bound to multiple Controls, the [`activeControl`](../api/UnityEngine.InputSystem.InputAction.html#UnityEngine_InputSystem_InputAction_activeControl) at any point is the one with the greatest level of ["actuation"](Controls.md#control-actuation), that is, the largest value returned from [`EvaluateMagnitude`](../api/UnityEngine.InputSystem.InputControl.html#UnityEngine_InputSystem_InputControl_EvaluateMagnitude_). If a Control exceeds the actuation level of the current [`activeControl`](../api/UnityEngine.InputSystem.InputAction.html#UnityEngine_InputSystem_InputAction_activeControl), it will itself become the active Control.
22-
23-
The following example demonstrates this mechanism with a [`Button`](RespondingToActions.md#button) Action and also demonstrates the difference to a [`PassThrough`](RespondingToActions.md#pass-through) Action.
24-
25-
```CSharp
26-
// Create a button and a pass-through action and bind each of them
27-
// to both triggers on the gamepad.
28-
var buttonAction = new InputAction(type: InputActionType.Button,
29-
binding: "<Gamepad>/*Trigger");
30-
var passThroughAction = new InputAction(type: InputActionType.PassThrough,
31-
binding: "<Gamepad>/*Trigger");
16+
There are two situations where a given input might lead to ambiguity:
3217

33-
buttonAction.performed += c => Debug.Log("${c.control.name} pressed (Button)");
34-
passThroughAction.performed += c => Debug.Log("${c.control.name} changed (Pass-Through)");
35-
36-
buttonAction.Enable();
37-
passThroughAction.Enable();
38-
39-
// Press the left trigger all the way down.
40-
// This will trigger both buttonAction and passThroughAction. Both will
41-
// see leftTrigger becoming the activeControl.
42-
Set(gamepad.leftTrigger, 1f);
43-
44-
// Will log
45-
// "leftTrigger pressed (Button)" and
46-
// "leftTrigger changed (Pass-Through)"
47-
48-
// Press the right trigger halfway down.
49-
// This will *not* trigger or otherwise change buttonAction as the right trigger
50-
// is actuated *less* than the left one that is already driving action.
51-
// However, passThrough action is not performing such tracking and will thus respond
52-
// directly to the value change. It will perform and make rightTrigger its activeControl.
53-
Set(gamepad.rightTrigger, 0.5f);
18+
1. Several controls are bound to the same action and more than one is feeding input into the Action at the same time. Example: an Action that is bound to both the left and right trigger on a Gamepad and both triggers are pressed.
19+
2. The input is part of a sequence of inputs and there are several possible such sequences. Example: one Action is bound to the `B` key and another Action is bound to `Shift-B`.
5420

55-
// Will log
56-
// "rightTrigger changed (Pass-Through)"
21+
## Multiple concurrently used controls
5722

58-
// Release the left trigger.
59-
// For buttonAction, this will mean that now all controls feeding into the action have
60-
// been released and thus the button releases. activeControl will go back to null.
61-
// For passThrough action, this is just another value change. So, the action performs
62-
// and its active control changes to leftTrigger.
63-
Set(gamepad.leftTrigger, 0f);
23+
>__Note:__ This section does not apply to [pass-through](./configure-action-type.md) actions, which do not perform conflict resolution, and are intended allow multiple concurrent inputs.
6424
65-
// Will log
66-
// "leftTrigger changed (Pass-Through)"
67-
```
25+
For a **Button** or **Value** [action type](./configure-action-type.md), there can only be one control at any time that is "driving" the action. This control is considered the [`activeControl`](../api/UnityEngine.InputSystem.InputAction.html#UnityEngine_InputSystem_InputAction_activeControl).
6826

69-
For [composite bindings](#composite-bindings), magnitudes of the composite as a whole rather than for individual Controls are tracked. However, [`activeControl`](../api/UnityEngine.InputSystem.InputAction.html#UnityEngine_InputSystem_InputAction_activeControl) will stick track individual Controls from the composite.
27+
When an action is bound to multiple controls, the active control at any point is the one with the greatest level of ["actuation"](./control-actuation.md) (the one with the largest value returned from [`EvaluateMagnitude`](../api/UnityEngine.InputSystem.InputControl.html#UnityEngine_InputSystem_InputControl_EvaluateMagnitude_)). If a different control exceeds the actuation level of the current active control, it becomes the active control.
7028

71-
##### Disabling Conflict Resolution
29+
For [composite bindings](./composite-bindings.md), magnitudes of the composite as a whole rather than for individual controls are tracked. However, [`activeControl`](../api/UnityEngine.InputSystem.InputAction.html#UnityEngine_InputSystem_InputAction_activeControl) will still track individual Controls from the composite.
7230

73-
Conflict resolution is always applied to [Button](RespondingToActions.md#button) and [Value](RespondingToActions.md#value) type Actions. However, it can be undesirable in situations when an Action is simply used to gather any and all inputs from bound Controls. For example, the following Action would monitor the A button of all available gamepads:
31+
## Disabling Conflict Resolution
7432

75-
```CSharp
76-
var action = new InputAction(type: InputActionType.PassThrough, binding: "<Gamepad>/buttonSouth");
77-
action.Enable();
78-
```
33+
Conflict resolution is always applied to **Button** or **Value** [action types](./configure-action-type.md). However, it can be undesirable in situations when an action is simply used to gather all inputs from bound Controls. For example, if you have a **Button** type action bound to the **A** button on all gamepads, a user holding down **A** on one gamepad means that the **A** button on other gamepads is ignored.
7934

80-
By using the [Pass-Through](RespondingToActions.md#pass-through) Action type, conflict resolution is bypassed and thus, pressing the A button on one gamepad will not result in a press on a different gamepad being ignored.
35+
By using the **Pass Through** action type, conflict resolution is bypassed, which means pressing the **A** button on one gamepad will not result in presses on other gamepads being ignored.
8136

82-
#### Multiple input sequences (such as keyboard shortcuts)
37+
## Multiple input sequences (such as keyboard shortcuts)
8338

84-
>__Note__: The mechanism described here only applies to Actions that are part of the same [`InputActionMap`](../api/UnityEngine.InputSystem.InputActionMap.html) or [`InputActionAsset`](../api/UnityEngine.InputSystem.InputActionAsset.html).
39+
>__Note__: The mechanism described here only applies to Actions that are part of the same [action map](./action-maps-panel.md) or [action assets](./action-assets.md).
8540
86-
Inputs that are used in combinations with other inputs may also lead to ambiguities. If, for example, the `b` key on the Keyboard is bound both on its own as well as in combination with the `shift` key, then if you first press `shift` and then `b`, the latter key press would be a valid input for either of the Actions.
41+
Inputs used in combinations with other inputs can also lead to ambiguities. If, for example, the **B** key on the Keyboard is bound both on its own as well as in combination with the **Shift** key, then if you first press **Shift** and then **B**, the latter key press would be a valid input for either of the Actions.
8742

88-
The way this is handled is that Bindings will be processed in the order of decreasing "complexity". This metric is derived automatically from the Binding:
43+
The way the Input System handles this, is that Bindings are processed in the order of decreasing complexity. This metric is derived automatically from the Binding:
8944

90-
* A binding that is *not* part of a [composite](#composite-bindings) is assigned a complexity of 1.
91-
* A binding that *is* part of a [composite](#composite-bindings) is assigned a complexity equal to the number of part bindings in the composite.
45+
* A binding that is *not* part of a [composite](composite-bindings.md) is assigned a complexity of 1.
46+
* A binding that *is* part of a [composite](composite-bindings.md) is assigned a complexity equal to the number of part bindings in the composite.
9247

93-
In our example, this means that a [`OneModifier`](#one-modifier) composite Binding to `Shift+B` has a higher "complexity" than a Binding to `B` and thus is processed first.
48+
In our example, this means that a **one-modifier composite** binding to **Shift** + **B** has a higher complexity than a Binding to **B** and gets processed first.
9449

95-
Additionally, the first Binding that results in the Action changing [phase](RespondingToActions.md#action-callbacks) will "consume" the input. This consuming will result in other Bindings to the same input not being processed. So in our example, when `Shift+B` "consumes" the `B` input, the Binding to `B` will be skipped.
50+
Additionally, the first Binding that results in the Action changing [phase](./set-callbacks-on-actions.md) will consume the input. This results in other Bindings to the same input not being processed. This means in our example, when the **Shift** + **B** binding consumes the **B** input, the Binding to **B** is skipped.
9651

9752
The following example illustrates how this works at the API level.
9853

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
# Configure Action type
22

3-
When you select an Action in the [Actions Editor Window](./actions-editor.md), you can edit its properties in the right-hand pane of the window.
3+
When you select an action in the [actions panel](./actions-panel.md) of the [Actions Editor window](./actions-editor.md), you can edit its properties in the right-hand [action properties panel](./action-properties-panel.md).
44

5-
The first of these properties is the Action Type.
5+
The first of these properties is the **Action Type**.
66

7-
![Action Properties](Images/ActionProperties.png)
7+
The action type influences how the Input System processes state changes for the action, and relate to whether this action represents a discrete on/off button-style interaction or a value that can change gradually over time.
88

9-
The Action type influences how the Input System processes state changes for the Action, and relate to whether this action represents a discrete on/off button-style interaction or a value that can change gradually over time.
9+
## Action types
1010

11-
The Action Type setting allows you to choose between **Button**, **Value** or **Pass Through**. The default Action type is Value.
11+
The **Action Type** setting allows you to choose between **Button**, **Value** or **Pass Through**. The default Action type is Value.
1212

13-
For device controls such as keyboard keys, mouse clicks, or gamepad buttons, which have only an on/off state, and no gradual value changes, select **Button**.
13+
| Value | Description |
14+
| :---------------------------- | :----------------------------- |
15+
| **Button** | Use this for device controls such as keyboard keys, mouse clicks, or gamepad buttons, which have only an on/off state, and no gradual value changes. |
16+
| **Value** | Use this for device controls such as mouse movement, a joystick or gamepad stick, or device orientation that provides gradually changing input over a range of values. |
17+
| **Pass Through** | Use this for the same types as **Value**, but this type provides no **phase** information or **conflict resolution** (see below). |
1418

15-
For device controls such as mouse movement, a joystick or gamepad stick, or device orientation that provides gradually changing input over a range of values, select **Value**.
16-
17-
If you select **Button** or **Value* as your Action Type, the Input System also provides data about the action such as whether it has started and stopped (known as the **Phase** of the action), and [conflict resolution](./binding-conflicts.md) in situations where you have mapped multiple bindings to the same action.
19+
If you select **Button** or **Value** as your Action Type, the Input System also provides data about the action such as whether it has started and stopped (known as the **Phase** of the action), and [conflict resolution](./binding-conflicts.md) in situations where you have mapped multiple bindings to the same action.
1820

1921
The third option, **Pass Through**, is also a value type, and as such is suitable for the same types of device controls as described for **Value**. The difference is that if your action is set to PassThrough, the Input System only provides basic information about the values incoming from the device controls bound to it, and does not provide the extra data relating to the phase of the action, nor does it perform [conflict resolution](./binding-conflicts.md).
2022

21-
Because pass-through actions don't perform conflict resolution, it means they don't use concept of a specific control driving the action. Instead, any change to any of the controls bound to the action triggers a callback with that Control's value. This is useful if you want to process all input from a set of controls, rather than only the most actuated from the set.
23+
Because pass-through actions don't perform conflict resolution, it means they don't use concept of a specific control driving the action. Instead, any change to any of the controls bound to the action triggers a callback with that Control's value. This is useful if you want to process all input from a set of controls at once on the same action, rather than only the most actuated from the set.

Packages/com.unity.inputsystem/Documentation~/restrict-binding-specific-device.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
# Restrict bindings to specific devices
22

3-
By default, Actions resolve their Bindings against all Devices present in the Input System (that is, [`InputSystem.devices`](../api/UnityEngine.InputSystem.InputSystem.html#UnityEngine_InputSystem_InputSystem_devices)). For example, if there are two gamepads present in the system, a Binding to `<Gamepad>/buttonSouth` picks up both gamepads and allows the Action to be used from either.
3+
By default, actions [resolve their bindings](./binding-resolution.md) against all devices present that the Input System is aware of (that is, those listed in [`InputSystem.devices`](../api/UnityEngine.InputSystem.InputSystem.html#UnityEngine_InputSystem_InputSystem_devices)). For example, if there are two gamepads connected, a binding to `<Gamepad>/buttonSouth` picks up both gamepads and allows the action to be performed from either gamepad.
44

5-
You can override this behavior by restricting [`InputActionAssets`](../api/UnityEngine.InputSystem.InputActionAsset.html) or individual [`InputActionMaps`](../api/UnityEngine.InputSystem.InputActionMap.html) to a specific set of Devices. If you do this, Binding resolution only takes the Controls of the given Devices into account.
6-
7-
>__Note__: [`InputUser`](user-management.md) and [`PlayerInput`](player-input-component.md) make use of this facility automatically. They set [`InputActionMap.devices`](../api/UnityEngine.InputSystem.InputActionMap.html#UnityEngine_InputSystem_InputActionMap_devices) automatically based on the Devices that are paired to the user.
5+
You can override this behavior by restricting an [action asset](./action-assets.md) or individual [action maps](./create-edit-delete-action-maps.md) to a specific set of Devices. If you do this, binding resolution only takes the controls of the specified devices into account.
86

7+
>__Note__: The Input System's [user management](user-management.md) feature and [Player Input component](player-input-component.md) make use of this automatically. They set the [`InputActionMap.devices`](../api/UnityEngine.InputSystem.InputActionMap.html#UnityEngine_InputSystem_InputActionMap_devices) for each player automatically, based on the device that is paired to each user.
98
109
To restrict an action map to just the first gamepad:
1110

0 commit comments

Comments
 (0)