Skip to content

Commit 21bd4a8

Browse files
authored
Merge branch 'develop' into ekcoh/rebinding-issues-events
2 parents 10d2579 + 64b9f9c commit 21bd4a8

File tree

7 files changed

+66
-57
lines changed

7 files changed

+66
-57
lines changed

Assets/Tests/InputSystem/Plugins/UITests.cs

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2871,26 +2871,29 @@ public IEnumerator UI_CanOperateMultiplayerUILocallyUsingGamepads()
28712871

28722872
[UnityTest]
28732873
[Category("UI")]
2874-
public IEnumerator UI_CanDriveUIFromGamepad()
2874+
2875+
[TestCase("Gamepad", ExpectedResult = 1)]
2876+
#if UNITY_WEBGL || UNITY_EDITOR
2877+
[TestCase("WebGLGamepad", ExpectedResult = 1)]
2878+
#endif
2879+
public IEnumerator UI_CanDriveUIFromGamepad(string deviceLayout)
28752880
{
2876-
var gamepad = InputSystem.AddDevice<Gamepad>();
2881+
var gamepad = (Gamepad)InputSystem.AddDevice(deviceLayout);
28772882

28782883
var scene = CreateTestUI();
28792884

2880-
var asset = ScriptableObject.CreateInstance<InputActionAsset>();
2881-
var map = asset.AddActionMap("map");
2882-
var moveAction = map.AddAction("move", type: InputActionType.PassThrough, binding: "<Gamepad>/*stick");
2883-
var submitAction = map.AddAction("submit", type: InputActionType.PassThrough, binding: "<Gamepad>/buttonSouth");
2884-
var cancelAction = map.AddAction("cancel", type: InputActionType.PassThrough, binding: "<Gamepad>/buttonEast");
2885+
var actions = new DefaultInputActions();
28852886

2886-
scene.uiModule.move = InputActionReference.Create(moveAction);
2887-
scene.uiModule.submit = InputActionReference.Create(submitAction);
2888-
scene.uiModule.cancel = InputActionReference.Create(cancelAction);
2887+
scene.uiModule.move = InputActionReference.Create(actions.UI.Navigate);
2888+
scene.uiModule.submit = InputActionReference.Create(actions.UI.Submit);
2889+
scene.uiModule.cancel = InputActionReference.Create(actions.UI.Cancel);
28892890

28902891
scene.uiModule.moveRepeatDelay = 0.1f;
28912892
scene.uiModule.moveRepeatRate = 0.1f;
28922893

2893-
map.Enable();
2894+
actions.Enable();
2895+
Assert.That(actions.UI.enabled, Is.True);
2896+
Assert.That(actions.Player.enabled, Is.True);
28942897

28952898
yield return null;
28962899

@@ -2913,7 +2916,7 @@ public IEnumerator UI_CanDriveUIFromGamepad()
29132916
OneEvent("type", EventType.Move),
29142917
OneEvent("device", gamepad),
29152918
OneEvent("moveDir", MoveDirection.Right),
2916-
OneEvent("moveVector", gamepad.leftStick.ReadValue())));
2919+
OneEvent("moveVector", new Vector2(1.0f, 0.0f))));
29172920
Assert.That(scene.rightChildReceiver.events, Is.Empty);
29182921

29192922
#if UNITY_INPUT_SYSTEM_INPUT_MODULE_NAVIGATION_DEVICE_TYPE
@@ -2932,7 +2935,7 @@ public IEnumerator UI_CanDriveUIFromGamepad()
29322935
OneEvent("type", EventType.Move),
29332936
OneEvent("device", gamepad),
29342937
OneEvent("moveDir", MoveDirection.Left),
2935-
OneEvent("moveVector", gamepad.leftStick.ReadValue())));
2938+
OneEvent("moveVector", new Vector2(-1.0f, 0.0f))));
29362939
Assert.That(scene.rightChildReceiver.events, Is.Empty);
29372940

