Commit e989ed77 authored by simon's avatar simon
Browse files

simple example

parent 079fca5e
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
package main

//import "log"
//import "time"
import "os"
import . "github.com/splace/joysticks"
import "fmt"

func main() {
	deviceReader, err := os.OpenFile("/dev/input/js1", os.O_RDWR, 0)
	var OSEvents chan osEventRecord
	go eventPipe(deviceReader, OSEvents)
	
}
+1 −0
Original line number Diff line number Diff line
plays notes, using, '[aplay](https://en.wikipedia.org/wiki/Aplay)' command, when you press buttons on a playstation-type controller

examples/play/play.go

0 → 100644
+25 −0
Original line number Diff line number Diff line
package main

import "log"
import "time"
import . "github.com/splace/joysticks"

func main() {
	timer:=time.After(time.Second*10)
	log.Println("press any button to start.")
	events := Capture(
		Channel{1, HID.OnClose},  // event[0] button #1 closes
	)
	log.Println("started with 10 second timeout.")
loop:
	for {
		select {
	    case <-timer:
			log.Println("Shutting down server due to timeout.")
			break loop
		case <-events[0]:
			log.Println("Button #1 pressed")
		}
	}
}