Beispiel #1
0
    public void Users_CanAssignControlScheme_AndAutomaticallyAssignMatchingUnusedDevices()
    {
        var keyboard = InputSystem.AddDevice <Keyboard>();

        InputSystem.AddDevice <Mouse>(); // Noise.
        var gamepad1 = InputSystem.AddDevice <Gamepad>();
        var gamepad2 = InputSystem.AddDevice <Gamepad>();
        var gamepad3 = InputSystem.AddDevice <Gamepad>();

        var singleGamepadScheme = new InputControlScheme("SingleGamepad")
                                  .WithRequiredDevice("<Gamepad>");
        var dualGamepadScheme = new InputControlScheme("DualGamepad")
                                .WithRequiredDevice("<Gamepad>")
                                .WithRequiredDevice("<Gamepad>");

        var user1 = new TestUser();
        var user2 = new TestUser();
        var user3 = new TestUser();

        InputUser.Add(user1);
        InputUser.Add(user2);
        InputUser.Add(user3);

        user1.AssignInputDevice(keyboard); // Should automatically be unassigned.
        user3.AssignInputDevice(keyboard); // Should not be affected by any of what we do here.

        user1.AssignControlScheme(singleGamepadScheme).AndAssignDevices();
        user2.AssignControlScheme(dualGamepadScheme).AndAssignDevices();

        Assert.That(user1.GetAssignedInputDevices(), Is.EquivalentTo(new[] { gamepad1 }));
        Assert.That(user2.GetAssignedInputDevices(), Is.EquivalentTo(new[] { gamepad2, gamepad3 }));
        Assert.That(user3.GetAssignedInputDevices(), Is.EquivalentTo(new[] { keyboard }));
    }
Beispiel #2
0
    public void Users_CanQueryUnassignedDevices()
    {
        var gamepad  = InputSystem.AddDevice <Gamepad>();
        var keyboard = InputSystem.AddDevice <Keyboard>();
        var mouse    = InputSystem.AddDevice <Mouse>();
        var touch    = InputSystem.AddDevice <Touchscreen>();
        var gyro     = InputSystem.AddDevice <Gyroscope>();

        var user1 = new TestUser();
        var user2 = new TestUser();
        var user3 = new TestUser();

        InputUser.Add(user1);
        InputUser.Add(user2);
        InputUser.Add(user3);

        user1.AssignInputDevice(gamepad);
        user3.AssignInputDevices(new InputDevice[] { keyboard, mouse });

        using (var unusedDevices = InputUser.GetUnassignedInputDevices())
        {
            Assert.That(unusedDevices, Has.Count.EqualTo(2));
            Assert.That(unusedDevices, Has.Exactly(1).SameAs(touch));
            Assert.That(unusedDevices, Has.Exactly(1).SameAs(gyro));
        }
    }
Beispiel #3
0
    public void Users_CanAssignControlScheme_AndMaskOutBindingsFromOtherControlSchemes()
    {
        var gamepad       = InputSystem.AddDevice <Gamepad>();
        var gamepadScheme = new InputControlScheme("Gamepad")
                            .WithRequiredDevice("<Gamepad>");

        var map    = new InputActionMap("map");
        var action = map.AddAction("action");

        action.AddBinding("<Gamepad>/buttonSouth", groups: "Gamepad");
        action.AddBinding("<Mouse>/leftButton", groups: "KeyboardMouse");

        var user = new TestUser();

        InputUser.Add(user);

        // Trying to do it before we've assigned actions should throw.
        Assert.That(() => user.AssignControlScheme(gamepadScheme)
                    .AndMaskBindingsFromOtherControlSchemes(), Throws.InvalidOperationException);

        user.AssignInputActions(map);
        user.AssignInputDevice(gamepad);
        user.AssignControlScheme(gamepadScheme)
        .AndMaskBindingsFromOtherControlSchemes();

        Assert.That(action.controls, Is.EquivalentTo(new[] { gamepad.buttonSouth }));
        Assert.That(map.bindingMask, Is.EqualTo(new InputBinding {
            groups = "Gamepad"
        }));
    }
