Skip to content

IOKit wrapper for Nintendo Joy-Con and ProController (macOS, Swift)

License

Notifications You must be signed in to change notification settings

Grublady/JoyConSwift

 
 

Repository files navigation

JoyConSwift

IOKit wrapper for Nintendo Joy-Con and ProController (macOS, Swift)

Set USB Capability

To use controllers, you need to check Signing & Capabilities > App SandBox > USB in your Xcode project.

usb_capability

Usage

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

Thanks to

dekuNukem/Nintendo_Switch_Reverse_Engineering - A look at inner workings of Joycon and Nintendo Switch

See also

JoyKeyMapper - Nintendo Joy-Con/ProController Key mapper for macOS

About

IOKit wrapper for Nintendo Joy-Con and ProController (macOS, Swift)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 98.4%
  • Other 1.6%