Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/magicien/joyconswift
IOKit wrapper for Nintendo Joy-Con and ProController (macOS, Swift)
https://github.com/magicien/joyconswift
gamepad iokit joy-con macos nintendo-switch pro-controller swift
Last synced: 2 days ago
JSON representation
IOKit wrapper for Nintendo Joy-Con and ProController (macOS, Swift)
- Host: GitHub
- URL: https://github.com/magicien/joyconswift
- Owner: magicien
- License: mit
- Created: 2019-07-12T16:30:56.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-04-04T10:53:08.000Z (over 1 year ago)
- Last Synced: 2024-05-02T04:00:02.456Z (7 months ago)
- Topics: gamepad, iokit, joy-con, macos, nintendo-switch, pro-controller, swift
- Language: Swift
- Size: 135 KB
- Stars: 48
- Watchers: 2
- Forks: 8
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# JoyConSwift
IOKit wrapper for Nintendo Joy-Con and ProController (macOS, Swift)## Installation
### Using [CocoaPods](http://cocoapods.org/)
Add the following to your [Podfile](http://guides.cocoapods.org/using/the-podfile.html):
```rb
pod 'JoyConSwift'
```## Set USB Capability
To use controllers, you need to check `Signing & Capabilities` > `App SandBox` > `USB` in your Xcode project.
## Usage
```swift
import JoyConSwift// Initialize the manager
let manager = JoyConManager()// Set connection event callbacks
manager.connectHandler = { controller in
// Do something with the controller
controller.setPlayerLights(l1: .on, l2: .off, l3: .off, l4: .off)
controller.enableIMU(enable: true)
controller.setInputMode(mode: .standardFull)
controller.buttonPressHandler = { button in
if button == .A {
// Do something with the A button
}
}
}
manager.disconnectHandler = { controller in
// Clean the controller data
}// Start waiting for the connection events
manager.runAsync()
```## Documentation
See [JoyConSwift Documentation](https://magicien.github.io/JoyConSwift/)
## Thanks to
[dekuNukem/Nintendo_Switch_Reverse_Engineering](https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering) - A look at inner workings of Joycon and Nintendo Switch
## See also
[JoyKeyMapper](https://github.com/magicien/JoyKeyMapper) - Nintendo Joy-Con/ProController Key mapper for macOS