Beispiel #4
0
    public void TODO_Users_CanAssignActionsToUsers()
    {
        var user = new TestUser();

        InputUser.Add(user);

        var action = new InputAction();

        user.GetInputActions().Push(action);

        Assert.Fail();
    }
Beispiel #5
0
    public void Users_AssigningSameDeviceToSameUserMoreThanOnce_IsIgnored()
    {
        var device = InputSystem.AddDevice <Gamepad>();
        var user   = new TestUser();

        InputUser.Add(user);

        user.AssignInputDevice(device);
        user.AssignInputDevice(device);
        user.AssignInputDevice(device);

        Assert.That(user.GetAssignedInputDevices(), Is.EquivalentTo(new InputDevice[] { device }));
    }
Beispiel #6
0
    public void Users_CanAssignActionAssetToUser()
    {
        var asset = ScriptableObject.CreateInstance <InputActionAsset>();

        var user = new TestUser();

        InputUser.Add(user);

        Assert.That(user.GetInputActions(), Is.Null);

        user.AssignInputActions(asset);

        Assert.That(user.GetInputActions(), Is.SameAs(asset));
    }
Beispiel #7
0
    public void Users_CanAssignActionMapsToUsers()
    {
        var map = new InputActionMap();

        var action1 = map.AddAction("action1");
        var action2 = map.AddAction("action2");

        var user = new TestUser();

        InputUser.Add(user);

        user.SetInputActions(map);

        Assert.That(user.GetInputActions(), Is.EquivalentTo(new[] { action1, action2 }));
    }
Beispiel #8
0
    public void Users_CanAssignSameDeviceToMoreThanOneUser()
    {
        var user1 = new TestUser();
        var user2 = new TestUser();

        InputUser.Add(user1);
        InputUser.Add(user2);

        var gamepad = InputSystem.AddDevice <Gamepad>();

        user1.AssignInputDevice(gamepad);
        user2.AssignInputDevice(gamepad);

        Assert.That(user1.GetAssignedInputDevices(), Is.EquivalentTo(new InputDevice[] { gamepad }));
        Assert.That(user2.GetAssignedInputDevices(), Is.EquivalentTo(new InputDevice[] { gamepad }));
    }
Beispiel #9
0
    public void Users_CanAssignControlScheme()
    {
        var user = new TestUser();

        Assert.That(user.GetControlScheme(), Is.Null);

        InputUser.Add(user);

        user.AssignControlScheme("scheme");

        Assert.That(user.GetControlScheme(), Is.EqualTo(new InputControlScheme("scheme")));

        user.AssignControlScheme(null);

        Assert.That(user.GetControlScheme(), Is.Null);
    }
Beispiel #10
0
    public void Users_AssignedDevices_AreLostWhenUserIsRemoved()
    {
        var device1 = InputSystem.AddDevice <Gamepad>();
        var device2 = InputSystem.AddDevice <Gamepad>();

        var user = new TestUser();

        InputUser.Add(user);

        user.AssignInputDevice(device1);
        user.AssignInputDevice(device2);

        InputUser.Remove(user);

        Assert.That(user.GetAssignedInputDevices(), Has.Count.Zero);
    }
