Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

PS4 joystick map on Iphone

Discussion in 'Scripting' started by clebertavares, Nov 6, 2019.

  1. clebertavares

    clebertavares

    Joined:
    Jan 2, 2012
    Posts:
    55
    Hello,

    I am using this code on my Mac:

    Code (CSharp):
    1.  
    2.         if (Input.GetKeyDown(KeyCode.JoystickButton0))
    3.         {
    4.             Debug.Log("a");
    5.         }
    6.  
    7.         if (Input.GetButton("PS4_Square"))
    8.         //its configured in editor -> project settings -> input manager
    9.         {
    10.             Debug.Log("b");
    11.         }
    12.  
    They both work on editor, printing the logs...

    But when I use them on IPhone build (changing the debug for something else...)

    It just dont work... But the PS4 controller work for " Input.GetAxis("Horizontal");", for example...

    I thinks its the mapping for buttons only... on the IPhone.

    Where can I get this information?
     
    Last edited: Nov 6, 2019
  2. clebertavares

    clebertavares

    Joined:
    Jan 2, 2012
    Posts:
    55
    square = 16
    x = 15
    circle = 14
    triangle = 13
    R2 = 12
    L2 = 11
    R1 = 10
    L1 = 9
    dpad left = 8 //dpad's dont map as buttons on editor
    dpad down = 7
    dpad right = 6
    dpad up = 5
    //4, 3, 2???tried all the rest... didnt work share, "mouse button", ps, push directionals left / right. these all work on editor
    options = 1

    Oh my... its completely different from editor... almost the opposite... why, unity, why...?
     
  3. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    I can pretty much guarantee this is because the driver used on the iPhone for the controller presents the controller differently than the driver used for it on your Mac.
     
    clebertavares likes this.
  4. Antistone

    Antistone

    Joined:
    Feb 22, 2014
    Posts:
    2,834
    If you want alternatives, Unity plugins exist that will try to automatically recognize gamepads and standardize their inputs. I'm currently using one called "Rewired" (though I have not tried to use gamepads on a phone).
     
    clebertavares and Joe-Censored like this.
  5. clebertavares

    clebertavares

    Joined:
    Jan 2, 2012
    Posts:
    55
    Yeah, I figure it out this... And I need to use on an Android too, so I am looking towards this kind of plugins and so on...

    Thanks.
     
    Joe-Censored likes this.