Skip to content

🎮 Connect a PlayStation DualShock controller with your go program.

License

Notifications You must be signed in to change notification settings

quartercastle/go-dualshock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

🎮 Connect a PlayStation DualShock controller with your go program.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Languages