Beispiel #11
0
    public void Users_CanRestrictBindingToAssignedInputDevices()
    {
        var gamepad1 = InputSystem.AddDevice <Gamepad>();
        var gamepad2 = InputSystem.AddDevice <Gamepad>();
        var gamepad3 = InputSystem.AddDevice <Gamepad>();

        var map1 = new InputActionMap("map");

        map1.AddAction("action").AddBinding("<Gamepad>/buttonSouth", groups: "Gamepad");
        var map2 = map1.Clone();

        var user1 = new TestUser();
        var user2 = new TestUser();

        InputUser.Add(user1);
        InputUser.Add(user2);

        user1.AssignInputDevice(gamepad1);
        user2.AssignInputDevice(gamepad2);

        user1.AssignInputActions(map1);
        user2.AssignInputActions(map2);

        // Have bound to everything available globally.
        Assert.That(map1["action"].controls, Is.EquivalentTo(new[] { gamepad1.buttonSouth, gamepad2.buttonSouth, gamepad3.buttonSouth }));
        Assert.That(map2["action"].controls, Is.EquivalentTo(new[] { gamepad1.buttonSouth, gamepad2.buttonSouth, gamepad3.buttonSouth }));

        user2.BindOnlyToAssignedInputDevices();

        // Have bound only to currently assigned devices.
        Assert.That(map1["action"].controls, Is.EquivalentTo(new[] { gamepad1.buttonSouth, gamepad2.buttonSouth, gamepad3.buttonSouth }));
        Assert.That(map2["action"].controls, Is.EquivalentTo(new[] { gamepad2.buttonSouth }));

        user2.ClearAssignedInputDevices();
        user2.AssignInputDevice(gamepad3);

        // Have updated bindings to reflect change in assigned devices.
        Assert.That(map1["action"].controls, Is.EquivalentTo(new[] { gamepad1.buttonSouth, gamepad2.buttonSouth, gamepad3.buttonSouth }));
        Assert.That(map2["action"].controls, Is.EquivalentTo(new[] { gamepad3.buttonSouth }));

        user2.BindOnlyToAssignedInputDevices(false);

        // Have gone back to binding to everything.
        Assert.That(map1["action"].controls, Is.EquivalentTo(new[] { gamepad1.buttonSouth, gamepad2.buttonSouth, gamepad3.buttonSouth }));
        Assert.That(map2["action"].controls, Is.EquivalentTo(new[] { gamepad1.buttonSouth, gamepad2.buttonSouth, gamepad3.buttonSouth }));
    }
Beispiel #12
0
    public void Users_CanActivateAndPassivateInput()
    {
        var gamepad = InputSystem.AddDevice <Gamepad>();

        var action             = new InputAction(binding: "<Gamepad>/leftTrigger");
        var actionWasTriggered = false;

        action.performed += _ => actionWasTriggered = true;

        var user = new TestUser();

        InputUser.Add(user);

        user.GetInputActions().Push(action);

        // Make sure user is passive by default.
        Assert.That(user.IsInputActive(), Is.False);

        InputSystem.QueueStateEvent(gamepad, new GamepadState {
            leftTrigger = 0.124f
        });
        InputSystem.Update();

        Assert.That(actionWasTriggered, Is.False);

        // Activate user input.
        user.ActivateInput();

        InputSystem.QueueStateEvent(gamepad, new GamepadState {
            leftTrigger = 0.234f
        });
        InputSystem.Update();

        Assert.That(actionWasTriggered, Is.True);
        actionWasTriggered = false;

        // Passivate user input again.
        user.PassivateInput();

        InputSystem.QueueStateEvent(gamepad, new GamepadState {
            leftTrigger = 0.234f
        });
        InputSystem.Update();

        Assert.That(actionWasTriggered, Is.False);
    }
Beispiel #13
0
    public void Users_CanAddAndRemoveUsers()
    {
        var user1 = new TestUser();
        var user2 = new TestUser();

        InputUser.Add(user1);
        InputUser.Add(user2);

        Assert.That(InputUser.all, Has.Count.EqualTo(2)); // Plus default user.
        Assert.That(InputUser.all, Has.Exactly(1).SameAs(user1));
        Assert.That(InputUser.all, Has.Exactly(1).SameAs(user2));

        InputUser.Remove(user1);

        Assert.That(InputUser.all, Has.Count.EqualTo(1));
        Assert.That(InputUser.all, Has.None.SameAs(user1));
        Assert.That(InputUser.all, Has.Exactly(1).SameAs(user2));
    }
