Swiftpack.co - Package - backslash-f/gcoverseer

swift-version swift-package-manager platform build-status license

GCOverseer

Combine wrapper around Apple's Game Controller Framework.

Tested platforms

  • iOS 14+
  • macOS 11+ (BigSur+)
  • Mac Catalyst 14+
  • tvOS 14+
  • Xcode 12+
  • Swift 5.3+

Usage

Handle connected / disconnected events

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)
    }
}

Integration

Xcode

Use Xcode's built-in support for SPM.

or...

Package.swift

In your Package.swift, add GCOverseer as a dependency:

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

Github

link
Stars: 1

Dependencies

Used By

Total: 0

Releases

v0.1.0 - 2020-10-13 20:59:09

In the very first pre-release, listen to game controller connect / disconnect events as follows:

let gcOverseer = GCOverseer()

gcOverseer.$isGameControllerConnected
  .sink { isConnected in
    // Do something
  }
  .store(in: &cancellables)
}