Search Unity

Resolved DualShock4 behaves incorrectly on Android and IOS

Discussion in 'Input System' started by BGCH, Feb 20, 2022.

  1. BGCH

    BGCH

    Joined:
    Nov 23, 2017
    Posts:
    20
  2. dmytro_at_unity

    dmytro_at_unity

    Unity Technologies

    Joined:
    Feb 12, 2021
    Posts:
    212
    @BGCH Hi, would you mind to report a bug for this and we can have a look, thanks!
     
  3. BGCH

    BGCH

    Joined:
    Nov 23, 2017
    Posts:
    20
    I sent a report
    case 1404866
     
    dmytro_at_unity likes this.
  4. BGCH

    BGCH

    Joined:
    Nov 23, 2017
    Posts:
    20
    ok i found the solution.
    the reason why this happens is that on android Unity creates a virtual keyboard and mouse (ps4 touchpad), and one of the keyboards reacts to the buttons R1 R2 L1 L2.
    the solution is to simply disable these devices

    Code (CSharp):
    1. private void FixPS4Android()
    2.         {
    3.             if (Application.platform == RuntimePlatform.Android)
    4.             {
    5.                 foreach (var item in InputSystem.devices)
    6.                 {
    7.                     if (item.name.Contains("Keyboard") && item.displayName == "Wireless Controller")
    8.                         InputSystem.DisableDevice(item);
    9.                     if (item.displayName == "Wireless Controller Touchpad" && item.name.Contains("Mouse"))
    10.                         InputSystem.DisableDevice(item);
    11.                 }
    12.             }
    13.         }
     
    neveract likes this.