https://github.com/mattrasband/ps4
Golang library to read evdev events for the Playstation 4 controller
https://github.com/mattrasband/ps4
evdev golang linux playstation-4 raspberry-pi
Last synced: 11 months ago
JSON representation
Golang library to read evdev events for the Playstation 4 controller
- Host: GitHub
- URL: https://github.com/mattrasband/ps4
- Owner: mattrasband
- Created: 2020-02-22T21:59:41.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-02-22T22:22:32.000Z (about 6 years ago)
- Last Synced: 2025-03-24T21:21:59.592Z (12 months ago)
- Topics: evdev, golang, linux, playstation-4, raspberry-pi
- Language: Go
- Size: 5.86 KB
- Stars: 7
- Watchers: 1
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ps4
A golang library to read from a Playstation 4 controller. This uses evdev, so it is **Linux Only**.
# Usage
```golang
pacakge main
import (
"context"
"fmt"
"github.com/mrasband/ps4"
)
func main() {
inputs, err := ps4.Discover()
if err != nil {
fmt.Printf("Error discovering controller: %s\n", err)
os.Exit(1)
}
var device *ps4.Input
for _, input := range inputs {
if input.Type == ps4.Controller {
device = input
break
}
}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
events, _ := ps4.Watch(ctx, device)
for e := range events {
fmt.Printf("%+v\n", e)
}
}
```
# Development
Any of the `_string.go` files are generated by `go generate`.