Skip to content
forked from mattrasband/ps4

Golang library to read evdev events for the Playstation 4 controller

Notifications You must be signed in to change notification settings

BenoitBotton/ps4

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ps4

A golang library to read from a Playstation 4 controller. This uses evdev, so it is Linux Only.

Usage

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.

About

Golang library to read evdev events for the Playstation 4 controller

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%