Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Assets/Tests/InputSystem/APIVerificationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,10 @@ public class Touchscreen : UnityEngine.InputSystem.Pointer, UnityEngine.InputSys
[Property("Exclusions", @"1.0.0
public bool filterNoiseOnCurrent { get; set; }
")]
// SwitchProControllerHID inherited from IInputStateCallbackReceiver and IEventPreProcessor, both are internal interfaces
[Property("Exclusions", @"1.0.0
public class SwitchProControllerHID : UnityEngine.InputSystem.Gamepad
")]
public void API_MinorVersionsHaveNoBreakingChanges()
{
var currentVersion = CoreTests.PackageJson.ReadVersion();
Expand Down
54 changes: 36 additions & 18 deletions Assets/Tests/InputSystem/SwitchTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using UnityEngine.InputSystem.HID;
using UnityEngine.InputSystem.Switch.LowLevel;
using UnityEngine.InputSystem.Processors;
using UnityEngine.TestTools.Utils;

internal class SwitchTests : CoreTestsFixture
{
Expand Down Expand Up @@ -35,31 +36,48 @@ public void Devices_SupportsHIDNpad()
InputSystem.QueueStateEvent(controller,
new SwitchProControllerHIDInputState
{
leftStickX = 0x1000,
leftStickY = 0x1000,
rightStickX = 0x7fff,
rightStickY = 0xefff,
leftStickX = 0x10,
leftStickY = 0x10,
rightStickX = 0x80,
rightStickY = 0xf2,
});
InputSystem.Update();

var leftStickDeadzone = controller.leftStick.TryGetProcessor<StickDeadzoneProcessor>();
var rightStickDeadzone = controller.rightStick.TryGetProcessor<StickDeadzoneProcessor>();

Assert.That(Vector2.Distance(controller.leftStick.ReadValue(), leftStickDeadzone.Process(new Vector2(-1.0f, 1.0f))), Is.LessThan(0.0001f));
Assert.That(Vector2.Distance(controller.rightStick.ReadValue(), rightStickDeadzone.Process(new Vector2(0.0f, -1.0f))), Is.LessThan(0.0001f));
var currentLeft = controller.leftStick.ReadValue();
var expectedLeft = leftStickDeadzone.Process(new Vector2(-1.0f, 1.0f));

AssertButtonPress(controller, new SwitchProControllerHIDInputState().WithButton(SwitchProControllerHIDInputState.Button.A), controller.buttonEast);
AssertButtonPress(controller, new SwitchProControllerHIDInputState().WithButton(SwitchProControllerHIDInputState.Button.B), controller.buttonSouth);
AssertButtonPress(controller, new SwitchProControllerHIDInputState().WithButton(SwitchProControllerHIDInputState.Button.X), controller.buttonNorth);
AssertButtonPress(controller, new SwitchProControllerHIDInputState().WithButton(SwitchProControllerHIDInputState.Button.Y), controller.buttonWest);
AssertButtonPress(controller, new SwitchProControllerHIDInputState().WithButton(SwitchProControllerHIDInputState.Button.StickL), controller.leftStickButton);
AssertButtonPress(controller, new SwitchProControllerHIDInputState().WithButton(SwitchProControllerHIDInputState.Button.StickR), controller.rightStickButton);
AssertButtonPress(controller, new SwitchProControllerHIDInputState().WithButton(SwitchProControllerHIDInputState.Button.L), controller.leftShoulder);
AssertButtonPress(controller, new SwitchProControllerHIDInputState().WithButton(SwitchProControllerHIDInputState.Button.R), controller.rightShoulder);
AssertButtonPress(controller, new SwitchProControllerHIDInputState().WithButton(SwitchProControllerHIDInputState.Button.ZL), controller.leftTrigger);
AssertButtonPress(controller, new SwitchProControllerHIDInputState().WithButton(SwitchProControllerHIDInputState.Button.ZR), controller.rightTrigger);
AssertButtonPress(controller, new SwitchProControllerHIDInputState().WithButton(SwitchProControllerHIDInputState.Button.Plus), controller.startButton);
AssertButtonPress(controller, new SwitchProControllerHIDInputState().WithButton(SwitchProControllerHIDInputState.Button.Minus), controller.selectButton);
var currentRight = controller.rightStick.ReadValue();
var expectedRight = rightStickDeadzone.Process(new Vector2(0.0f, -1.0f));

Assert.That(currentLeft, Is.EqualTo(expectedLeft).Using(Vector2EqualityComparer.Instance));
Assert.That(currentRight, Is.EqualTo(expectedRight).Using(new Vector2EqualityComparer(0.01f)));

AssertButtonPress(controller, StateWithButton(SwitchProControllerHIDInputState.Button.A), controller.buttonEast);
AssertButtonPress(controller, StateWithButton(SwitchProControllerHIDInputState.Button.B), controller.buttonSouth);
AssertButtonPress(controller, StateWithButton(SwitchProControllerHIDInputState.Button.X), controller.buttonNorth);
AssertButtonPress(controller, StateWithButton(SwitchProControllerHIDInputState.Button.Y), controller.buttonWest);
AssertButtonPress(controller, StateWithButton(SwitchProControllerHIDInputState.Button.StickL), controller.leftStickButton);
AssertButtonPress(controller, StateWithButton(SwitchProControllerHIDInputState.Button.StickR), controller.rightStickButton);
AssertButtonPress(controller, StateWithButton(SwitchProControllerHIDInputState.Button.L), controller.leftShoulder);
AssertButtonPress(controller, StateWithButton(SwitchProControllerHIDInputState.Button.R), controller.rightShoulder);
AssertButtonPress(controller, StateWithButton(SwitchProControllerHIDInputState.Button.ZL), controller.leftTrigger);
AssertButtonPress(controller, StateWithButton(SwitchProControllerHIDInputState.Button.ZR), controller.rightTrigger);
AssertButtonPress(controller, StateWithButton(SwitchProControllerHIDInputState.Button.Plus), controller.startButton);
AssertButtonPress(controller, StateWithButton(SwitchProControllerHIDInputState.Button.Minus), controller.selectButton);
}

private static SwitchProControllerHIDInputState StateWithButton(SwitchProControllerHIDInputState.Button button)
{
return new SwitchProControllerHIDInputState
{
leftStickX = 0x7f,
leftStickY = 0x7f,
rightStickX = 0x7f,
rightStickY = 0x7f,
}.WithButton(button);
}

#endif
Expand Down
2 changes: 2 additions & 0 deletions Packages/com.unity.inputsystem/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ however, it has to be formatted properly to pass verification tests.

### Fixed

- Fixed Switch Pro controller not working correctly in different scenarios ([case 1369091](https://issuetracker.unity3d.com/issues/nintendo-switch-pro-controller-output-garbage), [case 1190216](https://issuetracker.unity3d.com/issues/inputsystem-windows-switch-pro-controller-only-works-when-connected-via-bluetooth-but-not-via-usb), case 1314869).

#### Actions

* Fixed `InputAction.GetTimeoutCompletionPercentage` jumping to 100% completion early ([case 1377009](https://issuetracker.unity3d.com/issues/gettimeoutcompletionpercentage-returns-1-after-0-dot-1s-when-hold-action-was-started-even-though-it-is-not-performed-yet)).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ On UWP only USB connection is supported, motor rumble and lightbar are not worki
>6. Unity supports Made for iOS (Mfi) certified controllers on iOS. Xbox One and PS4 controllers are only supported on iOS 13 or higher.
>7. Consoles are supported using separate packages. You need to install these packages in your Project to enable console support.
>8. Unity officially supports PS4 controllers only on [Android 10 or higher](https://playstation.com/en-us/support/hardware/ps4-pair-dualshock-4-wireless-with-sony-xperia-and-android).
>9. Switch Joy-Cons are not currently supported on Windows and Mac. Also, Switch Pro controllers are supported only when connected via Bluetooth but not when connected via wired USB.
>9. Switch Joy-Cons are not currently supported on Windows and Mac.
>10. PS5 DualSense is supported on Windows and macOS via USB HID, though setting motor rumble and lightbar color when connected over Bluetooth is currently not supported.
On UWP only USB connection is supported, motor rumble and lightbar are not working correctly.
On Android it's expected to be working from Android 12.
Expand Down
Loading