Beispiel #14
0
    public void Users_CanAssignActionsToUsers()
    {
        var action = new InputAction();

        var user = new TestUser();

        InputUser.Add(user);

        Assert.That(user.GetInputActions(), Is.Empty);

        user.GetInputActions().Push(action);

        Assert.That(user.GetInputActions(), Is.EquivalentTo(new[] { action }));

        user.GetInputActions().Clear();

        Assert.That(user.GetInputActions(), Is.Empty);
    }
Beispiel #15
0
    public void Users_CanHaveUserNames()
    {
        var user = new TestUser();

        Assert.That(user.GetUserName(), Is.Null);

        InputUser.Add(user);

        Assert.That(user.GetUserName(), Is.Null);

        user.SetUserName("A");

        Assert.That(user.GetUserName(), Is.EqualTo("A"));

        user.SetUserName("B");

        Assert.That(user.GetUserName(), Is.EqualTo("B"));
    }
Beispiel #16
0
    public void Users_CanAssignControlScheme_AndAssignMissingDevices()
    {
        var gamepad1 = InputSystem.AddDevice <Gamepad>();
        var gamepad2 = InputSystem.AddDevice <Gamepad>();

        var gamepadScheme = new InputControlScheme("Gamepad")
                            .WithRequiredDevice("<Gamepad>")
                            .WithOptionalDevice("<Gamepad>");

        var user = new TestUser();

        InputUser.Add(user);

        user.AssignInputDevice(gamepad2);
        user.AssignControlScheme(gamepadScheme).AndAssignMissingDevices();

        Assert.That(user.GetAssignedInputDevices(), Is.EquivalentTo(new[] { gamepad2, gamepad1 }));
    }
Beispiel #17
0
    public void Users_HaveIndices()
    {
        var user1 = new TestUser();
        var user2 = new TestUser();

        Assert.That(user1.GetUserIndex(), Is.EqualTo(-1));

        InputUser.Add(user1);
        InputUser.Add(user2);

        Assert.That(user1.GetUserIndex(), Is.EqualTo(0));
        Assert.That(user2.GetUserIndex(), Is.EqualTo(1));

        InputUser.Remove(user1);

        Assert.That(user1.GetUserIndex(), Is.EqualTo(-1));
        Assert.That(user2.GetUserIndex(), Is.EqualTo(0));
    }
Beispiel #18
0
    public void Users_HaveUniqueIds()
    {
        var user1 = new TestUser();
        var user2 = new TestUser();

        Assert.That(user1.GetUserId(), Is.EqualTo(InputUser.kInvalidId));
        Assert.That(user2.GetUserId(), Is.EqualTo(InputUser.kInvalidId));

        InputUser.Add(user1);
        InputUser.Add(user2);

        Assert.That(user1.GetUserId(), Is.Not.EqualTo(InputUser.kInvalidId));
        Assert.That(user2.GetUserId(), Is.Not.EqualTo(InputUser.kInvalidId));
        Assert.That(user1.GetUserId(), Is.Not.EqualTo(user2.GetUserId()));

        InputUser.Remove(user1);

        Assert.That(user1.GetUserId(), Is.EqualTo(InputUser.kInvalidId));
    }
Beispiel #19
0
    public void Users_CanFindUserThatIsAssignedToSpecificDevice()
    {
        var gamepad1 = InputSystem.AddDevice <Gamepad>();
        var gamepad2 = InputSystem.AddDevice <Gamepad>();
        var gamepad3 = InputSystem.AddDevice <Gamepad>();

        var user1 = new TestUser();
        var user2 = new TestUser();

        InputUser.Add(user1);
        InputUser.Add(user2);

        user1.AssignInputDevice(gamepad1);
        user2.AssignInputDevice(gamepad2);

        Assert.That(InputUser.FindUserForDevice(gamepad1), Is.SameAs(user1));
        Assert.That(InputUser.FindUserForDevice(gamepad2), Is.SameAs(user2));
        Assert.That(InputUser.FindUserForDevice(gamepad3), Is.Null);
    }
