Loading examples/play.go +1 −1 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ import . "github.com/splace/sounds" func main() { events := Capture( Channel{10, State.OnDouble}, // event[0] button #10 double pressed Channel{10, State.OnLong}, // event[0] button #10 double pressed Channel{1, State.OnClose}, // event[1] button #1 closes Channel{1, State.OnMove}, // event[2] hat #1 moves ) Loading joysticks_linux.go +5 −5 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ type State struct { hatAxes map[uint8]hatAxis buttonCloseEvents map[uint8]chan event buttonOpenEvents map[uint8]chan event buttonDoublePressEvents map[uint8]chan event buttonLongPressEvents map[uint8]chan event hatChangeEvents map[uint8]chan event } Loading Loading @@ -149,8 +149,8 @@ func (js State) ProcessEvents() { if c, ok := js.buttonOpenEvents[js.buttons[evt.Index].number]; ok { c <- ButtonChangeEvent{toDuration(evt.Time)} } if c, ok := js.buttonDoublePressEvents[js.buttons[evt.Index].number]; ok { if toDuration(evt.Time)<js.buttons[evt.Index].time+time.Second/5{ if c, ok := js.buttonLongPressEvents[js.buttons[evt.Index].number]; ok { if toDuration(evt.Time)>js.buttons[evt.Index].time+time.Second{ c <- ButtonChangeEvent{toDuration(evt.Time)} } } Loading Loading @@ -196,9 +196,9 @@ func (js State) OnClose(button uint8) chan event { } // button goes closed func (js State) OnDouble(button uint8) chan event { func (js State) OnLong(button uint8) chan event { c := make(chan event) js.buttonDoublePressEvents[button] = c js.buttonLongPressEvents[button] = c return c } Loading joysticks_test.go +1 −1 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ import "math" func TestJoysticksCapture(t *testing.T) { events := Capture( Channel{10, State.OnDouble}, // event[0] button #10 double pressed Channel{10, State.OnLong}, // event[0] button #10 long pressed Channel{1, State.OnClose}, // event[1] button #1 closes Channel{1, State.OnMove}, // event[2] hat #1 moves ) Loading Loading
examples/play.go +1 −1 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ import . "github.com/splace/sounds" func main() { events := Capture( Channel{10, State.OnDouble}, // event[0] button #10 double pressed Channel{10, State.OnLong}, // event[0] button #10 double pressed Channel{1, State.OnClose}, // event[1] button #1 closes Channel{1, State.OnMove}, // event[2] hat #1 moves ) Loading
joysticks_linux.go +5 −5 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ type State struct { hatAxes map[uint8]hatAxis buttonCloseEvents map[uint8]chan event buttonOpenEvents map[uint8]chan event buttonDoublePressEvents map[uint8]chan event buttonLongPressEvents map[uint8]chan event hatChangeEvents map[uint8]chan event } Loading Loading @@ -149,8 +149,8 @@ func (js State) ProcessEvents() { if c, ok := js.buttonOpenEvents[js.buttons[evt.Index].number]; ok { c <- ButtonChangeEvent{toDuration(evt.Time)} } if c, ok := js.buttonDoublePressEvents[js.buttons[evt.Index].number]; ok { if toDuration(evt.Time)<js.buttons[evt.Index].time+time.Second/5{ if c, ok := js.buttonLongPressEvents[js.buttons[evt.Index].number]; ok { if toDuration(evt.Time)>js.buttons[evt.Index].time+time.Second{ c <- ButtonChangeEvent{toDuration(evt.Time)} } } Loading Loading @@ -196,9 +196,9 @@ func (js State) OnClose(button uint8) chan event { } // button goes closed func (js State) OnDouble(button uint8) chan event { func (js State) OnLong(button uint8) chan event { c := make(chan event) js.buttonDoublePressEvents[button] = c js.buttonLongPressEvents[button] = c return c } Loading
joysticks_test.go +1 −1 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ import "math" func TestJoysticksCapture(t *testing.T) { events := Capture( Channel{10, State.OnDouble}, // event[0] button #10 double pressed Channel{10, State.OnLong}, // event[0] button #10 long pressed Channel{1, State.OnClose}, // event[1] button #1 closes Channel{1, State.OnMove}, // event[2] hat #1 moves ) Loading