Loading joysticks.go +2 −2 Original line number Diff line number Diff line Loading @@ -51,7 +51,7 @@ func (b ButtonChangeEvent) Moment() time.Duration { // start interpreting whats appearing on osEvent channel, then put, on any registered channel(s), the requisite event. func (js State) ParcelOutEvents() { for { evt, ok := <-js.osEvent evt, ok := <-js.OSEvent if !ok { break } Loading Loading @@ -142,5 +142,5 @@ func (js State) HatExists(hat uint8) (ok bool) { } func (js State) InsertSyntheticEvent(v int16, t uint8, i uint8) { js.osEvent <- osEventRecord{Value: v, Type: t, Index: i} js.OSEvent <- osEventRecord{Value: v, Type: t, Index: i} } joysticks_linux.go +4 −4 Original line number Diff line number Diff line Loading @@ -31,7 +31,7 @@ func Capture(registrees ...Channel) []chan event { if js == nil { return nil } go js.ProcessEvents() go js.ParcelOutEvents() chans := make([]chan event, len(registrees)) for i, fns := range registrees { chans[i] = fns.Method(*js, fns.Number) Loading @@ -50,7 +50,7 @@ func Connect(index int) (js *State) { } js = &State{make(chan osEventRecord), make(map[uint8]button), make(map[uint8]hatAxis), make(map[uint8]chan event), make(map[uint8]chan event), make(map[uint8]chan event), make(map[uint8]chan event)} // start thread to read joystick events to the joystick.state osEvent channel go eventPipe(r, js.osEvent) go eventPipe(r, js.OSEvent) js.populate() return js } Loading @@ -58,7 +58,7 @@ func Connect(index int) (js *State) { // fill in the joysticks available events from the synthetic state events burst produced initially by the driver. func (js State) populate() { for buttonNumber, hatNumber, axisNumber := 1, 1, 1; ; { evt := <-js.osEvent evt := <-js.OSEvent switch evt.Type { case 0x81: js.buttons[evt.Index] = button{uint8(buttonNumber), toDuration(evt.Time), evt.Value != 0} Loading @@ -71,7 +71,7 @@ func (js State) populate() { hatNumber += 1 } default: go func() { js.osEvent <- evt }() // put the consumed, first, after end of synthetic burst, real event, back on channel. go func() { js.OSEvent <- evt }() // put the consumed, first, after end of synthetic burst, real event, back on channel. return } } Loading Loading
joysticks.go +2 −2 Original line number Diff line number Diff line Loading @@ -51,7 +51,7 @@ func (b ButtonChangeEvent) Moment() time.Duration { // start interpreting whats appearing on osEvent channel, then put, on any registered channel(s), the requisite event. func (js State) ParcelOutEvents() { for { evt, ok := <-js.osEvent evt, ok := <-js.OSEvent if !ok { break } Loading Loading @@ -142,5 +142,5 @@ func (js State) HatExists(hat uint8) (ok bool) { } func (js State) InsertSyntheticEvent(v int16, t uint8, i uint8) { js.osEvent <- osEventRecord{Value: v, Type: t, Index: i} js.OSEvent <- osEventRecord{Value: v, Type: t, Index: i} }
joysticks_linux.go +4 −4 Original line number Diff line number Diff line Loading @@ -31,7 +31,7 @@ func Capture(registrees ...Channel) []chan event { if js == nil { return nil } go js.ProcessEvents() go js.ParcelOutEvents() chans := make([]chan event, len(registrees)) for i, fns := range registrees { chans[i] = fns.Method(*js, fns.Number) Loading @@ -50,7 +50,7 @@ func Connect(index int) (js *State) { } js = &State{make(chan osEventRecord), make(map[uint8]button), make(map[uint8]hatAxis), make(map[uint8]chan event), make(map[uint8]chan event), make(map[uint8]chan event), make(map[uint8]chan event)} // start thread to read joystick events to the joystick.state osEvent channel go eventPipe(r, js.osEvent) go eventPipe(r, js.OSEvent) js.populate() return js } Loading @@ -58,7 +58,7 @@ func Connect(index int) (js *State) { // fill in the joysticks available events from the synthetic state events burst produced initially by the driver. func (js State) populate() { for buttonNumber, hatNumber, axisNumber := 1, 1, 1; ; { evt := <-js.osEvent evt := <-js.OSEvent switch evt.Type { case 0x81: js.buttons[evt.Index] = button{uint8(buttonNumber), toDuration(evt.Time), evt.Value != 0} Loading @@ -71,7 +71,7 @@ func (js State) populate() { hatNumber += 1 } default: go func() { js.osEvent <- evt }() // put the consumed, first, after end of synthetic burst, real event, back on channel. go func() { js.OSEvent <- evt }() // put the consumed, first, after end of synthetic burst, real event, back on channel. return } } Loading