Beispiel #20
0
    public void Users_CanAssignDevicesToUserStepByStep()
    {
        var device1 = InputSystem.AddDevice <Gamepad>();
        var device2 = InputSystem.AddDevice <Gamepad>();
        var device3 = InputSystem.AddDevice <Gamepad>();

        var user1 = new TestUser();
        var user2 = new TestUser();

        InputUser.Add(user1);
        InputUser.Add(user2);

        user1.AssignInputDevice(device1);
        user2.AssignInputDevice(device2);
        user1.AssignInputDevice(device3);

        Assert.That(user1.GetAssignedInputDevices(), Is.EquivalentTo(new InputDevice[] { device1, device3 }));
        Assert.That(user2.GetAssignedInputDevices(), Is.EquivalentTo(new InputDevice[] { device2 }));
    }
Beispiel #21
0
    public void Users_CanClearAssignedDevices()
    {
        var device = InputSystem.AddDevice <Gamepad>();

        var user1 = new TestUser();
        var user2 = new TestUser();
        var user3 = new TestUser();

        InputUser.Add(user1);
        InputUser.Add(user2);

        user1.AssignInputDevice(device);
        user1.ClearAssignedInputDevices();
        user2.ClearAssignedInputDevices();
        user3.ClearAssignedInputDevices();

        Assert.That(user1.GetAssignedInputDevices(), Is.Empty);
        Assert.That(user2.GetAssignedInputDevices(), Is.Empty);
        Assert.That(user3.GetAssignedInputDevices(), Is.Empty);
    }
Beispiel #22
0
    public void Users_CanAssignDevicesToUsers()
    {
        var user1 = new TestUser();
        var user2 = new TestUser();

        var gamepad  = InputSystem.AddDevice <Gamepad>();
        var keyboard = InputSystem.AddDevice <Keyboard>();
        var mouse    = InputSystem.AddDevice <Mouse>();

        Assert.That(user1.GetAssignedInputDevices(), Is.Empty);
        Assert.That(user2.GetAssignedInputDevices(), Is.Empty);

        InputUser.Add(user1);
        InputUser.Add(user2);

        user1.AssignInputDevices(new InputDevice[] { keyboard, mouse });
        user2.AssignInputDevice(gamepad);

        Assert.That(user1.GetAssignedInputDevices(), Is.EquivalentTo(new InputDevice[] { keyboard, mouse }));
        Assert.That(user2.GetAssignedInputDevices(), Is.EquivalentTo(new InputDevice[] { gamepad }));
    }
Beispiel #23
0
    /// <summary>
    /// Create a new player GameObject.
    /// </summary>
    /// <returns></returns>
    private DemoPlayerController SpawnPlayer()
    {
        // If we still have inactive player objects, use those and bring an inactive
        // player back to life.
        DemoPlayerController player = null;

        if (m_Players != null && m_ActivePlayerCount < m_Players.Length && m_Players[m_ActivePlayerCount] != null)
        {
            // Reuse a player we've previously created. Just reactivate it and wipe its state.
            player = m_Players[m_ActivePlayerCount];
            player.gameObject.SetActive(true);
            player.Reset();
        }
        else
        {
            // Otherwise create a new player.
            var playerObject = Instantiate(playerPrefab);
            player = playerObject.GetComponent <DemoPlayerController>();
            if (player == null)
            {
                throw new Exception("Missing DemoPlayerController component on " + playerObject);
            }
            player.PerformOneTimeInitialization(m_ActivePlayerCount == 0);
            player.onLeaveGame = OnPlayerLeavesGame;

            // Add to list.
            if (m_Players == null || m_Players.Length == m_ActivePlayerCount)
            {
                Array.Resize(ref m_Players, m_ActivePlayerCount + 10);
            }
            m_Players[m_ActivePlayerCount] = player;
        }

        // Register as input user with input system.
        InputUser.Add(player);

        ++m_ActivePlayerCount;
        return(player);
    }
