Fix initial isConnected value
Combine wrapper around Apple’s Game Controller Framework.
import SpriteKit import Combine import GCOverseer class GameScene: SKScene { let gcOverseer = GCOverseer() var cancellables = Set<AnyCancellable>() override init(size: CGSize) { super.init(size: size) // 🎮 gcOverseer.$isGameControllerConnected .sink { isConnected in // Do something } .store(in: &cancellables) } }
@Published var isGameControllerConnected: Bool
controllers()
extendedGamepadControllers()
extendedGamepad
dualshockControllers()
xboxControllers()
microGamepadControllers()
microGamepad
motionControllers()
motion
controllerFor(playerIndex:)
enableLogging() / disableLogging()
Use Xcode’s built-in support for SPM.
or…
In your Package.swift, add GCOverseer as a dependency:
Package.swift
GCOverseer
dependencies: [ .package(url: "https://github.com/backslash-f/gcoverseer", from: "0.1.0") ],
Associate the dependency with your target:
targets: [ .target(name: "App", dependencies: ["GCOverseer"]) ]
Run: swift build
swift build
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
GCOverseer
Combine wrapper around Apple’s Game Controller Framework.
Tested Platforms
Usage Examples
Handle Connected / Disconnected Events
Available Properties
@Published var isGameControllerConnected: BoolAvailable APIs
controllers()extendedGamepadControllers()extendedGamepadprofile that are connected to the device. E.g. Dualshock, Xbox controllers, etc.dualshockControllers()xboxControllers()microGamepadControllers()microGamepadprofile that are connected to the device. E.g. Apple’s Siri Remote.motionControllers()motionprofile that are connected to the device.controllerFor(playerIndex:)enableLogging() / disableLogging()Integration
Xcode
Use Xcode’s built-in support for SPM.
or…
Package.swift
In your
Package.swift, addGCOverseeras a dependency:Associate the dependency with your target:
Run:
swift build