Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
MFi Game Controller Support
-
Thanks @shaun-h! How did you figure that out?
I did a quick test, and it did load the framework. But then I just got an empty list when calling GCControllers.controllers() unfortunately. My wife stole the controller before I could try more things. I will check this out again soon though.
Thanks again!
-
I seem to be stuck again. I only get an empty list from GCController.controllers(), even though a controller is paired and connected.
It'll be some time, but next I'll try to do this in XCode and see what I get from the call. Unless someone else can figure out what's going on before that of course.
-
@Oscar I can't take credit, It was posted in the past by someone else and I kept the snippet stashed away.
I can't help you with the rest of it as I have never dealt with GCController before and don't have a controller to play with.I would be very interested in how you go with it though.
Cheers -
Are you able to test that the controller works in other iOS applications?
Also try reading through the apple documentation https://developer.apple.com/library/ios/documentation/GameController/Reference/GameController_RefColl/index.html
You need to call
startWirelessControllerDiscoveryWithCompletionHandler_
And then stop the search after you have your controller. -
@Cethric, I am pretty certain that you do not have to handle controller discovery in the app unless you want to.
https://developer.apple.com/library/ios/documentation/ServicesDiscovery/Conceptual/GameControllerPG/Introduction/Introduction.html
"Although support for pairing is normally provided by the operating system (typically in the Preferences or Settings, you can use the Game Controller framework to pair devices inside your game. "https://developer.apple.com/library/ios/documentation/ServicesDiscovery/Conceptual/GameControllerPG/DiscoveringControllers/DiscoveringControllers.html#//apple_ref/doc/uid/TP40013276-CH2-SW1
"Normally, discovery occurs outside your game—that is, a player usually pairs the controller before launching your game. However, you can let a player discover new controllers from within your game."Still I tried using startWirelessControllerDiscoveryWithCompletionHandler, but that didn't make a difference. I might have made a mistake though, because the completion handler block was never called, not even after a call to stopWirelessControllerDiscovery.
-
I do not have a controller to test this with. How ever the controller should be showing up in system preferences (if it is a wireless controller, don't know about wired (lightening) controllers, but I would assume they should as well)
Have you tryed testing the controller in another application/game? -
Also isn't there a tag that needs to go in the Application's plist file to say that it is allowed to connect to MFI Controllers? (I can't check this at the moment cause I am not at my computer)
-
@Cethric Yes, I made sure that the Controller was listed as connected in Settings, and that I could use it in another app.
I've looked around to find out if Game Controller support needs to be declared in the app plist. It seems to be true for tvOS apps, but I can't find anything about that for iOS. It would explain the behavior though.
-
I've run into the very same problem, unfortunately.
https://forum.omz-software.com/topic/2107/help-with-gamecontroller-frameworkNow I can be sure that it's not my fault that it doesnt work :P
-
I have a suspicion that MFi controllers require that the app is actually linked against the GameController framework – could be an optimization to turn off controller communication while an app is running that doesn't support them or something like that... I don't have a controller to test this unfortunately, though controller support is something that I find potentially interesting as an addition to the scene module. I might buy one for testing at some point.