Beispiel #24
0
    /// <summary>
    /// Create a new player GameObject.
    /// </summary>
    /// <param name="playerIndex"></param>
    /// <returns></returns>
    private DemoPlayerController SpawnPlayer(int playerIndex)
    {
        Debug.Assert(playerIndex >= 0);

        // Create player, if need be.
        DemoPlayerController playerComponent;

        if (m_Players != null && playerIndex <= m_Players.Length && m_Players[playerIndex] != null)
        {
            // Reuse a player we've previously created. Just reactivate it and wipe its state.
            playerComponent = m_Players[playerIndex];
            playerComponent.gameObject.SetActive(true);
            playerComponent.Reset();
        }
        else
        {
            // Create a new player object.
            var playerObject = Instantiate(playerPrefab);
            playerComponent = playerObject.GetComponent <DemoPlayerController>();
            if (playerComponent == null)
            {
                throw new Exception("Missing DemoPlayerController component on " + playerObject);
            }
            playerComponent.Initialize(playerIndex);
            playerComponent.onLeaveGame = OnPlayerLeavesGame;

            // Add to list.
            Array.Resize(ref m_Players, playerIndex + 1);
            m_Players[playerIndex] = playerComponent;
        }

        // Register as input user with input system.
        InputUser.Add(playerComponent);

        // Every player starts out with gameplay actions active.
        //playerComponent.SetInputActions(playerComponent.controls.gameplay);

        return(playerComponent);
    }
Beispiel #25
0
    public void Users_CanHavePlatformHandles()
    {
        var user = new TestUser();

        Assert.That(user.GetUserHandle(), Is.Null);

        InputUser.Add(user);

        Assert.That(user.GetUserHandle(), Is.Null);

        user.SetUserHandle(new InputUserHandle("test", 1));

        Assert.That(user.GetUserHandle(), Is.EqualTo(new InputUserHandle("test", 1)));

        user.SetUserHandle(null);

        Assert.That(user.GetUserHandle(), Is.Null);

        user.SetUserHandle(new InputUserHandle("test", 1));
        InputUser.Remove(user);

        Assert.That(user.GetUserHandle(), Is.Null);
    }
Beispiel #26
0
    public void Users_CanDetectWhenUnassignedDeviceIsUsed()
    {
        var gamepad1 = InputSystem.AddDevice <Gamepad>();
        var gamepad2 = InputSystem.AddDevice <Gamepad>();
        var gamepad3 = InputSystem.AddDevice <Gamepad>();

        var asset = ScriptableObject.CreateInstance <InputActionAsset>();
        var map   = new InputActionMap("map");

        asset.AddActionMap(map);

        var actionAssignedToUser = map.AddAction("action", binding: "<Gamepad>/buttonSouth");

        actionAssignedToUser.Enable();

        var actionNotAssignedToUser = new InputAction(binding: "<Gamepad>/buttonNorth");

        actionNotAssignedToUser.Enable();

        var user = new TestUser();

        InputUser.Add(user);

        // Noise.
        InputUser.Add(new TestUser());
        InputUser.all[1].AssignInputDevice(gamepad3);

        IInputUser   receivedUser    = null;
        InputAction  receivedAction  = null;
        InputControl receivedControl = null;

        InputUser.onUnassignedDeviceUsed +=
            (u, a, c) =>
        {
            Assert.That(receivedUser, Is.Null);
            receivedUser    = u;
            receivedAction  = a;
            receivedControl = c;
        };

        user.AssignInputActions(asset);
        user.AssignInputDevice(gamepad1);

        // No callback if using gamepad1.
        InputSystem.QueueStateEvent(gamepad1, new GamepadState().WithButton(GamepadButton.South));
        InputSystem.Update();

        Assert.That(receivedUser, Is.Null);
        Assert.That(receivedAction, Is.Null);
        Assert.That(receivedControl, Is.Null);

        // Callback when using gamepad2.
        InputSystem.QueueStateEvent(gamepad2, new GamepadState().WithButton(GamepadButton.South));
        InputSystem.Update();

        Assert.That(receivedUser, Is.SameAs(user));
        Assert.That(receivedAction, Is.SameAs(actionAssignedToUser));
        Assert.That(receivedControl, Is.SameAs(gamepad2.buttonSouth));

        receivedUser    = null;
        receivedControl = null;
        receivedAction  = null;

        // No callback when triggering action not assigned to user.
        InputSystem.QueueStateEvent(gamepad1, new GamepadState().WithButton(GamepadButton.North));
        InputSystem.Update();

        Assert.That(receivedUser, Is.Null);
        Assert.That(receivedAction, Is.Null);
        Assert.That(receivedControl, Is.Null);
    }