29382941
scene.leftChildReceiver.events.Clear();
@@ -2946,7 +2949,7 @@ public IEnumerator UI_CanDriveUIFromGamepad()
29462949
OneEvent("type", EventType.Move),
29472950
OneEvent("device", gamepad),
29482951
OneEvent("moveDir", MoveDirection.Up),
2949-
OneEvent("moveVector", gamepad.leftStick.ReadValue())));
2952+
OneEvent("moveVector", new Vector2(0.0f, 1.0f))));
29502953
Assert.That(scene.rightChildReceiver.events, Is.Empty);
29512954

29522955
scene.leftChildReceiver.events.Clear();
@@ -2960,7 +2963,7 @@ public IEnumerator UI_CanDriveUIFromGamepad()
29602963
OneEvent("type", EventType.Move),
29612964
OneEvent("device", gamepad),
29622965
OneEvent("moveDir", MoveDirection.Down),
2963-
OneEvent("moveVector", gamepad.leftStick.ReadValue())));
2966+
OneEvent("moveVector", new Vector2(0.0f, -1.0f))));
29642967
Assert.That(scene.rightChildReceiver.events, Is.Empty);
29652968

29662969
scene.leftChildReceiver.events.Clear();
@@ -2975,7 +2978,7 @@ public IEnumerator UI_CanDriveUIFromGamepad()
29752978
OneEvent("type", EventType.Move),
29762979
OneEvent("device", gamepad),
29772980
OneEvent("moveDir", MoveDirection.Down),
2978-
OneEvent("moveVector", gamepad.leftStick.ReadValue())));
2981+
OneEvent("moveVector", new Vector2(0.0f, -1.0f))));
29792982

29802983
scene.leftChildReceiver.events.Clear();
29812984

@@ -2989,7 +2992,7 @@ public IEnumerator UI_CanDriveUIFromGamepad()
29892992
OneEvent("type", EventType.Move),
29902993
OneEvent("device", gamepad),
29912994
OneEvent("moveDir", MoveDirection.Down),
2992-
OneEvent("moveVector", gamepad.leftStick.ReadValue())));
2995+
OneEvent("moveVector", new Vector2(0.0f, -1.0f))));
29932996

29942997
scene.leftChildReceiver.events.Clear();
29952998

@@ -3031,6 +3034,10 @@ public IEnumerator UI_CanDriveUIFromGamepad()
30313034

30323035
Assert.That(scene.leftChildReceiver.events, Is.Empty);
30333036
Assert.That(scene.rightChildReceiver.events, Is.Empty);
3037+
3038+
actions.Disable();
3039+
Assert.That(actions.UI.enabled, Is.False);
3040+
Assert.That(actions.Player.enabled, Is.False);
30343041
}
30353042

30363043
[Test]

Assets/Tests/InputSystem/Plugins/WebGLTests.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,8 @@ public void Devices_SupportsWebGLStandardGamepads()
4343
Assert.That(gamepad.leftTrigger.ReadUnprocessedValue(), Is.EqualTo(0.123).Within(0.0001));
4444
Assert.That(gamepad.rightTrigger.ReadUnprocessedValue(), Is.EqualTo(0.234).Within(0.0001));
4545

46-
AssertStickValues(gamepad.leftStick, new Vector2(0.345f, -0.456f), -0.456f, 0, 0, 0.345f);
47-
AssertStickValues(gamepad.rightStick, new Vector2(0.567f, -0.678f), -0.678f, 0, 0, 0.567f);
48-
46+
AssertStickValues(gamepad.leftStick, new Vector2(0.345f, -0.456f), 0, 0.456f, 0, 0.345f);
47+
AssertStickValues(gamepad.rightStick, new Vector2(0.567f, -0.678f), 0, 0.678f, 0, 0.567f);
4948

5049
InputSystem.QueueStateEvent(gamepad, new WebGLGamepadState
5150
{
@@ -54,9 +53,8 @@ public void Devices_SupportsWebGLStandardGamepads()
5453
});
5554
InputSystem.Update();
5655

