MFi Game Controllers

76 views
Skip to first unread message

Maximilian Csuk

unread,
Apr 2, 2015, 5:12:31 AM4/2/15
to rob...@googlegroups.com
Hi,

I'm trying to implement MFi controller support for one of my games. I'm using LibGDX and found that there is no ios-specific controller extension yet, so I'm trying to write it myself. The RoboVM docs seemed straight forward. I also looked at the RoboVM sample "Adventure" (https://github.com/robovm/robovm-samples/tree/master/Adventure) as it includes controller support. 

From what I understood, I need to call the following code at startup:
GCController.Notifications.observeDidConnect(new VoidBlock1<GCController>() {
    @Override
    public void invoke(GCController controller) {
        System.out.println("Connected game controller: " + controller);

        addController(controller, true); // add it to our list of controllers
    }
});
GCController.Notifications.observeDidDisconnect(new VoidBlock1<GCController>() {
    @Override
    public void invoke(GCController controller) {
       removeController(controller); // remove it from our list of controllers

        System.out.println("Disconnected game controller: " + controller);
    }
});

// And start looking for any wireless controllers.
GCController.startWirelessControllerDiscovery(new Runnable() {
    @Override
    public void run() {
        System.out.println("Finished finding controllers");
    }
});

The callback of startWirelessControllerDiscovery() immediately returns, prompting "Finished finding controllers". But I don't have the feeling it actually does anything. No controller connects are registered at all. There's maybe something wrong with my bluetooth setup or I need to do some additional things to make it recognize the controller, but I'm just guessing here. 

My robovm config includes
<framework>CoreGraphics</framework>
<framework>SpriteKit</framework>



I'm using a jailbreaked iPad 2 mini, with the "controllers for all" app (which has its own bluetooth stack, it seems) and a PS3 controller. Other games, (I tested with the app Cordy 2) work fine with the controller and prompt to press the PS button on startup, after which the controller is usable.

I've also tried to run the Adventure sample on my iPad, but it crashes after a few seconds. :(

Am I missing something?

Regards,
Max

Maximilian Csuk

unread,
Apr 4, 2015, 2:25:40 PM4/4/15
to rob...@googlegroups.com
I fixed it! :)

I was apparently missing some framework inclusions in the robovm.xml file. Here's what works:

<frameworks>

   <framework>UIKit</framework>

   <framework>OpenGLES</framework>

   <framework>QuartzCore</framework>

   <framework>CoreGraphics</framework>

   <framework>OpenAL</framework>

   <framework>AudioToolbox</framework>

   <framework>AVFoundation</framework>

   <framework>SpriteKit</framework>

   <framework>ExternalAccessory</framework>

   <framework>CoreBluetooth</framework>

   <framework>GameController</framework>

 </frameworks>



Is this documented somewhere? I've googled my heart out but couldn't find anything, neither in the Apple docs nor in the RoboVM docs... or did I simply overlook it? If not, this is definitely helpful and important information and should be documented somewhere. :)

Niklas Therning

unread,
Apr 7, 2015, 4:24:07 AM4/7/15
to Maximilian Csuk, rob...@googlegroups.com
Great to hear you managed to get it working! No we don't have this documented anywhere. Would you mind adding an issue to https://github.com/robovm/robovm-docs/issues so that we don't forget about it?

--
You received this message because you are subscribed to the Google Groups "RoboVM" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robovm+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Maximilian Csuk

unread,
Apr 7, 2015, 5:49:04 AM4/7/15
to rob...@googlegroups.com, maximil...@gmail.com
Reply all
Reply to author
Forward
0 new messages