MyNixOS website logo
Description

Nintendo Switch Controller Library.

Please see the README on GitHub at https://github.com/typedbyte/switch#readme

switch

Hackage

switch is a library for interacting with Nintendo Switch controllers, written in Haskell. It allows your application to detect controllers via Bluetooth, connect to them, read input (e.g., buttons, sensors) from them and sending commands (e.g., rumble) to them. Notable features of this library are:

  • Supports all popular controller types (left Joy-Con, right Joy-Con, Pro Controller).
  • Supports controller input: read button states, analog stick directions and battery information.
  • Supports controller output: send rumble commands, set player lights and configure the home light.
  • Supports position tracking of a controller using its accelerometer and gyroscope.
  • Provides a type-safe interface for controller interaction (e.g., trying to configure the home light of a controller which has no home light results in a compile error).

The communication protocol of the controllers is based on existing efforts of the reverse engineering community. The documentation of the library can be found on Hackage.

Usage

  1. Press and hold the SYNC button on your Nintendo Switch controller for a few seconds. It is the small black button on the side (Joy-Con) or top (Pro Controller) of the controller.
  2. Scan for Bluetooth devices on your computer. Depending on your controller, you should detect a device named Joy-Con (L), Joy-Con (R) or Pro Controller. Connect to it.
  3. Talk to the controller by developing and running an application that uses the switch library on your computer, or try one of the provided examples.

Compatibility

This library should work with Windows, Linux and macOS, but it was primarily tested under Windows 10.

Limitations and Remarks

The following features are not implemented yet:

  • Interacting with the NFC sensor of the right Joy-Con.
  • Interacting with the IR camera of the right Joy-Con.
Metadata

Version

0.1.0.0

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows