Commit 570db666 authored by simon's avatar simon
Browse files

expose channel

parent b2ccd289
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -63,14 +63,14 @@ func (b ButtonChangeEvent) Moment() time.Duration {
	return b.time
}

type channel struct {
type Channel struct {
	number    uint8
	channelFn func(state, uint8) chan event
}

// Capture arranges for the registrees (channels) to get particular events.
// Intended for bacic use since doesn't return state object.
func Capture(registrees ...channel) []chan event {
func Capture(registrees ...Channel) []chan event {
	js, err := Connect(1)
	if err != nil {
		return nil
+3 −3
Original line number Diff line number Diff line
@@ -15,9 +15,9 @@ import "math"

func TestJoysticksCapture(t *testing.T) {
	events := Capture(
		channel{10, state.OnOpen}, // event[0] button #10 opens
		channel{1, state.OnClose}, // event[1] button #1 closes
		channel{1, state.OnMove},  // event[2] hat #1 moves
		Channel{10, state.OnOpen}, // event[0] button #10 opens
		Channel{1, state.OnClose}, // event[1] button #1 closes
		Channel{1, state.OnMove},  // event[2] hat #1 moves
	)
	var x float32 = .5
	var f time.Duration = time.Second / 440