in swiftUI & tvOS 15, when calling the GCController.controllers() to get the list of controllers connected to the apple tv,
import GameController
...
let siriRemoteAsGameController = GCController.controllers().first
the Siri Remote is not registered as the first controller, in fact it is not registered at all !
up until tvOS 15 (14.7 for example) it was working
even if i register for notification the connect event isn't dispatched for the already connected Siri remote
NotificationCenter.default.addObserver(forName: .GCControllerDidConnect, object: nil, queue: .main) { note in
print("GCControllerDidConnect")
if let detectedGCController = note.object as? GCController {
print("Controller Detected")
}
}
GCController.startWirelessControllerDiscovery(completionHandler: {})
i cannot find a change in that area according to Appel's $#itty documentation
any help would be appreciated
based on this answer it seems that an interaction with the remote after calling (at least once) to GCController.controllers()
is required so the solution was this:
import GameController
struct ContentView2: View {
var body: some View {
// first call before remote interaction
let a = print("controllers: \(GCController.controllers())")
Button("Query controllers") {
// second call after a press button via remote interaction occurred
print("controllers: \(GCController.controllers())")
}
}
}