Skip to content

Latest commit

 

History

History
50 lines (37 loc) · 1.36 KB

README.md

File metadata and controls

50 lines (37 loc) · 1.36 KB

go-dualshock

Version Build Status GoDoc Go Report Card

Connect a PS4 DualShock controller with your go program.

Install

go get github.com/kvartborg/go-dualshock

Example

package main

import (
    "fmt"
    "log"
    "github.com/karalabe/hid"
    dualshock "github.com/kvartborg/go-dualshock"
)

func main() {
    vendorID, productID := uint16(1356), uint16(1476)
    devices := hid.Enumerate(vendorID, productID)

    if len(devices) == 0 {
        log.Fatal("no dualshock controller where found")
    }

    device, err := devices[0].Open()

    if err != nil {
        log.Fatal(err)
    }

    controller := dualshock.New(device)

    controller.Listen(func(state dualshock.State) {
        fmt.Println(state.Analog.L2)
    })
}

License

This project is licensed under the MIT License.