Controller list empty

Hello there,

I'm writing a small game in swift and try to use a 8bitdo NES30 bluetooth controller. The controller i correctly paired (and i can play with other games) but my swift code can t see it : controllerList = GCController.controllers()

Always return an empty list. Is it because my controller is not a MFI controller or maybe there is somethin to activate in project options ?

I tried to down a xcode project from internet and it seems that it doesn't see the controller also ! But I can play games such SuperOxWars or other from the store ...

My Iphone for test is an iphone 5

Thank you for your help

Replies

As per this link: Discovering and Connecting to Controllers


the list may be empty if you are querying for controllers during app launch. You should also register for the GCControllerDidConnectNotification (and GCControllerDidDisconnectNotification) to be notified if controllers are made available later.

Yes I've seen this, and try but the didreceive callback is never called. This is my code (It comes from the siri example):



func getControllers(){

controllerList = GCController.controllers()

if controllerList.count < 1 {

print("no controller try and attach to them")

attachControllers()

}

}


func attachControllers(){

registerForGameControllerNotifications() /

GCController.startWirelessControllerDiscoveryWithCompletionHandler({}) /

}


func registerForGameControllerNotifications() {

NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(GameViewController.handleControllerDidConnectNotification(_:)), name: GCControllerDidConnectNotification, object: nil)

NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(GameViewController.handleControllerDidDisconnectNotification(_:)), name: GCControllerDidDisconnectNotification, object: nil)

}




@objc func handleControllerDidConnectNotification(notification: NSNotification) {

/

gameController = notification.object as! GCController // Never called !!!

/

self.setupGCEvents()

}



@objc func handleControllerDidDisconnectNotification(notification: NSNotification) {

/

}

Hi again,


It seems that the 8bitdo NES30 is not fully compatible with ios. But it works well with some games. How can I use it with my own game ? Maybe the contoller is seen as a keyboard ? In this case how can I detect it in may games ?

Thank you for your help 🙂