Input System 1.2 released: More fixes and PS5 controller support for Desktop

Hello Input System users!

We released version 1.2.0 of the package which contains:

  • a handful of fixes mainly for things we broke with 1.1
  • Support for PS5 Dualsense for Desktop Standalone and editors

For all the details please see our package changelog.

We are also using this version to mark it as verified all the way back to 2019.4 LTS with the next patches for each Unity release.

If we missed any issues please continue submitting bug reports and feedback.

Thank you,
Input Team

3 Likes

I just updated to this version for the dualsense support, but I already hit a roadblock :frowning:

I am obviously doing something wrong, but I cannot figure out what!

I have this code to detect if its a playstation gamepad.

playerInput.devices[0] is DualShockGamepad

I then added this to detect if its both DualShock or dualsense, but I get an error on build. I don’t know why DualSenseGamepad isn’t showing up.

playerInput.devices[0] is DualShockGamepad || playerInput.devices[0] is DualSenseGamepadHID

Build Error:

Assets/Scripts/InputManager.cs(99,89): error CS0246: The type or namespace name ‘DualSenseGamepadHID’ could not be found (are you missing a using directive or an assembly reference?)

Any suggestions?

What’s the build target? DualSenseGamepadHID is only available on some build target. Note that DualSenseGamepadHID is just a DualShockGamepad, though. So the first check alone is enough.

Thanks for the fast response!

I am building for iOS. The controller works, but I cannot detect that it is a playstation controller so I cannot serve the correct gamepad icons.

Is duelsense not supported for iOS yet in Unity? If not, will it be supported soon?

It is only supported for Desktop Standalone MAc&Windows at the moment as per the changelog.

We currently have not timeline for when we extend that support to mobile platforms. Sorry.

Okay, thanks for letting me know. Just want to put in a request for it as its extremely important :slight_smile:

Is there any workaround to detect if it’s a dualsense?

EDIT:

For anyone looking for a workaround, you can use this line of code to get the name.

print(playerInput.devices[0].displayName);

@TomTheMan59 It should work on iOS since 14.5, but it will not be reported as “DualSenseGamepadHID” due to our limitations, it’s likely to be reported as “DualShock4GampadiOS” but I need to check. Can you give it a try and see if it works correctly?

Hi, I tried it but it doesn’t work on my 2018 iPad Pro 12.9in (3rd Generation) on 15.1

Doesn’t Work:

if(playerInput.devices[0] is DualShockGamepad || playerInput.devices[0] is DualShock4GampadiOS)

Works:

if(playerInput.devices[0] is DualShockGamepad || playerInput.devices[0].displayName.Contains("DualSense"))

Ah ok, seems like I forgot to add a type matcher and a class on iOS, sorry :frowning:
Would you mind to file a bug report for this? Thanks!

Case ID: 1378308

1 Like

Hi there. I’m sure I’m missing something obvious, but how do I upgrade the input system to 1.2.0? I’m on Unity 2021.1.16, and the InputSystem is on 1.0.2 (according to the PackageManager->UnityRegistry page).

Weirdly, the input system doesn’t show up in the PackageManager->In Project page, nor is it listed in the packages.json file. Does it somehow use a hard-coded version of the package per Unity release?

Oh, OK, manually adding
“com.unity.inputsystem”: “1.2.0”
to the packages json does the trick. Weird.

2 Likes

@Rob-Fireproof The reason you had to manually update is that editor/package association updates is tied to editor and those Unity “patches” that are mentioned in the post will be verified and rolled out independently of the package upgrade when new Unity updates are published.

Wait what? Are you saying that the package versions that are available/recommended for a Unity version is not something that’s fetched from Unity’s package server, but something that’s hard-coded in each Unity version?

So you can’t test a version of a package for a shipped Unity version and say “well, this works, we can recommend this for that shipped Unity version”, you have to ship a new minor Unity version?

That, uh, explains things, I guess? I’ve been wondering why packages that are supposed to be available isn’t available yet. But also that seems kinda horrible and not the point of packages at all. Am I missing something?

3 Likes

Branch 2020- of Package Manager where you could see all version was way better than this “theorically idiot proof” system that prevent you to see new and in pre-release package

Sadly Unity listened to the criticism that packages break projects when people willy-nilly upgrade them. So they decided to only show packages if they are either “thoroughly tested” with the Unity version at hand or “it is experimental somewhat” and they need people to test things.
In all other cases you need to install the package manually and if you want a specific version, you need to specify the version too.

I pretty much hate this and I predicted this BS before even they made this move, when there was a debate about this. And everyone said I’m wrong, it will be much better… :smile:

1 Like

Lol better for who

Dualsense Color & Rumble do not work!

This is color:

using UnityEngine;
using UnityEngine.InputSystem.DualShock;
public class NewBehaviourScript : MonoBehaviour
{
    private void Start()
    {
        DualSenseGamepadHID dualSense = new DualSenseGamepadHID();
        dualSense.SetLightBarColor(Color.red);
    }
}

This is Rumble:

using UnityEngine;
using UnityEngine.InputSystem.DualShock;
public class NewBehaviourScript : MonoBehaviour
{
    private void Start()
    {
        DualSenseGamepadHID dualSense = new DualSenseGamepadHID();
        dualSense.SetMotorSpeeds(1f, 1f);
    }
}

Dualsense is connected via cable -wired-. Why is that?

I don’t see a fix for GetTimeoutCompletionPercentage bug report #1377009
Code line numbers probably have changed - I posted this for 1.1.1

GetTimeoutCompletionPercentage doesn’t work

Always returns 1.0. Seems to be sampling a different time than what’s used to initialize the starttime
Unity.InputSystem\Packages\com.unity.inputsystem@1.1.1\InputSystem\Actions\InputAction.cs : 1371
Code (CSharp):

var duration = interactionState.timerDuration;
    var startTime = interactionState.timerStartTime;
    var endTime = startTime + duration;
    var remainingTime = endTime - InputRuntime.s_Instance.currentTime;
    if (remainingTime <= 0)
      timerCompletion = 1;
    else
      timerCompletion = (float)((duration - remainingTime) / duration);

when breaking into the code ‘remainingTime’ is something like -1200.0
Looks like timerStartTime is an offset from some value whereas InputRuntime.s_Instance.currentTime is the current realtime value.

Specifically timerStartTime is set by :
Unity.InputSystem\Packages\com.unity.inputsystem@1.1.1\InputSystem\InputManager.cs : 3447
Code (CSharp):

var currentTime = m_Runtime.currentTime - InputRuntime.s_CurrentTimeOffsetToRealtimeSinceStartup;

The fix is to fix the remainingTime calculation to use the same offset time value used for startTime
Code (CSharp):

    var duration = interactionState.timerDuration;
    var startTime = interactionState.timerStartTime;
    var endTime = startTime + duration;
    var remainingTime = endTime - (InputRuntime.s_Instance.currentTime - InputRuntime.s_CurrentTimeOffsetToRealtimeSinceStartup);
    if (remainingTime <= 0)
        timerCompletion = 1;
    else
        timerCompletion = (float)((duration - remainingTime) / duration);

Is there a function to detect any key on any device was pressed, yet?

e.g.

using UnityEngine;
public class NewBehaviourScript : MonoBehaviour
{
    private void Update()
    {
        if (Device.current.AnyKey.wasPressedThisFrame)
        {
            //Do something..
        }
    }
}