Beispiel #27
0
    public void Users_CanBeMonitoredForChanges()
    {
        InputUser.Add(new TestUser()); // Noise.
        InputUser.Add(new TestUser()); // Noise.
        var user = new TestUser();

        IInputUser      receivedUser   = null;
        InputUserChange?receivedChange = null;

        InputUser.onChange +=
            (usr, change) =>
        {
            Assert.That(receivedChange == null);
            receivedUser   = usr;
            receivedChange = change;
        };

        // Added.
        InputUser.Add(user);

        Assert.That(receivedUser, Is.SameAs(user));
        Assert.That(receivedChange, Is.EqualTo(InputUserChange.Added));

        receivedUser   = null;
        receivedChange = null;

        // NameChanged.
        user.SetUserName("NewName");

        Assert.That(receivedUser, Is.SameAs(user));
        Assert.That(receivedChange, Is.EqualTo(InputUserChange.NameChanged));

        receivedUser   = null;
        receivedChange = null;

        // HandleChanged.
        user.SetUserHandle(new InputUserHandle("test", 1));

        Assert.That(receivedUser, Is.SameAs(user));
        Assert.That(receivedChange, Is.EqualTo(InputUserChange.HandleChanged));

        receivedUser   = null;
        receivedChange = null;

        // Same name, no notification.
        user.SetUserName("NewName");

        Assert.That(receivedChange, Is.Null);

        // DevicesChanged.
        var device = InputSystem.AddDevice <Gamepad>();

        user.AssignInputDevice(device);

        Assert.That(receivedUser, Is.SameAs(user));
        Assert.That(receivedChange, Is.EqualTo(InputUserChange.DevicesChanged));

        receivedUser   = null;
        receivedChange = null;

        // Same device, no notification.
        user.AssignInputDevice(device);

        Assert.That(receivedChange, Is.Null);

        // DevicesChanges, removed.
        user.ClearAssignedInputDevices();

        Assert.That(receivedUser, Is.SameAs(user));
        Assert.That(receivedChange, Is.EqualTo(InputUserChange.DevicesChanged));

        receivedUser   = null;
        receivedChange = null;

        // ControlSchemeChanged.
        user.AssignControlScheme("gamepad");

        Assert.That(receivedUser, Is.SameAs(user));
        Assert.That(receivedChange, Is.EqualTo(InputUserChange.ControlSchemeChanged));

        receivedUser   = null;
        receivedChange = null;

        // Same control scheme, no notification.
        user.AssignControlScheme("gamepad");

        Assert.That(receivedChange, Is.Null);

        // Removed.
        InputUser.Remove(user);

        Assert.That(receivedUser, Is.SameAs(user));
        Assert.That(receivedChange, Is.EqualTo(InputUserChange.Removed));

        ////TODO: actions
        ////TODO: activate, passivate
    }