{"id":15654871,"url":"https://github.com/0xwdg/gamecontrollerkit","last_synced_at":"2025-04-16T05:51:07.473Z","repository":{"id":253830789,"uuid":"844534909","full_name":"0xWDG/GameControllerKit","owner":"0xWDG","description":"GameControllerKit is a Swift package that makes it easy to work with game controllers on iOS, macOS, and tvOS. It provides a simple API to connect to game controllers, read input from them, and control their lights and haptics.","archived":false,"fork":false,"pushed_at":"2025-02-20T20:19:32.000Z","size":942,"stargazers_count":36,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-16T02:09:23.017Z","etag":null,"topics":["0xwdg","controller","dualsense","dualshock","game","game-development","gamedev","gamedevelopment","games","hacktoberfest","ios","macos","playstation","spm","stadia","swift","swiftlang","switch","tvos","xbox"],"latest_commit_sha":null,"homepage":"https://0xwdg.github.io/GameControllerKit/","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/0xWDG.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-19T13:06:40.000Z","updated_at":"2025-03-30T03:25:00.000Z","dependencies_parsed_at":"2024-10-23T04:20:09.865Z","dependency_job_id":null,"html_url":"https://github.com/0xWDG/GameControllerKit","commit_stats":null,"previous_names":["0xwdg/gamecontrollerkit"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xWDG%2FGameControllerKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xWDG%2FGameControllerKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xWDG%2FGameControllerKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xWDG%2FGameControllerKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/0xWDG","download_url":"https://codeload.github.com/0xWDG/GameControllerKit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249204970,"owners_count":21229840,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["0xwdg","controller","dualsense","dualshock","game","game-development","gamedev","gamedevelopment","games","hacktoberfest","ios","macos","playstation","spm","stadia","swift","swiftlang","switch","tvos","xbox"],"created_at":"2024-10-03T12:54:33.616Z","updated_at":"2025-04-16T05:51:07.456Z","avatar_url":"https://github.com/0xWDG.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GameControllerKit\n\nGameControllerKit is a Swift package that makes it easy to work with game controllers on iOS, macOS, and tvOS. It provides a simple API to connect to game controllers, read input from them, and control their lights and haptics.\n\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2F0xWDG%2FGameControllerKit%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/0xWDG/GameControllerKit)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2F0xWDG%2FGameControllerKit%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/0xWDG/GameControllerKit)\n[![Swift Package Manager](https://img.shields.io/badge/SPM-compatible-brightgreen.svg)](https://swift.org/package-manager)\n![License](https://img.shields.io/github/license/0xWDG/GameControllerKit)\n\n## Requirements\n\n- Swift 5.9+ (Xcode 15+)\n- iOS 13+, macOS 10.15+, tvOS 16+\n\n## Installation (Pakage.swift)\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/0xWDG/GameControllerKit.git\", branch: \"main\"),\n],\ntargets: [\n    .target(name: \"MyTarget\", dependencies: [\n        .product(name: \"GameControllerKit\", package: \"GameControllerKit\"),\n    ]),\n]\n```\n\n## Installation (Xcode)\n\n1. In Xcode, open your project and navigate to **File** → **Swift Packages** → **Add Package Dependency...**\n2. Paste the repository URL (`https://github.com/0xWDG/GameControllerKit`) and click **Next**.\n3. Click **Finish**.\n\n## Usage\n\n```swift\nimport SwiftUI\nimport GameControllerKit\n\nstruct ContentView: View {\n    /// The game controller kit\n    @State\n    var gameController = GameControllerKit()\n\n    /// Log\n    @State\n    var log: [String] = []\n\n    var body: some View {\n        VStack {\n            Button {\n                gameController.set(color: .GCKRandom)\n            } label: {\n                Text(\"Random Color\")\n            }\n\n            Text(\"Controller: \\(gameController.controller?.productCategory ?? \"None\"), \" +\n                 \"\\((gameController.controllerType ?? .generic).description)\")\n            Text(\"Last action:\\n\\(String(describing: gameController.lastAction)).\")\n\n            GCKControllerView()\n                .environmentObject(gameController)\n\n            List {\n                ForEach(log.reversed(), id: \\.self) { text in\n                    Text(text)\n                }\n            }\n        }\n        .padding()\n        .onAppear {\n            gameController.set(handler: handler)\n            UIApplication.shared.isIdleTimerDisabled = true\n        }\n    }\n\n    /// Handler\n    ///\n    /// - Parameters:\n    ///   - action: action\n    ///   - pressed: is the button pressed?\n    ///   - controller: which controller?\n    public func handler(\n        action: GCKAction,\n        pressed: Bool,\n        controller: GCKController\n    ) {\n        log.append(\n            \"\\(String(describing: action))(\\(action.position.arrowRepresentation)) \\(pressed ? \"Pressed\" : \"Unpressed\"), \" +\n            \"Controller #id \\(String(describing: controller.playerIndex.rawValue))\"\n        )\n\n        if action == .buttonA \u0026\u0026 pressed {\n            // set to a random color\n            gameController.set(color: .GCKRandom)\n        }\n    }\n}\n```\n\n## Image of Usage Demo App\n\n### iOS\n![C65552DF-04CC-493E-AD73-C385A7CEC53C](https://github.com/user-attachments/assets/7bae192c-41ae-42d5-ad52-e204de73b3a0)\n\n### MacOS\n\u003cimg width=\"1012\" alt=\"AA801C52-88A1-4326-A5DC-3A04DF491077\" src=\"https://github.com/user-attachments/assets/f6eaa752-fdda-4ddd-8eeb-acbc9797dc94\"\u003e\n\n### tvOS\n![Screenshot 2024-08-29 at 14 43 51](https://github.com/user-attachments/assets/77def389-784e-44b5-9df8-80b675fdb8bf)\n\n## Contact\n\n🦋 [@0xWDG](https://bsky.app/profile/0xWDG.bsky.social)\n🐘 [mastodon.social/@0xWDG](https://mastodon.social/@0xWDG)\n🐦 [@0xWDG](https://x.com/0xWDG)\n🧵 [@0xWDG](https://www.threads.net/@0xWDG)\n🌐 [wesleydegroot.nl](https://wesleydegroot.nl)\n🤖 [Discord](https://discordapp.com/users/918438083861573692)\n\nInterested learning more about Swift? [Check out my blog](https://wesleydegroot.nl/blog/).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xwdg%2Fgamecontrollerkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F0xwdg%2Fgamecontrollerkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xwdg%2Fgamecontrollerkit/lists"}