Skip to content

Nick-Zuchlewski/joystick

 
 

Repository files navigation

joystick

Go Joystick API

Package joystick implements a Polled API to read the state of an attached joystick. Windows, Linux & OSX are supported. Package requires no external dependencies to be installed.

Mac OSX code developed by: ledyba

Forked from: simulatedsimian/joystick

Installation

go get github.com/simulatedsimian/joystick/...

Sample Program

go install github.com/simulatedsimian/joystick/joysticktest
joysticktest 0

Displays the state of the specified joystick

Example

import "github.com/Nick-Zuchlewski/joystick"

js, err := joystick.Open(jsid)
if err != nil {
  panic(err)
}

fmt.Printf("Joystick Name: %s", js.Name())
fmt.Printf("   Axis Count: %d", js.AxisCount())
fmt.Printf(" Button Count: %d", js.ButtonCount())

state, err := joystick.Read()
if err != nil {
  panic(err)
}

fmt.Printf("Axis Data: %v", state.AxisData)
js.Close()

About

Go Joystick API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 89.1%
  • C 10.9%