57-
AssertStickValues(gamepad.leftStick, new Vector2(-0.345f, 0.456f), 0, -0.456f, 0.345f, 0);
58-
AssertStickValues(gamepad.rightStick, new Vector2(-0.567f, 0.678f), 0, -0.678f, 0.567f, 0);
59-
56+
AssertStickValues(gamepad.leftStick, new Vector2(-0.345f, 0.456f), 0.456f, 0, 0.345f, 0);
57+
AssertStickValues(gamepad.rightStick, new Vector2(-0.567f, 0.678f), 0.678f, 0, 0.567f, 0);
6058

6159
// Test all buttons.
6260
AssertButtonPress(gamepad, new WebGLGamepadState().WithButton(GamepadButton.South), gamepad[GamepadButton.South]);

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ however, it has to be formatted properly to pass verification tests.
2222
- Fixed Input Actions code generation overwriting user files when the names happened to match. [ISXB-1257](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1257)
2323
- Fixed Input Actions code generation using locale-dependent rules when lowercasing and uppercasing strings. [ISXB-1406]
2424
- Fixed an issue when providing JoinPlayer with a specific split screen index. [ISXB-897](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-897)
25+
- Fixed Inspector Window being refreshed all the time when a PlayerInput component is present with Invoke Unity Events nofication mode chosen [ISXB-1448](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1448)
2526
- Fixed an issue where an action with a name containing a slash "/" could not be found via `InputActionAsset.FindAction(string,bool)`. [ISXB-1306](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1306).
27+
- Fixed Gamepad stick up/down inputs that were not recognized in WebGL. [ISXB-1090](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1090)
2628
- Fixed an issue in `RebindingUISample` that fired actions bound to the same control as the target control in a rebinding process. ISXB-1524.
2729

2830
## [1.14.0] - 2025-03-20

