https://github.com/quartercastle/go-dualshock
🎮 Connect a PlayStation DualShock controller with your go program.
https://github.com/quartercastle/go-dualshock
controller dualshock go playstation ps4
Last synced: over 1 year ago
JSON representation
🎮 Connect a PlayStation DualShock controller with your go program.
- Host: GitHub
- URL: https://github.com/quartercastle/go-dualshock
- Owner: quartercastle
- License: mit
- Created: 2018-10-13T10:56:16.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-06-18T10:59:17.000Z (almost 7 years ago)
- Last Synced: 2024-04-14T11:08:43.629Z (about 2 years ago)
- Topics: controller, dualshock, go, playstation, ps4
- Language: Go
- Homepage:
- Size: 8.79 KB
- Stars: 10
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-dualshock
[](https://github.com/kvartborg/go-dualshock/releases)
[](https://travis-ci.org/kvartborg/go-dualshock)
[](https://godoc.org/github.com/kvartborg/go-dualshock)
[](https://goreportcard.com/report/github.com/kvartborg/go-dualshock)
Connect a PS4 DualShock controller with your go program.
### Install
```sh
go get github.com/kvartborg/go-dualshock
```
### Example
```go
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](https://github.com/kvartborg/go-dualshock/blob/master/LICENSE).