Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug What is the correct way of ignoring noisy input devices like the DualShock4?

Discussion in 'Input System' started by Benzor, Nov 15, 2023.

  1. Benzor

    Benzor

    Joined:
    Dec 29, 2013
    Posts:
    14
    Scenario:
    1. I am playing my PC build of the game.
    2. I have both a keyboard and a DualShock4 controller connected to the PC. Both are valid and supported input devices. (If I disconnect one of them, the other works fine, and this is true in both cases)
    3. When I use my keyboard while the DualShock4 is connected, the keyboard input is ignored because the DualShock4 spams input every frame (presumably due to its gyro). It seems like it pushes itself to be "current input device" every frame and so keyboard input gets stomped. The only workaround is disconnecting the DualShock4, and this is not acceptable for players.
    I want to ignore ALL non-intentional input from the PS4. Anything that is not an explicit button press or an axis activation that goes beyond the specified deadzone setting. (Our game does not use the gyro so it can be ignored.) How do I do this?

    Specifically, I am reading inputs in C# from input actions. For example a line of movement input capture would look like this:

    `Vector2 rawAim = _inputActionMove.ReadValue<Vector2>();`
    where `_inputActionMove` is of type `InputAction`, which we fetch directly from our `@GameInputActions` generated C# class via `new GameInputAction().Gameplay.Move`

    Here is what I have already tried but does not work:
    • Some input devices provide a `noisy` bool flag. Cool story, but Unity Input System doesn't seem to provide a setting or mechanism for "don't make this input device active if it only gets noisy gyro updates." As per the docs, it only works for `Gamepad.current` but this would stop us from using the InputAction abstraction layer and force us to listen to explicit devices. I can't seem to use this, so: Not Good.
    • Manually turn off the DualShock4 device via in-game settings menus. This would technically meet requirements, but make seamless input device switching impossible for players, pushing the burden on them to manually manage their input device, so: Not Good.
    I would like to avoid needing to fork the Unity Input System package just to fix this because this feels like a bug. The Rewired package managed to handle this case gracefully so clearly it's technically possible.

    How do I make this work? Can I fix this myself or must I create a bug/ticket/feature request for the Unity Input System team to implement?
     
    NathBar likes this.
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    7,299
    Have you tested this though?

    I thought this was the case with my Switch Pro Controller, as when I was incorporating a system to handle the swapping of input from Keyboard & Mouse to a gamepad, the Switch kept forcing itself as the active one. I thought it might be the gyro, but just turns out it was just a thumb-stick with a bit of drift.

    I would do some testing first if you haven't already: https://docs.unity3d.com/Packages/com.unity.inputsystem@1.7/manual/Debugging.html
     
  3. Benzor

    Benzor

    Joined:
    Dec 29, 2013
    Posts:
    14
    • Yes I have already tested and confirmed that this issue is present in at least 3 different PS4 gamepads.
    • No, the input debugger reports no actual value changes, it just blasts the same data over and over. (it doesn't really matter what the specific source is, only that it's on blast even without user intent.)
    • Finally, the documentation clearly confirms this is a known issue, but it does not offer any workarounds for the C# event codepath. https://docs.unity3d.com/Packages/c.../manual/Settings.html#filter-noise-on-current
     
  4. Allan-MacDonald

    Allan-MacDonald

    Joined:
    Sep 21, 2015
    Posts:
    108
    Hey what did you end up coming up with?