Search Unity

No MFI controller detected?

Discussion in 'iOS and tvOS' started by bridgewaterrobbie, Feb 9, 2016.

  1. bridgewaterrobbie

    bridgewaterrobbie

    Joined:
    Feb 9, 2016
    Posts:
    8
    Hi, I am using Unity for a class and trying to make an MFI controller work with my phone. I set it up in the inputs menu, but it seems that the app I make does not detect the controller, even though other games do just fine (Even one unity game I got from the app store).

    Is there an extra step I should do, beyond mapping the buttons in the input menu? A separate mapping works just fine for windows/android with a controller.

    Thanks
     
  2. greggtwep16

    greggtwep16

    Joined:
    Aug 17, 2012
    Posts:
    1,546
    Since you're already familiar with the process for win/android there isn't anything extra that needs to happen for IOS. Just the entries in the input manager for the axis and the relevant code. The joystick buttons and axis are different for most platforms though so it might be worth running my free utility from the asset store to make sure that you are actually checking the right entries on IOS.

    https://www.assetstore.unity3d.com/en/#!/content/43621
     
  3. bridgewaterrobbie

    bridgewaterrobbie

    Joined:
    Feb 9, 2016
    Posts:
    8
    Okay then, any idea why it isn't working? Ive tried it with two different MFI compatible controllers (Moga rebel and Mad Catz CTRLI). The left stick isn't even working despite it being the same on all controllers, and I found a log command to output connected controllers- 0. Is this some bug with current version of unity? I have the latest Xcode, and latest unity (Updated both when this first happened). Its driving me a bit nuts.

    Oh and I have a 6S if that matters.
     
  4. greggtwep16

    greggtwep16

    Joined:
    Aug 17, 2012
    Posts:
    1,546
    When you ran the utility did anything show up when you hit any buttons or sticks?
     
  5. bridgewaterrobbie

    bridgewaterrobbie

    Joined:
    Feb 9, 2016
    Posts:
    8
    I haven't built that test for iOS, which I would need to do to test it. However given that unity itself reports that there are 0 controllers connected, I don't think it would work at all.


    This isn't a mapping issue its a detection issue, it simply ignores that I connect a controller to my phone

    I can test the script on my device in like an hour if you think it will make a significant difference.
     
  6. greggtwep16

    greggtwep16

    Joined:
    Aug 17, 2012
    Posts:
    1,546
    You are correct that if the call to getjoysticknames() returns no results that it won't make a difference, I missed that you said Unity reports no controllers connected.

    If you discover that the current version of Unity doesn't work but a previous one does with the same code, certainly submit a bug report.
     
  7. bridgewaterrobbie

    bridgewaterrobbie

    Joined:
    Feb 9, 2016
    Posts:
    8
    I never had a chance to try older versions of unity, so I don't k now if they work. I was just kind of hoping I was missing something simple, rather than it apparently being a bug. Can anyone with an iPhone and MFI check if they can make an app work with current versions of everything? Thanks.

    EDIT: I tried building that scene you recommended in a new project just to be sure. No luck.
     
    Last edited: Feb 9, 2016
  8. _Paulius

    _Paulius

    Mobile Developer Unity Technologies

    Joined:
    Jul 8, 2014
    Posts:
    173
    I don't have either of these controllers, but I've tried connecting Steelseries Stratus and Horipad ultimate gamepads that I have to an app built with 5.3.2f1 and they seems to be working fine. All the MFi controllers should work the same with Unity as far as I'm aware, so this might be a bug on our side.

    But it would make sense to make sure that the controller is actually detected by iOS with https://developer.apple.com/library...r/Reference/GameController_RefColl/index.html (or you could just try some non Unity game on the AppStore that has game pad support ; D). And if you can get the controller to work with other apps please submit a bug report and post the bug id here.
     
  9. bridgewaterrobbie

    bridgewaterrobbie

    Joined:
    Feb 9, 2016
    Posts:
    8
    Yes, I believe you are correct in that they should all work the same. I tried some non unity games and even a unity game from the app store and they worked fine with the controller (Sonic CD, which I play as well as something called "Sword of Rapier" which is built with unity and uses an MFI controller). I even tried with the following process: test other game(works) switch to mine(No) switch back without doing anything else(Still works).

    I will submit a bug report when I have time tomorrow then, but I would like to ask: What version of Xcode are you using? I just tried updating mine to the latest and it did not help.
     
  10. _Paulius

    _Paulius

    Mobile Developer Unity Technologies

    Joined:
    Jul 8, 2014
    Posts:
    173
    I've tried both 7.2 and 7.3 Beta, so this is probably not related to the version of Xcode.
     
  11. bridgewaterrobbie

    bridgewaterrobbie

    Joined:
    Feb 9, 2016
    Posts:
    8
    very strange then. I am on Xcode 7.2, with Unity 5.3.2f1 (Freshly installed). Mac 10.11.2(Going to probably update this tonight). Ive removed Unity and Xcode as near to fully as I can, both to try to solve this and also clear some space (Xcode was taking 30 gigs of old simulators)

    All in all it seems to be the ideal environment to try to test it in. On build settings I have Xcode running as release with the other options unchecked.

    Does all that match your settings?

    After that I just hit build and run. The app clearly works, but no controller is detected.
     
  12. _Paulius

    _Paulius

    Mobile Developer Unity Technologies

    Joined:
    Jul 8, 2014
    Posts:
    173
    I think we actually found what could be causing this. It's necessary to add the GameController or the GameKit framework in Xcode in Xcode for the controllers to actually be detected by the app. Unity doesn't currently do that automatically and I couldn't reproduce this with my project because it was using Game Center which also references the GameKit api.

    We've already fixed this and this fix should be included in the next path release, but you can just fix this manually by adding 'GameController.framework' to the linked frameworks list in your project's settings in Xcode.
     
    JoeStrout likes this.
  13. bridgewaterrobbie

    bridgewaterrobbie

    Joined:
    Feb 9, 2016
    Posts:
    8
    That is exactly what the problem was, thank you. You may want to put some kind of notice on the page for MFI controllers until then, it caused me and some of my classmates a lot of stress (I am in a Virtual Reality class, and we used Unity for our first project. Its of us in different groups spent hours debugging on this issue, since many of us had iPhones)
     
  14. bridgewaterrobbie

    bridgewaterrobbie

    Joined:
    Feb 9, 2016
    Posts:
    8
    Hi Paulius, I wanted to note one other thing I found. It seems the documentation you have here: http://docs.unity3d.com/Manual/iphone-joystick.html
    Is not right, at least anymore. I loaded up the app that Gregg recommended earlier to test inputs, and it doesn't match what you have.

    For example, right trigger is button 11 but axis 12. Pretty much every item on that list is wrong on either the button or axis side, except the sticks.
     
    efge likes this.
  15. greggtwep16

    greggtwep16

    Joined:
    Aug 17, 2012
    Posts:
    1,546
    In the past I have noted that as well especially during the TVOS beta. The most common documentation error is the higher number axis tend to be off by one lower than they should be. From a developer perspective I believe the documentation accidentally represents the enum used internally by Unity. The enum for the Axis is like the following:

    Axis 1 = 0;
    Axis 2 = 1;
    Axis 3 = 2;
    ctd.....

    I think when making the documentation this gets mixed up quite easily. The buttons on the other hand in the keycode enum are very high numbers and aren't mixed up as easily.
     
  16. zastrow

    zastrow

    Joined:
    May 23, 2012
    Posts:
    20
    Using Unity 5.3.4f1
    Had the same issue. Added 'GameController.framework' in Xcode to solve the problem.
    Thanks for the tip.
     
  17. LilGames

    LilGames

    Joined:
    Mar 30, 2015
    Posts:
    570
    @_Paulius
    Does Unity 5.6 add the GameController to Xcode automatically now?
     
    Last edited: Jul 24, 2017
    JoeStrout likes this.
  18. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    I'm using 2017.2, and GameController.framework is still not included automatically in my app. I had to dig up this thread and add the framework manually before I could access MFi inputs in my game.

    EDIT: And what's worse, I have to do this on every build, even when just using "Append" (rather than "Replace") mode. Unity, please fix this! :(
     
    Last edited: Apr 14, 2018
  19. shaofent

    shaofent

    Joined:
    Aug 28, 2017
    Posts:
    8
    Hello,
    I am using Unity 2018.3.0f2 for my project. After add GameController.framework, my game running on iphone still cannot detect the controller. Although system setting shows that my controller is connected, my game cannot detect the controller at all. No controller names are returned from the API Input.GetJoystickNames(). Do anybody have some ideas?
     
  20. FOKSlab

    FOKSlab

    Joined:
    Jun 27, 2017
    Posts:
    30
    I meet the same issue with 2020.2.4f1 is someone has a solution to this ?