Commit 28dfd6c7 authored by simon's avatar simon
Browse files

comment

parent ae117319
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
# joysticks
Go language joystick interface.

uses channels for events, so multi-threaded.
uses channels for events, for flexibility and multi-threading.

Overview/docs: [![GoDoc](https://godoc.org/github.com/splace/joysticks?status.svg)](https://godoc.org/github.com/splace/joysticks)

@@ -9,7 +9,7 @@ Installation:

     go get github.com/splace/joysticks

Example: play a note when pressing button #1. hat position changes frequency, y axis, and volume, x axis. (double press button #10 to exit) 
Example: play a note when pressing button #1. hat position changes frequency, y axis, and volume, x axis. (long press button #10 to exit) 

	package main

+2 −1
Original line number Diff line number Diff line
@@ -87,6 +87,7 @@ func Capture(registrees ...Channel) []chan event {

// Connect sets up a go routine that puts a joysticks events onto registered channels.
// register channels by using the returned state object's On<xxx>(index) methods.
// Note: only one event, of each type '<xxx>', for each 'index', re-registering stops previously registered event. 
// then activate using state objects ProcessEvents() method.(usually in a go routine.)
func Connect(index int) (js State, e error) {
	r, e := os.OpenFile(fmt.Sprintf("/dev/input/js%d", index-1), os.O_RDONLY, 0666)
@@ -195,7 +196,7 @@ func (js State) OnClose(button uint8) chan event {
	return c
}

// button goes closed
// button goes open and last event on it, closed, wasn't recent. (within 1 second) 
func (js State) OnLong(button uint8) chan event {
	c := make(chan event)
	js.buttonLongPressEvents[button] = c