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)); } }
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 })); }