Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/0xcafed00d/joystick
Go Joystick API
https://github.com/0xcafed00d/joystick
Last synced: about 2 months ago
JSON representation
Go Joystick API
- Host: GitHub
- URL: https://github.com/0xcafed00d/joystick
- Owner: 0xcafed00d
- License: mit
- Created: 2015-07-24T14:51:47.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-04-19T19:26:36.000Z (over 1 year ago)
- Last Synced: 2024-07-31T20:51:58.154Z (5 months ago)
- Language: Go
- Size: 33.2 KB
- Stars: 59
- Watchers: 4
- Forks: 17
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go - joystick - a polled API to read the state of an attached joystick. (Hardware / Search and Analytic Databases)
- awesome-go-extra - joystick - 07-24T14:51:47Z|2022-03-19T20:31:06Z| (Hardware / Tutorials)
README
# joystick
Go Joystick API[![GoDoc](https://godoc.org/github.com/0xcafed00d/joystick?status.svg)](https://godoc.org/github.com/0xcafed00d/joystick) [![Build Status](https://travis-ci.org/0xcafed00d/joystick.svg)](https://travis-ci.org/0xcafed00d/joystick)
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: https://github.com/ledyba
## Installation:
```bash
$ go get github.com/0xcafed00d/joystick/...
```
## Sample Program
```bash
$ go install github.com/0xcafed00d/joystick/joysticktest
$ joysticktest 0
```
Displays the state of the specified joystick
## Example:
```go
import "github.com/0xcafed00d/joystick"
```
```go
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()
```