Commit 9ede9fc7 authored by simon's avatar simon
Browse files

efficient but complex file name gen

parent c11e4113
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@ package joysticks

import (
	"encoding/binary"
	"fmt"
	"strconv"
	"io"
	"os"
	"time"
@@ -44,7 +44,7 @@ func Capture(registrees ...Channel) []chan event {
// Note: only one event, of each type '<xxx>', for each 'index', re-registering stops events going on the old channel.
// then activate using state objects ParcelOutEvents() method.(usually in a go routine.)
func Connect(index int) (js *State) {
	r, e := os.OpenFile(fmt.Sprintf("/dev/input/js%d", index-1), os.O_RDWR, 0400)
	r, e := os.OpenFile(string(strconv.AppendUint([]byte("/dev/input/js ")[0:13],uint64(index-1),10)), os.O_RDWR, 0)
	if e != nil {
		return nil
	}
@@ -95,3 +95,4 @@ func toDuration(m uint32) time.Duration {
}