@@ -15,8 +15,8 @@ import CoreHaptics
1515import OSLog
1616
1717/// Game Controller Kit
18- ///
19- /// GameControllerKit is a Swift package that makes it easy to work with
18+ ///
19+ /// GameControllerKit is a Swift package that makes it easy to work with
2020/// game controllers on iOS, macOS, and tvOS. It provides a simple API to
2121/// connect to game controllers, read input from them, and control their
2222/// lights and haptics.
@@ -184,11 +184,6 @@ public class GameControllerKit: ObservableObject {
184184 for (index, currentController) in controllers. enumerated ( ) {
185185 currentController. playerIndex = GCControllerPlayerIndex ( rawValue: index) ?? . indexUnset
186186
187- if !isConnected {
188- isConnected = true
189- controller = currentController
190- }
191-
192187 let currentControllerType : GCKControllerType = switch currentController. physicalInputProfile {
193188 case is GCDualSenseGamepad :
194189 . dualSense
@@ -208,6 +203,18 @@ public class GameControllerKit: ObservableObject {
208203 let contr = String ( describing: currentControllerType)
209204 logger. info ( " Did connect controller \( currentController. productCategory) recognized as \( contr) . " )
210205
206+ logger. info ( " CONNECTED: \( self . controllers. count) " )
207+
208+ // Disfavor Siri Remote over a external controller.
209+ if ( currentControllerType == . siriRemote && controllers. count == 1 ) ||
210+ currentControllerType != . siriRemote {
211+ isConnected = true
212+ controller = currentController
213+ controllerType = currentControllerType
214+
215+ logger. info ( " Did set controller \( currentController. productCategory) as main (first) controller. " )
216+ }
217+
211218 setupController ( controller: currentController)
212219 }
213220 }
0 commit comments