Packages/com.unity.inputsystem/Documentation~/SupportedDevices.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,16 @@ Support for the following Devices doesn't require specialized support of particu
1313
|------|-------|---|-----|---|-------|---|----|----|---|------|-----|
1414
|[Mouse](Mouse.md)|Yes|Yes|Yes|Yes|Yes|No|No|Yes|Yes|No|Yes|
1515
|[Keyboard](Keyboard.md)|Yes|Yes|Yes|Yes|Yes|No|No|Yes|Yes|No|Yes|
16-
|[Pen](Pen.md)|Yes|No (1)|No|Yes|Yes|Yes|No|No|No|No|No|
16+
|[Pen](Pen.md)|Yes|No |No|Yes|Yes|Yes|No|No|No|No|No|
1717
|[Touchscreen](Touch.md)|Yes|No|No|Yes|Yes|Yes|Yes(4)|No|No|No|Yes|
1818
|[Sensors](Sensors.md)|No|No|No|No|Yes|Yes|No|No|No|No|Yes(5)|
1919
|[Joystick](#other-gamepads-joysticks-and-racing-wheels) (2)|Yes|Yes|Yes|Yes|Yes|No|No|No|No|No|Yes|
2020

2121
>__Notes__:
22-
>1. Tablet support for macOS is coming in Unity 2020.1.
23-
>2. Joysticks are supported as generic HIDs (See [Other gamepads, joysticks, and racing wheels](#other-gamepads-joysticks-and-racing-wheels) below).
24-
>3. Consoles are supported using separate packages. You need to install these packages in your Project to enable console support.
25-
>4. Indirect touches are received from Siri Remote.
26-
>5. Sensor support for WebGL on Android and iOS devices is available in Unity 2021.2
22+
>1. Joysticks are supported as generic HIDs, refer to [Other gamepads, joysticks, and racing wheels](#other-gamepads-joysticks-and-racing-wheels) to learn more.
23+
>2. Consoles are supported using separate packages. You need to install these packages in your Project to enable console support.
24+
>3. Indirect touches are received from Siri Remote.
25+
>4. Sensor support for WebGL on Android and iOS devices is available in Unity 2021.2
2726
2827
## Gamepads
2928

@@ -39,11 +38,10 @@ Support for the following Devices doesn't require specialized support of particu
3938
>__Notes__:
4039
>1. The trigger motors on the Xbox One controller are only supported on UWP and Xbox.
4140
>2. WebGL support varies between browsers, Devices, and operating systems.
42-
>3. XInput controllers on Mac currently require the installation of the [Xbox Controller Driver for macOS](https://github.com/360Controller/360Controller). This driver only supports only USB connections, and doesn't support wireless dongles. However, the latest generation of Xbox One controllers natively support Bluetooth, and are natively supported on Macs as HIDs without any additional drivers when connected via Bluetooth.
41+
>3. XInput controllers on macOS currently require the installation of the [Xbox Controller Driver for macOS](https://github.com/360Controller/360Controller). This driver only supports only USB connections, and doesn't support wireless dongles. However, the latest generation of Xbox One controllers natively support Bluetooth, and are natively supported on Macs as HIDs without any additional drivers when connected via Bluetooth.
4342
>4. This includes any XInput-compatible Device.
44-
>5. Unity doesn't support motor rumble and lightbar color over Bluetooth. Unity doesn't support the gyro or accelerometer on PS4/PS5 controllers on platforms other than the PlayStation consoles. Unity also doesn't support the DualShock 4 USB Wireless Adaptor.
45-
On UWP only USB connection is supported, motor rumble and lightbar are not working correctly.
46-
>6. Unity supports Made for iOS (Mfi) certified controllers on iOS. Xbox One and PS4 controllers are only supported on iOS 13 or higher.
43+
>5. Unity doesn't support motor rumble and lightbar color over Bluetooth. Unity doesn't support the gyro or accelerometer on PS4/PS5 controllers on platforms other than the PlayStation consoles. Unity also doesn't support the DualShock 4 USB Wireless Adapter. On UWP, only USB connection is supported, motor rumble and lightbar are not working correctly.
44+
>6. Unity supports Made for iOS (MFi) certified controllers on iOS. Xbox One and PS4 controllers are only supported on iOS 13 or higher.
4745
>7. Consoles are supported using separate packages. You need to install these packages in your Project to enable console support.
4846
>8. Unity supports PS4 controllers on Android devices running [Android 10 or higher](https://playstation.com/en-us/support/hardware/ps4-pair-dualshock-4-wireless-with-sony-xperia-and-android).
4947
>9. Unity supports PS5 controllers on Android devices running [Android 12 or higher](https://playstation.com/en-gb/support/hardware/pair-dualsense-controller-bluetooth/).

Packages/com.unity.inputsystem/Documentation~/Workflow-Actions.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Once you have created and assigned the default project-wide actions, the Actions
2222

2323
The [Input Actions editor](ActionsEditor.html) provides a way to define and manage Actions which relate to what you want users to be able to do in your game or app. It also allows you to create bindings between your Actions and one or more types of control on various devices, such as a stick on a gamepad, a key on a keyboard, or a button on an XR controller.
2424

25-
Actions and Bindings allows you to separate the conceptual actions that you want in your game or app from the the specific decvices and controls that a player has to use to perform the actions, which can make your code simpler and more flexible. This is in contrast to [directly reading device states](Workflow-Direct.html) in your code, which can suit simple projects, but can become unwieldy and inflexible for more complex projects.
25+
Actions and Bindings allows you to separate the conceptual actions that you want in your game or app from the specific devices and controls that a player has to use to perform the actions, which can make your code simpler and more flexible. This is in contrast to [directly reading device states](Workflow-Direct.html) in your code, which can suit simple projects, but can become unwieldy and inflexible for more complex projects.
2626

2727
### The default Actions
2828

@@ -34,9 +34,9 @@ This means, in many cases, you can start scripting with the Input System without
3434

3535
There are various ways to access your actions from code. One of the simplest ways is to use the `FindAction` method.
3636

37-
`FindAction` allows you to search for an action by name from within the set of configured acations, and returns a reference which you can then either read the value directly (also called "polling"), or you can attach callback methods that are called the action is performed. The workflow described on this page focuses only on reading the action values. [You can read more about using callbacks here](RespondingToActions.html#action-callbacks).
37+
Use `FindAction` to search for an action by name from within the set of configured actions, and return a reference which you can then either read the value directly (also called "polling"), or you can attach callback methods that are called when the action is performed. The workflow described on this page focuses only on reading the action values. [You can read more about using callbacks here](RespondingToActions.html#action-callbacks).
3838

39-
> __Tip__: Finding and storing a reference to an Action is similar to finding and storing a reference to a Component, so if you have done that elsewhere in Unity, this may be a familiar process.
39+
> __Tip__: Finding and storing a reference to an Action is similar to finding and storing a reference to a Component, so if you have done that elsewhere in Unity, this might be a familiar process.
4040
4141
To use `FindAction` to get references to your Actions and read user input in your script, use the following steps:
4242

@@ -55,12 +55,12 @@ To use `FindAction` to get references to your Actions and read user input in you
5555
moveAction = InputSystem.actions.FindAction("Move");
5656
jumpAction = InputSystem.actions.FindAction("Jump");
5757

58-
1. In your Update() method, read the value from your action variables. This allows you to write code that reads the latest values coming from your Actions each frame and respond accordingly.<br/><br/>The way you read a value depends on the Action's **value type**. For example some actions may return a 1D or 2D axis value, and other actions may return a boolean true/false value. In this example, the "Move" action returns a 2D axis, and the "Jump" action returns a boolean.
58+
1. In your Update() method, read the value from your action variables. This allows you to write code that reads the latest values coming from your Actions each frame and respond accordingly.<br/><br/>The way you read a value depends on the Action's **value type**. For example some actions might return a 1D or 2D axis value, and other actions might return a Boolean true/false value. In this example, the **Move** action returns a 2D axis, and the **Jump** action returns a Boolean.
5959

6060
Vector2 moveValue = moveAction.ReadValue<Vector2>();
6161
bool jumpValue = jumpAction.IsPressed();
6262

63-
The example script below shows all these steps combined together into a single script:
63+
The following example script shows all these steps combined together into a single script:
6464

6565
```CSharp
6666
using UnityEngine;
@@ -95,14 +95,14 @@ public class Example : MonoBehaviour
9595
}
9696
```
9797

98-
> **Note:** You should avoid using `FindAction` in your Update() loop, because it performs a string-based lookup which could impact performance. This is why the Action refeferences in the example above are found during the Start() function, and stored in variables after finding them.
98+
> **Note:** You should avoid using `FindAction` in your `Update()` loop, because it performs a string-based lookup which could impact performance. This is why the Action references in the example above are found during the Start() function, and stored in variables after finding them.
9999
100-
> **Note:** The [InputSystem.actions](../api/UnityEngine.InputSystem.InputSystem.html) API refers specifically to the Action Asset assigned as the [project-wide actions](ProjectWideActions.md). Most projects only require one Action Asset, but if you are using more than one Action Asset, you must create a reference using the type InputActionAsset to the asset you wish to access.
100+
> **Note:** The [InputSystem.actions](../api/UnityEngine.InputSystem.InputSystem.html) API refers specifically to the Action Asset assigned as the [project-wide actions](ProjectWideActions.md). Most projects only require one Action Asset, but if you are using more than one Action Asset, you must create a reference using the type InputActionAsset to the asset you want to access.
101101
102102
## Pros and Cons
103103

104104
This is the recommended workflow with the Input System Package, providing a flexible but simple solution suitable for most projects.
105105

106-
You benefit from the Action-based features such as Action Maps, Bindings, and the ability to configure them in the Actions Editor. You can also implement [user rebinding at run time](ActionBindings.html#interactive-rebinding).
106+
You benefit from the Action-based features such as Action Maps, Bindings, and the ability to configure them in the Actions Editor. You can also implement [user rebinding at runtime](ActionBindings.html#interactive-rebinding).
107107

108-
This workflow alone doesn't provide built-in support for local multiplayer scenarios with multiple devices, so if you are producing a local multiplayer game you might want to consider using the [Actions & PlayerInput](./Workflow-PlayerInput.md) workflow.
108+
This workflow alone doesn't provide built-in support for local multiplayer scenarios with multiple devices, so if you are producing a local multiplayer game you might want to consider using the [Actions and PlayerInput](./Workflow-PlayerInput.md) workflow.

0 commit comments

Comments
 (0)